looking for way to include many times some .py code from anotherpython code

Martin MOKREJŠ mmokrejs at ribosome.natur.cuni.cz
Tue Mar 8 08:11:40 EST 2005


Scott David Daniels wrote:
> Martin MOKREJŠ wrote:
> 
>> Hi,
>>  I'm looking for some easy way to do something like include in c or PHP.
>> Imagine I would like to have:   ....
>>
>>  I know about module imports and reloads, but am not sure if this is 
>> the right way to go. Mainly, I want to assign to multiple object 
>> instances some self bound variables. Their values will be different, 
>> so I can't 
> 
>  > use global variables.
> 
> Someone will, no doubt, find a way to code this.  I suggest you are
> fighting the language here -- learn to use it instead.  Decide what
> you really want to do, not how you want to do it.  Then try to figure
> out how to accomplish your real goal in the normal flow of the language.

See my post on Mar 2 about "automating assignment of class variables".
I got no answers, maybe I wasn't clear enough ... :(

I need to define lots of variables. The variable names are often identical.
The problem is that if I put such a code into a function ... no, I'm not going
to pass anything to a function to get it returned back. I just want to get
lots of variables assigned, that all. If I put them into module, it get's
exectued only once unless I do reload. And I'd have to use:
"from some import *", because mainly I'm interrested in assigning to self:
self.x = "blah"
self.y = "uhm"

I'm newbie, sure.

M.



More information about the Python-list mailing list