Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18016
| From | Lie Ryan <lie.1296@gmail.com> |
|---|---|
| Subject | Re: confused about __new__ |
| Date | 2011-12-27 18:47 +1100 |
| References | <MPbKq.47607$cN1.25052@newsfe12.iad> <alpine.DEB.2.02.1112270633320.4050@pc7.dolda2000.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4129.1324972062.27778.python-list@python.org> (permalink) |
On 12/27/2011 04:48 PM, Fredrik Tolf wrote:
> On Mon, 26 Dec 2011, K. Richard Pixley wrote:
>> I don't understand. Can anyone explain?
>
> I'm also a bit confused about __new__. I'd very much appreciate it if
> someone could explain the following aspects of it:
>
> * The manual (<http://docs.python.org/reference/datamodel.html>) says
> that __new__ is "a static method (special-cased so you need not declare
> it as such)". What does "special-cased" mean? Apparently, for
> instance, in OP's case, Python did not automatically detect that it
> should not be bound as a method.
If you declare new in the regular way:
class Foo(object):
def __new__(cls):
...
Python would create __new__ as a static method even without applying the
staticmethod decorator; that python does not detect to special case
__new__ when it is added dynamically is probably an oversight in Python
2.x that was fixed in Python 3.x.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
confused about __new__ "K. Richard Pixley" <rich@noir.com> - 2011-12-26 20:28 -0800
Re: confused about __new__ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-27 04:53 +0000
Re: confused about __new__ K Richard Pixley <rich@noir.com> - 2011-12-26 21:27 -0800
Re: confused about __new__ Fredrik Tolf <fredrik@dolda2000.com> - 2011-12-27 06:48 +0100
Re: confused about __new__ K Richard Pixley <rich@noir.com> - 2011-12-27 09:41 -0800
Re: confused about __new__ Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 11:28 -0700
Re: confused about __new__ Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 13:34 -0700
Re: confused about __new__ K Richard Pixley <rich@noir.com> - 2011-12-27 14:19 -0800
Re: confused about __new__ Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 15:43 -0700
Re: confused about __new__ K Richard Pixley <rich@noir.com> - 2011-12-27 12:31 -0800
Re: confused about __new__ Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 00:28 -0700
Re: confused about __new__ Lie Ryan <lie.1296@gmail.com> - 2011-12-27 18:47 +1100
Re: confused about __new__ Fredrik Tolf <fredrik@dolda2000.com> - 2011-12-27 19:05 +0100
csiph-web