Check For SELF Variable Existance
robert.rawlins at thinkbluemedia.co.uk
Tue Mar 11 14:41:09 CET 2008
Thank you Simon,
I was hoping there would be something as simple as that :-)
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Simon Brunning
Sent: 11 March 2008 13:21
To: python-list at python.org
Subject: Re: Check For SELF Variable Existance
On Tue, Mar 11, 2008 at 11:00 AM, Robert Rawlins
<robert.rawlins at thinkbluemedia.co.uk> wrote:
> I want to be able to check if a class has a certain property in its 'self'
> scope, what's the best way to do this?
>>> class Spam(object):
... def egg(self):
... if hasattr(self, 'chips'): print 'got chips!'
>>> spam = Spam()
>>> spam.chips = 'beans'
simon at brunningonline.net
More information about the Python-list