[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: static variables
From:       BartC <bc () freeuk ! com>
Date:       2015-11-30 20:32:26
Message-ID: n3ibkd$nl0$1 () dont-email ! me
[Download RAW message or body]

On 30/11/2015 17:15, Ulli Horlacher wrote:
> def main():
>    a(1)
>    a(2)
>    a()
>    print(a.x)
>    if 'a.x' in globals(): print('global variable')
>    if 'a.x' in locals():  print('local variable')

Try this:

    if 'x' in a.__dict__:  print('attribute of a')

-- 
Bartc
-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic