Re: ImportError: No module named Adafruit_SSD1306 Update

2019-12-07 Thread Peter J. Holzer
quot;y") I would recommend to avoid that and stick to either tabs or spaces (personally, I prefer spaces). You might want to use an editor which can display tabs specially (like vim). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: Vim settings for Python (was: tab replace to space 4)

2019-12-08 Thread Peter J. Holzer
On 2019-12-07 11:59:31 -0800, Bill Campbell wrote: > On Sat, Dec 07, 2019, Peter J. Holzer wrote: > >As an aside, to prevent vim from inserting tabs in the first place, set > >expandtab > >sw=4 > >and maybe also > >ts=4 > > Inserting a comment

Re: Pickle caching objects?

2019-12-16 Thread Peter J. Holzer
source code, but ltrace reveals a lot of small mallocs, so it probably doesn't. -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"

Re: The file method read does not "see" CR

2019-12-16 Thread Peter J. Holzer
.x and 3.x, especially in the treatment of byte and character strings. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ |

Re: Transfer a file to httpserver via POST command from curl

2019-12-23 Thread Peter J. Holzer
priate. And sometimes the uploaded file is only part of the data (think of HTML forms with a file input field). Then POST is also the correct choice. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-

Re: PEP-Dilbert

2020-01-26 Thread Peter J. Holzer
; rumor or false-story! Interesting: In German, "Ente" (duck) also means a false story. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ |

Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-02-01 Thread Peter J. Holzer
t (there were a number of papers and talks about this topic over the last few years), so personally I would live with the risk or use a database. Subrisk: Your disk might lie to your computer about having stored the data. In this case there is nothing you can do except

Re: time.localtime add a parameter for timezone

2020-02-25 Thread Peter J. Holzer
e for the specified timezone? If so, an offset is not sufficient: It needs to be a timezone name (something like "Europe/Vienna"). Proper general handling of timezones should probably be in datetime. > There are a very few occasions when you want it, but more often you > should be working

Re: 【Regarding Performance of a Python Script....】

2020-02-29 Thread Peter J. Holzer
fore execing bash, python 3 doesn't do that. I can see no other obvious difference. So that's ~ 1020 extra system calls. If this is indeed the only difference, that's about 500 ns per system call. That sounds plausible. hp -- _ | Peter J. Holzer| Story must

Re: Python question

2020-03-08 Thread Peter J. Holzer
conditions). Whether you trust somebody else to compile the software is a question of trust, not of openness. Do you trust the person who compiled your compiler? hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: using classes

2020-03-13 Thread Peter J. Holzer
ent call last): File "joepareti54", line 19, in fiat = PKW("Fiat Marea",50,0,1) TypeError: __init__() takes 4 positional arguments but 5 were given hp PS: Please add spaces after commas. «PKW("Fiat Marea", 50, 0, 1)» is much easier to read than «PKW

Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread Peter J. Holzer
e', 'last_name']] vs. fname = db[people].employee.object.get(pk=1234)['first_name'] lname = db[people].employee.object.get(pk=1234)['last_name'] Plus the latter probably performs two database lookups, so you would want to write: person

Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread Peter J. Holzer
On 2020-03-19 14:24:35 +, Rhodri James wrote: > On 19/03/2020 13:00, Peter J. Holzer wrote: > > It's more compact, especially, if "d" isn't a one-character variable, > > but an expression: > > > > fname, lname = db[people].employee.obj

Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread Peter J. Holzer
On 2020-03-19 08:05:18 -0700, Dan Stromberg wrote: > On Thu, Mar 19, 2020 at 7:47 AM Peter J. Holzer wrote: > > On 2020-03-19 14:24:35 +, Rhodri James wrote: > > > On 19/03/2020 13:00, Peter J. Holzer wrote: > > > > It's more compact, especially, if

Re: How to incorporate environment from with python.

2020-03-22 Thread Peter J. Holzer
_LIBRARY_PATH"] = ... ... os.execv(sys.argv[0], sys.argv) # real content starts here hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing _

Re: Confusing textwrap parameters, and request for RE help

2020-03-25 Thread Peter J. Holzer
"tetrabromo-phenolsulfonephthalein" in that case but since you mentioned its for a twitter client, most users probably won't mind (and those who do mind will probably insist that the algorithm should be able to split it into tetrabromo-phenolsulfone- phthalein, if that&

Re: Confusing textwrap parameters, and request for RE help

2020-03-25 Thread Peter J. Holzer
; and "My computer now has proportional fonts"). -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" sign

Re: Confusing textwrap parameters, and request for RE help

2020-03-26 Thread Peter J. Holzer
On 2020-03-25 16:09:24 -0400, Richard Damon wrote: > On 3/25/20 3:52 PM, Peter J. Holzer wrote: > > If anything, I think it was fixed-width fonts which contributed to the > > decline of hyphenation: With a fixed-width font you can't get a proper > > justification anyway

Re: how to specify trusted hosts in windows config file

2020-04-05 Thread Peter J. Holzer
tthe will probably see something different there. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!&

Re: python script to give a list of prime no.

2020-04-05 Thread Peter J. Holzer
specially for a beginner, since it forces you to think what happens (The downside is of course that you may make mistakes - but then you can learn from them). -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |--

Re: "min( arg1, arg2, *args )" vs. "print( value, ... )"?

2020-04-09 Thread Peter J. Holzer
ller: is there any > >difference between "args, ..." and "*args" when he reads > >it in the documentation? > > `arg1, arg2, *args` is just a smart way to say you need at least 2 args. min(arg1, arg2, *args) is Python syntax. min(arg1, arg2, args, ...) i

Re: RFC: For Loop Invariants

2020-04-11 Thread Peter J. Holzer
hancement here. You save writing one colon and one newline here. The code itself is exactly the same. If the original was gross (I don't agree), then this is just as gross. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | |

Re: [RELEASE] Python 3.9.0a6 is now available for testing

2020-04-29 Thread Peter J. Holzer
w parser behaves a bit differently in edge cases. The question is whether and'\n' is supposed to be legal. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Crea

Re: why no camelCase in PEP 8?

2020-05-28 Thread Peter J. Holzer
guage is German, so I should be used to gratuitous capitalisation from early childhood - but I still find camelCase ugly. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative

Re: why no camelCase in PEP 8?

2020-05-28 Thread Peter J. Holzer
8, but with the coding standard of your company, but I would consider that excessive nitpickery. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writin

Re: creating a table within python code

2020-05-28 Thread Peter J. Holzer
5g2eme > > c:\Harvard\project1>flask run > * Serving Flask app ""create_db.py"" (lazy loading) [...] > ModuleNotFoundError: No module named '"create_db' ^^^^^^^^

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-28 Thread Peter J. Holzer
prevent many people from applying it (especially on Windows). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!

Re: Ram memory not freed after executing python script on ubuntu system

2020-05-28 Thread Peter J. Holzer
e memory (on Linux or any other sane OS). So either python is still running or something else is using the memory. To find out what is using the memory, run the command top in a terminal. Then press Shift-M to sort processes by memory consumption. The offenders should now be at the top.

Re: why no camelCase in PEP 8?

2020-05-28 Thread Peter J. Holzer
On 2020-05-29 06:27:31 +1000, Chris Angelico wrote: > On Fri, May 29, 2020 at 6:20 AM Peter J. Holzer wrote: > > On 2020-05-19 05:59:30 +1000, Chris Angelico wrote: > > > PEP 8 is a style guide for the Python standard library. It is the > > > rules you must comply w

Re: Format Logfile Name with logging.ini

2020-05-29 Thread Peter J. Holzer
r when=H would start a new log every hour (and rename the old log to contain a timestamp). You may need to write a handler which implements the behaviour you want. Or maybe there is one on PyPi. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: why no camelCase in PEP 8?

2020-05-29 Thread Peter J. Holzer
On 2020-05-29 06:27:31 +1000, Chris Angelico wrote: > On Fri, May 29, 2020 at 6:20 AM Peter J. Holzer wrote: > > On 2020-05-19 05:59:30 +1000, Chris Angelico wrote: > > > PEP 8 is a style guide for the Python standard library. It is the > > > rules you must comply w

Re: why no camelCase in PEP 8?

2020-05-29 Thread Peter J. Holzer
On 2020-05-28 18:14:53 -0400, Terry Reedy wrote: > On 5/28/2020 4:18 PM, Peter J. Holzer wrote: > > On 2020-05-19 05:59:30 +1000, Chris Angelico wrote: > > > Nobody ever requires you to comply with it for any other code. > > > > That's obviously not true: [...

Re: Ram memory not freed after executing python script on ubuntu system (rmlibre)

2020-05-29 Thread Peter J. Holzer
race to watch the mmap/munmap system calls) A program with more random allocation patterns may suffer severe internal fragmentation and end up with many mostly empty arenas. > You can try jemalloc instead of glibc. I think that would only make a difference if you have lots of objects betwe

Re: Trouble with making modules 'global'

2020-06-07 Thread Peter J. Holzer
> class 'Editor' as its main class. And nobody swoops in to point out that he isn't required to follow PEP 8? I'm disappointed. SCNR. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.a

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-06-07 Thread Peter J. Holzer
On 2020-05-28 20:51:59 -0400, Terry Reedy wrote: > On 5/28/2020 5:20 PM, Peter J. Holzer wrote: [The final "security-only" releases are source-only] > > This seems a rather odd policy to me. > > Not if one considers the intended users. > Do you prefer we not make t

Re: close() the file when opening "with"?

2020-06-14 Thread Peter J. Holzer
with "with" (and then the file will be automatically closed), but sometimes you want to do soemthing else. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creativ

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Peter J. Holzer
t[str, List] = None): if params is None: params = {} result = [] for k, v in params.items(): result.append([val + 10 for val in v]) return result hp [1] There is a very good talk by Raymond Hettinger on how variables and obj

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Peter J. Holzer
On 2020-06-14 19:44:32 +0200, Peter J. Holzer wrote: > [1] There is a very good talk by Raymond Hettinger on how variables and > objects in Python work. Unfortunately I can't find it at the moment. Sorry, that talk was by Ned Batchelder (that's why I couldn&#x

Re: Pycharm Won't Do Long Underscore

2020-06-24 Thread Peter J. Holzer
ts" or "license" for more information. >>> _ = 12 File "", line 1 _ = 12 ^ SyntaxError: invalid character '_' (U+FF3F) >>> a_ = 12 >>> a_ 12 >>> a__ Traceback (most recent call last):

Re: Pycharm Won't Do Long Underscore

2020-06-30 Thread Peter J. Holzer
On 2020-06-25 11:56:47 -0600, Michael Torrie wrote: > On 6/24/20 7:38 PM, Grant Edwards wrote: > > On 2020-06-24, Peter J. Holzer wrote: > >> There is U+FF3F Fullwidth Low Line. > >> > >>> If there were, Python would not know what to do with it > >>

Re: FW: Pycharm Won't Do Long Underscore

2020-06-30 Thread Peter J. Holzer
interesting concept. 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 -- http

Re: Questioning the effects of multiple assignment

2020-07-08 Thread Peter J. Holzer
bin/python3 def f(*a): a[0]["new"] = 2 v = { "old": 1} f(v) print(v) prints «{'old': 1, 'new': 2}». hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Ch

Re: Friday Finking: Limiting parameters

2020-07-11 Thread Peter J. Holzer
instead of passing the same 7 parameters to every function, I create a "Context" or "Job" class with those 7 fields which I then pass to each function. So it not just looks tidier, it also reduces the risk of inconsistencies. hp -- _ | Peter J. Holzer| Story mu

Re: Friday Finking: Limiting parameters

2020-07-21 Thread Peter J. Holzer
On 2020-07-12 08:56:47 +1200, DL Neil via Python-list wrote: > On 12/07/20 8:13 AM, Peter J. Holzer wrote: > > On 2020-07-11 09:54:33 +1200, dn via Python-list wrote: > > > Questions: > > > > > > Is the idea of limiting the number of parameters passed acr

Re: Friday Finking: Limiting parameters

2020-07-21 Thread Peter J. Holzer
ld be treated as a model-view relationship: You have two models (person and address) and a view (which combines some aspects of both while ignoring others). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...

Re: Whitespace not/required

2020-08-25 Thread Peter J. Holzer
ine = The mill's closed " > > Hey, why does this second example dispense with the braces-internal spaces? It doesn't. The space is still there - before the colon. > Should the closing brace be considered part of a conversion or > format-specification? No. > T

Re: About float/double type number in range.

2020-08-26 Thread Peter J. Holzer
this is not quote the same as what Joel proposed. Repeated addition is not the same as multiplication with floating point numbers. A generator based on Joel's idea would look like this: def fp_range(start, end, step): v = start n = int(math.ceil((end - start) / step)) for i

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Peter J. Holzer
n common since the mid-1990s), but even if the code made that assumption, one would expect that other code from the same library honors it. The second shouldn't be possible: If a message is mis-declared (that happens) one would expect that the error happens during parsing, not when trying

Re: Another 2 to 3 mail encoding problem

2020-08-31 Thread Peter J. Holzer
On 2020-08-27 09:34:47 +0100, Chris Green wrote: > Peter J. Holzer wrote: > > The problem is that the message contains a '\ufeff' character (byte > > order mark) where email/generator.py expects only ASCII characters. > > > > I see two possible reasons for t

Re: Truncation error

2020-10-10 Thread Peter J. Holzer
nits of their processors. I'm slightly less confident about the authors of the Decimal module. And I'm much less confident that the average Python programmer can implement a matrix multiplication with Decimal which is as numerically stable as what Matlab or Pandas provide using IEEE-754 ari

Re: Python's carbon guilt

2020-10-10 Thread Peter J. Holzer
urely such programs would use numpy or other specialized libraries which are already written in C or Fortran and may even use a GPU if present? There is of course still some overhead, but it's much smaller. hp -- _ | Peter J. Holzer| Story must make more sense than reality.

Re: Truncation error

2020-10-12 Thread Peter J. Holzer
On 2020-10-10 13:31:34 -0400, Dennis Lee Bieber wrote: > On Sat, 10 Oct 2020 17:58:34 +0200, "Peter J. Holzer" > declaimed the following: > > >On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: >

Re: Truncation error

2020-10-12 Thread Peter J. Holzer
On 2020-10-11 01:40:42 -, Grant Edwards wrote: > On 2020-10-10, Peter J. Holzer wrote: > > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: > > > > Decimal doesn't avoid floating point problems,

Re: MERGE SQL in cx_Oracle executemany

2020-10-18 Thread Peter J. Holzer
implicit).) > If you already have NULL values in the PROJECT column than use "add > constraint" > with NOVALIDATE option. Other than that, allowing NULL values in key columns > is > a sign of bad design. Namely, Oracle cannot index NULL columns, so PROJECT IS > NULL

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

2020-10-18 Thread Peter J. Holzer
is shown as it should be, except backslash. 0x1C isn't a backslash, it's a control character (FS - File Separator). 0x5C is a backslash, but of course that doesn't work here either, because the second argument to re.sub isn't a simple string: It contains escape sequenc

Re: Question on ABC classes

2020-10-25 Thread Peter J. Holzer
pe annotations, but they are ignored both by the compiler and at run-time. They are only for the benefit of linting tools like mypy and editor features like intellisense. > and the whole lot, indeed why even subclass ABC? Good question. In six years of programming Python, I've never used

Re: Best way to determine user's screensize?

2020-10-30 Thread Peter J. Holzer
ake it large enough for a list of mailboxes, a list of mails and one mail in some default pane configuration, but again not larger than the screen. * A media player would make it large enough for the playlist and some chrome. etc. -- _ | Peter J. Holzer| Story must make more sen

Re: Best way to determine user's screensize?

2020-10-30 Thread Peter J. Holzer
ainly wrong. So why should an application not use the screen size as one factor? hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ |

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-30 20:08:35 -0700, jf...@ms4.hinet.net wrote: > What's wrong the OP's question? Why can't just answer it? Igor already answered it: There is no best way in Python, because it depends on the framework (and there are many frameworks). hp -- _ | Peter J.

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-30 19:18:22 -0500, Igor Korot wrote: > On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > > I add my voice to those who detest applications that think they know > > > best and decide that

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 10:57 AM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list > > > wrote: > > > > I ha

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
in the approximate > center of the screen? Yes, I do. That puts all the windows on top of each other and I have to move them to a better position. I have configured my window manager to place new windows so that the overlap with existing windows is minimised. hp -- _ | Peter J. Ho

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 07:51:38 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2020-10-31 at 13:02:03 +0100, > "Peter J. Holzer" wrote: > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > There is no valid way for an application to read my mind and size &g

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 01:20:39 -, Grant Edwards wrote: > On 2020-10-30, Peter J. Holzer wrote: > > > So, assuming the user is invoking the application for the first time, > > how should an application determine how much of the screen it should > > use? > > You arrang

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 11:58:41 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2020-10-31 at 14:37:52 +0100, > "Peter J. Holzer" wrote: > > > On 2020-10-31 07:51:38 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > > The intial/default window should be bi

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 11:54:59 -0500, Igor Korot wrote: > On Sat, Oct 31, 2020, 8:40 AM Peter J. Holzer wrote: > > > On 2020-10-31 07:51:38 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > On 2020-10-31 at 13:02:03 +0100, > > > "Peter J. Holzer" wrote: >

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 11:52:31 -0700, Ethan Furman wrote: > On 10/31/20 11:24 AM, Peter J. Holzer wrote: > > On 2020-10-31 11:58:41 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > I don't think we're disagreeing too much here, either. IMO, the user > > > sh

Re: Best way to determine user's screensize?

2020-10-31 Thread Peter J. Holzer
On 2020-10-31 17:12:36 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2020-10-31 at 19:24:34 +0100, > "Peter J. Holzer" wrote: > > On 2020-10-31 11:58:41 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > I never claimed it was easy. Yes, the author of a

Re: Is there a conflict of libraries here?

2020-11-07 Thread Peter J. Holzer
m datetime import datetime Now the name datetime now refers to the class datetime: >>> datetime >>> id(datetime) 9612160 You can import one or both of them with different names: >>> import datetime as dt_module >>> dt_module >>> id(dt_module) 140407076788160

Re: Getting rid of virtual environments with a better dependency system

2020-11-12 Thread Peter J. Holzer
and then replaces the shebang in /usr/local/bin/mytool with "#!/usr/local/lib/mytool/venv/python", the user can just invoke "mytool" without caring about the virtual environment. If you do that for every Python script, size may be a problem, though: I just checked a few of my v

Re: Python Client Rest API Invocation - POST with empty body - Invalid character found in method name [{}POST]. HTTP method names must be tokens

2020-11-21 Thread Peter J. Holzer
st sent is "POST /env HTTP/1.1", not "{}POST /env HTTP/1.1", In wireshark "Follow TCP connection", the "{}" at the end of the request is squished together with the "HTTP/1.1 302 Found" at the beginning of the response, but they are in different col

Re: Regarding Regex timeout behavior to minimize CPU consumption

2020-12-05 Thread Peter J. Holzer
ce point of view. If that can be rewritten with less potential for backtracking, it might help. Generally, it should be possible to implement a timeout for any operation by either scheduling an alarm with signal.alarm or by executing the operation in a separate thread and killing the thread if it tak

Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Peter J. Holzer
(D.get('a', get_default())) > > Python has short-circuiting logical operations, so one way to get the > behavior you're looking for is: > > D.get('a') or get_default() That will call get_default for any falsey value (0, "", an empty list .

Re: Function returns old value

2020-12-17 Thread Peter J. Holzer
n distinguish between input that was pasted and input that was typed. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread Peter J. Holzer
eError: name '_' is not defined But this works: >>> print(_ if (_ := d.get('a', None)) is not None else get_default()) 1 (I would prefer ChrisA's solution, though.) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) |

Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations

2007-06-16 Thread Peter J. Holzer
release of perl5 (with development on perl 5.6 well on the way, yes). Maybe my memory is faulty but I don't have the impression that there was much more change in the six years between 5.0 and and 5.005_03 than in the seven years between 5.005 and 5.8.8 (despite everybody complaining that perl (

Re: Portable general timestamp format, not 2038-limited

2007-07-01 Thread Peter J. Holzer
sion FP numbers, so that's as portable as it gets and conversion from/to system time should be trivial. If you need to represent milliseconds exactly, you can just multiply the timestamp with 1000 (and get java timestamps). hp -- _ | Peter J. Holzer| I know I'd be res

Re: Portable general timestamp format, not 2038-limited

2007-07-02 Thread Peter J. Holzer
On 2007-07-03 05:12, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Peter J. Holzer wrote: >> On 2007-06-22 20:33, James Harris <[EMAIL PROTECTED]> wrote: >>> I have a requirement to store timestamps in a database. Simple enough >>> you might think but f

Re: Portable general timestamp format, not 2038-limited

2007-07-03 Thread Peter J. Holzer
0.5 seconds. > I always leave my PC's clock set to GMT, Your PC is directly linked to an observatory? Impressive :-). If you synchronize your PC to any external time source, it's almost certainly UTC, not GMT or UT1. If you don't synchronize it it's so far off that it doesn&#

Re: Portable general timestamp format, not 2038-limited

2007-07-03 Thread Peter J. Holzer
On 2007-07-03 23:15, CBFalconer <[EMAIL PROTECTED]> wrote: > "Peter J. Holzer" wrote: >> Richard Heathfield <[EMAIL PROTECTED]> wrote: >> > ... snip ... >> >>> In that case, the obvious choice is Greenwich Mean Time. :-) >> >&

Re: Portable general timestamp format, not 2038-limited

2007-07-03 Thread Peter J. Holzer
On 2007-07-04 00:14, Dr.Ruud <[EMAIL PROTECTED]> wrote: > Peter J. Holzer schreef: >> Since a day with a leap second has 86401 seconds (or 86399, but that >> hasn't happened yet) > > Many systems allow a seconds value of 0..61, so minutes (actually > months)

Re: Portable general timestamp format, not 2038-limited

2007-07-04 Thread Peter J. Holzer
On 2007-07-04 18:46, James Harris <[EMAIL PROTECTED]> wrote: > On 1 Jul, 15:11, "Peter J. Holzer" <[EMAIL PROTECTED]> wrote: > ... >> Stick to unix timestamps but store them as a double precision floating >> point number. The 53 bit mantissa gives you c

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

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

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: 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: 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: 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: `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-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: 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: 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]"

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

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

<    1   2   3   4   5   6   7   >