Accessors in Python (getters and setters)

Bruno Desthuilliers onurb at xiludom.gro
Tue Jul 11 04:15:10 EDT 2006


ZeD wrote:
> Bruno Desthuilliers wrote:
> 
> 
>>>I decided to change the name of an attribute. Problem is I've used the
>>>attribute in several places spanning thousands of lines of code. If I
>>>had encapsulated the attribute via an accessor, I wouldn't need to do
>>>an unreliable and tedious search and replace
>>
>>find and grep are usually mostly reliable for this kind of tasks.
> 
> 
> you mean sed :)

No, I meant find and grep.

> sed 's/oldName/newName/g' oldFile > newFile
> 
Yeah, fine - as long as your pretty sure the same name is not used in
other contexts in any of the source files...

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list