How to check the exists of a name?

StarWing weasley_wx at sina.com
Sun Oct 18 02:43:36 EDT 2009


On 10月18日, 下午2时37分, Chris Rebert <c... at rebertia.com> wrote:
> On Sat, Oct 17, 2009 at 11:30 PM, StarWing <weasley... at sina.com> wrote:
> > Sometimes I want to make a simple flags. and i need to check there is
> > a name in current scope or not (that is, we can visit this name, no
> > matter where is it). and how to do that in python?
>
> You should avoid needing to do that in the first place. Common
> alternatives include using a dict instead of variables, depending on
> your circumstances.
>
> Cheers,
> Chris
> --http://blog.rebertia.com

Okay... Thank you... But if I want to do that, what shall I do?

I got a idea, use a try...except statement. there are another way to
do it ?

(I just curious now, because I solve my problem in another way :-)



More information about the Python-list mailing list