Var substitution

Emile van Sebille emile at fenx.com
Thu Jun 27 11:39:24 EDT 2002


Guy
> >>> guy="name"
> >>> import os
> >>> os.guy
> 
> This is what should happen :
> 
> >>> import os
> >>> os.name
> 'nt'

Python 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> guy='name'
>>> import os

preferred is:
>>> getattr(os, guy)
'nt'

although:
>>> os.__dict__[guy]
'nt'

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list