(May-27-2018, 03:58 AM)buran Wrote: Of course everything is an object, no doubt about that!!! "
That's exactly why I don't get the difference you make between instances of classes and instances of objects...
Does "object of un-instantiated class" sounds better? If that is still unclear
Output:In [31]: type(list().__class__)
Out[31]: type
In [32]: type(dict().__class__)
Out[32]: type
In [33]: type('abc'.__class__)
Out[33]: type
Classes itself are objects of type .... type
, which is a trinity of function, metaclass and class factory.Even if object is un-hashable, the class of that object will be always hashable (unless you implement some crazy hack that will make it unhashable - if that is possible). Again, look at my code: I was not saving objects in a set - I was saving classes
PS Maybe, a little demonstration will help
Output:In [37]: class A:
...: def __init__(self, name):
...: self.name = name
...:
In [38]: set([A('volcano63').__class__, A('buran').__class__, A('sonicblind').__class__])
Out[38]: {__main__.A}
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.