Re: [Tutor] __init__

2016-08-31 Thread Steven D'Aprano
On Wed, Aug 31, 2016 at 06:35:44PM +, Albert-Jan Roskam wrote: > > >In Python 3, old-style classes are gone. Even in Python 2, they're > >discouraged. > > This suggests that old-style classes are still used, even in Python 3, > doesn't it? > > albertjan@debian:~$ python3.5 > Python 3.5.0 (

Re: [Tutor] generator object

2016-08-31 Thread Alan Gauld via Tutor
On 31/08/16 23:24, Alan Gauld via Tutor wrote: > Then I tried > ... > x = list(2) Should be list(gen(2)) I hope that was obvious... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.

Re: [Tutor] generator object

2016-08-31 Thread Peter Otten
Alan Gauld via Tutor wrote: > On 31/08/16 08:56, Alan Gauld via Tutor wrote: > >> A generator function can return any kind of object including >> basic types like numbers, bool etc.In addition, a generator >> function yields values which can also be of any type. > > Hmmm. > After reading Steven'

Re: [Tutor] generator object

2016-08-31 Thread Alan Gauld via Tutor
On 31/08/16 08:56, Alan Gauld via Tutor wrote: > A generator function can return any kind of object including > basic types like numbers, bool etc.In addition, a generator > function yields values which can also be of any type. Hmmm. After reading Steven's response I played around a bit. While a

Re: [Tutor] __init__

2016-08-31 Thread monik...@netzero.net
Thank you very much. This was very helpful. -- Original Message -- From: Steven D'Aprano To: tutor@python.org Subject: Re: [Tutor] __init__ Date: Wed, 31 Aug 2016 22:39:33 +1000 On Wed, Aug 31, 2016 at 04:05:26AM +, monik...@netzero.net wrote: > Somebody in this line of emai

Re: [Tutor] generator object

2016-08-31 Thread monik...@netzero.net
Aaron Maxwell made a clear distinction between generator function and that it returns a generator object. He emphasized that a couple of times. -- Original Message -- From: Alan Gauld via Tutor To: tutor@python.org Subject: Re: [Tutor] generator object Date: Wed, 31 Aug 2016 08:5

Re: [Tutor] generator object

2016-08-31 Thread monik...@netzero.net
Thank you everybody. This was very helpful Monika -- Original Message -- From: Steven D'Aprano To: tutor@python.org Subject: Re: [Tutor] generator object Date: Wed, 31 Aug 2016 21:24:57 +1000 On Wed, Aug 31, 2016 at 04:12:24AM +, monik...@netzero.net wrote: > > So generator

Re: [Tutor] __init__

2016-08-31 Thread Albert-Jan Roskam
>In Python 3, old-style classes are gone. Even in Python 2, they're >discouraged. This suggests that old-style classes are still used, even in Python 3, doesn't it? albertjan@debian:~$ python3.5 Python 3.5.0 (default, Apr 13 2016, 20:39:27) [GCC 4.9.2] on linux Type "help", "copyright", "cred

Re: [Tutor] __init__

2016-08-31 Thread Steven D'Aprano
On Tue, Aug 30, 2016 at 09:08:13PM +, monik...@netzero.net wrote: > OK so somebodys remark that there is a default __init__ provided was not > correct. It is correct. The default __init__ is provided by object, the root of the class hierarchy. > What about old style classes? When we have a

Re: [Tutor] __init__

2016-08-31 Thread Steven D'Aprano
On Wed, Aug 31, 2016 at 04:05:26AM +, monik...@netzero.net wrote: > Somebody in this line of emails mentioned that python provides default > __init__ if it its not stated in the class by the programmer. And that > it is called by __new__ That may have been me, except I didn't mention __new_

Re: [Tutor] generator object

2016-08-31 Thread Steven D'Aprano
On Wed, Aug 31, 2016 at 04:12:24AM +, monik...@netzero.net wrote: > > So generator function returns generator object according to Aaron > Maxwell. But does this mean that each time yields "returns" it is a > generator object? So if there are 5 yield "returns" there are 5 > generator objects

Re: [Tutor] generator object

2016-08-31 Thread Peter Otten
monik...@netzero.net wrote: > So generator function returns generator object according to Aaron Maxwell. It's always nice to give a link or a quote. > But does this mean that each time yields "returns" it is a generator > object? So if there are 5 yield "returns" there are 5 generator objects? >

Re: [Tutor] ImportError: cannot import name

2016-08-31 Thread Peter Otten
fa306...@skynet.be wrote: > Hello, > I use python 3.5.1 and try to import sompy and get the following error: > > File > "C:\Anaconda3\lib\site-packages\sompy-1.0-py3.5.egg\sompy\__init__.py", > line 30, in from sompy import SOMFactory > > ImportError: cannot import name 'SOMFactory' > > Wh

Re: [Tutor] generator object

2016-08-31 Thread Alan Gauld via Tutor
On 31/08/16 05:12, monik...@netzero.net wrote: So generator function returns generator object according to Aaron Maxwell. I don't believe that's correct. A generator function can return any kind of object including basic types like numbers, bool etc.In addition, a generator function yields va

Re: [Tutor] __init__

2016-08-31 Thread monik...@netzero.net
Somebody in this line of emails mentioned that python provides default __init__ if it its not stated in the class by the programmer. And that it is called by __new__ Then later on you corrected that. -- Original Message -- From: Alan Gauld via Tutor To: "monik...@netzero.net" C

[Tutor] generator object

2016-08-31 Thread monik...@netzero.net
So generator function returns generator object according to Aaron Maxwell. But does this mean that each time yields "returns" it is a generator object? So if there are 5 yield "returns" there are 5 generator objects? Or is there always only one generator object returned by the generator functio