replace mothod for only one object but not for a class

2008-10-14 Thread hofer
Hi, I have multiple objects all belonging to the same class (which I didn't implement and whose code I don't want to modify) Now I'd like to change one method for one object only (after it has been created) without adding any overhead to the call of the other object's methods. Is this possible

Re: replace mothod for only one object but not for a class

2008-10-15 Thread hofer
On Oct 14, 7:50 pm, hofer <[EMAIL PROTECTED]> wrote: > Hi, > > I have multiple objects all belonging to the same class >  (which I didn't implement and whose code I don't want to modify) > > Now I'd like to change one method for one object only (after it

Re: replace mothod for only one object but not for a class

2008-10-15 Thread hofer
Hi > > hofer a écrit : > >> I have multiple objects all belonging to the same class > >> (which I didn't implement and whose code I don't want to modify) > > >> Now I'd like to change one method for one object only (after it has > >> b

converting a sed / grep / awk / . . . bash pipe line into python

2008-09-02 Thread hofer
Hi, Something I have to do very often is filtering / transforming line based file contents and storing the result in an array or a dictionary. Very often the functionallity exists already in form of a shell script with sed / awk / grep , . . . and I would like to have the same implementation in m

dict slice in python (translating perl to python)

2008-09-10 Thread hofer
Hi, Let's take following perl code snippet: %myhash=( one => 1, two => 2, three => 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # <-- line of interest print "$v1\n$v2\n$v2\n"; How do I translate the second line in a similiar compact way to python? Below is what I tried. I'm just in

Re: dict slice in python (translating perl to python)

2008-09-11 Thread hofer
country = itemgetter('name age country'.split())(x) # or any of my above versions # a lot of code using name / age / country thanks a gain and bye H On Sep 10, 5:28 pm, hofer <[EMAIL PROTECTED]> wrote: > Let's take following perl code snippet: > > %myhash=( one  =

Re: dict slice in python (translating perl to python)

2008-09-11 Thread hofer
On Sep 11, 10:36 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: >I'd type the explicit > > v1,v2,v3 = mydict['one'], mydict['two'], mydict['two'] # 54 chars > Either > is only a couple more > characters to type.  It is completely > explicit and comprehensible to everyone, in comparison to > >  

Understanding (and getting rid) of optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a

2008-09-26 Thread hofer
Hi, I get following warning with a python script: optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up my code: from optparse import OptionParser if __name__ == '__main__': parser = OptionParser() parser.add_option('-G','--green'

Re: Understanding (and getting rid) of optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a

2008-09-26 Thread hofer
On Sep 26, 6:21 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > hofer wrote: > > Hi, > > > I get following warning with a python script: > > > optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will > > return a signed string in Python 2.4 and up > &