Re: Why this doesn't work?

2010-02-19 Thread Bruno Desthuilliers
at 0xb7cb522c m2 = f.bar m2 bound method Foo.bar of __main__.Foo object at 0xb7cb522c id(m1) 3084861188L id(m2) 3083656564L m1 is m2 False I think this should help you understand why your code doesn't work as you assumed it would !-) PS : as a side note, a common optimization trick

Re: Why this doesn't work?

2010-02-19 Thread mk
Steven D'Aprano wrote: On Thu, 18 Feb 2010 18:28:44 +0100, mk wrote: nostat.__orig_get__ = nostat.__get__ I should point out that leading-and-trailing-double-underscore names are reserved for use by the language. Right... I completely missed that. I will try to change the habit. I

Re: Why this doesn't work?

2010-02-19 Thread mk
John Posner wrote: a False I expected to see 'nostatget' output: nostat.__get__ = nostatget obviously failed to replace this function's __get__ method. I don't quite understand the above sentence, so I'm assuming that you wanted the final is test to be True instead of False. No. I should

Re: Why this doesn't work?

2010-02-19 Thread Bruno Desthuilliers
mk a écrit : Steven D'Aprano wrote: On Thu, 18 Feb 2010 18:28:44 +0100, mk wrote: nostat.__orig_get__ = nostat.__get__ I should point out that leading-and-trailing-double-underscore names are reserved for use by the language. Right... I completely missed that. I will try to change

Re: Why this doesn't work?

2010-02-19 Thread Bruno Desthuilliers
mk a écrit : John Posner wrote: a False I expected to see 'nostatget' output: nostat.__get__ = nostatget obviously failed to replace this function's __get__ method. I don't quite understand the above sentence, so I'm assuming that you wanted the final is test to be True instead of False.

Why this doesn't work?

2010-02-18 Thread mk
Sorry to bother everyone again, but I have this problem bugging me: #!/usr/bin/python -i class Foo(object): def nostat(self,val): print val nostat.__orig_get__ = nostat.__get__ @staticmethod def nostatget(*args, **kwargs): print 'args:', args, 'kwargs:',

Re: Why this doesn't work?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 18:28:44 +0100, mk wrote: nostat.__orig_get__ = nostat.__get__ I should point out that leading-and-trailing-double-underscore names are reserved for use by the language. It's unlikely that Python will introduce a special method named __orig_get__, and in truth the

Re: Why this doesn't work?

2010-02-18 Thread John Posner
On 2/18/2010 12:28 PM, mk wrote: Sorry to bother everyone again, but I have this problem bugging me: #!/usr/bin/python -i class Foo(object): def nostat(self,val): print val nostat.__orig_get__ = nostat.__get__ @staticmethod def nostatget(*args, **kwargs): print 'args:', args, 'kwargs:',

can someone tell me why this doesn't work please python 3

2009-01-14 Thread garywood
def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no', 'nope'): return False retries = retries - 1 if retries 0:

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Gary M. Josack
garywood wrote: def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no', 'nope'): return False retries = retries - 1 if retries

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Ben Kaplan
On Jan 14, 2009, at 9:44 AM, Gary M. Josack g...@byoteki.com wrote: garywood wrote: def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no',

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Gary M. Josack
Ben Kaplan wrote: On Jan 14, 2009, at 9:44 AM, Gary M. Josack g...@byoteki.com wrote: garywood wrote: def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return True if password

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Michael Hartl
garywood schrieb: def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no', 'nope'): return False retries = retries - 1 if

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Scott David Daniels
Gary M. Josack wrote: Ben Kaplan wrote: On Jan 14, 2009, at 9:44 AM, Gary M. Josack g...@byoteki.com wrote: garywood wrote: def ask_ok(prompt, retries=4, complaint=Yes or no, please!): while True: password = input(enter something) if password in ('y', 'ye', 'yes'): return

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Steven D'Aprano
On Wed, 14 Jan 2009 09:45:58 -0800, Dennis Lee Bieber wrote: Personally -- I'd accept anything that started with the character: while True: password = input(prompt).lower() if password.startswith(y): return True elif

Re: Why it doesn't work?

2006-01-09 Thread Martin P. Hellwig
Lad wrote: I have a list L={} Now I can assign the value L['a']=1 and I have L={'a': 1} but I would like to have a dictionary like this L={'a': {'b':2}} so I would expect I can do L['a']['b']=2 but it does not work. Why? Thank you for reply Rg, L. Hi, Perhaps what you try

Why it doesn't work?

2006-01-09 Thread Lad
I have a list L={} Now I can assign the value L['a']=1 and I have L={'a': 1} but I would like to have a dictionary like this L={'a': {'b':2}} so I would expect I can do L['a']['b']=2 but it does not work. Why? Thank you for reply Rg, L. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why it doesn't work?

2006-01-09 Thread Tomasz Lisowski
Lad wrote: I have a list L={} This IS a dictionary, not a list. Now I can assign the value L['a']=1 and I have L={'a': 1} but I would like to have a dictionary like this L={'a': {'b':2}} You need to initialise L['a'] first, before referencing L['a']['b'] So, you need to call first:

Re: Why it doesn't work?

2006-01-09 Thread Peter Otten
Lad wrote: I have a list A dictionary. L={} Now I can assign the value L['a']=1 and I have L={'a': 1} but I would like to have a dictionary like this L={'a': {'b':2}} so I would expect I can do L['a']['b']=2 but it does not work. Why? D[a][b] = 2 translates to