How to control the creation of an instance?

7stud bbxx789_05ss at yahoo.com
Sun Jun 3 03:28:18 EDT 2007


On Jun 3, 12:50 am, Steven D'Aprano
<s... at REMOVE.THIS.cybersource.com.au> wrote:
> On Sat, 02 Jun 2007 23:25:49 -0700, 7stud wrote:
> > Oops.  This line:
>
> >> temp = object.__new__(Sample, args, kwds)
>
> > should be:
>
> > temp = object.__new__(cls, args, kwds)
>
> > although it would seem that cls is always going to be Sample, so I'm
> > not sure what practical difference that makes.
>
> What if you are calling it from a sub-class?
>
> --
> Steven.

cls it is!




More information about the Python-list mailing list