forcing a definition to be called on attribute change

2006-10-24 Thread Michael Malinowski
Hey All, 
Apologies if this is a stupidly obvious or simple question. If I have a
class with a series of attributes, is there a way to run a function
definition in the class whenever a specific attribute is changed?

Something like the following 

class cSphere() :

def __init__(self):
Self.myAttr = 0

def runThisFunctionWhenMyAttrChanged() :
Pass




Thanks

Mike.

-- 
http://mail.python.org/mailman/listinfo/python-list


dictionaries - returning a key from a value

2006-09-01 Thread Michael Malinowski








Appologies if this is a somewhat simple question, but
currently I can return a value from a dictionary using its key by doing :

 

 dDictionary.get( key )

 

However, I am curious to know if its possible to get the key
from giving a value (basically the opposite of what I did above, instead of
getting a value from a key, I want the key from a value). Is there a way of
doing this? Or would I need to cycle all the keys until I hit a value match
(which seems somewhat cumbersome). 

 

Cheers

Mike. 






-- 
http://mail.python.org/mailman/listinfo/python-list

How to read the directory which the actively running python file is located in?

2006-12-01 Thread Michael Malinowski
Is there a way to read the directory that the currently running python file
is located in?
Cheers
Mike.

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to read the directory which the actively running python file islocated in?

2006-12-01 Thread Michael Malinowski
Nevermind, I got it using the sys.argv[0]

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Michael Malinowski
Sent: Friday, December 01, 2006 9:07 AM
To: [email protected]
Subject: How to read the directory which the actively running python file
islocated in?

Is there a way to read the directory that the currently running python file
is located in?
Cheers
Mike.

-- 
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list