Re: Searching for a file

2025-05-28 Thread Peter J. Holzer
ern. > >>> tmp_files = [] > >>> for dir in ['/tmp', '/var/tmp']: > ... tmp_files += [f for f in glob(join(dir, filename_to_find)) if > isfile(f) ] But then the glob is useless. Just try to open the file as Chris already demonstrated. hjp -

Re: Searching for a file

2025-05-27 Thread Peter J. Holzer
27;s purpose this isn't necessary. He just needs to test a fixed number of locations. Reading even one directory (muss less recursively scanning a whole tree like os.walk does) is just pointless extra work. hjp -- _ | Peter J. Holzer| Story must make more sense th

Re: backslash in triple quoted string

2025-05-11 Thread Peter J. Holzer via Python-list
cumentation should match the current implementation and not something which may or may not be implemented at some point in the future. > but seeing how many other things are done in Python, this is not an > exception. It would've been strange to have it done properly when > "prop

Re: backslash in triple quoted string

2025-05-11 Thread Peter J. Holzer via Python-list
gram now before it breaks. One could argue that it should say 'unrecognized escape sequence' instead of 'invalid escape sequence', since it isn't invalid yet, but that's nitpicking. hjp -- _ | Peter J. Holzer| Story must make more sense than

Re: Pip installs to unexpected place

2025-04-19 Thread Peter J. Holzer via Python-list
On 2025-04-18 13:08:36 -0400, Thomas Passin via Python-list wrote: > On 4/18/2025 11:38 AM, Peter J. Holzer via Python-list wrote: > > On 2025-04-18 13:24:28 +1200, Greg Ewing via Python-list wrote: > > > On 18/04/25 9:41 am, Mats Wichmann wrote: > > > > There'

Re: Pip installs to unexpected place

2025-04-19 Thread Peter J. Holzer via Python-list
On 2025-04-18 17:11:33 +0100, Oscar Benjamin via Python-list wrote: > On Fri, 18 Apr 2025 at 16:50, Peter J. Holzer via Python-list > wrote: > > > > On 2025-04-18 13:24:28 +1200, Greg Ewing via Python-list wrote: > > > On 18/04/25 9:41 am, Mats Wichmann wrote: > &

Re: Pip installs to unexpected place

2025-04-18 Thread Peter J. Holzer via Python-list
appealing to me (not to mention that it might be unacceptably slow). hjp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" s

Re: Strategies for avoiding having to use --break-system-packages with pip

2025-01-17 Thread Peter J. Holzer via Python-list
pts which activate the venv. Python does that all by itself. I have a small script, install-python[1], to assist with setting the hashbang, but if it's just a few scripts you can simply edit it manually. hp [1] https://git.hjp.at:3000/hjp/install-python/src/branch/master/install-pyth

Re: How to manage accented characters in mail header?

2025-01-06 Thread Peter J. Holzer via Python-list
achine-readable information like addresses or message ids. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"

Re: No module name mutagen

2025-01-01 Thread Peter J. Holzer via Python-list
t" I mean a collection of software for a common purpose. That might be a collection of scripts, it might be web site, etc. -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative w

Re: it's a shame... python error over error

2024-12-16 Thread Peter J. Holzer via Python-list
hon discussing the language and helping each other when we can (some of us are also contributors to Python). > doesn't ever understand the problem. Quite possibly, but in that case you haven't explained it well enough. hp -- _ | Peter J. Holzer| Story must make more sen

Re: it's a shame... python error over error

2024-12-14 Thread Peter J. Holzer via Python-list
different directory ("HOME/ext/..." is a relative path. That will not work in a different directory. Also "HOME" is a strange choice for a directory name. Did you mean $HOME?) or because the acceptance tests set up their own environment. I'd test the first idea first. Cd int

Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Peter J. Holzer via Python-list
in general no suitable human readable string representation of a whole email. You have to go through it part by part and decide what you want to do with each. For example, if you have a multipart/alternative with a text/plain and a text/html part what should the "string representation" be?

Re: Correct syntax for pathological re.search()

2024-10-21 Thread Peter J. Holzer via Python-list
On 2024-10-19 00:15:23 +0200, jak via Python-list wrote: > Peter J. Holzer ha scritto: > > As a trivial example, the regular expressions r"\\sout{" and r"\\sout\{" > > are equivalent (the \ before the { is redundant). Yet > > re.compile(s).pattern preserv

Re: Correct syntax for pathological re.search()

2024-10-18 Thread Peter J. Holzer via Python-list
On 2024-10-12 08:51:57 -0400, Thomas Passin via Python-list wrote: > On 10/12/2024 6:59 AM, Peter J. Holzer via Python-list wrote: > > On 2024-10-11 17:13:07 -0400, AVI GROSS via Python-list wrote: > > > Is there some utility function out there that can be called to sh

Re: Correct syntax for pathological re.search()

2024-10-12 Thread Peter J. Holzer via Python-list
sion than anything the re module could reasonably produce (although with the caveat that such a web site would use a different implementation and therefore might produce different results). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Sanitise user input for a script

2024-08-30 Thread Peter J. Holzer via Python-list
e in an email address is valid, but it is). Include meaningful error messages (not just "input invalid"). Helping your legitimate users is more important than slightly inconveniencing an attacker. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_)

Re: pdb: How to use the 'break' parameter?

2024-08-21 Thread Peter J. Holzer via Python-list
#x27;d' (I'm not sure what "indx = 4" was supposed to do. You can't assign inside of a condition.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "

Re: Help needed - - running into issues with python and its tools

2024-08-04 Thread Peter J. Holzer via Python-list
re is no way to set up a venv first and then install Python into it. Does Devuan have a testing or unstable suite? You might be able to install a newer Python version from that. If not your best bet is to install Python from source. hp -- _ | Peter J. Holzer|

Re: Relatively prime integers in NumPy

2024-07-12 Thread Peter J. Holzer via Python-list
gine brings me to https://numpy.org/doc/stable/reference/generated/numpy.gcd.html hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://

Re: Difference method vs attribut = function

2024-06-29 Thread Peter J. Holzer via Python-list
the context of a database app > where I build Getters for database data and pass one Getter per > instance. Or in this case, since each function is specific to one instance, you could just use a closure to capture the object. But that might be confusing to any future maintainers (e.g. yourse

Tkinter and astral characters (was: Decoding bytes to text strings in Python 2)

2024-06-24 Thread Peter J. Holzer via Python-list
t (unlike xfce4-terminal which shows the emoji just fine). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!&qu

Re: in Python: (101 102 103 201 202 203 301 302 303 401 402 403 )

2024-06-18 Thread Peter J. Holzer via Python-list
3 201 202 203 301 302 303 401 402 403 > > > I /think/ you can replace it with {1...4} and {1...3}? I know there is > some syntax for "range of numbers" but I can't remember it exactly. Only two dots, not three: % echo {1..4}0{1..3} 101 102 103 201 202 203 301 302 303 401

Re: Suggested python feature: allowing except in context maneger

2024-06-17 Thread j via Python-list
On 2024-06-13 23:49, Cameron Simpson via Python-list wrote: On 13Jun2024 19:44, dieter.mau...@online.de wrote: Why not use: ``` try:  with open()...    ... except FileNotFoundError:  ... ``` This is exactly what the OP was expressing dissatisfaction with. I'm -1 on the idea myself - not eve

Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-06-01 Thread Peter J. Holzer via Python-list
example, since you have a list of tuples, not a list of lists and a tuple is not an instance of a list. > return '(' + ' '.join(map(lispstr, exp)) + ')' > else: > return str(exp) > > def Lprint(x): print(lispstr(x)) I like to

Re: From JoyceUlysses.txt -- words occurring exactly once

2024-06-01 Thread Peter J. Holzer via Python-list
ypographical convention, so your texts are unlikely to make this distinction. hp [1] Which I use rarely, anyway. -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Cr

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

2024-05-20 Thread Peter J. Holzer via Python-list
python3 -m pip install --user --break-system-packages does indeed install into ~/.local/lib/python3.XX/site-packages. This inconvenient, but otoh I have accidentally installed packages into ~/.local in the past, so maybe it's good to make that more explicit. hp -- _ | P

venvs vs. package management (was: Terminal Emulator (Posting On Python-List Prohibited))

2024-05-18 Thread Peter J. Holzer via Python-list
If we relied on the distro's package management that would basically be a non-issue. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | ht

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

2024-05-18 Thread Peter J. Holzer via Python-list
ven less because many distributions come with a decent set of Python packages. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.

Re: Terminal Emulator

2024-05-18 Thread Peter J. Holzer via Python-list
width, parity, ...) and then hands over to login. Of course in the case of a linux console there is no modem and no serial line involved, so it doesn't have much to do. (Of course this raises the question whether the Linux console is a terminal or a terminal emu

Re: Terminal Emulator

2024-05-18 Thread Peter J. Holzer via Python-list
s capabilities. OTOH, there is something like domterm[1], which can (theoretically) display anything a browser can display. hp [1] https://domterm.org/index.html -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: Python Dialogs

2024-05-04 Thread Peter J. Holzer via Python-list
not being flush left? Ramism. > It is sort of contrary to what I think of as "normal" indentation. Stefan is well known for doing everything contrary to normal convention. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: xkcd.com/353 ( Flying with Python )

2024-03-31 Thread Peter J. Holzer via Python-list
gt; > Nonetheless, Perl folk do use that term, specifically. I'm pretty sure he's referring to the use of @ in python to denote a decorator here. Which is a totally different thing than a Perl sigil. hp -- _ | Peter J. Holzer| Story must make more sense than rea

Re: xkcd.com/353 ( Flying with Python )

2024-03-31 Thread Peter J. Holzer via Python-list
any direct connection to the xkcd cartoon. In my opinion the connection to Perl sigils is very direct. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/

Re: Configuring an object via a dictionary

2024-03-17 Thread Peter J. Holzer via Python-list
On 2024-03-17 17:15:32 +1300, dn via Python-list wrote: > On 17/03/24 12:06, Peter J. Holzer via Python-list wrote: > > On 2024-03-16 08:15:19 +, Barry via Python-list wrote: > > > > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list > > > > wrote: >

Re: Configuring an object via a dictionary

2024-03-16 Thread Peter J. Holzer via Python-list
#x27;t bulletproof but I've found it very handy. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" s

Re: A Single Instance of an Object?

2024-03-11 Thread Peter J. Holzer via Python-list
lo = lookup.get_lookup("test1") ... lo = lookup.get_lookup("test2") ... lo = lookup.get_lookup("test3") hp PS: You don't have to put that in a separate module but I think it's a lot cleaner that way. -- _ | Peter J. Holzer| Story mu

Re: Testing (sorry)

2024-02-20 Thread Peter J. Holzer via Python-list
send you a notification that the mail cannot currently be delivered and that it will keep trying. Such notifications are usually sent after a much shorter period (a few hours). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...

Re: Testing (sorry)

2024-02-18 Thread Peter J. Holzer via Python-list
s from you in the "nan" thread. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Desc

Re: Using my routines as functions AND methods

2024-01-06 Thread Peter J. Holzer via Python-list
> class Class1: > pass o = Class1() f1(o, 'The plain function') works for me. > class Class2: > pass > > c1 = Class1() > c1.newfunc = f1 > c1.newfunc('f1 assigned to instance') # Works as intended Now this doesn't work any more (but the O

Re: How/where to store calibration values - written by program A, read by program B

2023-12-30 Thread Peter J. Holzer via Python-list
On 2023-12-29 09:01:24 -0800, Grant Edwards via Python-list wrote: > On 2023-12-28, Peter J. Holzer via Python-list wrote: > > On 2023-12-28 05:20:07 +, rbowman via Python-list wrote: > >> On Wed, 27 Dec 2023 03:53:42 -0600, Greg Walters wrote: > >> > The big

Re: How/where to store calibration values - written by program A, read by program B

2023-12-28 Thread Peter J. Holzer via Python-list
urse write python files from a python script (in fact I do this), but that's not what this pattern is about, AFAICS. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, &quo

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread Peter J. Holzer via Python-list
etc. > or just specify the right version > on the command line. In that case you might as well not have included the > shebang line at all. Right. However, that's not how scripts are usually invoked on Unix. Using /usr/bin/env in the command line is supposed to fix that but of course it

Re: How/where to store calibration values - written by program A, read by program B

2023-12-09 Thread Peter J. Holzer via Python-list
nguishes between some primitive types (string, number, boolean, null) and provides two container types (dict/object, list/array). As long as those types are sufficient, JSON includes them. If you need anything else, you're on your own. hp -- _ | Peter J. Holzer| Story must ma

Re: Newline (NuBe Question)

2023-11-26 Thread Peter J. Holzer via Python-list
he (unspoken?) context here is "if tuples are sufficient, then ..." hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | chal

Re: Code improvement question

2023-11-17 Thread Peter J. Holzer via Python-list
On 2023-11-17 07:48:41 -0500, Thomas Passin via Python-list wrote: > On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote: > > Oh, and Python (just like Perl) allows you to embed whitespace and > > comments into Regexps, which helps readability a lot if you have to > &g

Re: Code improvement question

2023-11-17 Thread Peter J. Holzer via Python-list
xt) \b - a word boundary. [0-9]{2,7} - 2 to 7 digits - - a hyphen-minus [0-9]{2} - exactly 2 digits - - a hyphen-minus [0-9]{2} - exactly 2 digits \b - a word boundary. Seems quite straightforward to me. I'll be impressed if you can write that in P

Re: xor operator

2023-11-15 Thread Peter J. Holzer via Python-list
ead* of the list. I don't know whether that's possible in your situation, because you haven't told us anything about it. All I'm suggesting is taking a step back and reconsider your choice of data structure. hp -- _ | Peter J. Holzer| Story must make more sense than

Re: xor operator

2023-11-14 Thread Peter J. Holzer via Python-list
If you are willing to stray from the standard library, you could e.g. use pyroaring instead of sets: This is about as fast as all(test1) whether there are two bits set or a hundred. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || |

Re: Python 3.12.0 venv not working with psycopg2

2023-10-02 Thread Peter J. Holzer via Python-list
rking. > > https://github.com/psycopg/psycopg2/issues/1578 > https://github.com/python/cpython/issues/104830 You wil have to come up with a *minimal* test case which reproduces the problem. Expecting people to download and test your massive application is unreasonable. hp -

Re: path to python in venv

2023-09-27 Thread Peter J. Holzer via Python-list
nv/bin/python* lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python -> python3.10* lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python3 -> python3.10* lrwxrwxrwx 1 hjp hjp 15 Sep 28 00:45 venv/bin/python3.10 -> /bin/python3.10* hp -- _ | Peter J. Holzer| Story

dateutil on PyPI (was: PEP668 / pipx and "--editable" installs)

2023-09-20 Thread Peter J. Holzer via Python-list
On 2023-09-20 13:31:14 +, c.buhtz--- via Python-list wrote: > Dear Peter, > > maybe we have a missunderstanding. > > Am 20.09.2023 14:43 schrieb Peter J. Holzer via Python-list: > > > > > "dateutil" is not available from PyPi for Python 3.11 > >

Re: PEP668 / pipx and "--editable" installs

2023-09-20 Thread Peter J. Holzer via Python-list
On 2023-09-18 18:56:35 +, c.buhtz--- via Python-list wrote: > On 2023-09-18 10:16 "Peter J. Holzer via Python-list" > wrote: > > On 2023-09-15 14:15:23 +, c.buhtz--- via Python-list wrote: > > > I tried to install it via "pipx install -e .[develop]"

Re: PEP668 / pipx and "--editable" installs

2023-09-18 Thread Peter J. Holzer via Python-list
hon-dateutil Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) 247.7/247.7 kB 3.1 MB/s eta 0:00:00 Collecting six>=1.5 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Installing collected packages: six, python-dateutil Successfully installed python-dateutil-2.8.2 six

Re: Postgresql equivalent of Python's timeit?

2023-09-17 Thread Peter J. Holzer via Python-list
On 2023-09-17 11:01:43 +0200, Albert-Jan Roskam via Python-list wrote: >On Sep 15, 2023 19:45, "Peter J. Holzer via Python-list" > wrote: > > On 2023-09-15 17:42:06 +0200, Albert-Jan Roskam via Python-list wrote: > >    This is more related to Postg

Re: `time.perf_counter_ns` always a 64-bit int?

2023-09-16 Thread Peter J. Holzer via Python-list
it could. Unless you expect your system to have an uptime in excess of 292 years, don't worry. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative w

Re: Postgresql equivalent of Python's timeit?

2023-09-15 Thread Peter J. Holzer via Python-list
use most of the data will already be in memory.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.

Re: Passing info to function used in re.sub

2023-09-04 Thread Peter J. Holzer via Python-list
Do various things that involves for info # that what's available in m replacement_text = m.group(1) + local_var1 + local_var2 return replacement_text for md_text in ( "aardvark", "barbapapa", "ba ba ba ba barbara ann"): new_text

Re: What sort of exception when a class can't find something?

2023-08-31 Thread Peter J. Holzer via Python-list
hould > there be? Is it maybe a ValueError? It you are going for a builtin exception, I think KeyError is the most appropriate: It should be a LookupError, since the lookup failed and a database is more like a mapping than a sequence. But it would probably be best to define your own exception for t

Re: Using "textwrap" package for unwrappable languages (Japanese)

2023-08-30 Thread Peter J. Holzer via Python-list
On 2023-08-30 13:18:25 +, c.buhtz--- via Python-list wrote: > Am 30.08.2023 14:07 schrieb Peter J. Holzer via Python-list: > > another caveat: Japanese characters are usually double-width. So > > (unless your line length is 130 characters for English) you would > > want t

Re: Using "textwrap" package for unwrappable languages (Japanese)

2023-08-30 Thread Peter J. Holzer via Python-list
st_asian_width() seems to be the canonical name to find the width of a character, but it returns a code (like 'W' or 'Na') not a number.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Where is the error?

2023-08-06 Thread Peter J. Holzer via Python-list
ogram was a bit longer of course, so I checked the lines before that to see if I forgot to close any parentheses. Took me some time to notice the missing comma *after* the underlined expression. Is this "clairvoyant" behaviour a side-effect of the new parser or was that a delibe

Re: Bug in io.TextIOWrapper?

2023-06-19 Thread Peter J. Holzer via Python-list
>>> buffer.getvalue() Traceback (most recent call last): File "", line 1, in ValueError: I/O operation on closed file. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Str

Re: Log File

2023-05-31 Thread Peter J. Holzer
log a status message every once in a while (e.g. every 100 MB or every 10 lines). That will give you reassurance that the program is working and a rough estimate when it will be finished. Or you can log any other information you think might be useful. hp -- _ | Peter J. Holzer

Re: OT: Addition of a .= operator

2023-05-24 Thread Peter J. Holzer
ead that code. hp [1] Which is often yourself, a few months older. Or it could be an experienced colleague who's very familiar with the codebase. Or a new colleague trying to understand what this is all about (possibly while learning Python). -- _ | Peter J. Holzer| Story m

Re: Addition of a .= operator

2023-05-24 Thread Peter J. Holzer
On 2023-05-24 08:51:19 +1000, Chris Angelico wrote: > On Wed, 24 May 2023 at 08:48, Peter J. Holzer wrote: > > Yes, that probably wasn't the best example. I sort of deliberately > > avoided method chaining here to make my point that you don't have to > > inven

Re: Addition of a .= operator

2023-05-23 Thread Peter J. Holzer
On 2023-05-24 07:12:32 +1000, Chris Angelico wrote: > On Wed, 24 May 2023 at 07:04, Peter J. Holzer wrote: > > But I find it easier to read if I just reuse the same variable name: > > > > user = request.GET["user"] > > user = str(user, encodi

Re: Addition of a .= operator

2023-05-23 Thread Peter J. Holzer
;utf-8") user = user.strip() user = user.lower() user = orm.user.get(name=user) Each instance only has a livetime of a single line (or maybe two or three lines if I have to combine variables), so there's little risk of confusion, and reusing the variable name makes it very clea

Re: Addition of a .= operator

2023-05-20 Thread Peter J. Holzer
vement over self.data[line+len(chars)-1] + self.data[line+len(chars)-1] + after hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.h

Re: Problem with accented characters in mailbox.Maildir()

2023-05-09 Thread Peter J. Holzer
On 2023-05-08 23:02:18 +0200, jak wrote: > Peter J. Holzer ha scritto: > > On 2023-05-06 16:27:04 +0200, jak wrote: > > > Chris Green ha scritto: > > > > Chris Green wrote: > > > > > A bit more information, msg.get("subject"

Re: Problem with accented characters in mailbox.Maildir()

2023-05-08 Thread Peter J. Holzer
r += chunk[0].decode("windows-1252") elif type(chunk[0]) == bytes: r += chunk[0].decode('us-ascii') else: r += chunk[0] return r (this is maybe a bit more forgiving than the OP needs, but I had to deal with malformed m

Re: Cannot install pkg_resources using pip

2023-04-17 Thread Peter J. Holzer
And since Rich wrote that he's been comfortably using Slackware for 20 years, I'll trust that he knows how to do that and just needed a little nudge into the right direction. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Weak Type Ability for Python

2023-04-15 Thread Peter J. Holzer
e distinct operators for addition and string > concatenation, with automatic type conversion (non-numeric strings have a > numeric value of 0, which can hide bugs). You get a warning for that, though. hp -- _ | Peter J. Holzer| Story mus

Re: Weak Type Ability for Python

2023-04-15 Thread Peter J. Holzer
d > create an int, create an EnhancedInt instead". A bit tricky to > implement. Or alternatively you might be able to add or replace methods on the existing int class. So 5 is still just an int, but now (5 + "x") calls the modified __add__ method which knows how add a string to an

Re: Weak Type Ability for Python

2023-04-13 Thread Peter J. Holzer
strings. For arrays its a (somewhat bizarre) union. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signatu

Re: Weak Type Ability for Python

2023-04-13 Thread J. Pic
print(f'{x}{y}') ? On Wed, Apr 12, 2023 at 7:06 PM Ali Mohseni Roodbari < ali.mohseniroodb...@gmail.com> wrote: > Hi all, > Please make this command for Python (if possible): > > >>> x=1 > >>> y='a' > >>> wprint (x+y) > >>> 1a > > In fact make a new type of print command which can print and show

Re: Christoph Gohlke and compiled packages

2023-04-11 Thread Peter J. Holzer
hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://m

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

2023-03-31 Thread Peter J. Holzer
ard defines or even what C is. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature

Re: How does a method of a subclass become a method of the base class?

2023-03-27 Thread Peter J. Holzer
e statement it will create a new object of class EqualityConstraint and immediately discard it. That may have some useful side effect (for example the object may add itself to a list of constraints) but this is not apparent from this line. hp -- _ | Peter J. Holzer| Story must m

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Peter J. Holzer
f.choose_method will be the choose_method from UrnaryConstraint. If you call it on an object of class BinaryConstraint, then self.choose_method will be the choose_method from BinaryConstraint. hp PS: Pretty sure there's one "r" too many in UrnaryConstraint. -- _ | Pe

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

2023-03-18 Thread Peter J. Holzer
On 2023-03-18 16:06:49 +, Alan Gauld wrote: > On 18/03/2023 12:15, Peter J. Holzer wrote: > >> I think you might be meaning TurboPascal, Delphi's forerunner. It just > >> had a compiler and text editor. > > > > I'd still classify Turbo Pascal as an I

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

2023-03-18 Thread Peter J. Holzer
um2(): > return sum(range(100)) Here you already have the numbers you want to add. The OP needed to compute those numbers first. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- C

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

2023-03-18 Thread Peter J. Holzer
ct) with a traditional desktop GUI for 20 years) so the presence or absence of a GUI builder isn't an essential criterion on whether something is or is not an IDE. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | |

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

2023-03-14 Thread Peter J. Holzer
oesn't. You may want to try PyPy if your code uses tight loops like that. Or alternatively it may be possible to use numpy to do these operations. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: Fast full-text searching in Python (job for Whoosh?)

2023-03-08 Thread Peter J. Holzer
ow long that list can become. If it's 200 matches - sure, send them all, even if the client will display only 10 of them. Probably even for 2000. But if you might get 20 million matches you surely don't want to send them all to the client. hp -- _ | Peter J.

Re: Fast full-text searching in Python (job for Whoosh?)

2023-03-07 Thread Peter J. Holzer
;, the response to the first query might arrive after the response to the second query and you don't want to display "mansion" if the user already typed "mas".) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Peter J. Holzer
ot;C-nic" (nice pun, btw) or "Perlish" code. The Python community may be unique in having invented an adjective for that. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles S

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Peter J. Holzer
language will often write code which is correct but un-idiomatic, and you can often guess which language they come from (they are "writing FORTRAN in Python"). Also quite similar to natural languages where you can guess the native language of an L2 speaker by their accent and phrasing.

Re: How to escape strings for re.finditer?

2023-03-02 Thread Peter J. Holzer
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > > I had no doubt the code you ran was indented properly or it would not work. > > > > I am merely letting you know that somewhere in the process of copyin

Re: How to escape strings for re.finditer?

2023-02-28 Thread Peter J. Holzer
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > > It happens to be easy for me to fix but I sometimes see garbled code I > > then simply ignore. > > Truth to be told, that's one reason why I rarely re

Cryptic software announcements (was: ANN: DIPY 1.6.0)

2023-02-28 Thread Peter J. Holzer
ood idea if software announcements would include a single paragraph (or maybe just a single sentence) summarizing what the software is and does. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Ch

Re: How to escape strings for re.finditer?

2023-02-28 Thread Peter J. Holzer
ails to the end. The long lines and the triple-spaced paragraphs make it just too uncomfortable. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | htt

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Peter J. Holzer
tter. For example, in C on Linux a failed assertion causes a core dump. So you can inspect the complete state of the program. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, &q

Re: Is there a more efficient threading lock?

2023-02-25 Thread Peter J. Holzer
he application using py-spy, that with statement is > consuming huge amounts of CPU. Another thought: How accurate is py-spy? Is it possible that it assigns time actually spent in phrases = TextBlob(text, np_extractor=EXTRACTOR).noun_phrases to with BLOB_LOCK: ? hp -- _ | P

Re: Is there a more efficient threading lock?

2023-02-25 Thread Peter J. Holzer
ep if it can't get the lock right away. (Of course if it does get the lock, it will return immediately which may use a lot of CPU if you are calling it a lot.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Peter J. Holzer
On 2023-02-25 09:10:06 -0500, Thomas Passin wrote: > On 2/25/2023 1:13 AM, Peter J. Holzer wrote: > > On 2023-02-24 18:19:52 -0500, Thomas Passin wrote: > > > Sometimes you can use a second parameter to assert if you know what kind > > > of > > > error to

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-24 18:19:52 -0500, Thomas Passin wrote: > On 2/24/2023 2:47 PM, dn via Python-list wrote: > > On 25/02/2023 08.12, Peter J. Holzer wrote: > > > On 2023-02-24 16:12:10 +1300, dn via Python-list wrote: > > > > In some ways, providing this information seems

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
incomplete code - I didn't bother to implement multiple observations) and assert(header[0] == "Monat (MM)") (the code below is sloppy. Instead of fixing it I just made the original programmer's assumptions explicit) and of course assert False (this point should never

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
ssert 3 == 2 = 1 failed in 0.09s ===== hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Cr

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
, Yup. That is possible and has happened to me several times - of course always in a situation where I really needed that output ... hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles St

  1   2   3   4   5   6   7   8   9   10   >