Sponsored Content
Top Forums Programming What is wrong with below python inheritance code? Post 303020645 by Tanu on Wednesday 25th of July 2018 02:25:25 AM
Old 07-25-2018
just learnt below so updating here -

Code:
super().__init__(value)  -- when using super(), no need to pass self

Test.__init__(self,value)   -- when using BaseClassName, one needs to pass self too

These 2 Users Gave Thanks to Tanu For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is wrong with this code?

Hello everyone, can somebody tell me what is wrong with this code: while true do java myTime > myTime.log sleep 60 done I get the following error: ./myTime: Syntax error at line 1 : `while' is not matched. Thanks in advance! (6 Replies)
Discussion started by: Lem2003
6 Replies

2. Shell Programming and Scripting

What's wrong with this code?

Hello all, Can someone tell me why I'm getting an error in the following code: export return_code="$?" if then echo "load_shaw.sas failed." exit else echo "Trigger the next script..." # /path/to/next/script fi I get an error... (3 Replies)
Discussion started by: mmignot
3 Replies

3. Shell Programming and Scripting

What is wrong with this code

I just wanted to assign the filename to a variable filename="abc" datestrng=`date +%Y%m%d` filextn="txt" "LOCAL_FILE"${i}=${filename}"_"${datestrng}"."${filextn} echo "LOCAL_FILE"${i} I get the following error on 2nd last line ksh: LOCAL_FILE1=abc_20081114.txt: not... (3 Replies)
Discussion started by: mqasim
3 Replies

4. Shell Programming and Scripting

What's wrong with this code?

Trying to do a file count on files between a specific date. I entered the following command, but it's not working: find . -type f \( -newer startdate -a ! -newer enddate \) -exec "ls -l | wc -l" {} \; lil help? :D (4 Replies)
Discussion started by: bbbngowc
4 Replies

5. UNIX for Dummies Questions & Answers

Question on variable inheritance & code statements

1) I have the below code in concattxnrecords.sh shell script and it is calling the genericVars.sh shell script which is mentioned as below has some code inside it which would intialize some variables in it, now my question is will this shell script would inherit those variable definitions or not... (3 Replies)
Discussion started by: Ariean
3 Replies

6. Shell Programming and Scripting

python: what's wrong with my subprocess.Popen

my script is #!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def runForAWhile(cmd, secs=10): print("running %s" % cmd) timeout = datetime.timedelta(seconds=secs) print timeout proc = subprocess.Popen(cmd,... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

7. Programming

Inheritance

whats the use of inheriting with access specifier as private..? Please specify the answer with a simple example... Regards -- Madhu (5 Replies)
Discussion started by: MadhuM
5 Replies

8. Shell Programming and Scripting

What is wrong with my code?

Hello, all Suppose my current directory has 3 files: file_1 file_2 file_3 I wrote the following codes: awk 'BEGIN{while("ls"|getline d) {myarray++}}; END{close("ls");for (i in myarray){print i, myarray}}' /dev/null I expect the output be like: 1 file_1 2 file_2 3 file_3 ... (7 Replies)
Discussion started by: littlewenwen
7 Replies

9. Programming

Difference in multiple inheritance and multilevel inheritance: same method name ambiguity problem

Hi, In multi-level inheritance: class A { public: void fun() { cout << "A" << endl; } }; class B : public A { public: void fun() { cout << "A" << endl; } }; class C : public B { }; int main() { C c; c.fun(); // Ans: A } (1 Reply)
Discussion started by: royalibrahim
1 Replies

10. Shell Programming and Scripting

Python - Function print vs return - whats wrong

All, I have a basic buzz program written in python with return function. If i change return with print,it works fine but i want to know whats wrong with return statement.Can anyone help me whats wrong with this #!/usr/bin/python def div4and6(s,e): for i in range(s,e+1): if... (5 Replies)
Discussion started by: oky
5 Replies
SUPER(3pm)						User Contributed Perl Documentation						SUPER(3pm)

NAME
SUPER - control superclass method dispatch SYNOPSIS
Find the parent method that would run if this weren't here: sub my_method { my $self = shift; my $super = $self->super('my_method'); # Who's your daddy? if ($want_to_deal_with_this) { # ... } else { $super->($self, @_) } } Or Ruby-style: sub my_method { my $self = shift; if ($want_to_deal_with_this) { # ... } else { super; } } Or call the super method manually, with respect to inheritance, and passing different arguments: sub my_method { my $self = shift; # parent handles args backwardly $self->SUPER( reverse @_ ); } DESCRIPTION
When subclassing a class, you occasionally want to dispatch control to the superclass -- at least conditionally and temporarily. The Perl syntax for calling your superclass is ugly and unwieldy: $self->SUPER::method(@_); especially when compared to its Ruby equivalent: super; It's even worse in that the normal Perl redispatch mechanism only dispatches to the parent of the class containing the method at compile time. That doesn't work very well for mixins and roles. This module provides nicer equivalents, along with the universal method "super" to determine a class' own superclass. This allows you to do things such as: goto &{$_[0]->super('my_method')}; if you don't like wasting precious stack frames. (Because "super" returns a coderef, much like "can" in UNIVERSAL, this doesn't break "use strict 'refs'".) If you are using roles or mixins or otherwise pulling in methods from other packages that need to dispatch to their super methods, or if you want to pass different arguments to the super method, use the "SUPER()" method: $self->SUPER( qw( other arguments here ) ); FUNCTIONS and METHODS This module provides the following functions and methods: "super()" This function calls the super method of the currently-executing method, no matter where the super method is in the hierarchy. This takes no arguments; it passes the same arguments passed to the currently-executing method. The module exports this function by default. Note: you must have the appropriate "package" declaration in place for this to work. That is, you must have compiled the method in which you use this function in the package from which you want to use it. Them's the breaks with Perl 5. "find_parent( $class, $method, $prune, $invocant )" Attempts to find a parent implementation of $method starting with $class. If you pass $prune, it will not ignore the method found in that package, if it exists there. Pass $invocant if the object itself might have a different idea of its parents. The module does not export this function by default. Call it directly. "get_all_parents( $invocant, $class )" Returns all of the parents for the $invocant, if it supports the "__get_parents()" method or the contents of @ISA for $class. You probably oughtn't call this on your own. "SUPER()" Calls the super method of the currently-executing method. You can pass arguments. This is a method. NOTES
Beware: if you do weird things with code generation, be sure to name your anonymous subroutines. See Perl Hacks #57. Using "super" doesn't let you pass alternate arguments to your superclass's method. If you want to pass different arguments, use "SUPER" instead. D'oh. This module does a small amount of Deep Magic to find the arguments of method calling "super()" itself. This may confuse tools such as "Devel::Cover". In your own code, if you do complicated things with proxy objects and the like, define "__get_parents()" to return a list of all parents of the object to which you really want to dispatch. AUTHOR
Created by Simon Cozens, "simon@cpan.org". Copyright (c) 2003 Simon Cozens. Maintained by chromatic, <chromatic at wgz dot org> after version 1.01. Copyright (c) 2004-2009 chromatic. Thanks to Joshua ben Jore for bug reports and suggestions. LICENSE
You may use and distribute this silly little module under the same terms as Perl itself. perl v5.10.0 2009-09-13 SUPER(3pm)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy