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-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-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: 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: 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: 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: 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: 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-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-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: 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: 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: Log exception so traceback contains timestamp and level?

2021-02-07 Thread Peter J. Holzer
- Samba and PostgreSQL come to mind). Another possibility would be to write the logs into a database. That also has the advantage that the messages are stored in a structure and you don't have to parse them. hp -- _ | Peter J. Holzer| Story must make more sense than real

Re: New Python implementation

2021-02-16 Thread Peter J. Holzer
be useful, but that wouldn't be compatible with CPython's disassembler in input nor output. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writin

Re: Best practices for software architecture in Python

2021-02-16 Thread Peter J. Holzer
basics. One important question is whether there already is someone on the team who is already an experienced OO programmer (and who can therefore take the technical lead, coach their team-mates, etc.) or whether all of them have the same (lack of) experience. hp -- _ | Pet

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-22 Thread Peter J. Holzer
may not have that optimization (PyPy doesn't, I would assume that Jypthon or IronPython don't either because their method of garbage collection would make it hard). So for a beginner, the question is: Do you care about performance on Python implementations you don't use? For a u

Re: neonumeric - C++ arbitrary precision arithmetic library

2021-03-07 Thread Peter J. Holzer
nsides: Such a generic system might be slow and/or memory-hungry, it might not run on every platform, it might have a steep learning curve, and it's probably not so well-suited for non-compiler programs. > And if it's hard for this simple problem, how about more complex >

Re: neonumeric - C++ arbitrary precision arithmetic library

2021-03-09 Thread Peter J. Holzer
the end, one would have > to write a more or less full blown parser. Yes, but writing a parser is (comparatively) easy. Parser generators have existed for decades. It's the semantics that are difficult. I'm not saying that you are wrong. I am saying that you haven't

Re: Current thinking on required options

2021-04-19 Thread Peter J. Holzer
he user (me) from swapping them. 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: Determine what the calling program is

2021-04-19 Thread Peter J. Holzer
That doesn't work on Unix-like OSs. An environment variable can only be passwd to child processes, not to the parent or unrelated processes. So it can't be used to lock out other processes - they wouldn't ever see the variable. hp -- _ | Peter J. Holzer| Story must m

Re: Determine what the calling program is

2021-04-19 Thread Peter J. Holzer
processes until somebody notices the problem and removes it. The fcntl method suggested by several people has the advantage that the lock vanished with the process which holds it. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Simple question - end a raw string with a single backslash ?

2021-04-24 Thread Peter J. Holzer
dds syntactic sugar. It may be easier to read (especially for people used to other OO languages) and save a bit of typing, but it doesn't add anything you couldn't do in plain Perl5. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Peter J. Holzer
ly > provide a way to create queries, including drop table, The SQL builder tool isn't the right place to do this. Access privileges need to be managed in the database. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Ad-hoc SQL query builder for Python3?

2021-04-26 Thread Peter J. Holzer
On 2021-04-25 15:23:57 -0700, Rich Shepard wrote: > On Sun, 25 Apr 2021, Peter J. Holzer wrote: > > What should that sql query builder build the queries from? Or in other > > words what is the user supposed to input? > > Peter, > > From the dialog box offering tab

Re: Not found in the documentation

2021-04-28 Thread Peter J. Holzer
; definition. There is an indirect definition right at the start of chapter 3: "Input to the parser is a stream of tokens, generated by the lexical analyzer." So a token is what the unit of output of the lexer. This is the definition. The rest of the chapter defines the details. >

Re: Not found in the documentation

2021-05-01 Thread Peter J. Holzer
On 2021-04-28 08:16:19 -0700, elas tica wrote: > Peter J. Holzer a écrit : > > > Is the "is not" operator a token? > > Yes. See chapter 2.3.1. Sorry. I obviously read what I expected to read here, not what you actually wrote. "is not" ist of course not a

Re: learning python ...

2021-05-24 Thread Peter J. Holzer
quot;). The scoping and binding rules of Python were a conscious decision, not a quick hack intended to be fixed later. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "C

Re: Data structure for plotting monotonically expanding data set

2021-05-27 Thread Peter J. Holzer
not a single graph with 400 lines (that would be very cluttered). So I would swap the levels around: { "alice": { "20210527": 123, "20210526": 123, ... }, "bob": { "20210526": 3, "20210525", 1, ... }, "zebedee&qu

Re: imaplib: is this really so unwieldy?

2021-05-27 Thread Peter J. Holzer
u'll get a single wide character in a narrow string. A single emoji in a long English text. > Usually, if there are any wide characters, there'll be a good number > of them Oh, right. People who use emoji usually use a lot of them 😉. hp -- _ | Peter J. Holzer| S

Re: learning python ...

2021-05-27 Thread Peter J. Holzer
$x = 10; say $x; } say $x; You won't get a warning, and the program will print -- 10 5 -- But dynamic scope is something different. It's based on the call stack, not syntax. In Perl, you get dynamically scoped variables with local. This is quite deprecate

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-16 Thread Peter J. Holzer
7;s in https://docs.python.org/3/reference/expressions.html#atom-identifiers | When the name is bound to an object, evaluation of the atom yields that object. So in x = whatever a_list = [x for _ in range(3)] you get a list of 3 references to the same object, not 3 references to 3

Re: How to check if an image contains an element I am searchig for

2021-06-16 Thread Peter J. Holzer
essing of > satellite pictures for smart cars. Using satellite images probably makes that a lot easier (yes, you wrote "Google maps", but for some reason I thought of Google Street View). At least you have a consistent angle (almost from straight above) and know the sca

Re: Unable to remove setup of 3.9.5 from Windows 10

2021-06-20 Thread Peter J. Holzer
On 2021-06-20 15:24:29 +0900, tommy yama wrote: > Unrelated topic, but i thought Windows 10 will be retired anytime soon. October 2025, according to current plans. So you still have more than 4 years to upgrade to Windows 11 (or better yet, Linux ;-)). hp -- _ | Peter J. Hol

Re: Python and Ubuntu versions

2021-08-21 Thread Peter J. Holzer
oke > your Django app. If you are using mod_wsgi to run your Python apps you will probably have to rebuild that as well. The mod_wsgi supplied with Ubuntu uses the system Python and at least a cursory glance through the docs doesn't reveal a way to change that. hp --

Re: basic auth request

2021-08-22 Thread Peter J. Holzer
M (over HTTPS in all cases) I would prefer Basic Auth. Ideally I would use SCRAM or a public key method, but I admit that my security requirements were never high enough to actually bother to do that (actually, I used SSL client side auth once, 20 years ago, ...). hp -- _ | Peter

Re: on perhaps unloading modules?

2021-08-24 Thread Peter J. Holzer
On 2021-08-22 16:28:12 -0300, Hope Rouselle wrote: > I have a certain distaste for syntax too. For instance, I would much > rather write and read ``first(ls)'' than ``ls[0]''. Would you also prefer `twothousandthreehundredandtwentythird(ls)` over `ls[2322]`?

Re: basic auth request

2021-08-25 Thread Peter J. Holzer
On 2021-08-22 19:37:24 +1000, Chris Angelico wrote: > On Sun, Aug 22, 2021 at 6:45 PM Peter J. Holzer wrote: > > > > On 2021-08-22 05:04:43 +1000, Chris Angelico wrote: > > > On Sun, Aug 22, 2021 at 4:55 AM Martin Di Paola > > > wrote: > > > > HTTPS

Re: Pandas: Multiple CSVs in one Zip file

2021-08-26 Thread Peter J. Holzer
gzip tool (and - I presume - also the gzip library) can read a zip file with a single member. The error message would match that. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross,

Re: on writing a while loop for rolling two dice

2021-09-04 Thread Peter J. Holzer
object(), object() while x != y: c = c + 1 x, y = roll() return c, x, y Of course now you are back to two different values, but they look the same. Which may be better or worse for your students. Plus x and y are now bound to objects of different types during their lifetime, which may b

Re: on the popularity of loops while and for

2021-09-04 Thread Peter J. Holzer
ogrammer is very likely to use or encounter in other people's code should be covered more thoroughly than constructs that will be used only rarely. Some are so rare that they can be safely omitted. The while loop is certainly not in that category, but it probably makes sense t

Re: urgent

2021-09-04 Thread Peter J. Holzer
n linux > Type "help", "copyright", "credits" or "license" for more information. > REPL> import sys # in the original, this line will be messed up > REPL> sys.exit(0) # this one, too > username@hostname$ Yes, but then it doesn't look l

Re: The sqlite3 timestamp conversion between unixepoch and localtime can't be done according to the timezone setting on the machine automatically.

2021-09-04 Thread Peter J. Holzer
e time in the morning. Maybe you are talking about switching to DST for the whole year or just moving to CET? That would have the effect of it being noticably darker in the morning in winter. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Problem with python

2021-09-04 Thread Peter J. Holzer
On 2021-09-04 14:29:47 -0500, Igor Korot wrote: > Will this syntax work in python 2? Yes. It's just a redundant pair of parentheses. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |--

Re: Trouble propagating logging configuration

2021-09-04 Thread Peter J. Holzer
.getLogger(__name__) > > import mylibs.mylib > > then the 'logger' in 'mylibs.mylibs' does get configured properly. That normally shouldn't make any difference, since any functions in mylibs.mylib would be called only after the logger is initialized. Does

Re: Problem with python

2021-09-04 Thread Peter J. Holzer
ython 3 to be time well spent in 2021, especially not to someone who apparently just wants to report a bug to some unnamed project (whose maintainers may or may not care about Python2 compatibility). hp -- _ | Peter J. Holzer| Story must make more sense than real

Re: The sqlite3 timestamp conversion between unixepoch and localtime can't be done according to the timezone setting on the machine automatically.

2021-09-04 Thread Peter J. Holzer
On 2021-09-04 21:48:14 +0200, Peter J. Holzer wrote: > On 2021-09-02 08:32:36 +0100, Alan Gauld via Python-list wrote: > > On 31/08/2021 22:32, Chris Angelico wrote: > > > If we could abolish DST world-wide, life would be far easier. All the > > > rest of it would be ea

Re: on floating-point numbers

2021-09-05 Thread Peter J. Holzer
as >>> (8.41 + 6.15 + 2.31 + 7.73 + 7.77) + 7.23 39.61 So commutativity is preserved but associativity is lost. (Of course a single example doesn't prove that this is always the case, but it can be seen from the guarantees that IEEE-754 arithmetic gives you that

Re: on floating-point numbers

2021-09-05 Thread Peter J. Holzer
**13 * 5**3)) can represented exactly, but those with other prime factors (e.g. 1/3, 1/7, 1/24576 == 1/(2**13 * 3), 1/1024001 == 1/(11 * 127 * 733)) cannot. Similarly, for base 12 (2*2*3) numbers with 2 and 3 in the denominator can be represented and for base 60 (2*2*3*5), numbers with 2, 3 and 5.

Re: on floating-point numbers

2021-09-05 Thread Peter J. Holzer
ou call "safe", a * b / a will always be very close to b (unless there's an over- or underflow), but a + b - a can be quite different from b. In general when analyzing a numerical algorithm you have to pay a lot more attention to addition and subtraction than to multiplication and div

Re: on writing a while loop for rolling two dice

2021-09-11 Thread Peter J. Holzer
; written by someone who liked using macros to make C resemble Algol. Steve Bourne, the author of the eponymous shell. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "C

Re: Friday Finking: Contorted loops

2021-09-11 Thread Peter J. Holzer
infinite for loops 1 "infinite" for loop (i.e. it exits somewhere in the middle) 0 do/while loops. So even though do/while loops are available in C (and I don't find them horrible) I apparently found very little use for them (I'm sure if I look through more of my C programs I&#x

Re: on floating-point numbers

2021-09-11 Thread Peter J. Holzer
On 2021-09-05 22:32:51 -, Grant Edwards wrote: > On 2021-09-05, Peter J. Holzer wrote: [on the representability of fractional numbers as floating point numbers] > And once you understand that, ignore it and write code under the > assumumption that nothing can be exactly repre

Re: on floating-point numbers

2021-09-11 Thread Peter J. Holzer
On 2021-09-05 23:21:14 -0400, Richard Damon wrote: > > On Sep 5, 2021, at 6:22 PM, Peter J. Holzer wrote: > > On 2021-09-04 10:01:23 -0400, Richard Damon wrote: > >>> On 9/4/21 9:40 AM, Hope Rouselle wrote: > >>> Hm, I think I see what you're

Re: on floating-point numbers

2021-09-11 Thread Peter J. Holzer
On 2021-09-12 01:40:12 +1000, Chris Angelico wrote: > On Sun, Sep 12, 2021 at 1:07 AM Peter J. Holzer wrote: > > If you have any "decimals" (i.e decimal digits to the right of your > > decimal point) then the input values won't be exactly representable and > >

Re: Friday Finking: Contorted loops

2021-09-12 Thread Peter J. Holzer
ingle person and only a tinly sample from that person. To really answer that question you would have to look at a sizable sample from Github or something like that). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp

Re: Friday Finking: Contorted loops

2021-09-12 Thread Peter J. Holzer
On 2021-09-12 10:28:22 -0700, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2021-09-11 at 18:21:17 +0100, > Alan Gauld via Python-list wrote: > > On 11/09/2021 15:41, Peter J. Holzer wrote: > > > How is C's do/while loop more horrible than Pascal's repeat/unt

Re: Friday Finking: Contorted loops

2021-09-13 Thread Peter J. Holzer
he inner loop" or some other purely syntactic information. (In most cases I would just break up such a function into smaller functions instead of adding comments, though) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h..

Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-20 Thread Peter J. Holzer
C". A C operation may be compiled to a single machine instruction which is executed in a fraction of a nanosecond. A Python instruction (in CPython) always includes at least the interpreter overhead and often several method lookups and method calls. You want to amortize that overhead over

Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-20 Thread Peter J. Holzer
ne would expect - a good optimizing compiler may be able to detect that all that is not needed in a specific case and produce straightforward code. But unlike for JavaScript (which has a very similar problem) no company has spent millions of dollars on an optimizing JIT compiler for Python yet.

Re: XML Considered Harmful

2021-09-24 Thread Peter J. Holzer
ement, even with CSS), but even here you can see that attributes add clarity. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/

Re: XML Considered Harmful

2021-09-24 Thread Peter J. Holzer
ble to read their names as simply strings and insisted on interpreting them as something else (e.g. dates). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing _

Re: XML Considered Harmful

2021-09-24 Thread Peter J. Holzer
the data I have fit naturally within the data model of the format I'm trying to use". If it doesn't, look for something else. For me, CSV, JSON and XML form a hierarchy where each can naturally represent all the data of its predecessors, but not vice versa. hp -- _ | P

Re: XML Considered Harmful

2021-09-25 Thread Peter J. Holzer
On 2021-09-24 23:32:47 -, Jon Ribbens via Python-list wrote: > 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 si

Re: XML Considered Harmful

2021-09-28 Thread Peter J. Holzer
ey are the subject of the data: Devices that generate electricity by burning fuel and he's modelling some aspect of their operation. Maybe efficiency or power output or something like that (I tried to search for "IHR curve", but couldn't find anything). hp -- _ |

Re: XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\r\n\r\n\r\n\r\n'

2021-09-29 Thread Peter J. Holzer
x27;\r\n\r\n\r\n\r\n' > > The above testing file is located at here [1]. > > [1] https://github.com/hongyi-zhao/temp/blob/master/2021-2022-1.xls Why is that file name .xls when it's obviously an HTML file? hp -- _ | Peter J. Holzer| Story must make more sense

Re: Confusing error message: lambda walruses

2021-10-03 Thread Peter J. Holzer
«enclosure» which is an «atom» which is (through several more steps) an «expression» which can be used on the right side of a lambda. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles St

Re: Confusing error message: lambda walruses

2021-10-03 Thread Peter J. Holzer
t mention scope explicitely, but |The unnamed object behaves like a function object defined with: | |def (parameters): |return expression implies to me that it should create a new scope because a nested function defined with «def» would do that, to

Re: spyder does not work under root! [linux]

2021-10-13 Thread Peter J. Holzer
nything on the Spyder website about how it is implemented (I didn't look very hard) but the error message hints that there's a Chromium hidden somewhere. And Eric uses Qt5, and Chromium is derived from WebKit which is Qt's browser engine. It's a bit weird that this also re

Re: New assignmens ...

2021-10-27 Thread Peter J. Holzer
ssignment-statement ;] condition { statements } Then you could write while a, b = next_couple(a,b); b: ... That doesn't even need the walrus operator. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h..

Re: New assignmens ...

2021-10-27 Thread Peter J. Holzer
On 2021-10-24 11:23:48 +0200, O365 Dict wrote: > do: > a, b = calculate_next_couple(a, b) > while b: > more calculations I actually like that syntax. -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | |

Re: The task is to invent names for things

2021-10-27 Thread Peter J. Holzer
ng, you can undo it. After you assign, you can unassign. And > > > after you ite, you can unite! > > > > I wonder whether Japanese programmers would agree. > > Not sure. My knowledge of Japanese is extremely scanty. Can you elaborate? Don't know about Japanese but it w

Re: Does loading PDB slow down execution?

2021-10-27 Thread Peter J. Holzer
ease read the first mail in this thread. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signat

Re: Why so fast a web framework?

2021-10-27 Thread Peter J. Holzer
able contains only PHP based frameworks. How do you know that no Python based frameworks of similar performance exist? (And is the benchmark even meaningful?) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || |

Re: The task is to invent names for things

2021-10-27 Thread Peter J. Holzer
ean choosing nonsensical names most of the time. So I'll stick with mediocre names if in doubt. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http

Re: walrus with a twist :+= or ...

2021-10-28 Thread Peter J. Holzer
of the tight integration), so "but how do I type that in Notepad++?" is not a concern. But tying together a language to an IDE that tightly will turn away all programmers who are already used to a different IDE (or just plain editor) and want to continue to use that. hp -- _

Re: walrus with a twist :+= or ...

2021-10-29 Thread Peter J. Holzer
r problem with using a large number of characters: Some of them will be visually very similar, especially with monospaced fonts. I'm not getting any younger and with my preferred font (which is quite small) I already have to squint to distinguish between : and ; or between () and {}. hp

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-21 Thread Peter J. Holzer
99 == 24 > > False > > >>> 23.999 == 24 > > True > > >>> 0.3 + 0.3 + 0.3 == 0.9 > False Fascinating. The OP ran into the fact that FP numbers have a limited number of digits in the mantissa (completely independent of the base). Som

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-21 Thread Peter J. Holzer
;t need them. I don't actually think I ever used fractions.Fraction in my 7 years of Python programming. (I think I used Math::BigRat in Perl, but I've been programming in Perl for a lot longer.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_)

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-21 Thread Peter J. Holzer
a of 12 decimal digits. + 6667 = 13330 13330 / 2 = 6665 6665 < . QED. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-21 Thread Peter J. Holzer
On 2021-11-22 05:43:48 +1100, Chris Angelico wrote: > On Mon, Nov 22, 2021 at 5:42 AM Peter J. Holzer wrote: > > (I think I used Math::BigRat in Perl, but I've been > > programming in Perl for a lot longer.) > > Rodents Of Unusual Size? I don&#x

Re: Python child process in while True loop blocks parent

2021-12-05 Thread Peter J. Holzer
Python runs on a separate thread.  I think you have the relationship between processes and threads backwards. A process consists of one or more threads. Fork creates a new process and therefore also a new thread. hp -- _ | Peter J. Holzer| Story must make more sense

Re: Python child process in while True loop blocks parent

2021-12-08 Thread Peter J. Holzer
esn't need to use more than one thread or process. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"

Re: Short, perfect program to read sentences of webpage

2021-12-08 Thread Peter J. Holzer
ssions. Let's say you want to match strings, numbers, etc. Python provides regular expresssions for these tasks. In second case the dot ends a sentence in the first it doesn't. But to distinguish those cases you need to at least parse the sentences at the syntax level (which reg

Re: Odd locale error that has disappeared on reboot.

2021-12-09 Thread Peter J. Holzer
(which has happened in the past and probably will happen in the future). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.a

Re: How to package a Python command line app?

2021-12-09 Thread Peter J. Holzer
ion. Even if you don't, it may not matter. I just compiled a hello world program on Ubuntu 20 and ran it on Debian 6 (which is 10 years old). Obviusly a real program has more opportunities to run into compatibility problems, but glibc doesn't change all that much. hp -- _

Re: Isn't TypeError built in?

2021-12-25 Thread Peter J. Holzer
t; errors like the above are common when the virtual environment was built with a different (older) version of the Python interpreter than the one trying to use it. Nuking and rebuilding the virtual environment is usually the quickest way to fix it. hp -- _ | Peter J. Holzer| Story mu

Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Peter J. Holzer
2. CSS «word-break: break-all» seems like a really weird choice for English language text. If you really want to break words across lines, use «hyphens: auto». hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: What to write or search on github to get the code for what is written below:

2022-01-09 Thread Peter J. Holzer
ted .xlsx since at least 2014 (when I started using it). For new projects I would recommend openpyxl though, which is much more feature-complete. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charl

Re: A Newspaper for Python Mailing Lists

2022-01-11 Thread Peter J. Holzer
On 2022-01-11 12:38:44 -0800, Paul Bryan wrote: > Subscribed. 🙂️ Same. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://ww

Re: Why operations between dict views return a set and not a frozenset?

2022-01-11 Thread Peter J. Holzer
et({1, 2})) with 1 0 LOAD_CONST 0 (1) 2 LOAD_CONST 1 (2) 4 BUILD_SET2 and you see the difference between using a frozenset as a constant and building a set at runtime. hp -- _ | Pet

Re: Logging user activity

2022-02-07 Thread Peter J. Holzer
go through all the views in your app, see what data they are requesting and altering and craft appropriate log messages for each. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stros

Re: PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

2022-02-11 Thread Peter J. Holzer
ted that ability. 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 signat

Re: PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

2022-02-12 Thread Peter J. Holzer
On 2022-02-11 18:20:19 -0500, Dennis Lee Bieber wrote: > On Fri, 11 Feb 2022 20:37:57 +0100, "Peter J. Holzer" > declaimed the following: > > >Interestingly, Excel did have the ability for multiple users editing the > >same file at some time (maybe early 2

Re: URLError:

2022-02-12 Thread Peter J. Holzer
me to an address (try «nslookup» or «host» or «dig» depending on your OS)? * Can you access the whole URL with a different tool like «wget» or «curl»? hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: venv and executing other python programs

2022-02-15 Thread Peter J. Holzer
interested in discussing whether the > env-variant is good or bad. ;-) It's not that *I* use it, but > several progs in /usr/bin/. Progs in /usr/bin should IMHO never use /usr/bin/env. They should always use #!/usr/bin/python3. You might want to report that as a bug to your distribution.

Re: Best way to check if there is internet?

2022-02-26 Thread Peter J. Holzer
offline mode if none (except loopback) are up. But fundamentally it's about the state of the browser ("... must return false if the user agent will not contact the network ...") not about whether your computer has "internet access" in any meaningful sense. hp --

Re: PYT - How can I subscribe to a topic in the mailing list?

2022-02-26 Thread Peter J. Holzer
of those features that seemed like a good idea to the developers but aren't really used by anyone in practice. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, &qu

Re: PYT - The expressions described in the Python language reference yield only boolean values

2022-02-26 Thread Peter J. Holzer
wer | power | power | || primary | primary| primary| primary| atom| atom | atom | atom | literal | literal| literal| identifier | integer | integer

Re: Getting Syslog working on OSX Monterey

2022-02-28 Thread Peter J. Holzer
s can be configured to forward messages to a remote server, however). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | chall

Re: Timezone for datetime.date objects

2022-03-02 Thread Peter J. Holzer
Depends on the context, but without s specific context (like business days) I would agree. A day *is* a time period with a beginning and an end. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |--

<    3   4   5   6   7   8   9   10   11   12   >