Embedding questions

Olaf Appelt tholap at compuserve.com
Thu Dec 9 07:03:20 EST 1999


Hi Quinn,


thanks for commenting.


> If a and b have __add__ methods that return a Currency, c will be a
Currency,
> and c = a + b will work as expected.  Even if a is a Currency(5) and b is
int
> 10, you could have Currency __coerce__ the int into a Currency.

You misunderstand my problem. There's other state information coded into
class Currency, besides just the value.

I need to couple a given name with a certain instance, not just any instance
of the right 'type'.

Perhaps another example makes it clearer:

c = Currency (30)
c.SetMyState (whatever)

c = Currency (50)

Isn't it true that the second assignment creates a new instance of class
Currency, leaving my former instance with it's state set to whatever, no
longer bound to the name c?

> >Furthermore I want to avoid having module files lying around in
directories.
> >The code should be compiled, go into database and later be read from db
to
> >be executed. All that without going files. Just strings moved between
Python
> >API and DB.
> >
> >Is that possible?
>
> Should be.  See the pickle and marshal modules, and the compile builtin.

Thanks for the pointers.


Olaf








More information about the Python-list mailing list