class(obj) could return obj.__class__
3 Mar
2021
3 Mar
'21
9:59 p.m.
Please, consider class(obj) to return obj.__class__ consistenly with dir(), vars(), repr(), str(),…
class c: pass o = c() o.__class__ <class '__main__.c'> class(o) File "<stdin>", line 1 class(o) ^ SyntaxError: invalid syntax
Thank you in advance, H.
10:20 p.m.
Thank you, type(o) is sufficient. It is possible to use class properties:
type(o).__name__ 'c'
On Wed, Mar 03, 2021 at 10:03:03PM +0000, Paul Bryan wrote:
Since class is a keyword, this is unlikely. Why is type(o) insufficient?
On Wed, 2021-03-03 at 22:59 +0100, Hans Ginzel wrote:
class c: pass o = c() o.__class__ <class '__main__.c'> class(o) File "<stdin>", line 1 class(o) ^ SyntaxError: invalid syntax
1313
Age (days ago)
1313
Last active (days ago)
2 comments
2 participants
participants (2)
-
Hans Ginzel
-
Paul Bryan