getattr/setattr q.

Paulo da Silva psdasilvaX at esotericaX.ptX
Tue Apr 3 11:36:21 EDT 2007


Steven Bethard escreveu:
> Paulo da Silva wrote:
...

> If you're at the module level, you can do::
> 
>     globals()['x'] = 10
> 
> If you're inside a function, you probably want to look for another way
> of doing what you're doing.
> 
> What's the actual task you're trying to accomplish here?


None. I asked just for curiosity. My problem has to do with the normal
case of a class or class instance. When I saw setattr/getattr as the way
to solve my problem I just felt curiosity on if and how it could be done
outside a class.

Thank you very much for your response.
Paulo



More information about the Python-list mailing list