Bruno Desthuilliers wrote:
          return "%s(%d,%d)" % (type(self).__name__, self.a, self.b)

Er, yes exactly! I noticed it a few seconds after I had sent the message ;-(

I want to have a list of such classes instantiated automatically on

Of course I meant class instances ... sorry :) It's always good to have an example to compensate for English errors *g*.

bla = [A(*args) for args in ((1,2), (3,4))]

...

> Note that it's not a list of classes, but a list of instances of A. But
> given your specs, nope, your approach is the right one.

Ah I knew there was something and I couldn't find it in the docs anymore! Now my potential follow-up question is answered as well, namely how I can instantiate with variable argument lists, like this:

>>> bla = [A(*args) for args in ((), (1,), (1, 2))]
>>> map(str, bla)
['A(0,1)', 'A(1,1)', 'A(1,2)']

Basically (no pun intended[1]), Python is not C. Trying to write C in Python will only buy you pain and frustration (and this can be generalized for any combination of two languages for any known programming language).

Hehe. I am trying to develop a program prototype in python because of it's repaid prototyping properties, and once it's working I will port it to C, because of speed issues and the fact that it's running on an embedded machine without space for a python interpreter. I have like 4 Megs left, but until now noone has answered my question how I can cut down a standard python installation so that it fit's into 4 megs.

Thanks for your quick answer :)
T.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to