I have a simple example of class in python:
class song:
def __init__(self, x):
print x
bang=song(['Our whole universe was in a hot dense state,Then nearly fourteen billion years ago expansion started, wait...'])
This works. But in another book the word "object" is used when creating a new class:
class song(object):
def __init__(self,x):
print x
bang=song(['Our whole universe was in a hot dense state,Then nearly fourteen billion years ago expansion started, wait...'])
This works too. Plus if object is substituted with, for example, x:
class song(x):
def __init__(self,x):
print x
smile=song(['Our whole universe was in a hot dense state,Then nearly fourteen billion years ago expansion started, wait...'])
It doesn't work (NameError: name x is not defined
).
What's so special about object
, as far as I know it isn't even a reserved word, isn't it? And why the code with it works, while with x
- doesn't?