Jde to treba pres exec:

promena = "x"
hodnota = "Ahoj svete"
exec("%s=%s" % (promena,hodnota))
print x

TB


Lansky, Milan - Acision napsal(a):
>
> 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
> [email protected]
> http://www.py.cz/mailman/listinfo/python
_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python

Odpovedet emailem