Re: def __init__(self,cls):

2016-04-29 Thread Steven D'Aprano
On Fri, 29 Apr 2016 07:47 pm, San wrote: > Dear Group, > > Please explain the following in details. > > " > def __init__(self,cls): > self.cls = cls The answer is the same as the answer you were given when you asked this question on the tutor mailing list. Di

Re: def __init__(self,cls):

2016-04-29 Thread Michiel Overtoom
> On 2016-04-29, at 11:47, San wrote: > > Dear Group, please explain the following in details. Thanks in Advance. > > def __init__(self,cls): >self.cls = cls Is this homework? Why don't you explain it first in your own words, then let us comment on it?

def __init__(self,cls):

2016-04-29 Thread San
Dear Group, Please explain the following in details. " def __init__(self,cls): self.cls = cls " Thanks in Advance. San -- https://mail.python.org/mailman/listinfo/python-list

Re: def __init__(self):

2016-04-26 Thread Steven D'Aprano
On Wednesday 27 April 2016 02:59, Chris Kaynor wrote: > On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano > wrote: > >> Actually immutable, short of doing wicked things with ctypes. >> > > By wicked things with ctypes, do you mean something like this? By no means > do I suggest this actually be

Re: def __init__(self):

2016-04-26 Thread Chris Angelico
On Wed, Apr 27, 2016 at 3:13 AM, Chris Kaynor wrote: > Yah, if you really wanted to make it work properly, you'd need to incref > the newValue, while decref the oldValue. The incref would not be that > difficult, but the decref would be more challenging, as you may have to > also destroy the old o

Re: def __init__(self):

2016-04-26 Thread Ian Kelly
On Tue, Apr 26, 2016 at 11:13 AM, Chris Kaynor wrote: > Yah, if you really wanted to make it work properly, you'd need to incref > the newValue, while decref the oldValue. The incref would not be that > difficult, but the decref would be more challenging, as you may have to > also destroy the old

Re: def __init__(self):

2016-04-26 Thread Chris Kaynor
On Tue, Apr 26, 2016 at 10:04 AM, Chris Angelico wrote: > On Wed, Apr 27, 2016 at 2:59 AM, Chris Kaynor > wrote: > > On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano > > wrote: > > > >> Subclassing immutable built-ins is the most obvious and simple (and > >> probably > >> common) way to get an

Re: def __init__(self):

2016-04-26 Thread Chris Angelico
On Wed, Apr 27, 2016 at 2:59 AM, Chris Kaynor wrote: > On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano > wrote: > >> Subclassing immutable built-ins is the most obvious and simple (and >> probably >> common) way to get an immutable class. Actually immutable, short of doing >> wicked things with

Re: def __init__(self):

2016-04-26 Thread Chris Kaynor
On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano wrote: > Subclassing immutable built-ins is the most obvious and simple (and > probably > common) way to get an immutable class. Actually immutable, short of doing > wicked things with ctypes. > By wicked things with ctypes, do you mean something

Re: def __init__(self):

2016-04-26 Thread Marko Rauhamaa
Steven D'Aprano : > On Tue, 26 Apr 2016 06:25 pm, Marko Rauhamaa wrote: >> Check out some of the stdlib source code for example: >> >> >> class ThreadPoolExecutor(_base.Executor): >&

Re: def __init__(self):

2016-04-26 Thread Steven D'Aprano
On Wed, 27 Apr 2016 02:26 am, Random832 wrote: > On Tue, Apr 26, 2016, at 12:12, Steven D'Aprano wrote: >> The obvious reason for overriding __new__ is to construct an immutable >> instance. You have to override __new__, because by the time it returns >> the >> instance is immutable and you can no

Re: def __init__(self):

2016-04-26 Thread Random832
On Tue, Apr 26, 2016, at 12:12, Steven D'Aprano wrote: > The obvious reason for overriding __new__ is to construct an immutable > instance. You have to override __new__, because by the time it returns > the > instance is immutable and you can no longer initialise it. Other than by subclassing an e

Re: def __init__(self):

2016-04-26 Thread Steven D'Aprano
as been called. No object can guarantee that any method is called. Python doesn't make an exception for __new__ or __init__. I'm not sure why you would want it to. > Check out some of the stdlib source code for example: > > ===

Re: def __init__(self):

2016-04-26 Thread Gary Herron
On 04/26/2016 06:49 AM, Random832 wrote: On Tue, Apr 26, 2016, at 03:34, Ben Finney wrote: That's needlessly confusing: ‘__init__’ is not a constructor because it does not construct the instance. The ‘__new__’ method is the constructor for a class (and returns the new instance). the __new__ met

Re: def __init__(self):

2016-04-26 Thread Random832
On Tue, Apr 26, 2016, at 03:34, Ben Finney wrote: > That's needlessly confusing: ‘__init__’ is not a constructor because it > does not construct the instance. The ‘__new__’ method is the constructor > for a class (and returns the new instance). the __new__ method is the *allocator*. "constructor"

Re: def __init__(self):

2016-04-26 Thread Marko Rauhamaa
======= class ThreadPoolExecutor(_base.Executor): def __init__(self, max_workers): """Initializes a new ThreadPoolExecutor instance. Args: max_workers: The maximum number of threads that can be used to exec

Re: def __init__(self):

2016-04-26 Thread Ben Finney
Gary Herron writes: >The __init__ method is the constructor for instances of a class. It >is not required, but the situations in which a constructor is not >needed are few and unusual. That's needlessly confusing: ‘__init__’ is not a constructor because it does not construct the ins

Re: def __init__(self):

2016-04-26 Thread Gary Herron
On 04/25/2016 11:21 PM, San wrote: Hi All, Pls let me why " def __init__(self): " declaration required, what's the use of this one.Pls explain me in details. Thanks in advance. If you understand object-oriented-programming, then this will make sense: The __init_

Re: def __init__(self):

2016-04-25 Thread Ben Finney
San writes: > Pls let me why […] declaration required, what's the use of this one. Welcome to Python! Congratulations on beginning to learn this language. > Pls explain me in details. You should participate in our collaborative tutoring forum, ‘tutor’ https://mail.python.org/mailman/listinfo/

def __init__(self):

2016-04-25 Thread San
Hi All, Pls let me why " def __init__(self): " declaration required, what's the use of this one.Pls explain me in details. Thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list

Re: def __init__(self, link, *arg, **key):

2006-08-10 Thread flogic
Thanks a lot... CIAO Duncan Booth wrote: > flogic wrote: > > > Hi > > i m a newbie to python .. > > jus started to learn ...am quite confused about variable arguments used > > in python functions and in init. > > > > i dont where to use **keys , **kwds,*args ...etc... > > > > if anyone culd gi

Re: def __init__(self, link, *arg, **key):

2006-08-10 Thread Duncan Booth
flogic wrote: > Hi > i m a newbie to python .. > jus started to learn ...am quite confused about variable arguments used > in python functions and in init. > > i dont where to use **keys , **kwds,*args ...etc... > > if anyone culd give some explanation with examples or clear detailed > web link,

def __init__(self, link, *arg, **key):

2006-08-10 Thread flogic
thanks in advance i have a python code like shown below examples: def __init__(self, link, *arg, **key): blah blah def setTransponderDefaultConfiguration(self, *arg, **kwds): blah blah -- http://mail.python.org/mailman/listinfo/python-list