rt8396 at gmail.com
Fri Jan 2 08:54:36 CET 2009
On Jan 1, 4:40 pm, Robert Kern <robert.k... at gmail.com> wrote:
> Hamish McKenzie wrote:
> > sometimes I want to be able to initialize an instance with a variety of different data types.
> > as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion.
> > is there any other way to do it other than putting case statements in the __init__ method of the class, or having a Matrix.FromQuaternion( quat )?
> I recommend keeping the __init__() as dumb as possible. Ideally, it should just
> assign to attributes. I would add a from<foo>() classmethod for each <foo> that
> I wanted to support. If I really wanted an all-singing, all-dancing
> initialization method, I would add another classmethod that would just dispatch
> to the appropriate type-specific classmethod. I prefer classmethods to plain
> functions because I can subclass.
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless enigma
> that is made terrible by our own mad attempt to interpret it as though it had
> an underlying truth."
> -- Umberto Eco
Why are you busting into this thread? why have you not created your
own thread. Someone asked a question about recycle bin access and you
come in here, bust down the door and ask a completely off topic
question, which is OK if you start a new thread of your own. And the
most insane part to all of this, is that Steven just plays right
along?!?!? Come on Stevie, you know better than this!
PS (To OP) mark hammonds win32 package will not do what you ask, sorry
More information about the Python-list