ent in the body.
Makes sense.
> . On a superficial level, the answer is: "Because
> PyCapsule_GetPointer uses NULL to indicate failure."
Makes sense, too. Thanks.
--
https://mail.python.org/mailman/listinfo/python-list
Hi all,
the question is in the subject. I'd like the pointer to be able to be NULL
because that would make my code slightly cleaner. No big deal though.
--
https://mail.python.org/mailman/listinfo/python-list
I am writing a spot speedup in assembly language for a short but
computation-intensive Python loop, and I discovered something about Python
array handling that I would like to clarify.
For a simplified example, I created a matrix mx1 and assigned the array arr1 to
the third row of the matrix
Thanks for your comments. I'd like to make one small point. You say:
"Assignment in Python is a matter of object references. It's not
"conform them as long as they remain equal". You'll have to think in
terms of object references the entire way."
But w
0, 2023, 13:59 by li...@tompassin.net:
> Just to add a possibly picky detail to what others have said, Python does not
> have an "array" type. It has a "list" type, as well as some other, not
> necessarily mutable, sequence types.
>
> If you want to speed up list and
Yes, I did understand that. In your example, "a" and "b" are the same pointer,
so an operation on one is an operation on the other (because they’re the same
memory block). My issue in Python came up because Python can dynamically
change one or the other to a different obje
e precise, an operation on one name will be reflected in the other name.
The difference is in the names, not the pointers. Each name has the same
pointer in my example, but operations can be done in Python using either name.
Jan 11, 2023, 09:13 by r...@roelschroeven.net:
> Op 11/01/2
s[middle_by_two]
x = id(q)
y = id(b)
Now "x" and "y" are different, as we would expect. So when writing a spot
speed up in a compiled language, you can see in the Python source if either is
reassigned, so you’ll know how to handle it. The motivation behind my question
wa
34
> >>> b=1234
> >>> a is b
> False
>
> Not sure what happens if you manipulate the data referenced by 'b' in the
> first example thinking you are changing something referred to by 'a' ... but
> you might be smart to NOT th
original post is limited to a case such as x =
y where both "x" and "y" are arrays – whether they are lists in Python, or from
the array module – and the question in a compiled C extension is whether the
assignment can be done simply by "x" taking the pointer to &
Yes, in fact I asked my original question – "I discovered something about
Python array handling that I would like to clarify" -- because I saw that
Python did it that way.
Jan 14, 2023, 15:51 by ros...@gmail.com:
> On Sun, 15 Jan 2023 at 10:32, Jen Kris via Python-list
>
;
> [
>{ "value": "some_key", 'a':1, 'b':2},
>{ "value": "some_other_key", 'a':3, 'b':4}
> ]
[{"value": key, **value} for d in input_data for key, value in d.items()]
--
https://mail.python.org/mailman/listinfo/python-list
#x27;a':1, 'b':2},
{ "value": "some_other_key", 'a':3, 'b':4}
]
Assuming that I believe the above, rather than the code below, this works:
listOfDescriptors = [
{ ** (L := list(D.items())[0])[1], **{'value' : L[0] } }
for D
getopt for the
option stuff.
Cheers,
Cameron Simpson
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
o_stuff_with(sys.argv[1:])
>
> What is argparse really doing for you?
I second this. "if '-h' in sys.argv:" is usually what I do.
Alternatively, you could use "--arg=" syntax and place your string
"-4^2+5.3*abs(-2-1)/2" its right-hand side":
infix2postfix [options] "--infix=-4^2+5.3*abs(-2-1)/2"
This shouldn't be too hard for a user to work with. You could scan the
argument list for the presence of "--infix=" and display the help
message if it isn't there.
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Will all of you please stop sending me emails
Sent from my iPhone
> On Jan 24, 2023, at 2:59 PM, rbowman wrote:
>
> On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote:
>
>> $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08)
>> [GCC 9.4.0] on linux Type "hel
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""
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
>>>
rden - to support a relatively
rare requirement".
Perhaps someone will be inspired to write a function to do it. 😎
Best wishes
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
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
appear
in the list archive on the web.
https://mail.python.org/pipermail/python-list/
--
https://mail.python.org/mailman/listinfo/python-list
. Although sometimes it does feel like it
isn't, in that I reply to a post with an answer and then several
other people reply significantly later with the same answer, as if
my one had never existed... but whenever I check into it, my message
has actually always made it to the list.
--
https://mail.python.org/mailman/listinfo/python-list
On 2023-01-29, Peter J. Holzer wrote:
> On 2023-01-29 02:09:28 -, Jon Ribbens via Python-list wrote:
>> I'm not aware of any significant period in the last twenty-one years
>> that
> [the gateway]
>> hasn't been working. Although sometimes it does feel like
l of converting
the print command in python 2 into a function in python 3 if as a function
print() doesn't return anything useful? Surely even the length of the
formatted string as per C's sprintf() function would be helpful?
That's a fair question, or rather 2 fair questions.
Ther
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 2023-02-02, Stefan Ram wrote:
> Many licenses in the Python world are like: "You can make
> changes, but have to leave in my Copyright notice.".
>
> Would it be possible that the original author could not
> claim a Copyright anymore when code has been ch
what remains,
pretty much by definition, isn't going to be useful. You'd be
better off simply starting from scratch and having an unimpeachable
claim to own the entire copyright yourself.
--
https://mail.python.org/mailman/listinfo/python-list
devoted to each
fruit, but only ever one crate of fruit in each aisle, one would think
they could make better use of their shelf space.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
part
of it, and that was something he saw his colleagues failing to do.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
en retained for X versions of 3 just as C++ keeps old stuff
until its eventually deprecated them removed.
Yeah? So what would this do:
print ()
In Python 2 this prints an empty tuple.
In Python 3 this is a call to the print function with no arguments,
which prints a blank line.
You can'
f all available variables
and their values? If it were possible, it could be useful, and there
would be no impact on Python run-time speed if it were only constructed
on demand.
Best wishes
Rob
--
https://mail.python.org/mailman/listinfo/python-list
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
For a moment I thought this was going to be a script that
uses ChatGPT to generate a random news post and post it
to Usenet...
Which would also have been kind of cool, as long as it wasn't
overused.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
Hello,
On 2/11/23 03:31, Greg Ewing via Python-list wrote:
For a moment I thought this was going to be a script that
uses ChatGPT to generate a random news post and post it
to Usenet...
Which would also have been kind of cool, as long as it wasn't
overused.
Actually, I like cynical humo
Hello,
The installation file Python-3.8.10.exe (last version compatible with
Windows 7 (32 bit) ? )
does not automatically install pip on Windows 7.
Are there compatibility problems with Windows 7 ?
See attachment log file
Greetings
C.Sobotta
...
MSI (s) (3C:FC) [13:32:28:993]: Hello, I'm
future awaits [pun not intended] ...
--
https://mail.python.org/mailman/listinfo/python-list
ar problem,
since 1/3 isn't exactly representable in decimal either.
To avoid it you would need to use an algorithm that computes nth
roots directly rather than raising to the power 1/n.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
rt-Jan
_cache.get(arg) should be a little faster and use slightly fewer
resources than the try/except.
Provided that you can provide a default value to get() which will never
be a genuine "result".
--
https://mail.python.org/mailman/listinfo/python-list
ines terms which of course
isn't possible because the backslash must be the last character on the line.
Question: If the Python syntax were changed to allow comments after line-ending
backslashes, would it break any existing code? I can't think of an example.
--
https://mail.python.
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
v2
the term [call by name] suggests this should be possible.
But Python doesn't use call-by-name or anything remotely like it.
(Even if it did, the word "name" in that context doesn't mean
what it sounds like it means. The Algol docs used some words in
weird ways.)
--
G
the other hand, if they really want to, they will still
be able to abuse semicolons by doing this sort of thing:
a = 5; pass
b = 7; pass
c = a * b; pass
Then everyone will know it's some really serious code!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 23/02/23 9:37 am, Hen Hanna wrote:
for the first several weeks... whenever i used Python... all
i could think ofwas this is really Lisp (inside) with a thin
veil of Java/Pascal syntax..
- that everything is first
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 wr
notwithstanding that IMO it is
occasionally appropriate).
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
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_
On 24/02/23 9:26 am, avi.e.gr...@gmail.com wrote:
Python One-Liners: Write Concise, Eloquent Python Like a Professional
Illustrated Edition
by Christian Mayer (Author)
I didn't know there were any Professional Illustrated Editions
writing Pythom. You learn something every day! :-)
--
go out of their way to read the tutor list -- something that
is not of personal benefit to them.
Also, pointing people towards tutor lists, if not done carefully,
can give the impression of saying "newcomers are not welcome here".
That's not a message we want to send to Python n
On 2023-02-25, Paul Rubin wrote:
> Skip Montanaro writes:
>> from threading import Lock
>
> 1) you generally want to use RLock rather than Lock
Why?
> 2) I have generally felt that using locks at the app level at all is an
> antipattern. The main way I've stayed san
omic, I believe. But, I think it is better to not have any shared
> mutables regardless.
I think it is the case that x += 1 is atomic but foo.x += 1 is not.
Any replacement for the GIL would have to keep the former at least,
plus the fact that you can do hundreds of things like list.append(foo)
which are all effectively atomic.
--
https://mail.python.org/mailman/listinfo/python-list
On 2023-02-26, Barry Scott wrote:
> On 25/02/2023 23:45, Jon Ribbens via Python-list wrote:
>> I think it is the case that x += 1 is atomic but foo.x += 1 is not.
>
> No that is not true, and has never been true.
>
>:>>> def x(a):
>:... a += 1
>:...
>
On 2023-02-26, Chris Angelico wrote:
> On Sun, 26 Feb 2023 at 16:16, Jon Ribbens via Python-list
> wrote:
>> On 2023-02-25, Paul Rubin wrote:
>> > The GIL is an evil thing, but it has been around for so long that most
>> > of us have gotten used to it, and some u
sition, I think).
The semantics of list comprehensions was originally defined
in terms of nested for loops. A consequence was that the loop
variables ended up in the local scope just as with ordinary for
loops. Later it was decided to change that.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
lines and breaking them with the "\" line continuation character. In this
>> context it would have been nice to be able to add comments to lines terms
>> which of course isn't possible because the backslash must be the last
>> character on the line.
>>
&
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/
Robert Latest wrote:
> 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":
>>
>
print(match.start(), match.end())
I’ve tried several other attempts based on my reseearch, but still no match.
I don’t have much experience with regex, so I hoped a reg-expert might help.
Thanks,
Jen
--
https://mail.python.org/mailman/listinfo/python-list
On 28/02/23 7:40 am, avi.e.gr...@gmail.com wrote:
inhahe made the point that this may not have been the
original intent for python and may be a sort of bug that it is too late to fix.
Guido has publically stated that it was a deliberate design choice.
The merits of that design choice can be
python.org/mailman/listinfo/python-list
posite of the choice I
make.
--
~Ethan~
I've never tried Black or any other code formatter, but I'm sure we
wouldn't get on.
--
https://mail.python.org/mailman/listinfo/python-list
Yes, that's it. I don't know how long it would have taken to find that detail
with research through the voluminous re documentation. Thanks very much.
Feb 27, 2023, 15:47 by pyt...@mrabarnett.plus.com:
> On 2023-02-27 23:11, Jen Kris via Python-list wrote:
>
>>
_fixed_ string, not a
> pattern/regexp. So why on earth are you using regexps to do your searching?
>
> The `str` type has a `find(substring)` function. Just use that! It'll be
> faster and the code simpler!
>
> Cheers,
> Cameron Simpson
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
string.count() only tells me there are N instances of the string; it does not
say where they begin and end, as does re.finditer.
Feb 27, 2023, 16:20 by bobmellow...@gmail.com:
> Would string.count() work for you then?
>
> On Mon, Feb 27, 2023 at 5:16 PM Jen Kris via Python-list <
found + len(substring)
> ... do whatever with start and end ...
> pos = end
>
> Many people go straight to the `re` module whenever they're looking for
> strings. It is often cryptic error prone overkill. Just something to keep in
> mind.
>
> Cheers,
> Cameron Simpson
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
On 28/02/23 4:24 pm, Hen Hanna wrote:
is it poss. to peek at the Python-list's messages
without joining ?
It's mirrored to the comp.lang.python usenet group, or
you can read it through gmane with a news client.
--
Greg
--
https://mail.python.org/mailma
b 27, 2023, 18:16 by avi.e.gr...@gmail.com:
> Jen,
>
> Can you see what SOME OF US see as ASCII text? We can help you better if we
> get code that can be copied and run as-is.
>
> What you sent is not terse. It is wrong. It will not run on any python
> interpreter because you
gt; 26 40
>
> If you may have variable numbers of spaces around the symbols, OTOH, the
> whole situation changes and then regexes would almost certainly be the best
> approach. But the regular expression strings would become harder to read.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
27;using_simple_loop(KEY,
>> CORPUS)', globals=globals(), number=1000))
>> print('using_re_finditer:', timeit.repeat(stmt='using_re_finditer(KEY,
>> CORPUS)', globals=globals(), number=1000))
>>
>> This does 5 runs of 1000 repetitions each, and reports the time in seconds
>> for each of those runs.
>> Result on my machine:
>>
>> using_simple_loop: [0.1395295020792, 0.1306313000456,
>> 0.1280345001249, 0.1318618002423, 0.1308461032626]
>> using_re_finditer: [0.00386140005233, 0.00406190124297,
>> 0.00347899970256, 0.00341310216218, 0.003732001273]
>>
>> We find that in this test re.finditer() is more than 30 times faster
>> (despite the overhead of regular expressions.
>>
>> While speed isn't everything in programming, with such a large difference in
>> performance and (to me) no real disadvantages of using re.finditer(), I
>> would prefer re.finditer() over writing my own.
>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
hat should
>> be the main conclusion here.
>
> It is interesting, though, how pre-processing the search pattern can
> improve search times if you can afford the pre-processing. Here's a
> paper on rapidly finding matches when there may be up to one misspelled
> charact
ns.
The mysterious bit is that two of the above projects do nothing except
change the default of the one configuration option that *does* exist
(line length). I mean, "black"'s line-length choice of 88 is insane,
but I don't see the point of creating new pypi projects that do nothing
except run another project with a single option set!
--
https://mail.python.org/mailman/listinfo/python-list
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 2/03/23 10:59 am, gene heskett wrote:
Human skin always has the same color
Um... no?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ay to implement locks (push the
> locking all the way down to the CPU level).
Indeed, I remember thinking it was very fancy when they added the SWP
instruction to the ARM processor.
--
https://mail.python.org/mailman/listinfo/python-list
On 2023-03-02, Stephen Tucker wrote:
> The range function in Python 2.7 (and yes, I know that it is now
> superseded), provokes a Memory Error when asked to deiliver a very long
> list of values.
>
> I assume that this is because the function produces a list which it then
>
each of these words, in order, as a subsequence.
It struck me as being rather hard for a homework problem, unless I'm
missing something blindingly obvious.
Here is what I came up with (I could have done with
removeprefix/removesuffix but I'm stuck on Python 3.8 for now 🙁):
# Pack.py
ne or len(res) < len(BestResult):
BestResult = res
return Initial + BestResult + Final
print(Pack(['APPLE', 'PIE', 'APRICOT', 'BANANA', 'CANDY']))
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
e slightly more efficient, as it avoids a
global lookup and a function call. But as always, measurement
would be required to be sure.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 4/03/23 7:51 am, avi.e.gr...@gmail.com wrote:
I leave you with the question of the day. Was Voldemort pythonic?
Well, he was fluent in Parseltongue, which is not a good sign.
I hope not, otherwise we'll have to rename Python to "The Language
That Shall Not Be Named" an
On 5/03/23 5:12 pm, Dino wrote:
I can do a substring search in a list of 30k elements in less than 2ms
with Python. Is my reasoning sound?
I just did a similar test with your actual data and got
about the same result. If that's fast enough for you,
then you don't need to do anyt
uld be a good idea if software announcements would include
a single paragraph (or maybe just a single sentence) summarizing what
the software is and does.
hp
+1
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
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 c
impose additional delays
before the data actually gets written.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
-
Greg
--
https://mail.python.org/mailman/listinfo/python-list
/python-list
e a lot of
overlap between entries containing "V" and entries containing "6",
so you end up searching the same data multiple times.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 9/03/23 8:29 am, avi.e.gr...@gmail.com wrote:
They seem to be partially copying from python a
feature that now appears everywhere but yet strive for some backwards
compatibility. They simplified the heck out of all kinds of expressions by
using INDENTATION.
It's possible this was at
rting the module is not modifying the built-in.
If your Python has been compiled with gnu readline support,
input() *already* provides recall and editing facilities.
You only need to import the readline module if you want to
change the configuration.
Yes, it would be helpful if the docs fo
7;re Dutch?)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
rasing something that the
user didn't type in.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
/listinfo/python-list
On 10/03/23 1:46 pm, Grant Edwards wrote:
That's not how it acts for me. I have to "import readline" to get
command line recall and editing.
Maybe this has changed? Or is platform dependent?
With Python 3.8 on MacOSX I can use up arrow with input()
to recall stuff I've t
On 10/03/23 2:57 pm, Chris Angelico wrote:
import sys; "readline" in sys.modules
Is it?
Yes, it is -- but only when using the repl!
If I put that in a script, I get False.
My current theory is that it gets pre-imported when using
Python interactively because the repl itself uses it
for me.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 2023-03-13, Morten W. Petersen wrote:
> I was working in Python today, and sat there scratching my head as the
> numbers for calculations didn't add up. It went into negative numbers,
> when that shouldn't have been possible.
>
> Turns out I had a very small
it.
+1
Whenever I see code with type hints, I have to edit them out, either
mentally, or physically, to understand what the code is actually doing.
It's adding new syntax which I'm not used to and don't want to be forced
to learn.
Rob Cliffe
--
https://mail.python.org/mailman/
u haven't initialised yet.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
I accidentally used 'argparse' like this in my Python 3.9 program:
parser.add_argument ("-c, --clean", dest="clean", action="store_true")
parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")
ins
'parser.add_argument ("-c, --clean", dest="clean",
action="store_true")'
error: "-c, --clean", 2 options are unsupported.
BTW, accusing someone of 'trolling' is rather rude IMHO.
And thanks to ChrisA for a nice and normal answer.
--
--gv
--
https://mail.python.org/mailman/listinfo/python-list
2601 - 2700 of 6600 matches
Mail list logo