Re: Best use of "open" context manager

2024-07-12 Thread Albert-Jan Roskam via Python-list
Or like below, although pylint complains about this: "consider using with". Less indentation this way. f = None try: f = open(FILENAME) records = f.readlines() except Exception: sys.exit(1) finally: if f is not None: f.close() --

Re: Suggested python feature: allowing except in context maneger

2024-06-16 Thread Albert-Jan Roskam via Python-list
The example exception is not what bothers me. The syntax change is nowhere near as useful as `with` and context managers. They provide an excellent idiom for resource usage and release. Your suggestion complicates the `with` statement and brings only a tiny indentation

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Albert-Jan Roskam via Python-list
On Mar 10, 2024 12:59, Thomas Passin via Python-list wrote: On 3/10/2024 6:17 AM, Barry wrote: > > >> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list wrote: >> >> We just learned a few posts back that it might be specific to Linux; I ran it

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Albert-Jan Roskam via Python-list
On Mar 8, 2024 19:35, Thomas Passin via Python-list wrote: On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote: > Hi, > I was replacing some os.path stuff with Pathlib and I discovered this: > Path(256 * "x").i

pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Albert-Jan Roskam via Python-list
Hi, I was replacing some os.path stuff with Pathlib and I discovered this: Path(256 * "x").is_file() # OSError os.path.isfile(256 * "x") # bool Is this intended? Does pathlib try to resemble os.path as closely as possible? Best wishes, Albert-Jan --

Re: Postgresql equivalent of Python's timeit?

2023-09-17 Thread Albert-Jan Roskam via Python-list
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 Postgresql than to Python, I hope this is ok. >    I want to measure Postgres queries N

Postgresql equivalent of Python's timeit?

2023-09-15 Thread Albert-Jan Roskam via Python-list
Hi, This is more related to Postgresql than to Python, I hope this is ok. I want to measure Postgres queries N times, much like Python timeit (https://docs.python.org/3/library/timeit.html). I know about EXPLAIN ANALYZE and psql \timing, but there's quite a bit of variation in the

windows and file names 256 bytes

2015-06-24 Thread Albert-Jan Roskam via Python-list
Hi, Consider the following calls, where very_long_path is more than 256 bytes: [1] os.mkdir(very_long_path) [2] os.getsize(very_long_path) [3] shutil.rmtree(very_long_path) I am using Python 2.7 and [1] and [2] fail under Windows XP [3] fails under Win7 (not sure about XP). This is even when I

Re: How to check in script if Python or Jython is used

2015-06-21 Thread Albert-Jan Roskam via Python-list
Sun, Jun 21, 2015 12:24 PM CEST Cecil Westerhof wrote: On Sunday 21 Jun 2015 11:22 CEST, Laura Creighton wrote: In a message of Sun, 21 Jun 2015 10:12:06 +0200, Cecil Westerhof writes: I installed Jython and will start playing with it. There probably will be

Re: Find in ipython3

2015-06-06 Thread Albert-Jan Roskam via Python-list
quot;To run any command at the system shell, simply prefix it with !quot; See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html-- https://mail.python.org/mailman/listinfo/python-list

Re: What is considered an advanced topic in Python?

2015-05-30 Thread Albert-Jan Roskam via Python-list
Metaclasses, abc, asyncio, ast, some of the dunder methods, eg __del__, weakref, perhaps gc-- https://mail.python.org/mailman/listinfo/python-list

Re: programmatically change windows regional settings?

2015-05-24 Thread Albert-Jan Roskam via Python-list
- On Sun, May 24, 2015 4:45 PM CEST Laura Creighton wrote: In a message of Sun, 24 May 2015 14:07:37 +0100, Mark Lawrence writes: On 24/05/2015 13:50, Albert-Jan Roskam via Python-list wrote: Hi, In Windows I can change the regional settings manually

Re: programmatically change windows regional settings?

2015-05-24 Thread Albert-Jan Roskam via Python-list
- On Sun, May 24, 2015 3:07 PM CEST Mark Lawrence wrote: On 24/05/2015 13:50, Albert-Jan Roskam via Python-list wrote: Hi, In Windows I can change the regional settings manually in the control panel. But how do I do this programmatically? I tried setting LANG

programmatically change windows regional settings?

2015-05-24 Thread Albert-Jan Roskam via Python-list
Hi, In Windows I can change the regional settings manually in the control panel. But how do I do this programmatically? I tried setting LANG but this does not work in Windows. Kernel32's SetLocaleInfo sounds promising, but This setting only affects the user override portion of the locale

Re: need help with an accessibility prototype

2015-05-22 Thread Albert-Jan Roskam via Python-list
- On Fri, May 22, 2015 9:50 PM CEST Laura Creighton wrote: In a message of Fri, 22 May 2015 12:29:20 -0400, Eric S. Johansson writes: 2 needs. first is determining if NaturallySpeaking injects keycodes or ascii char into the windows input queue. second is building

Re: Looking for direction

2015-05-14 Thread Albert-Jan Roskam via Python-list
- On Thu, May 14, 2015 3:35 PM CEST Dennis Lee Bieber wrote: On Wed, 13 May 2015 16:24:30 -0700, 20/20 Lab l...@pacbell.net declaimed the following: Now is were I have my problem: myList = [ [123, XXX, Item, Qty, Noise], [72976, YYY, Item, Qty, Noise],

Re: Updating a package on PyPi, testing and etiquette

2015-05-12 Thread Albert-Jan Roskam via Python-list
- On Tue, May 12, 2015 8:01 PM CEST Rob Gaddi wrote: So I've got a package I put up on PyPi a while back (ctypes-bitfield, if it matters). For version 0.2.6 I had access to some older versions of Python and was able to run my test suite on Python 2.6 and 3.0.

Re: Why does unicode-escape decode escape symbols that are already escaped?

2015-05-10 Thread Albert-Jan Roskam via Python-list
- On Sun, May 10, 2015 5:53 PM CEST Somelauw . wrote: In Python 3, decoding € with unicode-escape returns 'â\x82¬' which in my opinion doesn't make sense. The € already is decoded; if it were encoded it would look like this: '\u20ac'. So why is it doing this? In

Re: Encrypt python files

2015-05-06 Thread Albert-Jan Roskam via Python-list
- On Wed, May 6, 2015 11:04 AM CEST Steven D'Aprano wrote: On Wednesday 06 May 2015 17:23, Palpandi wrote: On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote: Hi, What are the ways to encrypt python files? No, I just want to hide the scripts

Re: DRM is self-defeating (was: Encrypt python files)

2015-05-06 Thread Albert-Jan Roskam via Python-list
- On Wed, May 6, 2015 9:41 AM CEST Ben Finney wrote: Palpandi palpandi...@gmail.com writes: On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote: What are the ways to encrypt python files? No, I just want to hide the scripts from others. Which