Re: Pip installs to unexpected place

2025-04-17 Thread Roel Schroeven via Python-list
Op 15/04/2025 om 20:31 schreef Mats Wichmann via Python-list: To be clear: you do not have to activate a virtualenv to use *Python* from it. If you just call the python by the path it's in, it figures everything out (and sets some variables you can query vi sysconfig if you have reason to actua

Re: Tools to help with text mode (i.e. non-GUI) input

2025-01-16 Thread Roel Schroeven via Python-list
Op 11/01/2025 om 15:28 schreef Chris Green via Python-list: I'm looking for Python packages that can help with text mode input, i.e. for use with non-GUI programs that one runs from the command prompt in a terminal window running a bash shell or some such. What I'm specifically after is a way to

Re: super().__init__() and bytes

2024-12-04 Thread Roel Schroeven via Python-list
Op 4/12/2024 om 0:14 schreef Greg Ewing via Python-list: On 4/12/24 3:24 am, Roel Schroeven wrote: It's not entirely clear to me though how bytes.__new__ *can* set an object's value. Isn't __new__ also a regular function? Yes, but the __new__ methods of the builtin immutable ob

Re: super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
Op 3/12/2024 om 13:55 schreef Anders Munch via Python-list: Roel Schroeven wrote: > As a follow-up, it looks like this behavior is because bytes and int are immutable. Yes. OK. > But that doesn't tell me why using super().__init__() doesn't work for immutable classes. byt

Re: super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
Op 3/12/2024 om 10:41 schreef Roel Schroeven via Python-list: [...] When I try the same with bytes as base class though, that doesn't work (at least in the Python version I'm using, which is CPython 3.11.2 64-bit on Windows 10): class MyBytes(bytes):     def __init__(

super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
We can use super().__init__() in the __init__() method of a derived class to initialize its base class. For example: import string class MyTemplate(string.Template):     def __init__(self, template_string):     super().__init__(template_string) print(MyTemplate('Hello ${name}').substitute(na

Re: FileNotFoundError thrown due to file name in file, rather than file itself

2024-11-13 Thread Roel Schroeven via Python-list
Op 12/11/2024 om 20:10 schreef Left Right via Python-list: > I am not entirely convinced by NB2. I am, in fact, a sort of sysadmin > person and most of my programs write to a log file. The programs are > also moderately complex, so a single program might access a database, > query an LDAP serve

Re: Two python issues

2024-11-06 Thread Roel Schroeven via Python-list
Op 5/11/2024 om 15:48 schreef Raymond Boute via Python-list: L.S., Python seem to suffer from a few poor design decisions regarding strings and lists that affect the elegance of the language. (a) An error-prone "feature" is returning -1 if a substring is not found by "find", since -1 current

Re: Anonymous email users

2024-06-17 Thread Roel Schroeven via Python-list
AVI GROSS via Python-list schreef op 17/06/2024 om 17:03: I simply am thinking that people who do not allow me to easily reply to them directly, should be ignored by me and not get my cooperation that way. FWIW, personally I (mostly) don't see the point of replying to people personally. To me a

Re: pip and venvs on Debian

2024-05-21 Thread Roel Schroeven via Python-list
Op 20/05/2024 om 23:48 schreef Akkana Peck via Python-list: Every so often I need to regenerate it (like when Debian updates the system Python version) but that's easy to do: I don't try to duplicate what's installed there, I just delete the old venv, create a new one and then pip install pack

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Roel Schroeven via Python-list
Skip Montanaro via Python-list schreef op 20/05/2024 om 0:08: Modern debian (ubuntu) and fedora block users installing using pip. > Even if you're telling it to install in ~/.local? I could see not allowing to run it as root. I assumed pip install --user would work, but no. I tried it (on Debi

Re: Configuring an object via a dictionary

2024-03-20 Thread Roel Schroeven via Python-list
Op 19/03/2024 om 0:44 schreef Gilmeh Serda via Python-list: On Mon, 18 Mar 2024 10:09:27 +1300, dn wrote: > YMMV! > NB your corporate Style Guide may prefer 'the happy path'... If you only want to check for None, this works too: >>> name = None >>> dafault_value = "default" >>> name or default

Re: Configuring an object via a dictionary

2024-03-16 Thread Roel Schroeven via Python-list
Barry via Python-list schreef op 16/03/2024 om 9:15: > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: > > I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Grant Edwards via Python-list schreef op 6/03/2024 om 18:59: On 2024-03-06, Roel Schroeven via Python-list wrote: > Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >> >>> from scoping2 import * > > [...] > > I would advice not to use 'import *&

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >>> from scoping2 import * Ah yes, that explains what's happening. After that statement, the name dt_expiry in the current namespace is bound to the same object that the name dt_expiry in the namespace of module scoping2 is bound to. F

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 16:39 schreef Roel Schroeven via Python-list: Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interp

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interpreter"? Other people have put your code in a script, executed it, and saw

Re: Is there a way to implement the ** operator on a custom object

2024-02-09 Thread Roel Schroeven via Python-list
Left Right via Python-list schreef op 9/02/2024 om 17:09: In order for the "splat" operator to work, the type of the object must populate slot `tp_as_mapping` with a struct of this type: https://docs.python.org/3/c-api/typeobj.html#c.PyMappingMethods and have some non-null implementations of the

Re: A problem with str VS int.

2023-12-12 Thread Roel Schroeven via Python-list
Op 12/12/2023 om 9:22 schreef Steve GS via Python-list: With all these suggestions on how to fix it, no one seems to answer why it fails only when entering a two-digit number. One and three work fine when comparing with str values. It is interesting that the leading 0 on a two digit worked. Stil

Re: Newline (NuBe Question)

2023-11-26 Thread Roel Schroeven via Python-list
Michael F. Stemper via Python-list schreef op 25/11/2023 om 15:32: On 24/11/2023 21.45,avi.e.gr...@gmail.com wrote: > Grizz[l]y, > > I think the point is not about a sorted list or sorting in general It is > about reasons why maintaining a data structure such as a list in a program > can be us

Re: Running a subprocess in a venv

2023-10-21 Thread Roel Schroeven via Python-list
Larry Martell via Python-list schreef op 21/10/2023 om 15:01: I have a python script, and from that I want to run another script in a subprocess in a venv. What is the best way to do that? I could write a file that activates the venv then runs the script, then run that file, but that seems messy.

Re: Where I do ask for a new feature

2023-10-20 Thread Roel Schroeven via Python-list
Op 20/10/2023 om 5:16 schreef Bongo Ferno via Python-list: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, avi.e...@gmail.com wrote: > There are many ways to make transient variables that disappear at some time > and do we need yet another? Yes, you can create one of those ways but what >

Re: How to write list of integers to file with struct.pack_into?

2023-10-03 Thread Roel Schroeven via Python-list
Jen Kris via Python-list schreef op 2/10/2023 om 17:06: My previous message just went up -- sorry for the mangled formatting.  Here it is properly formatted: I want to write a list of 64-bit integers to a binary file.  Every example I have seen in my research converts it to .txt, but I want

Re: Why doc call `__init__` as a method rather than function?

2023-09-18 Thread Roel Schroeven via Python-list
Op 15/09/2023 om 15:05 schreef anthony.flury via Python-list: Like all of the other methods you shouldn't ever need to call them directly : these are called dunder methods and represent functions and features which are called by other operators. The only recommended way to call A.__init__

Re: Confusing behavior of PYTHONWARNINGS

2023-09-18 Thread Roel Schroeven via Python-list
Op 16/09/2023 om 10:17 schreef Meowxiik via Python-list: Hello, For the third time I am trying to work with `PYTHONWARNINGS` filter, and for the third time I am having a terrible time. I'd like to seek your assistance, I have a few questions: **Question 1:** Does the environment variable onl

Re: How to add CC and BCC while sending mails using python

2023-06-20 Thread Roel Schroeven via Python-list
sonam Kumari via Python-list schreef op 20/06/2023 om 9:49: > > I've tried the above code and the bcc address does not receive the message, on the To & CC addresses receive it. > > Here are snippets from my code, perhaps something will stand out to you? > > to = 'e...@domain.gov' > cc = 'e..

Re: Should NoneType be iterable?

2023-06-20 Thread Roel Schroeven via Python-list
Op 20/06/2023 om 2:50 schreef Greg Ewing via Python-list: I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. I guess it depends on the reason why there

Re: File system path annotations

2023-06-19 Thread Roel Schroeven via Python-list
Op 19/06/2023 om 11:44 schreef Peter Slížik: Thank you, Roel. You've answered all my questions. > [PEP 519]: ...as that can be represented with typing.Union[str, bytes, os.PathLike] easily enough and the hope is users > will slowly gravitate to path objects only. I read a lot on Python and, f

Re: File system path annotations

2023-06-19 Thread Roel Schroeven via Python-list
Op 19/06/2023 om 10:43 schreef Peter Slížik via Python-list: Hello, what is the preferred way of annotating file system paths? This StackOverflow answer (and a few others) recommend using the str | os.PathLike union. However, byte arrays can be

Re: f-string syntax deficiency?

2023-06-06 Thread Roel Schroeven via Python-list
Op 6/06/2023 om 16:48 schreef Chris Angelico via Python-list: On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "Syntax

Re: f-string syntax deficiency?

2023-06-06 Thread Roel Schroeven
Op 6/06/2023 om 16:41 schreef Roel Schroeven: 'return' being a keyowrd is definitely going to be the problem. *keyword -- "Don't Panic." -- Douglas Adams, The Hitchhiker's Guide to the Galaxy -- https://mail.python.org/mailman/listinfo/python-list

Re: f-string syntax deficiency?

2023-06-06 Thread Roel Schroeven
Op 6/06/2023 om 16:08 schreef Chris Angelico: On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > The following f-string does not parse and gives syntax error on 3.11.3: > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > However this expression, which is similar does parse cor

Re: "Invalid literal for int() with base 10": is it really a literal?

2023-05-26 Thread Roel Schroeven
Op 26/05/2023 om 10:29 schreef Chris Angelico: However, if you want to change the wording, I'd be more inclined to synchronize it with float(): >>> float("a") Traceback (most recent call last): File "", line 1, in ValueError: could not convert string to float: 'a' I was looking for other Va

"Invalid literal for int() with base 10": is it really a literal?

2023-05-26 Thread Roel Schroeven
Kevin M. Wilson's post "Invalid literal for int() with base 10?" got me thinking about the use of the word "literal" in that message. Is it correct to use "literal" in that context? It's correct in something like this: >>> int('invalid') Traceback (most recent call last):   File "", line 1, in

Re: Invalid literal for int() with base 10?

2023-05-26 Thread Roel Schroeven
Op 25/05/2023 om 23:30 schreef Kevin M. Wilson via Python-list: Ok, I'm not finding any info. on the int() for converting a str to an int (that specifies a base parameter)?! The picture is of the code I've written... And the base 10 paradigm involved?? years = int('y') # store for calculationVa

Re: Dataclasses, immutability(?), and ChatGPT

2023-04-12 Thread Roel Schroeven
Op 12/04/2023 om 6:58 schreef dn via Python-list: Are dataclasses (or instances thereof) mutable or immutable? - and in what sense? Instances of dataclasses are mutable, just like normal classes. Dataclasses *are* normal classes, with some extra special methods. They are totally different from

Re: Christoph Gohlke and compiled packages

2023-04-11 Thread Roel Schroeven
Op 11/04/2023 om 12:58 schreef Chris Angelico: On Tue, 11 Apr 2023 at 20:15, Jim Schwartz wrote: > > What’s the problem now? Is it with python on windows? I use python on windows so I’d like to know. Thanks > Python itself is fine, but a lot of third-party packages are hard to obtain. So if

Re: built-in pow() vs. math.pow()

2023-03-30 Thread Roel Schroeven
Andreas Eisele schreef op 30/03/2023 om 11:15: I sometimes make use of the fact that the built-in pow() function has an optional third argument for modulo calculation, which is handy when dealing with tasks from number theory, very large numbers, problems from Project Euler, etc. I was unpleasa

Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Roel Schroeven
Peter J. Holzer schreef op 18/03/2023 om 13:15: On 2023-03-18 08:46:42 +, Alan Gauld wrote: > On 17/03/2023 17:55, Thomas Passin wrote: > >> I used Delphi and Smalltalk/V which both pretty much only exist within > >> their own IDEs and I used their features extensively. > > > > Back when

Re: Friday finking: IDE 'macro expansions'

2023-03-17 Thread Roel Schroeven
Op 17/03/2023 om 0:54 schreef Thomas Passin: What I find more useful is matching brackets/parens/braces.  Not inserting them but highlighting or (better) jumping to the matching one when asked. That is very helpful indeed. Even better than simply highlighting is (IMO) a thing called "Rainbow B

Re: Debugging reason for python running unreasonably slow when adding numbers

2023-03-16 Thread Roel Schroeven
Op 14/03/2023 om 8:48 schreef Alexander Nestorov: I have the following code: ... for i in range(151): # 150 iterations    ... Nothing to do with your actual question and it's probably just a small oversight, but still I thought it was worth a mention: that comment does not accu

Re: We can call methods of parenet class without initliaze it?

2023-03-15 Thread Roel Schroeven
Op 15/03/2023 om 10:57 schreef scruel tao: The following code won’t be allowed in Java, but in python, it works fine: ```python class A: A = 3 def __init__(self): print(self.A) def p(self): print(self.A) self.A += 1 class B(A): def __init__(self)

Re: Testing list sequence question

2023-03-04 Thread Roel Schroeven
Thomas Passin schreef op 4/03/2023 om 18:49: On 3/4/2023 11:38 AM, Gabor Urban wrote: > Hi guys, > > I have a strange problem that I do not understand. I am testing function > which returns a dictionary. The code should ensure that the keys of the > dictionary are generated in a given order.

Re: Testing list sequence question

2023-03-04 Thread Roel Schroeven
Gabor Urban schreef op 4/03/2023 om 17:38: Hi guys, I have a strange problem that I do not understand. I am testing function which returns a dictionary. The code should ensure that the keys of the dictionary are generated in a given order. I am testing the function with the standard unittest

Re: How to escape strings for re.finditer?

2023-02-28 Thread Roel Schroeven
Op 28/02/2023 om 14:35 schreef Thomas Passin: On 2/28/2023 4:33 AM, Roel Schroeven wrote: [...] (2) Searching for a string in another string, in a performant way, is not as simple as it first appears. Your version works correctly, but slowly. In some situations it doesn't matter, but in

Re: How to escape strings for re.finditer?

2023-02-28 Thread Roel Schroeven
Op 28/02/2023 om 3:44 schreef Thomas Passin: On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote: And, just for fun, since there is nothing wrong with your code, this minor change is terser: example = 'X - abc_degree + 1 + qq + abc_degree + 1' for match in re.finditer(re.escape('abc_degree + 1'

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Roel Schroeven
Op 27/02/2023 om 9:56 schreef inhahe: On Mon, Feb 27, 2023 at 3:52 AM Roel Schroeven wrote: > Op 26/02/2023 om 6:53 schreef Hen Hanna: > > > There are some similarities between Python and Lisp-family > > > languages, but really Python is its own thing. > > > >

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Roel Schroeven
Op 26/02/2023 om 6:53 schreef Hen Hanna: > There are some similarities between Python and Lisp-family > languages, but really Python is its own thing. Scope (and extent ?) of variables is one reminder that Python is not Lisp  fori in range(5):  print( i )

Re: Line continuation and comments

2023-02-24 Thread Roel Schroeven
Mark Bourne schreef op 24/02/2023 om 22:04: Personally, I don't particularly like the way you have to put multiline strings on the far left (rather than aligned with the rest of the scope) to avoid getting spaces at the beginning of each line. I find it makes it more difficult to see where the s

Re: Tuple Comprehension ???

2023-02-21 Thread Roel Schroeven
Hen Hanna schreef op 21/02/2023 om 5:13: (A) print( max( * LisX )) (B) print( sum( * LisX ))<--- Bad syntax !!! What's most surprising is (A) is ok, and (B) is not. even tho' max() and sum() have (basically) the same

Re: Am I banned from Discuss forum?

2023-02-11 Thread Roel Schroeven
Michael Torrie schreef op 11/02/2023 om 4:59: I didn't know there was a Discourse forum. Is it supposed to be sync > with the mailing list and USENET? Or is it intended to replace this > mailing list? I rarely see Python devs on this list, so maybe > they've chosen to hang out exclusively in D

Re: DeprecationWarning but replacement doesn't work

2023-02-04 Thread Roel Schroeven
Chris Green schreef op 4/02/2023 om 16:17: I am using Image from PIL and I'm getting a deprecation warning as follows:- /home/chris/bin/picShrink.py:80: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead. But if I change l

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Roel Schroeven
2qdxy4rzwzuui...@potatochowder.com schreef op 19/01/2023 om 19:30: > The PEP-8 rules are good, but they can't cover all cases perfectly. Some the PEP-8 rules are debatable. Regardless, they can't cover all cases perfectly. (IOW, we agree on the bit that's relevant to this thread.) PEP 8 even

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Roel Schroeven
Op 19/01/2023 om 11:32 schreef Stefan Ram: dn writes: >The longer an identifier, the more it 'pushes' code over to the right or >to expand over multiple screen-lines. Some thoughts on this are behind >PEP-008 philosophies, eg line-limit. Raymond Hettinger (transcribed, shortened and parti

Re: To clarify how Python handles two equal objects

2023-01-14 Thread Roel Schroeven
Chris Angelico schreef op 15/01/2023 om 1:41: On Sun, 15 Jan 2023 at 11:38, Jen Kris wrote: > > Yes, in fact I asked my original question – "I discovered something about Python array handling that I would like to clarify" -- because I saw that Python did it that way. > Yep. This is not spec

Re: file.read Method Documentation (Python 2.7.10)

2023-01-11 Thread Roel Schroeven
Chris Angelico schreef op 11/01/2023 om 18:36: On Thu, 12 Jan 2023 at 04:31, Stephen Tucker wrote: > 1. Create BOM.txt > 2. Input three bytes at once from BOM.txt and print them > 3. Input three bytes one at a time from BOM.txt and print them All of these correctly show that a file, in binary m

Re: To clarify how Python handles two equal objects

2023-01-11 Thread Roel Schroeven
Op 11/01/2023 om 16:33 schreef Jen Kris via Python-list: Yes, I did understand that.  In your example, "a" and "b" are the same pointer, so an operation on one is an operation on the other (because they’re the same memory block). Sorry if you feel I'm being overly pedantic, but your explanatio

Re: To clarify how Python handles two equal objects

2023-01-10 Thread Roel Schroeven
Jen Kris via Python-list schreef op 10/01/2023 om 21:41: But where they have been set to the same object, an operation on one will affect the other as long as they are equal (in Python). As long as they are *identical*, not equal. Identical as in having the same identity as Python defines it. I

Re: Possible re bug when using ".*"

2022-12-28 Thread Roel Schroeven
Roel Schroeven schreef op 28/12/2022 om 19:59: Alexander Richert - NOAA Affiliate via Python-list schreef op 28/12/2022 om 19:42: In a couple recent versions of Python (including 3.8 and 3.10), the following code: import re print(re.sub(".*", "replacement", "pat

Re: Possible re bug when using ".*"

2022-12-28 Thread Roel Schroeven
Alexander Richert - NOAA Affiliate via Python-list schreef op 28/12/2022 om 19:42: In a couple recent versions of Python (including 3.8 and 3.10), the following code: import re print(re.sub(".*", "replacement", "pattern")) yields the output "replacementreplacement". This behavior does not occu

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Chris Angelico schreef op 13/12/2022 om 22:58: Okay, so. exactly the same as if you use standard double quotes, but change the configuration option. So the options are: make everything worse for everyone by exacerbating the problem of non-standard identifier quoting, or get this API so SQLite

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Roel Schroeven schreef op 13/12/2022 om 22:36: sqlite> insert into foo values ("xyzzy", "xyzzy"); SQLite accepts it like that, but I really should have used single quotes there instead of double quotes. It's a bad habit from using MySQL for too long I guess. -- &q

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Roel Schroeven schreef op 13/12/2022 om 22:18: Chris Angelico schreef op 13/12/2022 om 20:01: > > Perhaps it's a better idea to use [identifier] or `identifier` instead > > though (I just learned about those on > > https://sqlite.org/lang_keywords.html). Both are not stand

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Chris Angelico schreef op 13/12/2022 om 20:01: On Wed, 14 Dec 2022 at 06:00, Roel Schroeven wrote: > > Stefan Ram schreef op 13/12/2022 om 8:42: > > "John K. Parejko" writes: > > >I was just burned by this, where some tests I’d written > > >against an

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Stefan Ram schreef op 13/12/2022 om 8:42: "John K. Parejko" writes: >I was just burned by this, where some tests I’d written >against an sqlite database did not fail in the way that they >“should” have, because of this double-quoted string issue. In standard SQL, double quotes denote identif

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 15:15 schreef Roel Schroeven: +1 to expose the sqlite3_db_config() function, or maybe just a special case for this specific option. Actually I'm surprised SQLite doesn't have a PRAGMA command to customize this behavior. That would make it possible to customiz

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 14:23 schreef Thomas Passin: On 12/13/2022 4:09 AM, Chris Angelico wrote: On Tue, 13 Dec 2022 at 19:52, Roel Schroeven wrote: Like Lars Liedtke this is not an exact answer to your question, but you can side-step the issue by using parametrized queries, i.e. instead of

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 1:41 schreef John K. Parejko: Asking here before I file an improvement request issue on the python GitHub: sqlite has a known misfeature with double-quoted strings, whereby they will be interpreted as string literals if they don’t match a valid identifier [1]. The note in the

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Roel Schroeven
Op 7/12/2022 om 4:37 schreef Jach Feng: MRAB 在 2022年12月7日 星期三上午11:04:43 [UTC+8] 的信中寫道: > On 2022-12-07 02:23, Jach Feng wrote: > > s0 = r'\x0a' > > At this moment it was done by > > > > def to1byte(matchobj): > > return chr(int('0x' + matchobj.group(1), 16)) > > s1 = re.sub(r'\\x([0-9

Re: Passing information between modules

2022-11-20 Thread Roel Schroeven
Thomas Passin schreef op 20/11/2022 om 20:33: https://devblogs.microsoft.com/oldnewthing/20050607-00/?p=35413 https://devblogs.microsoft.com/oldnewthing/20101125-00/?p=12203 Now that I think about it, The Old New Thing is also where I got the global vs local thing: "Don’t use global state to ma

Re: Passing information between modules

2022-11-20 Thread Roel Schroeven
Stefan Ram schreef op 20/11/2022 om 11:39: The idea is about parameterizing the behavior of a module. For example, the module "M" may contain functions that contain "input.read()" to get input and "output.write()" to write output. Then one would write code like (the following is no

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-14 Thread Roel Schroeven
Op 14/11/2022 om 4:23 schreef DFS: On 11/13/2022 9:11 PM, Chris Angelico wrote: On Mon, 14 Nov 2022 at 11:53, DFS wrote: On 11/13/2022 5:20 PM, Jon Ribbens wrote: On 2022-11-13, DFS wrote: In code, list.clear is just ignored. At the terminal, list.clear shows in code: x = [1,2,3] x.clea

Re: Operator: inappropriate wording?

2022-10-26 Thread Roel Schroeven
elas tica schreef op 26/10/2022 om 21:01: Quotes from The Python Language Reference, Release 3.10.8: - Note that tuples are not formed by the parentheses, but rather by use of the comma operator (p. 66) - Note: If the object is a class instance and the attribute reference occurs on both sid

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Roel Schroeven
Jon Ribbens via Python-list schreef op 24/10/2022 om 19:01: On 2022-10-24, Chris Angelico wrote: > On Tue, 25 Oct 2022 at 02:45, Jon Ribbens via Python-list wrote: >> Adding in the omitted , , , , and >> would make no difference and there's no particular reason to recommend >> doing so as fa

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Roel Schroeven
(Oops, accidentally only sent to Chris instead of to the list) Op 24/10/2022 om 10:02 schreef Chris Angelico: On Mon, 24 Oct 2022 at 18:43, Roel Schroeven wrote: > Using html5lib (install package html5lib) instead of html.parser seems > to do the trick: it inserts right before the next

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Roel Schroeven
Op 24/10/2022 om 9:42 schreef Roel Schroeven: Using html5lib (install package html5lib) instead of html.parser seems to do the trick: it inserts right before the next , and one before the closing . On my system the same happens when I don't specify a parser, but IIRC that's a b

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Roel Schroeven
Op 24/10/2022 om 4:29 schreef Chris Angelico: Parsing ancient HTML files is something Beautiful Soup is normally great at. But I've run into a small problem, caused by this sort of sloppy HTML: from bs4 import BeautifulSoup # See: https://gsarchive.net/gilbert/plays/princess/tennyson/tenniv.htm

Re: What to use for finding as many syntax errors as possible.

2022-10-11 Thread Roel Schroeven
Op 10/10/2022 om 19:08 schreef Robert Latest via Python-list: Antoon Pardon wrote: > I would like a tool that tries to find as many syntax errors as possible > in a python file. I'm puzzled as to when such a tool would be needed. How many syntax errors can you realistically put into a single P

Re: What can I do about this?

2022-08-29 Thread Roel Schroeven
Mark Bourne schreef op 29/08/2022 om 13:02: Roel Schroeven wrote: > $ source {path_to_venv}/bin/pip3  # activate the venv I think this first line should probably be: $ source {path_to_venv}/bin/activate # activate the venv i.e. with `activate` rather than `pip3`? Oops, yes, of cou

Re: What can I do about this?

2022-08-29 Thread Roel Schroeven
Op 29/08/2022 om 2:55 schreef gene heskett: On 8/28/22 19:39, Peter J. Holzer wrote: On 2022-08-28 18:40:17 -0400, gene heskett wrote: Persuant to my claim the py3.10 is busted, here is a sample. This is me, trying to make pronterface, inside a venv: When the package manager version will only

Re: Simple TCP proxy

2022-07-30 Thread Roel Schroeven
Morten W. Petersen schreef op 29/07/2022 om 22:59: OK, sounds like sunshine is getting the best of you. It has to be said: that is uncalled for. Chris gave you good advice, with the best of intentions. Sometimes we don't like good advice if it says something we don't like, but that's no reaso

Re: random.SystemRandom().randint() inefficient

2022-07-27 Thread Roel Schroeven
Cecil Westerhof via Python-list schreef op 27/07/2022 om 17:43: "Michael F. Stemper" writes: > This is orthogonal to your question, but might be of some use to you: > > The combination of using len(to_try) as an argument to randint() and > saving the output to a variable named "index" suggests

Re: list indices must be integers or slices, not str

2022-07-20 Thread Roel Schroeven
Frank Millman schreef op 20/07/2022 om 13:04: >> On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: >>>   >>> >>>   >>> x = list(range(10)) >>>   >>> >>>   >>> '{x[1]}'.format(**vars()) >>> '1' >>>   >>> >>>   >>> '{x[-1]}'.format(**vars()) >>> Traceback (most recent call last): >>>     File "",

Re: [Neuroimaging] what's the problem??????

2022-07-15 Thread Roel Schroeven
Dennis Lee Bieber schreef op 15/07/2022 om 19:11: ... is, itself, returning a dictionary on which .values() can be applied. In that case, the list() call is likely redundant as .values() already returned a list (hmmm, is list(some_list) a no-op, or does it wrap some_list into another list -- in t

Re: calculate diff between dates

2022-07-13 Thread Roel Schroeven
Op 12/07/2022 om 14:37 schreef נתי שטרן: I glad for any help http://www.catb.org/~esr/faqs/smart-questions.html -- "Binnen een begrensde ruimte ligt een kritiek punt, waar voorbij de vrijheid afneemt naarmate het aantal individuen stijgt. Dit gaat evenzeer op voor mensen in de begrensde ruimte

Re: REPL with multiple function definitions

2022-06-26 Thread Roel Schroeven
Rob Cliffe via Python-list schreef op 27/06/2022 om 0:14: This 2-line program def f(): pass def g(): pass runs silently (no Exception).  But: 23:07:02 c:\>python Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" o

Re: sre_constants MODIFIED CLASS - ERROR

2022-06-24 Thread Roel Schroeven
Op 24/06/2022 om 14:14 schreef נתי שטרן: My TARGET  is to bind many code libraries to one Huge code file that works optimally and do optimizations if needed. In this file have code of huge part of falconpy, ALL code of re, argparse, are and many other code libraries Don't do that. Sorry, it's ju

Re: sre_constants MODIFIED CLASS - ERROR

2022-06-24 Thread Roel Schroeven
Op 24/06/2022 om 11:10 schreef נתי שטרן: OK. I lifted the full library to a HUGE python file that was saved on LAN in MY WORK Do I need to lift many other libraries to the file? I glad to any answer Answer this: what is it that your _actually_ trying to do? What is the ultimate goal of all that

Re: argparse modify

2022-06-24 Thread Roel Schroeven
Op 24/06/2022 om 0:32 schreef Dennis Lee Bieber: On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer" declaimed the following: >??? wrote at 2022-6-23 15:31 +0300: >>how to solve this (argparse) >>MAXREPEAT = _NamedIntConstant(32,name=str(32)) >>TypeError: 'name' is an invalid keyword a

Re: sre_constants MODIFIED CLASS - ERROR

2022-06-24 Thread Roel Schroeven
Op 24/06/2022 om 10:43 schreef נתי שטרן: what's the problem with the code Have you seen the replies from Mats Wichmann and Chris Angelico, who helpfully pointed out some problems with your code and possible improvements? Please take those into account instead of asking the same thing over

Re: "CPython"

2022-06-20 Thread Roel Schroeven
Paulo da Silva schreef op 20/06/2022 om 21:01: Às 18:19 de 20/06/22, Stefan Ram escreveu: >The same personality traits that make people react >to troll postings might make them spread unconfirmed >ideas about the meaning of "C" in "CPython". > >The /core/ of CPython is written in

Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Roel Schroeven
Chris Angelico schreef op 14/06/2022 om 20:47: > def main(): > for each in (iterEmpty, iter1, iter2, iterMany): > baseIterator = each() > chopFirst = mapFirst(baseIterator, lambda x: x[1:-1]) > andCapLast = mapLast(chopFirst, lambda x: x.upper()) > print(repr("

Re: How to replace characters in a string?

2022-06-08 Thread Roel Schroeven
Op 8/06/2022 om 11:25 schreef Dave: Hi, I misunderstood how it worked, basically I’ve added this function: def filterCommonCharacters(theString): myNewString = theString.replace("\u2019", "'") return myNewString Which returns a new string replacing the common characters. This can e

Re: tail

2022-04-24 Thread Roel Schroeven
dn schreef op 24/04/2022 om 0:04: Disagreeing with @Chris in the sense that I use tail very frequently, and usually in the context of server logs - but I'm talking about the Linux implementation, not Python code! If I understand Marco correctly, what he want is to read the lines from bottom to t

Re: How to test input via subprocess.Popen with data from file

2022-03-11 Thread Roel Schroeven
Op 11/03/2022 om 10:11 schreef Roel Schroeven: Op 10/03/2022 om 13:16 schreef Loris Bennett: Hi, I have a command which produces output like the following:    Job ID: 9431211    Cluster: curta    User/Group: build/staff    State: COMPLETED (exit code 0)    Nodes: 1    Cores per node: 8    CPU

Re: How to test input via subprocess.Popen with data from file

2022-03-11 Thread Roel Schroeven
Op 10/03/2022 om 13:16 schreef Loris Bennett: Hi, I have a command which produces output like the following: Job ID: 9431211 Cluster: curta User/Group: build/staff State: COMPLETED (exit code 0) Nodes: 1 Cores per node: 8 CPU Utilized: 01:30:53 CPU Efficiency: 83.63% of

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-11 Thread Roel Schroeven
Op 11/03/2022 om 3:50 schreef Chris Angelico: On Fri, 11 Mar 2022 at 09:51, Cousin Stanley wrote: > The following will display a list of lxqt packages > that are in the repository and available to install > > apt-cache search lxqt | grep ^lxqt > Much faster: apt-cache pkgnames lxqt

Re: Behavior of the for-else construct

2022-03-04 Thread Roel Schroeven
Op 4/03/2022 om 1:43 schreef Chris Angelico: Think of it like this: for item in search_list: if condition: pass else: print("Condition not true for this item") for item in search_list: if condition: break else: print("Condition not true for any item") There's a par

Re: Behavior of the for-else construct

2022-03-04 Thread Roel Schroeven
Op 4/03/2022 om 8:18 schreef Chris Angelico: On Fri, 4 Mar 2022 at 18:13, Dieter Maurer wrote: > One of my use cases for `for - else` does not involve a `break`: > the initialization of the loop variable when the sequence is empty. > It is demonstrated by the following transscript: > > ```pycon

Re: Behavior of the for-else construct

2022-03-03 Thread Roel Schroeven
Op 3/03/2022 om 14:24 schreef computermaster360: I want to make a little survey here. Do you find the for-else construct useful? Have you used it in practice? Do you even know how it works, or that there is such a thing in Python? - No, or at least not when balanced against the drawbacks as I pe

  1   2   3   4   5   >