How to call the super class instance variables in sub class in python3

16 views
Skip to first unread message

nagar...@enthsquare.com

unread,
Oct 3, 2018, 5:43:51 PM10/3/18
to Django users
how i can call super class instance varibles in subclass (python3)

daniel main

unread,
Oct 4, 2018, 5:24:39 AM10/4/18
to django...@googlegroups.com
Use the super() builtin function. It returns an object that has the ability to instantiate your parent class. see  sample code:

class Animal(object):
def __init__(self,*args,**kwargs):
pass
#print(types,'Base class with Animal')
class Mammal(Animal):
def __init__(self):
super().__init__('Child classs for mammal')
print('Child Class for mammal')

m = Mammal()
The output:
usr/bin/python3.6 /home/bug/PycharmProjects/pydummies/graphics/one.py
Child Class for mammal

Process finished with exit code 0
Thanks.






On Wed, 3 Oct 2018 at 17:43, <nagar...@enthsquare.com> wrote:
how i can call super class instance varibles in subclass (python3)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6a92d85-7311-4f7a-8460-185a51b20154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages