Re: Python's super() considered super!

2011-05-30 Thread Duncan Booth
Ethan Furman et...@stoneleaf.us wrote: foo(x=1, y=2, z=3) Traceback (most recent call last): File pyshell#8, line 1, in module foo(x=1, y=2, z=3) File pyshell#4, line 2, in foo bar(y=2, **kwargs) TypeError: bar() got multiple values for keyword argument 'y' And the above

Re: Python's super() considered super!

2011-05-27 Thread Raymond Hettinger
On May 26, 6:39 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: We also, though, need *real* URLs. Blind URLs through obfuscation services have their uses, but surely not in a forum like this. The real URL is URL:http://news.ycombinator.com/item?id=2588262. Fair enough. I had copied the link

Re: Python's super() considered super!

2011-05-27 Thread Ben Finney
Raymond Hettinger pyt...@rcn.com writes: Hope you enjoyed the post. I certainly did. But I'm not better enlightened on why ‘super’ is a good thing. The exquisite care that you describe programmers needing to maintain is IMO just as much a deterrent as the super-is-harmful essay. -- \

Re: Python's super() considered super!

2011-05-27 Thread Michele Simionato
On Friday, May 27, 2011 10:49:52 AM UTC+2, Ben Finney wrote: The exquisite care that you describe programmers needing to maintain is IMO just as much a deterrent as the super-is-harmful essay. Worth quoting. Also I think this article may encourage naive programmers along the dark path of

Re: Python's super() considered super!

2011-05-27 Thread Steven D'Aprano
On Fri, 27 May 2011 18:49:52 +1000, Ben Finney wrote: Raymond Hettinger pyt...@rcn.com writes: Hope you enjoyed the post. I certainly did. But I'm not better enlightened on why ‘super’ is a good thing. Perhaps Raymond assumed that by now everybody knows that multiple inheritance in

Re: Python's super() considered super!

2011-05-27 Thread Duncan Booth
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I was thrilled to learn a new trick, popping keyword arguments before calling super, and wondered why I hadn't thought of that myself. How on earth did I fail to realise that a kwarg dict was mutable and therefore you can remove

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 26 Mai, 18:31, Raymond Hettinger pyt...@rcn.com wrote: I just posted a tutorial and how-to guide for making effective use of super(). One of the reviewers, David Beazley, said, Wow,  that's really great!    I see this becoming the definitive post on the subject The direct link is:  

Re: Python's super() considered super!

2011-05-27 Thread Mel
sturlamolden wrote: I really don't like the Python 2 syntax of super, as it violates the DRY principle: Why do I need to write super(type(self),self) when super() will do? Assuming that 'self' will always be named 'self' in my code, I tend to patch __builtins__.super like this: import sys

Re: Python's super() considered super!

2011-05-27 Thread Steven D'Aprano
On Fri, 27 May 2011 10:33:20 -0400, Mel wrote: sturlamolden wrote: I really don't like the Python 2 syntax of super, as it violates the DRY principle: Why do I need to write super(type(self),self) when super() will do? Assuming that 'self' will always be named 'self' in my code, I tend to

Re: Python's super() considered super!

2011-05-27 Thread Michele Simionato
The fact that even experienced programmers fail to see that super(type(self),self) in Python 2 is NOT equivalent to super() in Python 3 is telling something. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's super() considered super!

2011-05-27 Thread Duncan Booth
sturlamolden sturlamol...@yahoo.no wrote: On 26 Mai, 18:31, Raymond Hettinger pyt...@rcn.com wrote: I just posted a tutorial and how-to guide for making effective use of super(). One of the reviewers, David Beazley, said, Wow,  that's really great!    I see this becoming the definitive post

Re: Python's super() considered super!

2011-05-27 Thread harrismh777
Steven D'Aprano wrote: Python causes trouble by letting the users get at the internals, but things like this make it worthwhile. Only if by worthwhile you mean buggy as hell. I *don't* believe this... the king of metaphors and bogus analogies has come up with 'buggy as hell' !!?

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 27 Mai, 16:27, sturlamolden sturlamol...@yahoo.no wrote: Assuming that 'self' will always be named 'self' in my code, I tend to patch __builtins__.super like this: import sys def super():     self = sys._getframe().f_back.f_locals['self']     return __builtins__.super(type(self),self)

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 27 Mai, 17:05, Duncan Booth duncan.bo...@invalid.invalid wrote: class C(B): pass C().foo() ... infinite recursion follows ... That's true :( -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 27 Mai, 17:05, Duncan Booth duncan.bo...@invalid.invalid wrote: Oops. There's a reason why Python 2 requires you to be explicit about the class; you simply cannot work it out automatically at run time. Python 3 fixes this by working it out at compile time, but for Python 2 there is no way

Re: Python's super() considered super!

2011-05-27 Thread Steven D'Aprano
On Fri, 27 May 2011 08:31:40 -0700, sturlamolden wrote: On 27 Mai, 17:05, Duncan Booth duncan.bo...@invalid.invalid wrote: Oops. There's a reason why Python 2 requires you to be explicit about the class; you simply cannot work it out automatically at run time. Python 3 fixes this by working

Re: Python's super() considered super!

2011-05-27 Thread Ethan Furman
Duncan Booth wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I was thrilled to learn a new trick, popping keyword arguments before calling super, and wondered why I hadn't thought of that myself. How on earth did I fail to realise that a kwarg dict was mutable and therefore

Re: Python's super() considered super!

2011-05-27 Thread Eric Snow
On Fri, May 27, 2011 at 4:37 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 27 May 2011 18:49:52 +1000, Ben Finney wrote: Raymond Hettinger pyt...@rcn.com writes: Hope you enjoyed the post. I certainly did. But I'm not better enlightened on why ‘super’ is

RE: Python's super() considered super!

2011-05-27 Thread Prasad, Ramit
We also, though, need *real* URLs. Blind URLs through obfuscation services have their uses, but surely not in a forum like this. The real URL is URL:http://news.ycombinator.com/item?id=2588262. I remember reading a news article where a man was arrested (or was it fired) for pornography because

Re: Python's super() considered super!

2011-05-27 Thread Ian Kelly
On Thu, May 26, 2011 at 10:31 AM, Raymond Hettinger pyt...@rcn.com wrote: I just posted a tutorial and how-to guide for making effective use of super(). I posted this already on the HackerNews thread but it seems to have largely gone unnoticed, so I'm reposting it here. It seems to me that the

Re: Python's super() considered super!

2011-05-27 Thread Chris Angelico
On Sat, May 28, 2011 at 4:10 AM, Prasad, Ramit ramit.pra...@jpmchase.com wrote: We also, though, need *real* URLs. Blind URLs through obfuscation services have their uses, but surely not in a forum like this. The real URL is URL:http://news.ycombinator.com/item?id=2588262. I remember reading a

Re: Python's super() considered super!

2011-05-27 Thread Chris Angelico
On Sat, May 28, 2011 at 4:31 AM, Ian Kelly ian.g.ke...@gmail.com wrote: It seems to me that the example of combining built-in dictionary classes is naively optimistic. So... Can anyone offer a non-trivial example of multiple inheritance that *doesn't* have pitfalls? From what I've seen, MI

Re: Python's super() considered super!

2011-05-27 Thread John Nagle
On 5/27/2011 11:46 AM, Chris Angelico wrote: On Sat, May 28, 2011 at 4:31 AM, Ian Kellyian.g.ke...@gmail.com wrote: It seems to me that the example of combining built-in dictionary classes is naively optimistic. So... Can anyone offer a non-trivial example of multiple inheritance that

Re: Python's super() considered super!

2011-05-27 Thread Stefan Behnel
Steven D'Aprano, 27.05.2011 18:06: On Fri, 27 May 2011 08:31:40 -0700, sturlamolden wrote: On 27 Mai, 17:05, Duncan Boothduncan.bo...@invalid.invalid wrote: Oops. There's a reason why Python 2 requires you to be explicit about the class; you simply cannot work it out automatically at run

Re: Python's super() considered super!

2011-05-27 Thread Ethan Furman
I suspect the larger issue is that Multiple Inheritance is complex, but folks don't appreciate that. Ask anyone about meta-classes and their eyes bug-out, but MI? Simple! NOT. On the other hand, perhaps the docs should declare that the built-in objects are not designed for MI, so that

Re: Python's super() considered super!

2011-05-27 Thread Ryan Kelly
On Fri, 2011-05-27 at 15:05 +, Duncan Booth wrote: sturlamolden sturlamol...@yahoo.no wrote: I really don't like the Python 2 syntax of super, as it violates the DRY principle: Why do I need to write super(type(self),self) when super() will do? Assuming that 'self' will always be named

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 27 Mai, 23:49, Stefan Behnel stefan...@behnel.de wrote: I think Sturla is referring to the compile time bit. CPython cannot know that the builtin super() will be called at runtime, even if it sees a super() function call. Yes. And opposite: CPython cannot know that builtin super() is not

Re: Python's super() considered super!

2011-05-27 Thread sturlamolden
On 27 Mai, 18:06, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Why? The fault is not that super is a function, or that you monkey- patched it, or that you used a private function to do that monkey- patching. The fault was that you made a common, but silly, mistake when

Re: Python's super() considered super!

2011-05-27 Thread Thomas Rachel
Am 28.05.2011 01:57 schrieb sturlamolden: Yes. And opposite: CPython cannot know that builtin super() is not called, even if it does not see the name 'super'. I can easily make foo() alias super(). Another alternative would have been to make use of __xxx magic. If every class had an

Python's super() considered super!

2011-05-26 Thread Raymond Hettinger
I just posted a tutorial and how-to guide for making effective use of super(). One of the reviewers, David Beazley, said, Wow, that's really great!I see this becoming the definitive post on the subject The direct link is: http://rhettinger.wordpress.com/2011/05/26/super-considered-super/

Re: Python's super() considered super!

2011-05-26 Thread Raymond Hettinger
It would also be great if some of you would upvote it on HackerNews. Here's a link to the super() how-to-guide and commentary: bit.ly/ iFm8g3 Raymod -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's super() considered super!

2011-05-26 Thread Dotan Cohen
On Thu, May 26, 2011 at 19:39, Raymond Hettinger pyt...@rcn.com wrote: It would also be great if some of you would upvote it on HackerNews. Here's a link to the super() how-to-guide and commentary:  bit.ly/ iFm8g3 Is that the same link as in the OP? I don't click on blind links, so if it

Re: Python's super() considered super!

2011-05-26 Thread Ian Kelly
On Thu, May 26, 2011 at 12:13 PM, Dotan Cohen dotanco...@gmail.com wrote: On Thu, May 26, 2011 at 19:39, Raymond Hettinger pyt...@rcn.com wrote: It would also be great if some of you would upvote it on HackerNews. Here's a link to the super() how-to-guide and commentary:  bit.ly/ iFm8g3

Re: Python's super() considered super!

2011-05-26 Thread Dotan Cohen
On Thu, May 26, 2011 at 21:38, Ian Kelly ian.g.ke...@gmail.com wrote: It's a link to ycombinator: http://news.ycombinator.com/item?id=2588262 Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's super() considered super!

2011-05-26 Thread Terry Reedy
On 5/26/2011 2:13 PM, Dotan Cohen wrote: On Thu, May 26, 2011 at 19:39, Raymond Hettingerpyt...@rcn.com wrote: It would also be great if some of you would upvote it on HackerNews. Here's a link to the super() how-to-guide and commentary: bit.ly/ iFm8g3 Is that the same link as in the

Re: Python's super() considered super!

2011-05-26 Thread Ben Finney
Raymond Hettinger pyt...@rcn.com writes: I just posted a tutorial and how-to guide for making effective use of super(). Thanks very much! We need articles like this. Raymond Hettinger pyt...@rcn.com writes: Here's a link to the super() how-to-guide and commentary: bit.ly/ iFm8g3 We also,