Base class in Python
Hi, In Java, all classes are subclasses of the "Object" class. Is there something like that in Python? I find it kind of useful to have some generic class so I can store things into its attributes easily. E.g: a = generic() a.b = 3 a.c ='Hallo' This is nicer than using a dictionary. At this moment I have to define class generic: def __init__(self): pass Not really bothersome, but is there a more straightforward way of doing it? Hung Jung ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
----- Original Message ----- From: Hung Jung Lu <hungjunglu@hotmail.com>
This is nicer than using a dictionary. At this moment I have to define
class generic: def __init__(self): pass
Not really bothersome, but is there a more straightforward way of doing it?
Sure: class generic: pass :-) Seriously, though, if you're just using it as a container, this isn't that bothersome. I once proposed a syntax on comp.lang.python which would allow you to write: object g: a = 3 instead of g = generic() g.a = 3 ...and it was greeted with a general shrug and the killing observation that it would require adding a new keyword. Cheers, Evan @ digicool
participants (2)
-
Evan Simpson -
Hung Jung Lu