J
Jason Friedman
Hi, what is the difference between:
def MyClass(object):
pass
and
def MyClass():
pass
def MyClass(object):
pass
and
def MyClass():
pass
Hi, what is the difference between:
def MyClass(object):
pass
and
def MyClass():
pass
Interesting. I actually read "class" for "def" and replied accordingly.Alf said:* Jason Friedman:
If you really meant 'def', then the first is a routine taking one
argument, and the second is a routine of no arguments.
If you meant 'class' instead of 'def', then it depends on the Python
version.
In Py2 the first then defines a new-style class, while the second
defines an old-style class. E.g. you can see some difference by checking
with 'isinstance'. In Py3 there's no difference.
Interesting. I actually read "class" for "def" and replied accordingly.
As can plainly be seen ...
Steve said:Interesting. I actually read "class" for "def" and replied accordingly.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.