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
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
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
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
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.
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:',
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
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:',
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:
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
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',
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
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
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
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
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
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
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:
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
19 matches
Mail list logo