Re: ``if var'' and ``if var is not None''

2019-08-31 Thread Frank Millman
On 2019-09-01 8:12 AM, Hongyi Zhao wrote: Hi, The following two forms are always equivalent: ``if var'' and ``if var is not None'' Regards Not so. Here is an example - >>> var = [] >>> bool(var) False >>> bool(var is not None) True >>> Frank Millman -- https://mail.python.org/mailman/lis

Re: ``if var'' and ``if var is not None''

2019-08-31 Thread Chris Angelico
On Sun, Sep 1, 2019 at 4:16 PM Hongyi Zhao wrote: > > Hi, > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > Ahh... False. I'll go False. I'll be honest, I might have heard that one before, though. Sort of cheating. ChrisA -- https://mail.python.o

``if var'' and ``if var is not None''

2019-08-31 Thread Hongyi Zhao
Hi, The following two forms are always equivalent: ``if var'' and ``if var is not None'' Regards -- https://mail.python.org/mailman/listinfo/python-list

Append some stuff into a file with only the last appended line reserved.

2019-08-31 Thread Hongyi Zhao
Hi: I want to append some log of pycurl's downloading info to file, and I only want to reserve the last appended line when write. How to do this? -- https://mail.python.org/mailman/listinfo/python-list

Re: Pygal bar colors

2019-08-31 Thread Cameron Simpson
On 31Aug2019 19:11, CrazyVideoGamez wrote: How do you change the color of the bar in pygal? I want to change it from red to blue. Help! http://www.pygal.org/en/stable/documentation/custom_styles.html You _did_ look at the documentation didn't you? This took me about a minute to find, and I'v

Pygal bar colors

2019-08-31 Thread CrazyVideoGamez
How do you change the color of the bar in pygal? I want to change it from red to blue. Help! -- https://mail.python.org/mailman/listinfo/python-list

Re: pandas loc on str lower for column comparison

2019-08-31 Thread Sayth Renshaw
On Sunday, 1 September 2019 05:19:34 UTC+10, Piet van Oostrum wrote: > Sayth Renshaw writes: > > > But on both occasions I receive this error. > > > > # KeyError: 'the label [Current Team] is not in the [index]' > > > > if I test df1 before trying to create the new column it works just fine. > >

Re: pandas loc on str lower for column comparison

2019-08-31 Thread Piet van Oostrum
Sayth Renshaw writes: > But on both occasions I receive this error. > > # KeyError: 'the label [Current Team] is not in the [index]' > > if I test df1 before trying to create the new column it works just fine. > What do you mean by testing df1? And could it be that 'Current Team' is spelled diff

Re: open, close

2019-08-31 Thread Manfred Lotz
On Sat, 31 Aug 2019 16:37:23 +0200 Peter Otten <__pete...@web.de> wrote: > Manfred Lotz wrote: > > > Hi there, > > This is a beginner question. > > > > I learned that > > > > with open("foo.txt") as f: > > lines = f.readlines() > > > > using the with-construct is the recommended way to

Re: open, close

2019-08-31 Thread Manfred Lotz
On Sat, 31 Aug 2019 15:43:41 +0200 Piet van Oostrum wrote: > Max Zettlmeißl writes: > > > On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz > > wrote: > >> > >> Could I use the latter as a substitute for the with-construct? > >> > > > > You can't use the second statement as a proper substitute

Re: open, close

2019-08-31 Thread Peter Otten
Manfred Lotz wrote: > Hi there, > This is a beginner question. > > I learned that > > with open("foo.txt") as f: > lines = f.readlines() > > using the with-construct is the recommended way to deal with files > making sure that close() always happens. > > However, I also could do: > >

Re: open, close

2019-08-31 Thread Grant Edwards
On 2019-08-31, Manfred Lotz wrote: > Hi there, > This is a beginner question. > > I learned that > > with open("foo.txt") as f: > lines = f.readlines() > > using the with-construct is the recommended way to deal with files > making sure that close() always happens. More importantly, it m

Re: open, close

2019-08-31 Thread Piet van Oostrum
Max Zettlmeißl writes: > On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz wrote: >> >> Could I use the latter as a substitute for the with-construct? >> > > You can't use the second statement as a proper substitute for the first one. > > With the context manager, it is ensured that the file is close

Re: open, close

2019-08-31 Thread Max Zettlmeißl via Python-list
On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz wrote: > > Could I use the latter as a substitute for the with-construct? > You can't use the second statement as a proper substitute for the first one. With the context manager, it is ensured that the file is closed. It's more or less equal to a "fin

open, close

2019-08-31 Thread Manfred Lotz
Hi there, This is a beginner question. I learned that with open("foo.txt") as f: lines = f.readlines() using the with-construct is the recommended way to deal with files making sure that close() always happens. However, I also could do: lines = open("foo.txt").readlines() I have to a

Re: An "Object" class?

2019-08-31 Thread Gregory Ewing
Cristian Cocos wrote: And that is because entities belonging to the same taxonomical class ("clade") have common features, and also inherit the features of the taxonomical parent. I think the notion you're after is what is known in the Python world as a "protocol". This is an informal collectio