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()
--
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
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
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
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
--
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
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
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
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
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
Metaclasses, abc, asyncio, ast, some of the dunder methods, eg __del__,
weakref, perhaps gc--
https://mail.python.org/mailman/listinfo/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
-
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
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
-
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
-
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],
-
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.
-
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
-
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
-
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
20 matches
Mail list logo