Var substitution
Mark McEahern
marklists at mceahern.com
Thu Jun 27 10:22:39 EDT 2002
> What i'm wanting to know, is there any way of looking at a variables
> value rather than its name.
>
> Example
>
> Unix : ${MyVar}
> Dos : %MyVar%
>
> Both of the above will be subtituted with the values.
>
> Example python script (below causes error):
>
> >>> guy="name"
> >>> import os
> >>> os.guy
>
> This is what should happen :
>
> >>> import os
> >>> os.name
> 'nt'
eval?
<ducking, running for cover>
// m
p.s. but seriously, do you have a more realistic example? Surely your
motivation is more than merely to write obfuscated code. If not, you could
just do this:
import os
guy = os.name
print guy
Or are you looking for string interpolation? search the archives of
Python-Dev because that was recently discussed.
-
More information about the Python-list
mailing list