When to use super(type) in python?

0 votes
When can I use super(type)? Not super(type,obj) but super(type) - with one argument.
Jun 3 in Python by ana1504.k
• 7,870 points
27 views

1 answer to this question.

0 votes
super(x) returns an "unbound" descriptor, that is, an object that knows how to get data, but has no idea where. If you assign super(x) to a class attribute and then retrieve it, the descriptor machinery cares for proper binding:

class A(object):
    def foo(self):
        print 'parent'

class B(A):
    def foo(self):
        print 'child'

B.parent = super(B)
B().foo()
B().parent.foo()
answered Jun 3 by SDeb
• 13,160 points

Related Questions In Python

0 votes
1 answer

When to use %r instead of %s in Python? [duplicate]

The %s specifier converts the object using ...READ MORE

answered Aug 2, 2018 in Python by bug_seeker
• 15,350 points
64 views
0 votes
1 answer

When is the perfect time to use Tornado in python?

There is a server and a webframework. ...READ MORE

answered Feb 14 in Python by ariaholic
• 7,340 points
49 views
0 votes
2 answers

How to use threading in Python?

 Thread is the smallest unit of processing that ...READ MORE

answered Apr 6 in Python by anonymous
93 views
0 votes
1 answer

How to use “raise” keyword in Python

You can use it to raise errors ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 56,900 points
40 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 282 views
0 votes
1 answer

When to use file vs open in Python?

File() has been removed since Python 3.0 ...READ MORE

answered Oct 30, 2018 in Python by SDeb
• 13,160 points
29 views
0 votes
1 answer

How to use multiprocessing queue in Python?

This is a simple example of a ...READ MORE

answered Oct 25, 2018 in Python by SDeb
• 13,160 points
376 views