Re: How to have python 2 and 3 both on windows?

2022-04-23 Thread Dennis Lee Bieber
On Sun, 24 Apr 2022 01:19:38 + (UTC), Sunil KR declaimed the following: > >-- Why are my strings being sent to python3, so that I get the unicode related >error? >-- in other cases I see error pertaining to the print function In python2, the default for strings is BYTES -- you must

Re: How to have python 2 and 3 both on windows?

2022-04-23 Thread Sunil KR via Python-list
I am happy with how the python starts up. When I use python I get python 2.  I am ok with using py -3 for my new scripts, even using the shebang like #!py -3 I don't want to put a unix (or for that matter windows) path in the shebang, as it is not platform portable But the real question/s for me i

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 10:04, Cameron Simpson wrote: > > On 24Apr2022 08:21, Chris Angelico wrote: > >On Sun, 24 Apr 2022 at 08:18, Cameron Simpson wrote: > >> An approach I think you both may have missed: mmap the file and use > >> mmap.rfind(b'\n') to locate line delimiters. > >> https://docs.

Re: tail

2022-04-23 Thread Cameron Simpson
On 24Apr2022 08:21, Chris Angelico wrote: >On Sun, 24 Apr 2022 at 08:18, Cameron Simpson wrote: >> An approach I think you both may have missed: mmap the file and use >> mmap.rfind(b'\n') to locate line delimiters. >> https://docs.python.org/3/library/mmap.html#mmap.mmap.rfind > >Yeah, I made a v

Re: Style for docstring

2022-04-23 Thread dn
On 23/04/2022 08.35, Michael F. Stemper wrote: > On 22/04/2022 14.59, Chris Angelico wrote: >> On Sat, 23 Apr 2022 at 05:56, Michael F. Stemper >> wrote: >>> >>> I'm writing a function that is nearly self-documenting by its name, >>> but still want to give it a docstring. Which of these would be >

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 08:18, Cameron Simpson wrote: > > On 24Apr2022 07:15, Chris Angelico wrote: > >On Sun, 24 Apr 2022 at 07:13, Marco Sulla > >wrote: > >> Emh, why chunks? My function simply reads byte per byte and compares > >> it to b"\n". When it find it, it stops and do a readline(): >

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 08:06, dn wrote: > > On 24/04/2022 09.15, Chris Angelico wrote: > > On Sun, 24 Apr 2022 at 07:13, Marco Sulla > > wrote: > >> > >> On Sat, 23 Apr 2022 at 23:00, Chris Angelico wrote: > > This is quite inefficient in general. > > Why inefficient? I think that

Re: tail

2022-04-23 Thread Cameron Simpson
On 24Apr2022 07:15, Chris Angelico wrote: >On Sun, 24 Apr 2022 at 07:13, Marco Sulla wrote: >> Emh, why chunks? My function simply reads byte per byte and compares >> it to b"\n". When it find it, it stops and do a readline(): [...] >> This is only for one line and in utf8, but it can be general

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 08:03, Peter J. Holzer wrote: > > On 2022-04-24 04:57:20 +1000, Chris Angelico wrote: > > On Sun, 24 Apr 2022 at 04:37, Marco Sulla > > wrote: > > > What about introducing a method for text streams that reads the lines > > > from the bottom? Java has also a ReversedLinesFi

Re: tail

2022-04-23 Thread dn
On 24/04/2022 09.15, Chris Angelico wrote: > On Sun, 24 Apr 2022 at 07:13, Marco Sulla > wrote: >> >> On Sat, 23 Apr 2022 at 23:00, Chris Angelico wrote: > This is quite inefficient in general. Why inefficient? I think that readlines() will be much slower, not only more time c

Re: tail

2022-04-23 Thread Peter J. Holzer
On 2022-04-24 04:57:20 +1000, Chris Angelico wrote: > On Sun, 24 Apr 2022 at 04:37, Marco Sulla > wrote: > > What about introducing a method for text streams that reads the lines > > from the bottom? Java has also a ReversedLinesFileReader with Apache > > Commons IO. > > It's fundamentally diffi

Re: Receive a signal when waking or suspending?

2022-04-23 Thread Skip Montanaro
> I don't know in Python, but maybe you can create a script that writes > on a named pipe and read it from Python? > https://askubuntu.com/questions/226278/run-script-on-wakeup Thanks, that gives me something to munch on. -- https://mail.python.org/mailman/listinfo/python-list

Re: Receive a signal when waking or suspending?

2022-04-23 Thread dn
On 24/04/2022 07.36, Skip Montanaro wrote: > It's not clear there is a straightforward way to catch a signal or get > an event notification when my computer (Dell running XUbuntu 20.04) is > about to sleep or when it's just awakened. The app uses tkinter. Is > there some more-or-less easy way to do

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 07:13, Marco Sulla wrote: > > On Sat, 23 Apr 2022 at 23:00, Chris Angelico wrote: > > > > This is quite inefficient in general. > > > > > > Why inefficient? I think that readlines() will be much slower, not > > > only more time consuming. > > > > It depends on which is more

Re: tail

2022-04-23 Thread Marco Sulla
On Sat, 23 Apr 2022 at 23:00, Chris Angelico wrote: > > > This is quite inefficient in general. > > > > Why inefficient? I think that readlines() will be much slower, not > > only more time consuming. > > It depends on which is more costly: reading the whole file (cost > depends on size of file) o

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 06:41, Marco Sulla wrote: > > On Sat, 23 Apr 2022 at 20:59, Chris Angelico wrote: > > > > On Sun, 24 Apr 2022 at 04:37, Marco Sulla > > wrote: > > > > > > What about introducing a method for text streams that reads the lines > > > from the bottom? Java has also a Reversed

Re: tail

2022-04-23 Thread Marco Sulla
On Sat, 23 Apr 2022 at 20:59, Chris Angelico wrote: > > On Sun, 24 Apr 2022 at 04:37, Marco Sulla > wrote: > > > > What about introducing a method for text streams that reads the lines > > from the bottom? Java has also a ReversedLinesFileReader with Apache > > Commons IO. > > It's fundamentally

Re: Receive a signal when waking or suspending?

2022-04-23 Thread Marco Sulla
I don't know in Python, but maybe you can create a script that writes on a named pipe and read it from Python? https://askubuntu.com/questions/226278/run-script-on-wakeup -- https://mail.python.org/mailman/listinfo/python-list

Receive a signal when waking or suspending?

2022-04-23 Thread Skip Montanaro
It's not clear there is a straightforward way to catch a signal or get an event notification when my computer (Dell running XUbuntu 20.04) is about to sleep or when it's just awakened. The app uses tkinter. Is there some more-or-less easy way to do this? Mac support would be nice (I have my eye on

Re: Style for docstring

2022-04-23 Thread jan via Python-list
"return true iff this". I like this. jan On 23/04/2022, Stefan Ram wrote: > Rob Cliffe writes: >>I'm curious as to why so many people prefer "Return" to "Returns". > > The commands, er, names of functions, use the imperative mood > ("print", not "prints"). So, "return" aligns with that moo

Re: tail

2022-04-23 Thread Chris Angelico
On Sun, 24 Apr 2022 at 04:37, Marco Sulla wrote: > > What about introducing a method for text streams that reads the lines > from the bottom? Java has also a ReversedLinesFileReader with Apache > Commons IO. It's fundamentally difficult to get precise. In general, there are three steps to reading

Re: Style for docstring

2022-04-23 Thread Dan Stromberg
On Fri, Apr 22, 2022 at 12:56 PM Michael F. Stemper < michael.stem...@gmail.com> wrote: > I'm writing a function that is nearly self-documenting by its name, > but still want to give it a docstring. Which of these would be > best from a stylistic point of view: > > >Tells caller whether or not

tail

2022-04-23 Thread Marco Sulla
What about introducing a method for text streams that reads the lines from the bottom? Java has also a ReversedLinesFileReader with Apache Commons IO. -- https://mail.python.org/mailman/listinfo/python-list

Re: Style for docstring

2022-04-23 Thread Avi Gross via Python-list
Given what you added, Michael, your function is part of a larger collection of functions and being compatible with the others is a valid consideration. Whatever you decide, would ideally be done consistently with all or most of them. And, of course, it others in the collection also can handle mu

Re: Style for docstring

2022-04-23 Thread Michael F. Stemper
On 22/04/2022 16.12, alister wrote: On Fri, 22 Apr 2022 14:36:27 -0500, Michael F. Stemper wrote: I'm writing a function that is nearly self-documenting by its name, but still want to give it a docstring. Which of these would be best from a stylistic point of view: for guidance I would suge

Re: Style for docstring

2022-04-23 Thread Michael F. Stemper
On 22/04/2022 21.58, Avi Gross wrote: Python does have a concept of "truthy" that includes meaning for not just the standard Booleans but for 0 and non-zero and the empty string and many more odd things such as an object that defines __bool__ (). But saying it returns a Boolean True/False value

Re: upgrade pip

2022-04-23 Thread Eryk Sun
On 4/22/22, Tola Oj wrote: > im trying to upgrade my pip so i can install openpyxl. i though i had > successfully upgraded pip, and then I was trying to install openpyxl, but I > was getting this: > > C:\Users\ojomo>"C:\Program Files\Python310\python.exe" -m pip install > --upgrade > > [...] > > "