From the documentation on the sys module at
https://docs.python.org/3/library/sys.html:
sys.call_tracing(/func/, /args/)
Call |func(*args)|, while tracing is enabled. The tracing state is
saved, and restored afterwards. This is intended to be called from a
debugger from a checkpoint, to recurs
On 12/11/2024 08:52, Loris Bennett via Python-list wrote:
Cameron Simpson writes:
Generally you should put a try/except around the smallest possible
piece of code.
That is excellent advice.
Best wishes
Rob Cliffe
So:
config = configparser.ConfigParser()
try:
config.r
On 07/09/2024 22:20, Karsten Hilbert via Python-list wrote:
Am Sat, Sep 07, 2024 at 02:09:28PM -0700 schrieb Adrian Klaver:
Right, and this was suggested elsewhere ;)
And, yeah, the actual code is much more involved :-D
I see that.
The question is does the full code you show fail?
The co
On 07/09/2024 16:48, Karsten Hilbert via Python-list wrote:
Dear all,
unto now I had been thinking this is a wise idiom (in code
that needs not care whether it fails to do what it tries to
do^1):
conn = psycopg2.connection(...)
curs = conn.cursor()
try:
c
On 06/07/2024 12:57, Oscar Benjamin via Python-list wrote:
On Sat, 6 Jul 2024 at 11:55, Rob Cliffe via Python-list
wrote:
Consider this scenario (which I ran into in real life):
I want to open a text file and do a lot of processing on the lines
of that file.
If the file does not
On 07/07/2024 02:08, Cameron Simpson wrote:
On 06Jul2024 11:49, Rob Cliffe wrote:
try:
f = open(FileName) as f:
FileLines = f.readlines()
except FileNotFoundError:
print(f"File {FileName} not found")
sys.exit()
# I forgot to put "f.close()" here -:)
for ln in File Lines:
Consider this scenario (which I ran into in real life):
I want to open a text file and do a lot of processing on the lines
of that file.
If the file does not exist I want to take appropriate action, e.g.
print an error message and abort the program.
I might write it like this:
try:
Recently I acquired a new laptop running WIndows 11; my previous one
uses WIndows 10. I encountered a strange problem:
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
import itertools
def chunk1(seq):
return [ ch * len(list(grp)) for (ch, grp) in itertools.groupby(s) ]
def chunk2(seq):
return [ (ch, len(list(grp))) for (ch, grp) in itertools.groupby(s) ]
s='aaabbaa'
print(chunk1(s))
print(chunk2(s))
###
Program out
OK, here is the advanced version:
import os
class _cls(object):
def __repr__(self):
os.system('cls')
return ''
cls = _cls()
Now when you type
cls
it clears the screen. The only flaw is that there is a blank line at
the very top of the screen, and the ">>>" prompt appears on
On 05/06/2024 04:09, Cameron Simpson wrote:
On 04Jun2024 22:43, Rob Cliffe wrote:
import os
def cls(): x=os.system("cls")
Now whenever you type
cls()
it will clear the screen and show the prompt at the top of the screen.
(The reason for the "x=" is: os.system returns a result, in this case
Welcome to Python! A great language for program development.
Answers might be platform-dependent (are you using WIndows, Linux, etc.).
However, the following works for me on WIndows. You can put it in the
startup.py file so you don't have to type it every time you start up the
IDLE.
import
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
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
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
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
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
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
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('
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 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
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
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 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.
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
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*
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
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
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 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!
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,
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
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
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 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 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 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 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 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 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 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 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 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
[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 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
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 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
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 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
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 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 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 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 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
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
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 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
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
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
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
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
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 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
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
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
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 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 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 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: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
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: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
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:
...
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
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
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 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
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
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
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
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
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 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
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
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,
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
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
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 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
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
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
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
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
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 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 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 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 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 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 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
1 - 100 of 112 matches
Mail list logo