[RELEASE] The first Python 3.11 beta (3.11.0b1) is available - Feature freeze is here

2022-05-07 Thread Pablo Galindo Salgado
We did it, team!! After quite a bumpy release process and a bunch of last-time fixes, we have reached **beta 1** and **feature freeze**. What a ride eh? You can get the shiny new release artefacts from here: https://www.python.org/downloads/release/python-3110b1/ ## This is a beta preview of Pyth

Re: tail

2022-05-07 Thread Chris Angelico
On Sun, 8 May 2022 at 07:19, Stefan Ram wrote: > > MRAB writes: > >On 2022-05-07 19:47, Stefan Ram wrote: > ... > >>def encoding( name ): > >>path = pathlib.Path( name ) > >>for encoding in( "utf_8", "latin_1", "cp1252" ): > >>try: > >>with path.open( encoding=encoding

Re: Python/New/Learn

2022-05-07 Thread Grant Edwards
On 2022-05-06, dn wrote: > The problem with some of the advice given in this thread, eg using > StackOverflow or YouTube videos, is that a beginner (particularly) > has no measure of the material's quality. Both platforms are riddled > with utter-junk - even 'dangerous' advice. And the "quality

Re: tail

2022-05-07 Thread Chris Angelico
On Sun, 8 May 2022 at 04:37, Marco Sulla wrote: > > On Sat, 7 May 2022 at 19:02, MRAB wrote: > > > > On 2022-05-07 17:28, Marco Sulla wrote: > > > On Sat, 7 May 2022 at 16:08, Barry wrote: > > >> You need to handle the file in bin mode and do the handling of line > > >> endings and encodings yo

Re: tail

2022-05-07 Thread MRAB
On 2022-05-07 19:47, Stefan Ram wrote: Marco Sulla writes: Well, ok, but I need a generic method to get LF and CR for any encoding an user can input. "LF" and "CR" come from US-ASCII. It is theoretically possible that there might be some encodings out there (not for Unicode) that are

Re: tail

2022-05-07 Thread MRAB
On 2022-05-07 19:35, Marco Sulla wrote: On Sat, 7 May 2022 at 19:02, MRAB wrote: > > On 2022-05-07 17:28, Marco Sulla wrote: > > On Sat, 7 May 2022 at 16:08, Barry wrote: > >> You need to handle the file in bin mode and do the handling of line endings and encodings yourself. It’s not that hard

Re: tail

2022-05-07 Thread Dennis Lee Bieber
On Sat, 7 May 2022 20:35:34 +0200, Marco Sulla declaimed the following: >Well, ok, but I need a generic method to get LF and CR for any >encoding an user can input. Other than EBCDIC, and AS BYTES should appear as x0A and x0D in any of the 8-bit encodings (ASCII, ISO-8859-x, CP, UT

Re: tail

2022-05-07 Thread Marco Sulla
On Sat, 7 May 2022 at 19:02, MRAB wrote: > > On 2022-05-07 17:28, Marco Sulla wrote: > > On Sat, 7 May 2022 at 16:08, Barry wrote: > >> You need to handle the file in bin mode and do the handling of line > >> endings and encodings yourself. It’s not that hard for the cases you > >> wanted. > >

Re: tail

2022-05-07 Thread MRAB
On 2022-05-07 17:28, Marco Sulla wrote: On Sat, 7 May 2022 at 16:08, Barry wrote: You need to handle the file in bin mode and do the handling of line endings and encodings yourself. It’s not that hard for the cases you wanted. "\n".encode("utf-16") b'\xff\xfe\n\x00' "".encode("utf-16") b

Re: tail

2022-05-07 Thread Dan Stromberg
I believe I'd do something like: #!/usr/local/cpython-3.10/bin/python3 """ Output the last 10 lines of a potentially-huge file. O(n). But technically so is scanning backward from the EOF. It'd be faster to use a dict, but this has the advantage of working for huge num_lines. """ import d

Re: tail

2022-05-07 Thread Marco Sulla
On Sat, 7 May 2022 at 16:08, Barry wrote: > You need to handle the file in bin mode and do the handling of line endings > and encodings yourself. It’s not that hard for the cases you wanted. >>> "\n".encode("utf-16") b'\xff\xfe\n\x00' >>> "".encode("utf-16") b'\xff\xfe' >>> "a\nb".encode("utf-16

Re: Python/New/Learn

2022-05-07 Thread o1bigtenor
On Sat, May 7, 2022 at 3:29 AM Peter J. Holzer wrote: > > On 2022-05-07 14:07:53 +1200, Greg Ewing wrote: > > On 7/05/22 12:27 pm, Stefan Ram wrote: > > >So, one might actually be able to learn the pronunciation > > >of a foreign language from text in a book better than from > > >an au

Re: tail

2022-05-07 Thread Barry
> On 7 May 2022, at 14:24, Marco Sulla wrote: > > On Sat, 7 May 2022 at 01:03, Dennis Lee Bieber wrote: >> >>Windows also uses for the EOL marker, but Python's I/O system >> condenses that to just internally (for TEXT mode) -- so using the >> length of a string so read to compute a

Re: tail

2022-05-07 Thread Avi Gross via Python-list
Marco, I think it was made clear from the start that "text" files in the classic sense have no random access method at any higher level than reading a byte at some offset from the beginning of the file, or back from the end when it has not grown. The obvious fact is that most of the time the li

Re: tail

2022-05-07 Thread Marco Sulla
On Sat, 7 May 2022 at 01:03, Dennis Lee Bieber wrote: > > Windows also uses for the EOL marker, but Python's I/O system > condenses that to just internally (for TEXT mode) -- so using the > length of a string so read to compute a file position may be off-by-one for > each EOL in the stri

Re: Python/New/Learn

2022-05-07 Thread Peter J. Holzer
On 2022-05-07 14:07:53 +1200, Greg Ewing wrote: > On 7/05/22 12:27 pm, Stefan Ram wrote: > >So, one might actually be able to learn the pronunciation > >of a foreign language from text in a book better than from > >an audio tape (or an audio file or a video with sound)! > > Such books

Re: Instatiating module / Reusing module of command-line tool

2022-05-07 Thread Cameron Simpson
On 06May2022 14:11, Loris Bennett wrote: >r...@zedat.fu-berlin.de (Stefan Ram) writes: >> If you need a class, you can write a class. >> >> When one imports a module, the module actually gets executed. >> That's why people write "if __name__ == '__main__':" often. >> So, everything one wan