Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Peter J. Holzer
On 2022-10-25 06:56:58 +1100, Chris Angelico wrote: > On Tue, 25 Oct 2022 at 04:22, Peter J. Holzer wrote: > > There may be several reasons: > > > > * Historically, some browsers differed in which end tags were actually > > optional. Since (AFAIK) no mainstream brow

Re: A typing question

2022-10-30 Thread Peter J. Holzer
#v+ #!/usr/bin/python3 class Foos: Foos = [1, 2, 3] f = Foos() print(f.Foos) #v- This works and I see no reason why it shouldn't work. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: Fwd: A typing question

2022-10-30 Thread Peter J. Holzer
is inferred that's not the same as «Optional[it's type]», or is it? If it's referring to the global symbol «Foos» (i.e. the class defined later) that hasn't been defined yet, so it shouldn't work (or alternatively, if forward references are allowed it should alw

Re: Fwd: A typing question

2022-10-30 Thread Peter J. Holzer
On 2022-10-30 09:23:27 -0400, Thomas Passin wrote: > On 10/30/2022 6:26 AM, Peter J. Holzer wrote: > > On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: > > > The funny thing is that if I replace foos by Foos it works because it gets > > > known by

Re: Fwd: A typing question

2022-10-31 Thread Peter J. Holzer
On 2022-10-30 11:26:56 +0100, Peter J. Holzer wrote: > On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: > > The funny thing is that if I replace foos by Foos it works because it gets > > known by the initial initialization :-) ! > > > >

Re: Fwd: A typing question

2022-10-31 Thread Peter J. Holzer
On 2022-10-30 20:43:23 +0100, Peter Otten wrote: > On 30/10/2022 14:37, Peter J. Holzer wrote: > > On 2022-10-30 09:23:27 -0400, Thomas Passin wrote: > > > On 10/30/2022 6:26 AM, Peter J. Holzer wrote: > > > > On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: > &

Re: for -- else: what was the motivation?

2022-11-05 Thread Peter J. Holzer
On 2022-10-22 15:04:58 +0200, Peter J. Holzer wrote: > On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > > http://literateprogramming.com/ &g

Re: How to manage python shebang on mixed systems?

2022-11-09 Thread Peter J. Holzer
rd unix utilities" may be missing, too. For example on an embedded system there might only be the bare minimum to run the application. I even had a redhat system once which didn't have grep installed.) (Personally I avoid using env: I don't want my scripts to depe

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
e other people posting in this thread I don't think float is the wrong type for the job. It might be, but you haven't given enough details to tell whether the inevitable rounding error matters or not. In my experience in almost all cases where people think it matters it really doesn&

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
On 2022-12-17 21:45:06 +0100, Paul St George wrote: > It was the rounding rounding error that I needed to avoid (as Peter J. > Holzer suggested). The use of decimal solved it and just in time. I > was about to truncate the number, get each of the characters from the > string mantissa,

Re: Single line if statement with a continue

2022-12-19 Thread Peter J. Holzer
hand for “one or more lines of code which do something with `thing`”. So there is nothing after it because it is included in it. That said, the "fail and bail" technique is often more readable than putting the main incode inside of an if - especially if that code is long and/or i

Re: String to Float, without introducing errors

2022-12-19 Thread Peter J. Holzer
d by the decimal to float conversion was unacceptable, showing IMHO a fundamental misunderstanding of the numbers they are working with. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles

Re: String to Float, without introducing errors

2022-12-19 Thread Peter J. Holzer
On 2022-12-19 15:14:14 +, MRAB wrote: > On 2022-12-19 14:10, Peter J. Holzer wrote: > > He also interpreted the notation "6.67430(15)E-11" wrong. The > > digits in parentheses represent the uncertainty in the same number of > > last digits. So "6.674

Re: Installation hell

2022-12-19 Thread Peter J. Holzer
st > -V:3.10 *Python 3.10 (64-bit) > -V:3.9 Python 3.9 (64-bit) > -V:3.7 Python 3.7 (64-bit) > -V:2.7 But that works only for Python. Shell expansion works for any command. If you use Linux, learn how to use your shell (and maybe learn different shells -

Re: Installation hell

2022-12-19 Thread Peter J. Holzer
On 2022-12-20 04:15:07 +1100, Chris Angelico wrote: > On Tue, 20 Dec 2022 at 03:56, Peter J. Holzer wrote: > > It is however, quite noticable that almost everyone who asks a question > > about their Python installation on this list is using Windows. I don't > > think

Re: pygame.midi input/output not working

2022-12-22 Thread Peter J. Holzer
bility we haven't solved yet". Does anybody know what the issue is? hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at

Re: Possible re bug when using ".*"

2023-01-01 Thread Peter J. Holzer
#x27;s not a bug, it's a change in behaviour to bring it more into line with > other regex implementations in other languages. Interesting. Perl does indeed behave that way, too. Never noticed that in 28 years of using it. hp -- _ | Peter J. Holzer| Story must make

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Peter J. Holzer
xactly which one you're writing to, just flush. I don't think fsync() will have an effect on an FD connected to a terminal (or a pipe or a socket). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Peter J. Holzer
writing to stderr, and even that can log to any stream - just pass it as an argument. If none of existing handlers does what you want you can always write your own. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | |

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Peter J. Holzer
sort of. That is all log messages go to stderr, but not all log levels are logged. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ |

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Peter J. Holzer
s can > be answered: "They didn't". Which is almost exactly what I wrote in <20230104162154.uzljittbs6xwt...@hjp.at> ;-) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Cha

Re: Recommendations in terms of threading, multi-threading and/or asynchronous processes/programming? - Sent Mail - Mozilla Thunderbird

2023-01-06 Thread Peter J. Holzer
nd what the constraints and requirements are and is completely impossible to answer in the abstract. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-06 Thread Peter J. Holzer
nd how it > works. It probably helps to have worked with log4j before that. The structure is very similar, although I find Python logging easier to use (but then I never did much Java programming so that's probably just a matter of familiarity. hp PS: The TimeoutSwitchingFileHandler mentio

Re: Recommendations in terms of threading, multi-threading and/or asynchronous processes/programming? - Sent Mail - Mozilla Thunderbird

2023-01-08 Thread Peter J. Holzer
lest to look into. I agree with that assessment. 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: To clarify how Python handles two equal objects

2023-01-11 Thread Peter J. Holzer
". Or we can even use the P-word. And since we know that variables in Python can only contain references and never values, we can abbreviate "a reference to an object" as "an object" in most contexts. hp -- _ | Peter J. Holzer| Story must make more sense than re

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Peter J. Holzer
ointer than to move an entire array if it’s > possible, but special care must be taken.  I still don't understand what you mean by that. hp [1] Not quite true. The run-time system must keep track of the variables, so there likely is a pointer to q somewhere. But it

Re: The Zen of D.E.K.

2023-01-13 Thread Peter J. Holzer
ncy (as opposed to developer-time efficiency), Python might not be your language of choice at least for the part where efficiency is crucial. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles

Re: Fast lookup of bulky "table"

2023-01-15 Thread Peter J. Holzer
t to actually measure performance, and a good profiler helps very much in identifying hot spots. Unfortunately until recently Python was a bit deficient in this area, but [Scalene](https://pypi.org/project/scalene/) looks promising. hp -- _ | Peter J. Holzer| Story must make mor

Re: Fast lookup of bulky "table"

2023-01-15 Thread Peter J. Holzer
On 2023-01-15 10:38:22 -0500, Thomas Passin wrote: > On 1/15/2023 6:14 AM, Peter J. Holzer wrote: > > On 2023-01-14 23:26:27 -0500, Dino wrote: > > > Anyway, my Flask service initializes by loading a big "table" of 100k rows > > > and 40 columns or

Re: Fast lookup of bulky "table"

2023-01-16 Thread Peter J. Holzer
icense. I don't see where a view would help here - but maybe you are thinking of a more complex database than you describe. > Some programmers don't realise that SQL can also be used for calculations, > eg the eponymous COUNT(), which saves (CPU-time and coding-effort) over > post

Re: Fast lookup of bulky "table"

2023-01-16 Thread Peter J. Holzer
t becomes more and more pronounced the farther the database is from the client. For complicated queries the parsing and planning overhead can also become significant. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h.

Re: IDLE "Codepage" Switching?

2023-01-18 Thread Peter J. Holzer
t; the console isn't mentioned, but there's no reason it should have glyphs for > any random unicode character. Also note that the characters between 128 (U+0080) and 159 (U+009F) inclusive aren't printable characters. They are control characters. hp -- _ | Pete

Re: IDLE "Codepage" Switching?

2023-01-18 Thread Peter J. Holzer
thon 2.7. Python2 has been deprecated for years has has reached its official end of life 3 years ago. There really shouldn't be any reason to use Python 2.7 any more except reverse-engineering old applications in order to port them to Python 3. In particular, the type "str" is v

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-22 Thread Peter J. Holzer
ast too incomplete to be useful. It handles only single letters as operands and treats everything else (except parentheses) as an operator, handling only +, -, *, / and ^ correctly (actually, ^ is typically right associative, so that's arguably wrong, too). hp -- _ | Peter J. Holzer

Re: HTTP server benchmarking/load testing in Python

2023-01-25 Thread Peter J. Holzer
nto a place with better airflow. 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 Descr

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
otice the error message; it ^^^ > > says that the key 'y' does not exist. [...] > > In [1]: x = { "y": "z" } > > In [2]: s = "-> {x[y]}" > > In [3]: print(s.for

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
you need to implement enough of a Python parser/interpreter to cover the cases you are interested in. The latter might be an interesting exercise, but I would suggest looking at existing template engines like Jinja2 for production purposes. hp -- _ | Peter J. Holzer

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
: > > >>> s = "{\"x\" * 4}" > >>> eval("f'" + s + "'") > '' That's exactly the result I expected. What did you expect? hp -- _ | Peter J. Holzer| Story must make more sense than

Usenet vs. Mailing-list (was: evaluation question)

2023-01-28 Thread Peter J. Holzer
ailing list, but nothing posted to the group via > NNTP get send on the mailing list. This is wrong. I did get Muttley's any your postings via the mailing-list. (I also get Stefan Ram's postings despite his "no distribution outside of Usenet" header). hp -- _ |

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-29 Thread Peter J. Holzer
ch later) edition, wennn "--" was already really common. But POSIX did lead the way in some cases and it might have been the case here, too. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-29 Thread Peter J. Holzer
ork as designed. But since you are probably the only person who will have to read your code in the future that's not our problem. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Char

To gateway or not to gateway a specific person (was: Evaluation of variable as f-string)

2023-01-29 Thread Peter J. Holzer
ng lists that you don't want your messages to > be seen on them? He's Stefan Ram :-). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ |

Re: Usenet vs. Mailing-list

2023-01-29 Thread Peter J. Holzer
e). I have to admit that I'm sometimes guilty of this behaviour, too. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ |

Re: Evaluation of variable as f-string

2023-01-29 Thread Peter J. Holzer
n > *arbitrary* dictionary x and a string s As I wrote before: An f-string isn't a string. It's a grammatical construct. So you want to execute Python code which is what eval and exec do. hp -- _ | Peter J. Holzer| Story must make more sense than r

Re: evaluation question

2023-02-01 Thread Peter J. Holzer
On 2023-02-01 09:00:39 -, mutt...@dastardlyhq.com wrote: > Its not evolution, its revolution. Evolution retains old functionality. Tell a penguin that it can fly :-) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | |

Re: How to read file content and send email on Debian Bullseye

2023-02-05 Thread Peter J. Holzer
-mail can be anything or not be configured at all - so it might not be the best choice. > Otherwise you haven't said what part of the process you need help with. Yeah, that was the reason I didn't reply to the original mail. I simply couldn't figure out where the problem was.

Re: Question about logging.config.dictConfig

2023-02-07 Thread Peter J. Holzer
t; 'fmt': '%(asctime)s %(levelname)-7s %(name)s %(funcName)s > %(message)s' 'format' > } > }, [...] > } > logging.config.dictConfig(config) > > When I run uselog.py it prints

Re: Comparing caching strategies

2023-02-17 Thread Peter J. Holzer
having said that, there may well be non-integer data that can be > mapped into and out of integers. As an example, airports or radio > stations have names like LAX or WPIX. If you limit yourself to ASCII > letters then every one of them can be stored as a 32-bit integer, > perhaps with some

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
al in binary, Be careful: "Rational" and "irrational" have a standard meaning in mathematics and it's independent of base. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Char

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
point". hp [1] It's really unfortunate that the point which separates the integer and the fractional part of a number is called a "decimal point" in English. Makes it hard to talk about non-integer numbers in other bases. -- _ | Peter

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
any current manufacturers. Doesn't IBM any more? Their POWER processors used to implement decimal FP (starting with POWER8, if I remember correctly). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: Comparing caching strategies

2023-02-18 Thread Peter J. Holzer
27;t care what they need it for. The thought was > about whether something that does not start as an integer can be uniquely > mapped into and out of integers of size 32 bits. That's what confused me. You seemed to concentrate on the "map things to integers" part which has been

Re: Precision Tail-off?

2023-02-18 Thread Peter J. Holzer
e to think of it, it doesn't even have a a y**x operation - just some simpler operations which can be used to implement it. GCC doesn't inline pow(y, x) on x86/64 - it just calls the library function. hp -- _ | Peter J. Holzer| Story must make more sense than reality

Re: Comparing caching strategies

2023-02-18 Thread Peter J. Holzer
ess > patterns. Yes, Roaring Bitmaps are somewhat similar. Judy arrays are more versatile (they support more data types) and in many ways more sophisticated, despite being 10+ years older. OTOH Roaring Bitmaps are a lot simpler which may have contributed to their popularity. hp --

Re: File write, weird behaviour

2023-02-19 Thread Peter J. Holzer
tent if you try this. You can only add at the end of the file. If you want to insert something, you have to rewrite everything from that position. (So typically, for small files you wouldn't update a file in place, you would just replace it completely. For large data sets which need to be updated you w

Re: File write, weird behaviour

2023-02-19 Thread Peter J. Holzer
close() might result in the arguments of f.write() not being completely > written to the disk, even if the program exits successfully." He does call file.close(): > > > file.close() so that doesn't seem relevant. hp -- _ | Peter J. Holzer| Story must

Re: semi colonic

2023-02-24 Thread Peter J. Holzer
On 2023-02-23 15:56:54 -0500, avi.e.gr...@gmail.com wrote: > I am not sure it is fair to blame JSON for a design choice. We can't blame JSON (it has no agency), but as you say, it it was a choice. And we can absolutely blame Doug for making that choice! hp -- _ | Peter J

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

2023-02-24 Thread Peter J. Holzer
in f | return (a + b) * (c + d) | ^ | TypeError: can only concatenate str (not "int") to str would tell me that (c + d) caused the problem and therefore that c must be a str which it obviously shouldn't be. hp -- _ | Peter J. Holzer| St

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

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
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
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-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: 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: 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: 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: 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

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
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

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: 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: 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: 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: 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: 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: 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-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
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: 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: 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: 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: 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: 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

<    1   2   3   4   5   6   7   >