class declaration shortcut
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Thu Mar 1 00:20:32 CET 2007
Luis M. González wrote:
> I've come across a code snippet in www.rubyclr.com where they show
> how easy it is to declare a class compared to equivalent code in
> c#. I wonder if there is any way to emulate this in Python.
> The code is as follows:
> Person = struct.new( :name, :birthday, :children)
What's easy about this?
Also, this is a definition and not just a declaration.
> But this above is not what I want.
> I guess I should find a way to include the constructor code inside
> this function, but I don't know if this is possible.
Could you please describe what exactly you want in an abstract way?
> Also, I wonder if there is a way to use the variable name in order
> to create a class with the same name (as in "Person"above).
Two classes with the same name?
In Python, classes have no name. They are anonymous objects which
can be bound to names.
BOFH excuse #367:
Webmasters kidnapped by evil cult.
More information about the Python-list