I don't use docstrings much; instead I put a line or two of comments
after the `def ` line.
But my practice in such situations is as per the OP's 3rd suggestion, e.g.
# Returns True if .
I'm curious as to why so many people prefer "Return" to "Returns".
Checking out help() on a few funct
Well, de gustibus non est disputandum. For me, the switch from the
imperative mode to the descriptive mode produces a mild cognitive
dissonance.
Best wishes
Rob Cliffe
On 25/04/2022 23:34, Cameron Simpson wrote:
On 23Apr2022 03:26, Avi Gross wrote:
We know some people using "professional" l
On 28/04/2022 14:27, Stephen Tucker wrote:
To Cameron Simpson,
Thanks for your in-depth and helpful reply. I have noted it and will be
giving it close attention when I can.
The main reason why I am still using Python 2.x is that my colleagues are
still using a GIS system that has a Python pro
I was shocked to discover that when repeatedly running the following
program (condensed from a "real" program) under Python 3.8.3
for p in { ('x','y'), ('y','x') }:
print(p)
the output was sometimes
('y', 'x')
('x', 'y')
and sometimes
('x', 'y')
('y', 'x')
Can anyone explain why running
On 16/05/2022 04:13, Dan Stromberg wrote:
On Sun, May 15, 2022 at 8:01 PM Rob Cliffe via Python-list
wrote:
I was shocked to discover that when repeatedly running the following
program (condensed from a "real" program) under Python 3.8.3
for p in { ('x
Thanks, Paul. Question answered!
Rob Cliffe
On 16/05/2022 04:36, Paul Bryan wrote:
This may explain it:
https://stackoverflow.com/questions/27522626/hash-function-in-python-3-3-returns-different-results-between-sessions
On Mon, 2022-05-16 at 04:20 +0100, Rob Cliffe via Python-list wrote
This 2-line program
def f(): pass
def g(): pass
runs silently (no Exception). But:
23:07:02 c:\>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(): pass
... d
On 26/06/2022 23:22, Jon Ribbens via Python-list wrote:
On 2022-06-26, Rob Cliffe wrote:
This 2-line program
def f(): pass
def g(): pass
runs silently (no Exception). But:
23:07:02 c:\>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32
bit (Intel)] on win32
Type
I have an application in which I wanted a fixed-length "array of bytes"
(that's intended as an informal term) where I could read and write
individual bytes and slices, and also pass the array to a DLL (one I
wrote in C) which expects an "unsigned char *" parameter.
I am using ctypes to talk to t
That worked. Many thanks Eryk.
Rob
On 30/06/2022 23:45, Eryk Sun wrote:
On 6/30/22, Rob Cliffe via Python-list wrote:
AKAIK it is not possible to give ctypes a bytearray object and persuade
it to give you a pointer to the actual array data, suitable for passing
to a DLL.
You're overlo
I too have occasionally used for ... else. It does have its uses. But
oh, how I wish it had been called something else more meaningful,
whether 'nobreak' or whatever. It used to really confuse me. Now I've
learned to mentally replace "else" by "if nobreak", it confuses me a bit
less.
Rob Cl
On 15/12/2022 04:35, Chris Angelico wrote:
On Thu, 15 Dec 2022 at 14:41, Aaron P wrote:
I occasionally run across something like:
for idx, thing in enumerate(things):
if idx == 103:
continue
do_something_with(thing)
It seems more succinct and cleaner to use:
if idx == 10
On 14/12/2022 13:49, Stefan Ram wrote:
I also found an example similar to what was discussed here
in pypy's library file "...\Lib\_tkinter\__init__.py":
|def _flatten(item):
|def _flatten1(output, item, depth):
|if depth > 1000:
|raise ValueError("nesting too deep i
On 20/01/2023 15:29, Dino wrote:
let's say I have this list of nested dicts:
[
{ "some_key": {'a':1, 'b':2}},
{ "some_other_key": {'a':3, 'b':4}}
]
I need to turn this into:
[
{ "value": "some_key", 'a':1, 'b':2},
{ "value": "some_other_key", 'a':3, 'b':4}
]
Assuming that I believe t
On 25/01/2023 19:38, Thomas Passin wrote:
Stack overflow to the rescue:
Search phrase: "python evaluate string as fstring"
https://stackoverflow.com/questions/47339121/how-do-i-convert-a-string-into-an-f-string
def effify(non_f_str: str):
return eval(f'f"""{non_f_str}"""')
print(ef
On 24/01/2023 04:22, Dino wrote:
$ python
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = True
>>> isinstance(b,bool)
True
>>> isinstance(b,int)
True
>>>
That immediately tells you that either
On 23/01/2023 18:02, Chris Angelico wrote:
On Tue, 24 Jan 2023 at 04:56, Johannes Bauer wrote:
Hi there,
is there an easy way to evaluate a string stored in a variable as if it
were an f-string at runtime?
...
This is supposedly for security reasons. However, when trying to emulate
this be
Whoa! Whoa! Whoa!
I appreciate the points you are making, Chris, but I am a bit taken
aback by such forceful language.
On 27/01/2023 19:18, Chris Angelico wrote:
On Sat, 28 Jan 2023 at 05:31, Rob Cliffe via Python-list
wrote:
On 23/01/2023 18:02, Chris Angelico wrote:
Maybe, rather than
On 30/01/2023 09:41, mutt...@dastardlyhq.com wrote:
On Sun, 29 Jan 2023 23:57:51 -0500
Thomas Passin wrote:
On 1/29/2023 4:15 PM, elvis-85...@notatla.org.uk wrote:
On 2023-01-28, Louis Krupp wrote:
On 1/27/2023 9:37 AM, mutt...@dastardlyhq.com wrote:
eval("print(123)")
123
Does OP ex
On 27/01/2023 23:41, Chris Angelico wrote:
On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list
wrote:
Whoa! Whoa! Whoa!
I appreciate the points you are making, Chris, but I am a bit taken
aback by such forceful language.
The exact same points have already been made, but not listened to
On 02/02/2023 09:31, mutt...@dastardlyhq.com wrote:
On Wed, 1 Feb 2023 18:28:04 +0100
"Peter J. Holzer" wrote:
--b2nljkb3mdefsdhx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On 2023-02-01 09:00:39 -, mutt...@dastardly
[re-sending this to both the list and to Chris, as a prior send to the
list only was bounced back]
On 31/01/2023 22:33, Chris Angelico wrote:
Thanks for clarifying.
Hm. So 'x' is neither in locals() nor in globals(). Which starts me
wondering (to go off on a tangent): Should there be a nonlo
On 07/02/2023 08:15, Chris Angelico wrote:
On Tue, 7 Feb 2023 at 18:49, Rob Cliffe via Python-list
wrote:
On 02/02/2023 09:31, mutt...@dastardlyhq.com wrote:
On Wed, 1 Feb 2023 18:28:04 +0100
"Peter J. Holzer" wrote:
--b2nljkb3mdefsdhx
Content-Type: text/plain; charset=us-asc
On 11/02/2023 00:39, Dino wrote:
First off, a big shout out to Peter J. Holzer, who mentioned roaring
bitmaps a few days ago and led me to quite a discovery.
I was intrigued to hear about roaring bitmaps and discover they really
were a thing (not a typo as I suspected at first).
What next, I
On 18/02/2023 15:29, Thomas Passin wrote:
On 2/18/2023 5:38 AM, Albert-Jan Roskam wrote:
I sometimes use this trick, which I learnt from a book by Martelli.
Instead of try/except, membership testing with "in"
(__contains__) might
be faster. Probably "depends". Matter of measuring
On 23/02/2023 02:04, Thomas Passin wrote:
On 2/22/2023 7:58 PM, avi.e.gr...@gmail.com wrote:
So can anyone point to places in Python where a semicolon is part of
a best
or even good way to do anything?
I use the semicolon (once in a while) is for quick debugging. I
might add as line l
On 18/02/2023 17:19, Albert-Jan Roskam wrote:
On Feb 18, 2023 17:28, Rob Cliffe via Python-list
wrote:
On 18/02/2023 15:29, Thomas Passin wrote:
> On 2/18/2023 5:38 AM, Albert-Jan Roskam wrote:
>> I sometimes use this trick, which I learnt from a book by
On 22/02/2023 20:05, Hen Hanna wrote:
Python makes programming (debugging) so easy
I agree with that!
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
On 23/02/2023 00:58, avi.e.gr...@gmail.com wrote:
So can anyone point to places in Python where a semicolon is part of a best
or even good way to do anything?
Yes. Take this bit of toy code which I just dreamed up. (Of course it
is toy code; don't bother telling me how it could be written
On 23/02/2023 02:25, Hen Hanna wrote:
i sometimes put extra commas... as:
[ 1, 2, 3, 4, ]
That is a good idea.
Even more so when the items are on separate lines:
[
"spam",
"eggs",
"cheese",
]
and you may want to chang
On 22/02/2023 15:23, Paul Bryan wrote:
Adding to this, there should be no reason now in recent versions of
Python to ever use line continuation. Black goes so far as to state
"backslashes are bad and should never be used":
https://black.readthedocs.io/en/stable/the_black_code_style/future_styl
On 27/02/2023 21:04, Ethan Furman wrote:
On 2/27/23 12:20, rbowman wrote:
> "By using Black, you agree to cede control over minutiae of hand-
> formatting. In return, Black gives you speed, determinism, and freedom
> from pycodestyle nagging about formatting. You will save time and
mental
>
On 01/03/2023 18:46, Thomas Passin wrote:
If this is what actually happened, this particular behavior occurs
because Python on Windows in a console terminates with a
instead of the usual .
I think you mean .
--
https://mail.python.org/mailman/listinfo/python-list
I found Hen Hanna's "packing" problem to be an intriguing one: Given a
list of words:
['APPLE', 'PIE', 'APRICOT', 'BANANA', 'CANDY']
find a string (in general non-unique) as short as possible which
contains the letters of each of these words, in order, as a subsequence.
It struck me as being
Slightly improved version (deals with multiple characters together
instead of one at a time):
# Pack.py
def Pack(Words):
if not Words:
return ''
# The method is to build up the result by adding letters at the
beginning
# and working forward, and by adding letters at the end,
On 01/03/2023 00:13, Peter J. Holzer wrote:
[This isn't specifically about DIPY, I've noticed the same thing in
other announcements]
On 2023-02-28 13:48:56 -0500, Eleftherios Garyfallidis wrote:
Hello all,
We are excited to announce a new release of DIPY: DIPY 1.6.0 is out from
the oven!
On 05/03/2023 22:59, aapost wrote:
On 3/5/23 17:43, Stefan Ram wrote:
The following behaviour of Python strikes me as being a bit
"irregular". A user tries to chop of sections from a string,
but does not use "split" because the separator might become
more complicated so that a regu
On 14/03/2023 21:28, avi.e.gr...@gmail.com wrote:
TThere are people now trying to in some ways ruin the usability by putting in
type hints that are ignored and although potentially helpful as in a linter
evaluating it, instead often make it harder to read and write code if required
to use it
f
Rob Cliffe via Python-list
Date: Thursday, March 2, 2023 at 2:12 PM
To: python-list@python.org
Subject: Re: Packing Problem
*** Attention: This is an external email. Use caution responding, opening
attachments or clicking on links. ***
Slightly improved version (deals with multiple charac
This puzzled me at first, but I think others have nailed it. It is not
to do with the 'with' statement, but with the way functions are defined.
When a class is instantiated, as in x=X():
the instance object gets (at least in effect), as attributes,
copies of functions defined *in the class*
I am trying to learn tkinter.
Several examples on the internet refer to a messagebox class
(tkinter.messagebox).
But:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> impor
On 20/05/2023 18:54, Alex Jando wrote:
I have many times had situations where I had a variable of a certain type, all
I cared about it was one of it's methods.
For example:
import hashlib
hash = hashlib.sha256(b'word')
hash = hash.
This sort of code might be better as a single expression. For example:
user = (
request.GET["user"]
.decode("utf-8")
.strip()
.lower()
)
user = orm.user.get(name=user)
LOL. And I thought I was the one with a (self-confessed) tendency to
write too slick, dense, smart-alec
On 23/05/2023 22:03, Peter J. Holzer wrote:
On 2023-05-21 20:30:45 +0100, Rob Cliffe via Python-list wrote:
On 20/05/2023 18:54, Alex Jando wrote:
So what I'm suggesting is something like this:
hash = hashlib.sha256(b'w
I have recently started converting a large project to tkinter, starting
with zero knowledge of tkinter. (You are free to think: BAD IDEA. 😁)
I am well aware that adopting a new tool always involves a learning
curve, and that one is prone to think that things are more difficult
than they are/sho
Thanks to everyone who replied. All replies were constructive, none
were telling me to stop belly-aching.
I forgot/omitted to state that it was I who wrote the original project
(in a completely different language), making the task of re-writing it
much less formidable. And meaning that I am fa
I am using Python 3.11.4.
Can anyone explain why Decimal values behave differently from ints when
negative values are used in divmod as follows:
>>> divmod(-1, 60)
(-1, 59) # as expected
>>> divmod(Decimal("-1"), 60)
(Decimal('-0'), Decimal('
I am currently using Python 3.11.4.
First I want to say: f-strings are great! I use them all the time,
mostly but by no means exclusively for debug messages. And in 3.12 they
will get even better.
And the improved error messages in Python (since 3.9) are great too!
Keep up the good work.
How
On 11/09/2023 21:25, Mirko via Python-list wrote:
Am 11.09.23 um 14:30 schrieb John O'Hagan via Python-list:
I was surprised that the code below prints 'called' three times.
from tkinter import *
from tkinter.ttk import *
root=Tk()
def callback(*e):
print('called')
tree = Treeview(ro
On 12/09/2023 19:51, Mirko via Python-list wrote:
I have also found that after() is a cure for some ills, though I
avoid using it more than I have to because it feels ... a bit
fragile, perhaps.
Yeah. Though for me it was the delay which made it seem fragile. With
a 0 delay, this looks muc
It's not a bug, it's an empty unpacking.
Just as you can write
[A,B] = [1,2] # Sets A to 1, B to 2
Best wishes
Rob Cliffe
On 23/09/2023 04:41, Greg Ewing via Python-list wrote:
On 23/09/23 4:51 am, Stefan Ram wrote:
[]=[]
(Executes with no error.)
#
[]=[]
( 1 )
#\_/#
(Executes wi
Recently I switched from Python 3.8.3 to Python 3.11.4. A strange
problem appeared which was not there before:
I am using the win32clipboard backage (part of pywin32), and when I use
SetClipboardData() to write text which consists ENTIRELY OF DIGITS to
the clipboard, I either get an error (not
Apologies if this is not a Python question.
I recently moved from a WIndows 10 laptop to a Windows 11 one.
Although there is nothing wrong with the sound on the new machine (I can
listen to podcasts and watch videos), I find that outputting "\a" to the
console (aka stdout) no longer beeps (or
On 14/01/2021 17:44, Denys Contant wrote:
I don't understand why sqrt is not a built-in function.
Why do we have to first import the function from the math module?
I use it ALL THE TIME!
I agree that, especially if you have experience in other languages, this
feels odd, and I have some sympath
I can't work out why
1 + - 1
1 + (not 1)
are legal syntax, but
1 + not 1
isn't.
Is there a good reason for this?
Thanks
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
This is a valid Python program:
def f(): pass
print(f)
But at the REPL:
>>> def f(): pass
... print(f)
File "", line 2
print(f)
^
SyntaxError: invalid syntax
It doesn't seem to matter what the second line is. In the REPL you have
to leave a blank line after the "def" line. Why?
T
On 31/03/2021 09:35, Alexey wrote:
среда, 31 марта 2021 г. в 01:20:06 UTC+3, Dan Stromberg:
What if you increase the machine's (operating system's) swap space? Does
that take care of the problem in practice?
I can`t do that because it will affect other containers running on this host.
In my
On 02/04/2021 23:10, dn via Python-list wrote:
(f) the space-saver:
resource = "Oil"; time = 1; crude = 2; residue = 3; my_list = "long"
IMO This can be OK when the number of items is VERY small (like 2) and
not expected to increase (or decrease). Especially if there are
multiple simil
On 03/04/2021 04:09, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-04-03 at 02:41:59 +0100,
Rob Cliffe via Python-list wrote:
x1 = 42; y1 = 3; z1 = 10
x2 = 41; y2 = 12; z2 = 9
x3 = 8; y3 = 8; z3 = 10
(please imagine it's in a fixed font with everything n
On 05/04/2021 00:47, dn via Python-list wrote:
On 04/04/2021 01.00, Rob Cliffe via Python-list wrote:
On 03/04/2021 04:09, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-04-03 at 02:41:59 +0100,
Rob Cliffe via Python-list wrote:
x1 = 42; y1 = 3; z1 = 10
x2 = 41; y2 = 12
On 05/04/2021 17:52, Chris Angelico wrote:
On Tue, Apr 6, 2021 at 2:32 AM Rob Cliffe via Python-list
wrote:
It doesn't appear to, at least not always. In Python 3.8.3:
from dis import dis
def f(): x = 1 ; y = 2
def g(): (x,y) = (1,2)
dis(f)
dis(g)
Output:
2 0 LOAD_
On 05/04/2021 17:52, Chris Angelico wrote:
I don't understand. What semantic difference could there be between
x = { 1: 2 } ; y = [3, 4] ; z = (5, 6)
and
x, y, z = { 1:2 }, [3, 4], (5, 6)
? Why is it not safe to convert the latter to the former?
But I withdraw "set" from my "
On 05/04/2021 18:33, Chris Angelico wrote:
Firstly, anything with any variable at all can involve a lookup, which
can trigger arbitrary code (so "variables which do not occur on the
LHS" is not sufficient).
Interesting. I was going to ask: How could you make a variable lookup
trigger arbitra
On 12/04/2021 09:29, Steve Keller wrote:
Just a short style question: When returning multiple return values, do
you use parenthesis?
E.g. would you write
def foo():
return 1, 2
a, b = foo()
or do you prefer
def foo():
return (1, 2)
(a, b) = foo()
Stev
On 24/05/2021 14:34, hw wrote:
Your claim that I'm insulting python or anoyone is ridiculous.
According to your logic, C is insulting python. I suggest you stop
making assumptions.
Calling a mature, widely used language "unfinished" because of what
*you* see as a defect *is* insulting.
(Of
Please don't be put off by your experience so far. Everyone stumbles
along the way and runs into "gotchas" when learning a new language.
Python is a fantastic language for development. One of my early
"epiphany" moments was experimenting with different algorithms to try to
find the right one
This puzzled me, so I played around with it a bit (Python 3.8.3):
n = []
for i in range(3):
n.append((1,7,-3,None,"x"))
for i in range(3):
n.append((1,7,-3,None,"x"))
print([id(x) for x in n])
a = 4
n = []
for i in range(3):
n.append((1,7,-3,a,None,"x"))
for i in range(3):
n.appe
On 18/06/2021 11:04, Chris Angelico wrote:
sys.version
'3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]'
def chk(x):
... if not(0 < x < 10): raise Exception
...
dis.dis(chk)
2 0 LOAD_CONST 1 (0)
2 LOAD_FAST0
On 19/06/2021 07:50, Chris Angelico wrote:
On Sat, Jun 19, 2021 at 4:16 PM Rob Cliffe via Python-list
wrote:
On 18/06/2021 11:04, Chris Angelico wrote:
sys.version
'3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]'
def chk(x):
... if not(0 < x
I'm afraid I can't help at all, but I have many times (well, it feels
like many) encountered the
"%1 is not a valid Win32 application"
error message. It looks like a format string that has not been given an
argument to format.
I would guess it's a bug either in Windows or somewhere in Pyth
On 11/08/2021 19:10, MRAB wrote:
On 2021-08-11 18:10, Wolfram Hinderer via Python-list wrote:
Am 11.08.2021 um 05:22 schrieb Terry Reedy:
Python is a little looser about whitespace than one might expect
from reading 'normal' code when the result is unambiguous in that it
cannot really mean a
Well, up to a point.
In Python 2 the output from
print 1, 2
is '1 2'
In Python 3 if you add brackets:
print(1, 2)
the output is the same.
But if you transplant that syntax back into Python 2, the output from
print(1, 2)
is '(1, 2)'. The brackets have turned two separate items into a s
Ah, Z80s (deep sigh). Those were the days! You could disassemble the
entire CP/M operating system (including the BIOS), and still have many
Kb to play with! Real programmers don't need gigabytes!
On 29/09/2021 03:03, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-09-29 at 09:21:34 +1000,
As far as I know, it can't be done.
If I was REALLY desperate I might try (tested)
import os
os.rename('myfile.myext', 'myfile.py')
import myfile
os.rename('myfile.py', 'myfile.myext')
# with appropriate modifications if myfile is not in the current directory
but this is a horrible solution, sub
On 25/10/2021 02:57, Stefan Ram wrote:
GetKeyState still returns that the tab key
is pressed after the tab key already has been released.
Well, how then am I going to make my slide show stop the
moment the key is being released?
Does tkinter allow you to trap KeyUp (and KeyDown) ev
On 20/11/2021 22:59, Avi Gross via Python-list wrote:
there are grey lines along the way where some
mathematical proofs do weird things like IGNORE parts of a calculation by
suggesting they are going to zero much faster than other parts and then wave
a mathematical wand about what happens when
On 21/11/2021 01:02, Chris Angelico wrote:
If you have a number with a finite binary representation, you can
guarantee that it can be represented finitely in decimal too.
Infinitely repeating expansions come from denominators that are
coprime with the numeric base.
Not quite, e.g. 1/14 is
You could evaluate y separately:
yval =
for item in x[:-yval] if yval else x:
[do stuff]
or you could do it using the walrus operator:
for item in x[:-yval] if (yval := ) else x:
[do stuff]
or, perhaps simplest, you could do
for item in x[:-y or None]: # a value of None for a slice a
If for ... else was spelt more intelligibly, e.g. for ... nobreak, there
would be no temptation to use anything like `elif'. `nobreakif' wouldn't
be a keyword.
Rob Cliffe
On 30/11/2021 06:24, Chris Angelico wrote:
for ns in namespaces:
if name in ns:
print("Found!")
brea
On 10/02/2022 12:13, BlindAnagram wrote:
Is there any difference in performance between these two program layouts:
def a():
...
def(b):
c = a(b)
or
def(b):
def a():
...
c = a(b)
I would appreciate any insights on which layout to choose in which
circumsta
On 10/02/2022 21:43, Friedrich Rentsch wrote:
I believe to have observed a difference which also might be worth
noting: the imbedded function a() (second example) has access to all
of the imbedding function's variables, which might be an efficiency
factor with lots of variables. The access is
I would not use `os` as an identifier, as it is the name of an important
built-in module.
I think itertools.product is what you need.
Example program:
import itertools
opsys = ["Linux","Windows"]
region = ["us-east-1", "us-east-2"]
print(list(itertools.product(opsys, region)))
Output:
[('Linux
On 03/03/2022 14:07, Larry Martell wrote:
On Wed, Mar 2, 2022 at 9:42 PM Avi Gross via Python-list
wrote:
Larry,
i waited patiently to see what others will write and perhaps see if you explain
better what you need. You seem to gleefully swat down anything offered. So I am
not tempted to
It has occasional uses (I THINK I've used it myself) but spelling it
`else` is very confusing. So there have been proposals for an
alternative spelling, e.g. `nobreak`.
There have also been suggestions for adding other suites after `for', e.g.
if the loop WAS exited with `break`
if the
I find it so hard to remember what `for ... else` means that on the very
few occasions I have used it, I ALWAYS put a comment alongside/below the
`else` to remind myself (and anyone else unfortunate enough to read my
code) what triggers it, e.g.
for item in search_list:
...
On 04/03/2022 00:34, Chris Angelico wrote:
On Fri, 4 Mar 2022 at 10:09, Avi Gross via Python-list
wrote:
The drumbeat I keep hearing is that some people hear/see the same word as
implying something else. ELSE is ambiguous in the context it is used.
What I'm hearing is that there are, broad
s
of some type Having a way to enter them using keyboards is a challenge.
Back to the topic, I was thinking wickedly of a way to extend the FOR loop with
existing keywords while sounding a tad ominous is not with an ELSE but a FOR
... OR ELSE ...
-Original Message-
From: Rob Cliffe via P
On 04/03/2022 00:43, Chris Angelico wrote:
On Fri, 4 Mar 2022 at 11:14, Rob Cliffe via Python-list
wrote:
I find it so hard to remember what `for ... else` means that on the very
few occasions I have used it, I ALWAYS put a comment alongside/below the
`else` to remind myself (and anyone
On 04/03/2022 01:44, Ethan Furman wrote:
On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote:
> There are three types of programmer: those that can count, and those
that can't.
Actually, there are 10 types of programmer: those that can count in
binary, and those that can't.
On 04/03/2022 00:55, Chris Angelico wrote:
for victim in debtors:
if victim.pay(up): continue
if victim.late(): break
or else:
victim.sleep_with(fishes)
If you mean "or else" to be synonymous with "else", then only the last
debtor is killed, whether he has paid up or not, whic
On 04/03/2022 20:52, Avi Gross via Python-list wrote:
I have an observation about exception handling in general. Some people use
exceptions, including ones they create and throw, for a similar idea. You might
for example try to use an exception if your first attempt fails that specifies
try
On 05/03/2022 01:15, Cameron Simpson wrote:
I sort of wish it had both "used break" and "did not use break"
branches, a bit like try/except/else.
And "zero iterations".
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
On WIndows 10, running Python programs in a DOS box, I would like one
Python program to chain to another. I.e. the first program to be
replaced by the second (*not* waiting for the second to finish, as with
e.g. os.system). This doesn't seem a lot to ask, but so far I have been
unable to so t
so; shutting it down becomes constant time.
But I would still like to be able to do it as I originally planned, if
possible. Not least because I may have other uses for program
"chaining" in future.
Best wishes
Rob Cliffe
On 23/08/2020 21:37, dn via Python-list wrote:
On 23/0
On 24/08/2020 00:08, Eryk Sun wrote:
For Windows, we need to spawn, wait, and proxy the exit status.
Sorry, I understand very little of this. Here's where I get stuck:
(1) "*spawn*": I see that there are some os.spawn* functions. I
tried this:
# File X1.py
import os, sys
On 24/08/2020 00:57, Chris Angelico wrote:
On Mon, Aug 24, 2020 at 9:51 AM Rob Cliffe via Python-list
wrote:
Let me describe my actual use case. I am developing a large Python
program (in Windows, working in DOS boxes) and I constantly want to
modify it and re-run it. What I have been
On 24/08/2020 13:20, Eryk Sun wrote:
You can work with job objects via ctypes or PyWin32's win32job module.
I can provide example code for either approach.
No need, I'm already convinced that this is not the way for me to go.
from the DOS prompt, it works as expected.
You're not running D
On 24/08/2020 19:54, Terry Reedy wrote:
On 8/23/2020 3:31 AM, Rob Cliffe via Python-list wrote:
On WIndows 10, running Python programs in a DOS box,
Please don't use 'DOS box' for Windows Command Prompt or other Windows
consoles for running Windows programs from a command l
On 26/08/2020 12:02, Peter J. Holzer wrote:
On 2020-08-26 22:40:36 +1200, dn via Python-list wrote:
On 26/08/2020 19:58, Joel Goldstick wrote:
[...]
<<< Code NB Python v3.8 >>>
def fp_range( start:float, stop:float, step:float=1.0 )->float:
"""Generate a range of floating-point number
On 29/08/2020 08:58, Shivlal Sharma wrote:
from functools import*
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
add = reduce(lambda a : a + 1, nums)
print(add)
error: -
TypeError Traceback (most recent call last)
in ()
1 from functools import*
2 nums = [1, 2
1 - 100 of 112 matches
Mail list logo