Just want to point out you can make any function into a generator by having
a yield statement like this:
>>> def previous(listing):
while listing: yield listing.pop()
>>> for num in previous([1,2,3,4]): print(num)
4
3
2
1
The above is an EXAMPLE, not a particularly great way to
Prahallad Achar writes:
> I get list object instead gen obj
If you have a list "l" and want a generator, you can use
( x for x in l)
or simpler "iter(l)" - which gives you an interator over "l".
An "iterator" is slightly more general than a generator
(every generator is also an iterator).
Greg,
Good eye. You are correct!
Yes, that is a side effect I did not intend when I cut and paste and the
darn spell-checker saw it as useful to make my code act like the start of a
normal text sentence. I just replicated it:
>>> float(" nan")
Nan
As I watched, "nan" went to "Nan"
So, indeed,
vergos.niko...@gmail.com writes:
> Τη Πέμπτη, 14 Φεβρουαρίου 2019 - 8:56:31 μ.μ. UTC+2, ο χρήστης MRAB έγραψε:
>
>> It doesn't have a 'b' prefix, so either it's Python 2 or it's a Unicode
>> string that was decoded wrongly from the bytes.
>
> Yes it doesnt have the 'b' prefix so that hexadecimal
On 2019-02-13, Grant Edwards wrote:
> For many, many years I've always installed ActiveState's ActivePython
> Community edition when forced to use Windows. It has always included
> all of the "extra" libraries that I didn't wan't to install (or
> couldn't because I didn't have a C compiler for Wi
Prahallad Achar於 2019年2月15日星期五 UTC+8下午5時27分36秒寫道:
> I get list object instead gen obj
>
> On Fri, 15 Feb 2019, 13:57 Chris Angelico
> > On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar
> > wrote:
> > >
> > > How about this
> > > List1=[ 1,2,3,4]
> > > Rever_gen = ( x*x for x in list1, reversed
I get list object instead gen obj
On Fri, 15 Feb 2019, 13:57 Chris Angelico On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar
> wrote:
> >
> > How about this
> > List1=[ 1,2,3,4]
> > Rever_gen = ( x*x for x in list1, reversed = True)
> >
> > Rever_gen gets generator object and iterating it now ge
Avi Gross wrote:
I can see why you may be wondering. You see the nan concept as having a
specific spelling using all lowercase and to an extent you are right.
No, he's talking about this particular line from the transcript you
posted:
>>>float(" nan")
> Nan
This suggests that the interpreter
On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar wrote:
>
> How about this
> List1=[ 1,2,3,4]
> Rever_gen = ( x*x for x in list1, reversed = True)
>
> Rever_gen gets generator object and iterating it now gets reverse order..
>
> Am I correct here? Suggest me
>
How about reversed(list1) ?
ChrisA
-
vergos.niko...@gmail.com wrote:
[python] con = pymysql.connect( db = 'clientele', user = 'vergos', passwd =
'**', charset = 'utf8' ) cur = con.cursor() [/python]
From that i understand that the names being fetched from the db to pyhton
script are being fetced as utf8, right?
No, I don't th
10 matches
Mail list logo