[python] problem s odkazem na promennou

RMiklos na pss.sk RMiklos na pss.sk
Čtvrtek Březen 6 11:17:48 CET 2008


Podobne to ide aj v Perle:
$nazev_promenne='var01';
$$nazev_promenne=1;
print 
"\$nazev_promenne=$nazev_promenne,\n\$$nazev_promenne=$$nazev_promenne\n"

Myslim si, ze v Pythone sa toto neda urobit.
Ja by som v Pythone pouzil na ukladanie nazvov premennych a ich hodnot 
slovnik, asi takto
>>> nazev_promenne={}
>>> nazev_promenne['var01']=1
>>> print nazev_promenne

 



"Lansky, Milan - Acision" <milan.lansky na acision.com> 
Sent by: python-bounces na py.cz
06.03.2008 10:40
Please respond to
Konference PyCZ <python na py.cz>


To
python na py.cz
cc

Subject
[python] problem s odkazem na promennou






Lze se v Pythonu odkazat na promenou jejiz nazev neni dopredu znam? 
Rekneme, jak nastavit promennou var01, kdyz mam k dispozici pouze
retezec ‘var01’?
 
V bashi se to resi funkci eval:
# nazev_promenne=var01
# eval $nazev_promenne=1
# echo $var01
1
 
Dekuji za odpoved.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an 
intended recipient then please promptly delete this e-mail and any 
attachment and all copies and inform the sender. Thank you. 
_______________________________________________
Python mailing list
Python na py.cz
http://www.py.cz/mailman/listinfo/python

Mgr. Ing. Roman MIKLÓ© 
Prvá stavebná sporiteµňa a.s. 
Bajkalská 30, P. O. Box 48 
829 48  Bratislava 25 
Tel.: +421/ 2 / 582 31 174 
Fax: +421/ 2 / 582 31 109 

Mgr. Ing. Roman MIKLÓ© 
Prvá stavebná sporiteµňa a.s. 
Bajkalská 30, P. O. Box 48 
829 48  Bratislava 25 
Tel.: +421/ 2 / 582 31 174 
Fax: +421/ 2 / 582 31 109 



Daląí informace o konferenci Python