[Tutor] python $i equivalent ?

Michele Alzetta michele.alzetta at aliceposta.it
Fri Jun 11 14:19:01 EDT 2004

Thanks to all for the hints; I have yet to try out the solution because
I'm just ending a binge of overwork (over 50 hours in 4 days, including
one night on duty) ... it probably won't be until next thursday that
I'll have some leisure to try this out.

Anyway, my impression is that the problem as someone correctly stated is
a question of scopes and that:
myvars = {}
for element in list:
    myvars[element] = Class()

'ought' to work as I want. 
( "exec element" seems interesting anyway. This real-life example is
bringing up no end of interesting pythonic things !)

Of course, what I'm aiming at is:

schedule = {}

list = [(label1, startdatetuple1, enddatetuple1),(label2,  \
startdatetuple2, enddatetuple2),(label3, etc. etc.

for label, starttimetuple, endtimetuple in list:
    schedule[label] = Shift(starttimetuple,endtimetuple)

(Shift and TimeSpan classes are described in earlier posts).

Thanks again to all !

Michele Alzetta

More information about the Tutor mailing list