Re: learning python ...

2021-05-24 Thread Jon Ribbens via Python-list
On 2021-05-24, Alan Gauld wrote: > On 24/05/2021 16:54, Michael F. Stemper wrote: > >> In my early days of writing python, I created lists named "list", >> dictionaries named "dict", and strings named "str". I mostly know better >> now, but sometimes still need to restrain my fingers. > > I think

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Jon Ribbens via Python-list
On 2021-05-26, Alan Gauld wrote: > On 25/05/2021 23:23, Terry Reedy wrote: >> In CPython's Flexible String Representation all characters in a string >> are stored with the same number of bytes, depending on the largest >> codepoint. > > I'm learning lots of new things in this thread! > > Does th

Re: Definition of "property"

2021-05-30 Thread Jon Ribbens via Python-list
On 2021-05-30, Irv Kalb wrote: > I understand what a "property" is, how it is used and the benefits, > but apparently my explanation hasn't made the light bulb go on for my > editor. The editor is asking for a definition of property. I've > looked at many articles on line and a number of books,

Re: Definition of "property"

2021-05-31 Thread Jon Ribbens via Python-list
On 2021-05-30, Terry Reedy wrote: > Note: at least one person says a property *pretends* to be an attribute. No, I said it pretends to be a *data* attribute. It is effectively several methods in a trenchcoat pretending to be a variable. -- https://mail.python.org/mailman/listinfo/python-list

Re: Definition of "property"

2021-06-01 Thread Jon Ribbens via Python-list
On 2021-05-31, Greg Ewing wrote: > On 31/05/21 9:13 am, Jon Ribbens wrote: >> No, I said it pretends to be a *data* attribute. > > I don't think it's pretending to be anything. From the outside, > it's just an attribute. >From the outside, it's just a *data* attribute. Which, from the inside, it

Re: Definition of "property"

2021-06-01 Thread Jon Ribbens via Python-list
On 2021-06-01, Greg Ewing wrote: > On 1/06/21 2:34 am, Jon Ribbens wrote: >> From the outside, it's just a *data* attribute. Which, from the inside, >> it isn't. Hence "pretending". > > But what is it about the external appearance that would make > you think it's a data attribute, rather than som

Re: Replacement for Mailman

2021-06-08 Thread Jon Ribbens via Python-list
On 2021-06-08, D'Arcy Cain wrote: > Given that mailman still runs under 2.7 and that's being deprecated, > does anyone have a suggestion for a replacement? There is always Mailman 3... -- https://mail.python.org/mailman/listinfo/python-list

Re: Replacement for Mailman

2021-06-08 Thread Jon Ribbens via Python-list
On 2021-06-08, Grant Edwards wrote: > On 2021-06-08, Paul Bryan wrote: >> How about Mailman 3.x on Python 3.x? > > According to https://www.gnu.org/software/mailman/requirements.html > mailman 3.x still requires Python 2.7 for the archiver and the web UI. I'm pretty sure that's out of date. --

Re: Replacement for Mailman

2021-06-08 Thread Jon Ribbens via Python-list
On 2021-06-08, Terry Reedy wrote: > On 6/8/2021 4:36 PM, Jon Ribbens via Python-list wrote: >> On 2021-06-08, Grant Edwards wrote: >>> On 2021-06-08, Paul Bryan wrote: >>>> How about Mailman 3.x on Python 3.x? >>> >>> According to https:

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Jon Ribbens via Python-list
On 2021-08-03, Michael Torrie wrote: > On 8/2/21 1:43 PM, Sven R. Kunze wrote: >> maybe, I am missing something here but is it possible to specify a >> delimiter for list arguments in argparse: >> >> https://docs.python.org/3/library/argparse.html >> >> Usually, '--' is used to separate two lis

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Jon Ribbens via Python-list
On 2021-08-03, Roel Schroeven wrote: > Jon Ribbens via Python-list schreef op 3/08/2021 om 17:48: >> On 2021-08-03, Michael Torrie wrote: >> > On 8/2/21 1:43 PM, Sven R. Kunze wrote: >> >> maybe, I am missing something here but is it possible to specify a >>

Re: Ask for help on using re

2021-08-06 Thread Jon Ribbens via Python-list
On 2021-08-06, jak wrote: > Il 06/08/2021 16:17, jak ha scritto: >> Il 06/08/2021 12:57, Jach Feng ha scritto: >>> That's an interest solution! Where the '|' operator in re.compile() >>> was documented? >> >> I honestly can't tell you, I've been using it for over 30 years. In any >> case you can

Re: basic auth request

2021-08-17 Thread Jon Ribbens via Python-list
On 2021-08-17, Barry wrote: >> That's usually irrelevant, since the alternative is most likely to be >> form fill-out, which is exactly as secure. If you're serving over >> HTTPS, the page is encrypted, and that includes the headers; if you're >> not, then it's not encrypted, and that includes the

Re: basic auth request

2021-08-18 Thread Jon Ribbens via Python-list
On 2021-08-18, Robin Becker wrote: > On 17/08/2021 22:47, Jon Ribbens via Python-list wrote: > ... >> That's only true if you're not using HTTPS - and you should *never* >> not be using HTTPS, and that goes double if forms are being filled >> in and d

Re: Decoding of EmailMessage text

2021-08-23 Thread Jon Ribbens via Python-list
On 2021-08-23, Loris Bennett wrote: > If instead of > > mail.set_content(body) > > I do > > mail.set_content(body, cte="quoted-printable") Try print(mail.get_content()) rather than print(mail.as_string()) -- https://mail.python.org/mailman/listinfo/python-list

Re: basic auth request

2021-08-25 Thread Jon Ribbens via Python-list
On 2021-08-25, Chris Angelico wrote: > On Wed, Aug 25, 2021 at 5:20 PM Barry Scott wrote: >> Only if this threat model matters to you or your organisation. >> Personal its low down of the threats I watch out for. >> >> The on-line world and the real-world are the same here. >> >> If a business ch

Re: basic auth request

2021-08-25 Thread Jon Ribbens via Python-list
On 2021-08-25, Chris Angelico wrote: > On Thu, Aug 26, 2021 at 12:16 AM Jon Ribbens via Python-list > wrote: >> There are so many trusted CAs these days that the chances of them all >> being secure approaches zero - they are not all equal yet they are all >> equally truste

Re: basic auth request

2021-08-25 Thread Jon Ribbens via Python-list
On 2021-08-25, Chris Angelico wrote: > On Thu, Aug 26, 2021 at 12:48 AM Jon Ribbens via Python-list > wrote: >> Another attempt at combatting this problem is DNS CAA records, >> which are a way of politely asking all CAs in the world except the >> ones you choose "ple

Re: basic auth request

2021-08-25 Thread Jon Ribbens via Python-list
On 2021-08-25, Eli the Bearded <*@eli.users.panix.com> wrote: > In comp.lang.python, Jon Ribbens wrote: >> Another attempt at combatting this problem is DNS CAA records, >> which are a way of politely asking all CAs in the world except the >> ones you choose "please don't issue a certificate for

Re: Inheriting from str

2021-09-20 Thread Jon Ribbens via Python-list
On 2021-09-20, ast wrote: > Hello > > class NewStr(str): > def __init__(self, s): > self.l = len(s) > > Normaly str is an immutable type so it can't be modified > after creation with __new__ > > But the previous code is working well > > obj = NewStr("qwerty") > obj.l > 6 > > I don't und

Re: XML Considered Harmful

2021-09-21 Thread Jon Ribbens via Python-list
On 2021-09-21, Michael F. Stemper wrote: > On the prolog thread, somebody posted a link to: > > > One thing that it tangentially says is "XML is not the answer." > > I read this page right when I was about to write an XML parser > to get data

Re: XML Considered Harmful

2021-09-21 Thread Jon Ribbens via Python-list
On 2021-09-21, Pete Forman wrote: > CSV is quite good as a lowest common denominator exchange format. I say > quite because I would characterize it by 8 attributes and you need to > pick a dialect such as MS Excel which sets out what those are. XML and > JSON are controlled much better. You can ea

Re: XML Considered Harmful

2021-09-23 Thread Jon Ribbens via Python-list
On 2021-09-23, Stefan Ram wrote: > The real problem with CSV is that there is no CSV. > > This is not a specific data language with a specific > specification. Instead it is a vague designation for > a plethora of CSV dialects, which usually dot not even > have a specification. Indeed.

Re: XML Considered Harmful

2021-09-24 Thread Jon Ribbens via Python-list
On 2021-09-24, Chris Angelico wrote: > On Sat, Sep 25, 2021 at 8:53 AM dn via Python-list > wrote: >> On 25/09/2021 06.59, Peter J. Holzer wrote: >> > CSV: Good for tabular data of a single data type (strings). As soon as >> > there's a second data type (numbers, dates, ...) you leave standard >>

Re: XML Considered Harmful

2021-09-25 Thread Jon Ribbens via Python-list
On 2021-09-25, Peter J. Holzer wrote: > On 2021-09-24 23:32:47 -0000, Jon Ribbens via Python-list wrote: >> JSON Schema provides a way to denote composite types. > > I probably wasn't clear what I meant. In XML, every element has a tag, > which is basically its type. So by

Re: New assignmens ...

2021-10-22 Thread Jon Ribbens via Python-list
On 2021-10-22, Stefan Ram wrote: > Paulo da Silva writes: >>Why doesn't this work >> if (self.ctr:=self.ctr-1)<=0: >>while this works >> if (ctr:=ctr-1)<=0: > > assignment_expression ::= [identifier ":="] expression, > but the attribute references "self.ctr" is no identifier! This

Re: New assignmens ...

2021-10-23 Thread Jon Ribbens via Python-list
On 2021-10-23, Chris Angelico wrote: > I've never used ctr:=ctr-1 either, though, so I don't know the actual > use cases. Why is this being used in an assignment expression? Is it > an ersatz loop? > > Common use-cases include: > > if m := re.match(...): > > while data := thing.read(): > > etc. Al

Re: New assignmens ...

2021-10-23 Thread Jon Ribbens via Python-list
On 2021-10-23, Chris Angelico wrote: > On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list > wrote: >> On 2021-10-23, Chris Angelico wrote: >> > In what situations do you need to mutate an attribute and also test >> > it, and how much hassle is it to simp

Re: New assignmens ...

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Paul Rubin wrote: > Chris Angelico writes: >> But it all depends on the exact process being done, which is why I've >> been asking for real examples. > > My most frequent use case for walrus is so common that I have sometimes > implemented a special class for it: > >if g := re.

Re: Get a Joke in Python

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Greg Ewing wrote: > On 29/10/21 11:34 am, Chris Angelico wrote: >> On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse >> wrote: >>> QA engineer walks into a bar. Orders a beer. Orders 0 beers. >>> Orders 9 beers. Orders a lizard. Orders -1 beers. >>> Orders a sfdeljknesv.

Re: Avoid nested SIGINT handling

2021-11-10 Thread Jon Ribbens via Python-list
On 2021-11-10, Paulo da Silva wrote: > Hi! > > How do I handle a SIGINT (or any other signal) avoid nesting? I don't think you need to. Python will only call signal handlers in the main thread, so a handler can't be executed while another handler is running anyway. -- https://mail.python.org/mai

Re: Proliferation of Python packaging formats

2021-11-17 Thread Jon Ribbens via Python-list
On 2021-11-17, Skip Montanaro wrote: > Is the proliferation of packaging formats in Python as nutzo as this author > believes? > > https://drewdevault.com/2021/11/16/Python-stop-screwing-distros-over.html > > Asking because I've never been in the business of releasing "retail" Python > application

Re: copy.copy

2021-11-22 Thread Jon Ribbens via Python-list
On 2021-11-22, ast wrote: > Hi, > > >>> a = 6 > >>> b = 6 > >>> a is b > True > > ok, we all know that Python creates a sole instance > with small integers, but: > > >>> import copy > >>> b = copy.copy(a) > >>> a is b > True > > I was expecting False Why did you expect False? For immutable types

Re: Short, perfect program to read sentences of webpage

2021-12-08 Thread Jon Ribbens via Python-list
On 2021-12-08, Julius Hamilton wrote: > 1. The HTML extraction is not perfect. It doesn’t produce as clean text as > I would like. Sometimes random links or tags get left in there. And the > sentences are sometimes randomly broken by newlines. Oh. Leaving tags in suggests you are doing this very

Re: keep getting a syntax error on the very first program I am running

2022-01-14 Thread Jon Ribbens via Python-list
On 2022-01-15, Bob Griffin wrote: >I am running this program and keep getting this error. Is this normal? > >Invalid syntax. Perhaps you forgot a comma? > >Also the t in tags is highlighted. > >I even tried different versions of Python also. > >Python 3.10.1 (tags/v3.10.1:2cd

Re: Behavior of the for-else construct

2022-03-03 Thread Jon Ribbens via Python-list
On 2022-03-03, computermaster360 wrote: > Do you find the for-else construct useful? Have you used it in > practice? Yes, I use it frequently. > I have used it maybe once. My issue with this construct is that > calling the second block `else` doesn't make sense; a much more > sensible name would

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread Jon Ribbens via Python-list
On 2022-04-14, Paul Bryan wrote: > I think because minutes and hours can easily be composed by multiplying > seconds. days is separate because you cannot compose days from seconds; > leap seconds are applied to days at various times, due to > irregularities in the Earth's rotation. That's an argu

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread Jon Ribbens via Python-list
On 2022-04-14, MRAB wrote: > On 2022-04-14 16:22, Jon Ribbens via Python-list wrote: >> On 2022-04-14, Paul Bryan wrote: >>> I think because minutes and hours can easily be composed by multiplying >>> seconds. days is separate because you cannot compose days from se

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-14 15:22:29 -0000, Jon Ribbens via Python-list wrote: >> On 2022-04-14, Paul Bryan wrote: >> > I think because minutes and hours can easily be composed by multiplying >> > seconds. days is separate because you canno

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Jon Ribbens wrote: > On 2022-04-16, Peter J. Holzer wrote: >> Python missed the switch to DST here, the timezone is wrong. > > Because you didn't let it use any timezone information. You need to > either use the third-party 'pytz' module, or in Python 3.9 or above, > the built-in '

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-16 13:47:32 -0000, Jon Ribbens via Python-list wrote: >> That's impossible unless you redefine 'timedelta' from being, as it is >> now, a fixed-length period of time, to instead being the difference >> bet

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-16 14:22:04 -0000, Jon Ribbens via Python-list wrote: >> On 2022-04-16, Jon Ribbens wrote: >> > On 2022-04-16, Peter J. Holzer wrote: >> >> Python missed the switch to DST here, the timezone is wrong. >> >

Re: Automate extract domain

2019-05-12 Thread Jon Ribbens via Python-list
On 2019-05-12, Birdep wrote: > I am trying to extract domain name from a adblock rule , so what > pattern should i used to extract domain name only? > > import re > domains = ['ru', ' fr' ,'eu', 'com'] with open('easylist.txt', 'r') as f: > a=f.read() result=re.findall(r'[a-zA-Z0-9-]+\.[a-zA

Re: PEP 594 cgi & cgitb removal

2019-05-23 Thread Jon Ribbens via Python-list
On 2019-05-23, Paul Rubin wrote: > dieter writes: >> Should "cgi" disappear from the standard library > > It's also a concern that cgi may be disappearing from web servers. Last > I heard, nginx didn't support it. That's part of why I still use > apache, or (local only) even CGIHTTPServer.py.

Re: PEP 594 cgi & cgitb removal

2019-05-24 Thread Jon Ribbens via Python-list
On 2019-05-23, Gunnar Þór Magnússon wrote: >> nginx is the current hotness. CGI has not been hotness since the >> mid 90s. > > Serverless is the new hotness, and serverless is CGI. Technology is > cyclical. Sorry, in what sense do you mean "Serverless is CGI"? As far as I can tell, it's just a s

Re: PEP 594 cgi & cgitb removal

2019-05-25 Thread Jon Ribbens via Python-list
On 2019-05-25, Michael Torrie wrote: > On 05/24/2019 04:27 AM, Jon Ribbens via Python-list wrote: >> Sorry, in what sense do you mean "Serverless is CGI"? >> >> As far as I can tell, it's just a script to automatically upload >> bits of code into vari

Re: How do you insert an item into a dictionary (in python 3.7.2)?

2019-06-28 Thread Jon Ribbens via Python-list
On 2019-06-28, Larry Martell wrote: > On Fri, Jun 28, 2019 at 11:10 AM CrazyVideoGamez > wrote: >> >> How do you insert an item into a dictionary? For example, I make a >> dictionary called "dictionary". >> >> dictionary = {1: 'value1', 2: 'value3'} >> >> What if I wanted to add a value2 in the m

Re: Handle foreign character web input

2019-06-29 Thread Jon Ribbens via Python-list
On 2019-06-28, Chris Angelico wrote: > On Sat, Jun 29, 2019 at 6:31 AM Tobiah wrote: >> A guy comes in and enters his last name as RÖnngren. >> >> So what did the browser really give me; is it encoded >> in some way, like latin-1? Does it depend on whether >> the name was cut and pasted from a W

Re: if bytes != str:

2019-08-04 Thread Jon Ribbens via Python-list
On 2019-08-04, Hongyi Zhao wrote: > I read and learn the the following code now: > > https://github.com/shadowsocksr-backup/shadowsocksr-libev/blob/master/src/ > ssrlink.py > > In this script, there are the following two customized functions: > > -- > def to_bytes(s): > if bytes != s

Re: _unquote

2019-08-04 Thread Jon Ribbens via Python-list
On 2019-08-04, Hongyi Zhao wrote: > See the following code excerpted from https://github.com/shichao-an/ > homura/blob/master/homura.py: > > --- > def unquote(s): > res = s > if not PY3: > if isinstance(res, six.text_type): > res = s.encode('utf-8') > return _unquot

Re: Web framework for static pages

2019-08-12 Thread Jon Ribbens via Python-list
On 2019-08-12, Morten W. Petersen wrote: > What I guess I'm looking for, is something that will help create a > static website, in a simple and efficient manner. Without being bloated. > > I don't have a lot of hair on my head, but I would be pulling it out > because of some of the websites I s

Re: Web framework for static pages

2019-08-13 Thread Jon Ribbens via Python-list
On 2019-08-13, Morten W. Petersen wrote: > Ideally I'd want a static site generator that makes it easy and quick to > create a website which is pretty, accessible, works across browsers and > standards compliant and doesn't freeze the browser on a low-end phone. That isn't what they do. All those

Re: Web framework for static pages

2019-08-13 Thread Jon Ribbens via Python-list
On 2019-08-13, Morten W. Petersen wrote: > Ok. Isn't it a bit splitting of hairs to talk about static site generators > and their templates? No, not even slightly. You appear to be thinking that static site generators come with a pre-made set of design templates, and as far as I am aware they gen

Re: from ./.. import

2019-10-04 Thread Jon Ribbens via Python-list
On 2019-10-04, Hongyi Zhao wrote: > See this file: > https://github.com/hongyi-zhao/dotbot/blob/master/dotbot/messenger/ > messenger.py > > It has the following codes: > > from ..util.singleton import Singleton > from ..util.compat import with_metaclass > from .color import Color > from .level imp

Re: SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-07 Thread Jon Ribbens via Python-list
On 2019-11-07, Veek M wrote: > Could someone suggest some introductory reading material that will allow > me to use 'telnetlib' with 'ssl' or 'ssltelnet'. > (currently using Pan since Knode is dropped on Debian) > > I'm trying to write something that will download the NNTP headers over > TLS.

Re: strptime for different languages

2019-12-17 Thread Jon Ribbens via Python-list
On 2019-12-17, Ulrich Goebel wrote: > I need to interpret a date string to get a datetime object. That should > be done with strptime from the module datetime. > > But I don't know enough about the locale settings from where the date > sting comes. Actually the date_string cames from different c

Re: Sandboxing eval() (was: Calculator)

2020-01-19 Thread Jon Ribbens via Python-list
On 2020-01-19, mus...@posteo.org wrote: > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? > > I have an application that loads calculation recipes (a few lines of > variab

Re: Clarification on Immutability please

2020-01-21 Thread Jon Ribbens via Python-list
On 2020-01-21, Chris Angelico wrote: > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker wrote: >> I am left concluding that mytup is not actually a tuple (even though type >> (mytup) tells me that it is). > > If type(mytup) is tuple, then mytup really truly is a tuple. There is > no other conclusio

Re: Clarification on Immutability please

2020-01-21 Thread Jon Ribbens via Python-list
On 2020-01-21, Chris Angelico wrote: > On Wed, Jan 22, 2020 at 8:01 AM Jon Ribbens via Python-list > wrote: >> On 2020-01-21, Chris Angelico wrote: >> > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker >> > wrote: >> >> I am left concluding that mytup

Re: JavaScript's void operator in Python?

2020-02-02 Thread Jon Ribbens via Python-list
On 2020-02-02, Stefan Ram wrote: > JavaScript has a void operator that maps everything to > undefined. E.g., > > JavaScript console > >|< void( console.log( 2 ) ) >| 2 >|> undefined > > I can easily write a corresponding function in Python. > > main.py > > def void( x ): > pass > >

Re: JavaScript's void operator in Python?

2020-02-02 Thread Jon Ribbens via Python-list
On 2020-02-02, Stefan Ram wrote: > Greg Ewing writes: >>If the functions you're calling all return None, you can >>do this: >> >>> print(2); print(3) > > »print(2); print(3)« is not an expression anymore but an stmt_list. > It cannot be used in all places where an expression is allowed. Why

Re: JavaScript's void operator in Python?

2020-02-02 Thread Jon Ribbens via Python-list
On 2020-02-02, Stefan Ram wrote: > Jon Ribbens writes: >>Why does it matter if the return value is None? > > In a lambda, a return value of None sometimes would be > convenient as by convention it indicates that the return > value does not carry any information and the function is > inten

Re: datetime seems to be broken WRT timezones (even when you add them)

2020-02-10 Thread Jon Ribbens via Python-list
On 2020-02-10, Python wrote: > So far, so good. However, when you go to use this object, the time it > represents is in fact wrong. Unsurprisingly for a language feature that's been around for nearly 17 years, no it isn't. > For example: > print dt.strftime("%s") > 1580452245 That's askin

Re: datetime seems to be broken WRT timezones (even when you add them)

2020-02-11 Thread Jon Ribbens via Python-list
On 2020-02-11, Chris Angelico wrote: >> That's the key piece of info. This does appear to work, though still >> not on python2. That, as you say, is my problem. But thankfully Jon >> Ribbens has the save: > > Isn't it time to stop going to great effort to support Python 2? That depends on what

Re: datetime seems to be broken WRT timezones (even when you add them)

2020-02-11 Thread Jon Ribbens via Python-list
On 2020-02-11, Chris Angelico wrote: > On Tue, Feb 11, 2020 at 10:01 PM Jon Ribbens via Python-list > wrote: >> So while it's been about 6 years since anyone should have been >> starting any new projects using Python 2, there are plenty of >> projects that are o

Re: Technical debt - was Re: datetime seems to be broken WRT timezones (even when you add them)

2020-02-12 Thread Jon Ribbens via Python-list
On 2020-02-12, Chris Angelico wrote: > But you CAN rewrite code such that it reduces technical debt. You can > refactor code to make it more logical. ... but if doing so costs more than the debt, you shouldn't do it. -- https://mail.python.org/mailman/listinfo/python-list

Re: Mental model of lookahead assertions

2020-02-28 Thread Jon Ribbens via Python-list
On 2020-02-27, Stefan Ram wrote: > One can count overlapping occurences as follows. > >|>>> print(len(findall('(?=aa)','cb'))) >|3 > > Every web page says that lookahead assertions do > not consume nor move the "current position". > > But what mental model can I make of the regex > e

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a écrit : >> moi writes: >> 'ÿ'.encode('utf-8') >> > b'\xc3\xbf' >> 'ÿ'.encode('utf-16-le') >> > b'\xff\x00' >> 'ÿ'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expected. > Yes > >

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a écrit : moi writes: 'ÿ'.encode('utf-8') > b'\xc3\xbf' 'ÿ'.encode('utf-16-le') > b'\xff\x00' 'ÿ'.encod

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ÄCcritâ : moi writes: 'Ä¿'.encode('utf-8') > b'\xc3\xbf' 'Ä¿'.encode('utf-16-le') > b'\xff\x00' 'Ä¿'.

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ÄCcritâ : >> moi writes: >> 'Ä¿'.encode('utf-8') >> > b'\xc3\xbf' >> 'Ä¿'.encode('utf-16-le') >> > b'\xff\x00' >> 'Ä¿'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expected. > Ye

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ÄäCcritÄø : >> moi writes: >> 'Ääâ¿'.encode('utf-8') >> > b'\xc3\xbf' >> 'Ääâ¿'.encode('utf-16-le') >> > b'\xff\x00' >> 'Ääâ¿'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expect

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ÄäCcritÄø : moi writes: 'Ääâ¿'.encode('utf-8') > b'\xc3\xbf' 'Ääâ¿'.encode('utf-16-le') > b'\xff\x00'

Re: ÿ in Unicode

2020-03-06 Thread Jon Ribbens via Python-list
On 2020-03-06, Jon Ribbens wrote: > What's the bug, or source of amusement? Oh, that's fun. There's a Russian Fidonet gateway, that somehow still exists, that's re-injecting usenet posts back into the group. -- https://mail.python.org/mailman/listinfo/python-list

Re: link to venv python sees a different sys.path

2020-03-11 Thread Jon Ribbens via Python-list
On 2020-03-11, Robin Becker wrote: > I'm trying to understand why python 3.8.2 venv behaves differently > when it is executed va a link Because site.py contains a function called venv() which looks up the path of the executed python binary, and searches for the virtual environment relative to tha

Re: php to python code converter

2020-05-14 Thread Jon Ribbens via Python-list
On 2020-05-14, MRAB wrote: > Look at the date of the original post. It says "8 May 2009". That's over > 11 years ago! > > Since then, Google Code has ceased to exist. Disgraceful, all URLs should continue to work for at least as long as this one has: http://info.cern.ch/hypertext/WWW/TheProject.

Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-02 Thread Jon Ribbens via Python-list
On 2020-07-02, Michael Torrie wrote: > Agreed. She just needs to fix her commit message to remove the sentence > about the relics of white supremacy. The fact she would conflate an > author's name with some kind of race-related thing is a bit > embarrassing, frankly. She didn't - you did. -- ht

Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Jon Ribbens via Python-list
On 2020-07-03, Rhodri James wrote: > On 02/07/2020 23:46, Random832 wrote: >> On Thu, Jul 2, 2020, at 18:29, Michael Torrie wrote: >>> Come again? I can see no other link in the verbage with the >>> "relics of white supremacy" that she referred to. If there are >>> other links, they should be in

Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Jon Ribbens via Python-list
On 2020-07-02, Michael Torrie wrote: > On 7/2/20 1:26 PM, Jon Ribbens via Python-list wrote: >> On 2020-07-02, Michael Torrie wrote: >>> Agreed. She just needs to fix her commit message to remove the sentence >>> about the relics of white supremacy. The fact she wou

Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Jon Ribbens via Python-list
On 2020-07-03, Ethan Furman wrote: > On 07/02/2020 07:42 PM, Jon Ribbens via Python-list wrote: >> She didn't - you did. > > Please keep the discourse civil. Petty taunts are not helpful. Sorry, I don't understand what you are getting at. My comment was not a "pet

Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Jon Ribbens via Python-list
On 2020-07-03, Michael Torrie wrote: > On 7/3/20 10:57 AM, Jon Ribbens via Python-list wrote: >> On 2020-07-03, Ethan Furman wrote: >>> On 07/02/2020 07:42 PM, Jon Ribbens via Python-list wrote: >>>> She didn't - you did. >>> >>> Please ke

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Chris Angelico wrote: > On Mon, Jul 6, 2020 at 8:36 PM Adam Funk wrote: >> Is there a "bulletproof" version of json.dump somewhere that will >> convert bytes to str, any other iterables to list, etc., so you can >> just get your data into a file & keep working? > > That's the PHP d

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Chris Angelico wrote: > On Mon, Jul 6, 2020 at 10:11 PM Jon Ribbens via Python-list > wrote: >> While I agree entirely with your point, there is however perhaps room >> for a bit more helpfulness from the json module. There is no sensible >> reason I can thi

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Frank Millman wrote: > On 2020-07-06 2:06 PM, Jon Ribbens via Python-list wrote: >> While I agree entirely with your point, there is however perhaps room >> for a bit more helpfulness from the json module. There is no sensible >> reason I can think of that it

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, J. Pic wrote: > Well I made a suggestion on python-ideas and a PyPi lib came out of it, but > since you can't patch a lot of internal types it's not so useful. > > Feel free to try it out: > > https://yourlabs.io/oss/jsonlight/ While I applaud your experimentation, that is not suit

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Chris Angelico wrote: > On Mon, Jul 6, 2020 at 11:06 PM Jon Ribbens via Python-list > wrote: >> The 'json' module already fails to provide round-trip functionality: >> >> >>> for data in ({True: 1}, {1: 2}, (1, 2)): >>

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Frank Millman wrote: > On 2020-07-06 3:08 PM, Jon Ribbens via Python-list wrote: >> On 2020-07-06, Frank Millman wrote: >>> On 2020-07-06 2:06 PM, Jon Ribbens via Python-list wrote: >>>> While I agree entirely with your point, there is however pe

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Chris Angelico wrote: > I think that even in non-strict mode, round-tripping should be > achieved after one iteration. That is to say, anything you can > JSON-encode will JSON-decode to something that would create the same > encoded form. Not sure if there's anything that would viol

Re: Bulletproof json.dump?

2020-07-06 Thread Jon Ribbens via Python-list
On 2020-07-06, Chris Angelico wrote: > On Tue, Jul 7, 2020 at 12:01 AM Jon Ribbens via Python-list > wrote: >> I think what you're saying is, if we do: >> >> json1 = json.dumps(foo) >> json2 = json.dumps(json.loads(json1)) >> assert json1 == js

Re: Access last element after iteration

2020-07-07 Thread Jon Ribbens via Python-list
On 2020-07-07, Frank Millman wrote: > After iterating over a sequence, the final element is still accessible. > In this case, the variable 'i' still references the integer 4. ... > Is this guaranteed in Python, or should it not be relied on? It is guaranteed, *except* if the sequence is empty an

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Jon Ribbens via Python-list
On 2020-07-31, Stefan Ram wrote: > You can write > >|>>> 1,+2, >|(1, 2) > > , but not > >|>>> (1,)+2, >|TypeError: can only concatenate tuple (not "int") to tuple > > . Why? (Python 3.9) For the obvious reason, as indicated by the error message? What are you expecting these expressions to

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Jon Ribbens via Python-list
On 2020-07-31, Bart wrote: > Not sure about the trailing commas on each. It seems Python ignores > trailing commas on tuple constructors, so that the A,B, would be a > 2-tuple, and A+B, would have been a 1-tuple if A+B had been legal. It's not just tuples, it's lists, sets, dictionaries, etc. I

Re: Why x+=1 doesn't return x value instead of an object

2020-10-30 Thread Jon Ribbens via Python-list
On 2020-10-31, Stefan Ram wrote: > Siddhharth Choudhary writes: >>I want to know why x+=1 does not return the value of the variable. > > Which value? The old or the new one? > > Expressions never return values. Except when they're assignment expressions, when they do. -- https://mail.python

Re: Why x+=1 doesn't return x value instead of an object

2020-10-30 Thread Jon Ribbens via Python-list
On 2020-10-31, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list > wrote: >> >> On 2020-10-31, Stefan Ram wrote: >> > Siddhharth Choudhary writes: >> >>I want to know why x+=1 does not return the value of the variable.

Re: Letter replacer - suggestions?

2020-12-07 Thread Jon Ribbens via Python-list
On 2020-12-07, Chris Angelico wrote: > On Tue, Dec 8, 2020 at 6:41 AM Grant Edwards > wrote: >> On 2020-12-07, MRAB wrote: >> > Avoid a 'bare' except unless you _really_ mean it, which is >> > virtually never. Catch only those exceptions that you're going to >> > handle. >> >> And sometimes "ha

Re: How to enter multiple, similar, dictionaries?

2023-12-11 Thread Jon Ribbens via Python-list
On 2023-12-11, Chris Green wrote: > Chris Green wrote: >> Is there a way to abbreviate the following code somehow? >> >> lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'} >> sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'} >> la = {'dev':'bbb', 'input':'2', 'name':'Leisu

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-02 Thread Jon Ribbens via Python-list
On 2024-02-02, Lawrence D'Oliveiro wrote: > On 1 Feb 2024 10:09:10 GMT, Stefan Ram wrote: > >> Heck, even of the respected members of this newsgroup, IIRC, no one >> mentioned "__await__". > > It’s part of the definition of an “awaitable”, if you had looked that up. > >

Re: Popping key causes dict derived from object to revert to object

2024-03-25 Thread Jon Ribbens via Python-list
On 2024-03-25, Loris Bennett wrote: > "Michael F. Stemper" writes: > >> On 25/03/2024 01.56, Loris Bennett wrote: >>> Grant Edwards writes: >>> On 2024-03-22, Loris Bennett via Python-list wrote: > Yes, I was mistakenly thinking that the popping the element would > leav

Re: Timezone in HH:MM Format

2024-06-18 Thread Jon Ribbens via Python-list
On 2024-06-18, Ivan "Rambius" Ivanov wrote: > Hello, > > How can I convert a date, usually datetime.now(), into a format where > the timezone is in hours:minutes format. I was able to get that format > in shell: > > $ date +%Y-%m-%dT%H:%M:%S%:z > 2024-06-18T19:24:09-04:00 > > The closest I got in

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-08, Greg Ewing wrote: > On 8/09/24 9:20 am, Karsten Hilbert wrote: >> try: >> do something >> except: >> log something >> finally: >> .commit() >> >> cadence is fairly Pythonic and elegant in that it ensures the >> the .commit() wil

<    1   2   3   >