Re: forcing a definition to be called on attribute change

2006-10-24 Thread Bruno Desthuilliers
Rob Williscroft a écrit : > Bruno Desthuilliers wrote in news:[EMAIL PROTECTED] in > comp.lang.python: > > >>>class cSphere() : >> >>OT : prefixing classes names with 'c' is totally unpythonic. > > > My understanding of "pythonic" is that its about how you use the > language not what style yo

Re: forcing a definition to be called on attribute change

2006-10-24 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Rob Williscroft wrote: > Bruno Desthuilliers wrote in news:[EMAIL PROTECTED] in > comp.lang.python: > >>> class cSphere() : >> >> OT : prefixing classes names with 'c' is totally unpythonic. > > My understanding of "pythonic" is that its about how you use the > languag

Re: forcing a definition to be called on attribute change

2006-10-24 Thread Rob Williscroft
Bruno Desthuilliers wrote in news:[EMAIL PROTECTED] in comp.lang.python: >> class cSphere() : > > OT : prefixing classes names with 'c' is totally unpythonic. My understanding of "pythonic" is that its about how you use the language not what style you code in. Here's a variation of the usual

Re: forcing a definition to be called on attribute change

2006-10-24 Thread Bruno Desthuilliers
Michael Malinowski wrote: > 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 s/run a function definition in the class/call a method/ > whenever a specific attribute i

Re: forcing a definition to be called on attribute change

2006-10-24 Thread Fredrik Lundh
Michael Malinowski wrote: > 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? you can implement a __setattr__ hook, or, in Python 2.2 and

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__(sel