Embedding questions

Kevin Dahlhausen morse at harborcom.net
Fri Dec 10 09:26:10 EST 1999


>Shall I take that as a recommendation that I shouldn't use Python for what I
>need?

Nope, just have to change your paradigm a bit.

>Olaf
>
>class Currency
>...

>c = Currency ()

>c = 5

>The above, if I got this correctly would make c first an instance of class
>Currency and then re-assign that name to a different variable of type
>integer.


I think you're abusing operator overloading by saying c=5, and expecting c to
maintain other state information, it's not really assigning 5 to 'c', but
assiging some single attribute of c to 5,

If I had:
c = Currency()
d = Currency()
.
.
c = d
 
What would you expect/want to happen?

I had trouble with not being able to overload the assignment operator when I
first started learning Python.  After awhile now, I don't miss it.  I guess that
will change as I start doing more C++.




More information about the Python-list mailing list