Steven D'Aprano added the comment:
> when you import readline, at the end of program, the console remains unusable
I cannot replicate that. I've been using readline in versions of Python
starting from 2.4 to 3.9 and it has not left the console in an unusual state.
Can you give
Steven D'Aprano added the comment:
By the way, there is no need to use the u'' prefix on strings in Python 3.
Unfortunately, I think this is a case where pprint doesn't meet your
expectations. pprint is designed to print the repr of a string, while regular
print prints t
Steven D'Aprano added the comment:
I'm getting similar results in Python 3.9.
[steve ~]$ python3.9 -m timeit -s "a = 'A'*1" -s "import re"
"re.search('^x', a)"
5000 loops, best of 5: 67.3 usec per loop
[steve ~]$ python3.9 -m t
Steven D'Aprano added the comment:
Guido wrote:
> it would require the math.log function to recognize rationals
I don't think it would. You don't need a type-check, you just need to check for
a pair of numerator and denominator attributes.
So we could do something like
Steven D'Aprano added the comment:
As Guido says, a full explanation will have to to a user-forum such as
https://discuss.python.org/c/users/7 but consider this example and see if it
gives you insight:
def demo():
x = 1
return (
x - 1
)
print("T
Steven D'Aprano added the comment:
On Sat, Jan 16, 2021 at 08:59:13AM +, Serhiy Storchaka wrote:
>
> Serhiy Storchaka added the comment:
>
> ^ matches not just the beginning of the string. It matches the
> beginning of a line, i.e. an anchor just after '\n'
Steven D'Aprano added the comment:
Use the walrus operator:
if profile := users.get(uid, None) is not None:
print(f"user: {profile['name']}")
--
nosy: +steven.daprano
resolution: -> rejected
stage: ->
Steven D'Aprano added the comment:
Oops sorry I got the operator precedence wrong:
if (profile := users.get(uid, None)) is not None:
The walrus operator was added in Python 3.8. Using the "as" key word was
considered and rejected. See the PEP:
https://www.python.org/de
Steven D'Aprano added the comment:
I'm not having a good day :-(
> the process to get new syntax added to the library
The process to get new syntax added to the **language**.
--
___
Python tracker
<https://bugs.pytho
Steven D'Aprano added the comment:
All versions older than 3.10 are in feature freeze and cannot get new features
or enhancements, only bugfixes.
Slices are far more general than range objects. How do you propose to deal with
slice objects such as this?
slice('item
Steven D'Aprano added the comment:
It is intended behaviour. `raise ... from` is a general mechanism that you can
call anywhere, it is not just limited to raising from the previous exception.
It is designed for explicitly setting the chained exception to some arbitrary
exception. Se
Steven D'Aprano added the comment:
How do you "the wrong message" to implicitly chain exceptions rather
than explicitly?
The difference between:
try:
len(1)
except TypeError as e:
raise ValueError(msg) from e
and
try:
len(1)
e
Steven D'Aprano added the comment:
Just for the record:
> The optimization takes the execution from ~6300ms to ~4500ms on my machine
> (representing a 28% - 39% improvement depending on how you calculate it)
The correct answer is 28%, which uses the initial value as the base:
Steven D'Aprano added the comment:
This is a operation precedence issue.
The line:
t0, t1 = t if t is not None else [], []
is parsed as:
(t if t is not None else []), []
so you need brackets around the "else" operand to get the effect you want.
t0, t1 = t i
Steven D'Aprano added the comment:
This is not a bug, but an issue with the way the Unicode standard defines the
lowercase of dotted I.
See #34723
Fortunately, Unicode will (hopefully!) fix this in revision 14.0, which is
scheduled to be included in Python 3.10.
Until then, perhap
Steven D'Aprano added the comment:
https://mathworld.wolfram.com/j.html
D and SmartBASIC use a literal suffix "i" for imaginary numbers. I can't
find any other languages which support literal syntax for complex
numbers, but I haven't looked very far.
https://www
Steven D'Aprano added the comment:
I think it always helps to look at what other languages do. It doesn't
mean that we must follow them, but it may help us decide that the choice
made in Python 1 was a mistake and it is worth going through the pain of
deprecation, or that i
Steven D'Aprano added the comment:
Versions 3.6-3.9 are all in feature-freeze, so the earliest this could be added
is version 3.10.
--
nosy: +steven.daprano
versions: -Python 3.6, Python 3.7, Python 3.8, Python 3.9
___
Python tracker
&
Steven D'Aprano added the comment:
Ctrl-C is a red-herring here. Esc-Enter alone is sufficient to switch control
processing.
Tested in Python 2.7 and 3.9 using xfce4-terminal in Fedora:
1. Ctrl-L clears the terminal window;
2. Type Esc-Enter;
3. Ctrl-L now inserts an actual ^L (c
Steven D'Aprano added the comment:
Hi Aleksandr,
In future, when posting what you think might be a bug, please try to cut the
code down to the bare minimum needed. In this case, it doesn't matter at all
that the strings you are processing come from splitting a larger string.
s
Steven D'Aprano added the comment:
Slicing is described here:
https://docs.python.org/3/tutorial/introduction.html
--
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
This is not a language bug, it is a bug in your code: you are modifying the
list as you iterate over it.
There are lots of ways to do that task correctly, perhaps the easiest is with a
filter:
str_list = list(filter(bool, str_list))
or a
Steven D'Aprano added the comment:
The problem here is that you are shortening the list as you walk along it,
which means you skip items. You expected to visit:
"Emma", "Jon", "", "Kelly","Eric", "", "", "
Steven D'Aprano added the comment:
Gary, I cannot replicate that inconsistency in 3.9.0.
>>> x = "abc"
>>> x is "abc"
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> if x is "abc": pass
...
Steven D'Aprano added the comment:
This is not a bug, it is working correctly, as designed.
List multiplication does not *copy* the list, it replicates the reference to
the same list object. So [[0]]*5 does not make five different sublists, but the
same list repeated five times. Exactl
Steven D'Aprano added the comment:
There is also an FAQ about this:
https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimensional-list
See also:
https://docs.python.org/3/faq/programming.html#why-did-changing-list-y-also-change-list-x
By the way, for future bug re
Steven D'Aprano added the comment:
Terry, this may be an IDLE issue, can you confirm whether or not the difference
in behaviour is intentional?
--
nosy: +terry.reedy
resolution: not a bug ->
stage: resolved ->
status: closed -> open
Steven D'Aprano added the comment:
Hi Diasy, welcome!
Please don't post screen shots of code. That makes it difficult or impossible
for the blind and visually impaired to contribute, and it means that we have to
retype your code from scratch to run it, which may introduce
Steven D'Aprano added the comment:
>>> '\N{LATIN SMALL LETTER SHARP S}'
'ß'
>>> '\N{LATIN CAPITAL LETTER SHARP S}'
'ẞ'
The history of ß is complicated and differs in the Germany speaking countries
of Austria, Switzerland and Ger
Steven D'Aprano added the comment:
Python 3.9 is in feature freeze, this couldn't be added before 3.10 now.
You have:
", ".join(["a", "b", "c"], ", and ")
outputing this:
"a, b, and, c"
So what are the sem
Steven D'Aprano added the comment:
Looking more closely, I think that the semantics are to concatenate the extra
argument to the second-last item:
", ".join(["a", "b", "c"])
# -> "a, b, c"
", ".join(["a&
Change by Steven D'Aprano :
--
resolution: -> rejected
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
Python 3.5 to 3.9 are all in feature freeze and can accept no new features; new
features can only be added to 3.10.
But having said that, I agree with Mark that the correct solution here is to
use format, not str. Szymon, unless you have a very arg
Steven D'Aprano added the comment:
Here's an example that shows what is going on:
def demo():
a = 1
class B:
x = a
print(B.x) # Okay.
class C:
x = a # Fails.
if False:
a = None
print(C.x)
If you run that, B.x is print
Steven D'Aprano added the comment:
Looking at the disassembly of the demo() function also shows differences
between the B and C classes.
I seem to recall discussion about this on, maybe, the Python-Dev list. I think
resolving this will probably have to wait on a re-design of the
Steven D'Aprano added the comment:
Heaps are not sorted lists! It is true that a sorted list is a heap, but heaps
are not necessarily sorted.
Here is another heap which is not sorted:
>>> L = []
>>> for n in (9, 7, 8, 11, 4):
... heapq.heappush(L, n)
...
>>
Steven D'Aprano added the comment:
3.5 and 3.6 are now only accepting security fixes.
Only the stability of random.random is guaranteed across versions, but you are
calling randrange:
https://docs.python.org/3/library/random.html#notes-on-reproducibility
So I am pretty sure that this
Steven D'Aprano added the comment:
On Fri, May 22, 2020 at 10:23:06AM +, Rémi Lapeyre wrote:
> As you said the PEP would have to explain why not just use sympy and
> honestly I don't have a very good argument there for now.
Because sympy is a beast. It's an excell
Steven D'Aprano added the comment:
Works for me in Python 3.7. See attached file.
Given that Python 3.5 is only longer accepting security fixes, and that numpy
is a third-party library, unless you can reproduce this in a more recent
version I think we should close this.
--
Change by Steven D'Aprano :
--
Removed message: https://bugs.python.org/msg369846
___
Python tracker
<https://bugs.python.org/issue40761>
___
___
Pytho
Change by Steven D'Aprano :
Removed file: https://bugs.python.org/file49191/test_asserttrue.py
___
Python tracker
<https://bugs.python.org/issue40761>
___
___
Pytho
Steven D'Aprano added the comment:
Works for me in 3.7. See attached file. Can you provide a minimal piece of code
that demonstrates the bug?
Since Python 3.5 is now only accepting security fixes, and numpy is a
third-party library, unless you can demonstrate this in a more recent vers
Change by Steven D'Aprano :
Added file: https://bugs.python.org/file49192/test_asserttrue.py
___
Python tracker
<https://bugs.python.org/issue40761>
___
___
Pytho
Steven D'Aprano added the comment:
The csv file object knows the encoding it was opened with, I think?
If so, we could add an enhancement that bytes objects are first decoded to str
using the same encoding the file was opened with. That seems like a reasonable
new feature to me.
Every
Steven D'Aprano added the comment:
On further thought, no, I don't think it would be a reasonable feature.
User opens the CSV file, probably using the default encoding (UTF-8?)
but potentially in anything.
They collect some data as bytes. Those bytes could be from any unknown
enco
Steven D'Aprano added the comment:
Rémi is correct, this is not a bug.
The problem isn't with list.count. If you print list.count each time through
the loop, you will see that it is working perfectly.
The problem is that you are modifying the list as you are iterating over it.
Steven D'Aprano added the comment:
Typo:
"on each step, you delete one item from the from and step forward"
Should be, you delete one item from the FRONT and step forward.
--
___
Python tracker
<https://bugs.pyt
Steven D'Aprano added the comment:
Thanks Raymond, that is the intended effect, and your analysis seems
plausible.
--
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
You don't need `b = bytes([0x41, 0x0D, 0x0A])`, this will work just as well:
b = b'\x41\x0D\x0A'
and this is even better:
b = b'A\r\n'
> It seems like bytes.decode always replaces "\n" with "\r\n
Steven D'Aprano added the comment:
> notice the stripped characters in the `repr`
Er, no. Your regex looks like line noise, and it hurts my brain to look at it
:-)
If you have spotted a difference, can you tell us what characters are stripped?
When I try running it, I don
Steven D'Aprano added the comment:
Wait, I'm sorry, do you mean this?
py> repr(r)[13:-16]
'?i)b((?:[a-z][w-]+:(?:/{1,3}|[a-z0-9%])|wwwd{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/)(?:[^s()<>]+|(([^s()<>]+|(([^s()<&
Steven D'Aprano added the comment:
This is working as designed. assertCountEqual is documented here:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertCountEqual
It says: "Test that sequence *first* contains the same elements as *second*..."
notice that
Steven D'Aprano added the comment:
Alas, this gotcha is the consequence of the way `+=` is defined in Python.
Although the behaviour is surprising, there's nothing to fix because everything
is working as expected:
* addition to a list will extend the list, as expected;
* trying
Steven D'Aprano added the comment:
> I wouldn't trust a language behaving crazy like this
I guess then you won't trust C, Java, C++, Swift, Javascript, Ruby, Cobol,
Fortran, and pretty much every programming language in existence. The only ones
that escape this are on
Steven D'Aprano added the comment:
On Mon, Jun 15, 2020 at 07:37:16PM +, mike stern wrote:
> sorry but I don't see the option to delete
Your keyboard has a Delete key and a Backspace key. Select the quoted
text in your email client and press one or the other.
If you can
Steven D'Aprano added the comment:
Further to what Mark said, I'm afraid you are mistaken when you thought that
"the result was correct" on R. R cheats by not printing the full precision of
the number, they just stop printing digits, giving a false impression of
accuracy
Steven D'Aprano added the comment:
Mike, the bug tracker is not a help-desk for questions. There are many other
forums where you can ask for help:
- the python-list and tutor mailing lists
https://www.python.org/community/lists/
- Stackoverflow
- The Python IRC channel
Steven D'Aprano added the comment:
"Class attribute" and "instance attribute" are the usual terms used in the
Python documentation and community. I have heard other terms used in other
language communities, in particular "members" and "variables&quo
Steven D'Aprano added the comment:
By the way, for future reports, it is much better to give the URL of the page
and copy and paste the exact quote than to give a screen shot. Using a screen
shot is inconvenient for us (we have to try to guess what URL you are referring
to, there are
Steven D'Aprano added the comment:
Thank you for your long and detailed bug report, but please post one issue per
bug report.
Tim, we agree that the notion of significant figures is irrelevant; is Carlos'
even/odd test sufficiently flawed that we should close this bug report, o
Steven D'Aprano added the comment:
If you change the starting point of the rounding away from zero, the bias flips
back and forth, which is exactly what I would expect from Banker's Rounding:
def check_bias(start):
d = 0.001
ne = no = 0
for i in
Steven D'Aprano added the comment:
Just change the f string quotes.
Python strings, whether f-strings or not, can be delimited by '' or "" or
triple quotes. So this works:
>>> f"But, {'this quote is right.'}"
'But, this quote is r
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
title: Android Game -> SPAM
type: security ->
___
Python tracker
<https://bug
Steven D'Aprano added the comment:
This is definitely cool though. It might make a really sweet example in the
demos that come with Python, or in the tutorial, showcasing both the
awesomeness of HelioViewer and how to use Python to connect to web APIs.
https://github.com/python/cpython
Steven D'Aprano added the comment:
This is correct behaviour. What makes you think otherwise?
For future bug reports, please don't post screen shots of text, copy and paste
the text into the body of your bug report.
Posting screenshots makes it difficult for us to copy and run
Steven D'Aprano added the comment:
In your first example, `min([(-5, 2), (0, 2)])` the min() function compares the
two tuples and finds that the first one is lexicographically smaller:
py> (-5, 2) < (0, 2)
True
so (-5, 2) is considered the minimum. In the second example
Steven D'Aprano added the comment:
The idiom of a module running doctests on itself when executed as a script is a
common idiom.
If modulegraph and pyinstaller can't cope a module importing another module
from inside an if statement, that's a bug in them, not in the heapq mo
New submission from Steven D'Aprano :
Sorry Yashwanthbarad, this isn't a bug, you expect the wrong result.
Augmented assignment for lists is documented to be the same as calling the
extend method, which means your AppenedFuncShortHandOperator function modifies
the argument lis
Steven D'Aprano added the comment:
Converting *all* exceptions into RuntimeError is certainly not a good idea,
especially since you include KeyboardInterrupt and other non-errors.
I'm probably going to be on the losing side of this one (I lost the argument
back when a similar
Steven D'Aprano added the comment:
This is a bug tracker for issues with the Python language, interpreter and
standard library. For third party applications like pip, please report bugs to
their maintainers.
https://github.com/pypa/pip/issues
--
nosy: +steven.daprano
resol
Steven D'Aprano added the comment:
This is a bug tracker for issues with the Python language, interpreter and
standard library. For third party applications like pip, please report bugs to
their maintainers.
https://github.com/pypa/pip/issues
--
nosy: +steven.daprano
resol
Change by Steven D'Aprano :
--
Removed message: https://bugs.python.org/msg374932
___
Python tracker
<https://bugs.python.org/issue41495>
___
___
Pytho
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
title: Technical advise -> SPAM
___
Python tracker
<https://bugs.p
Steven D'Aprano added the comment:
Python 3.6 has reached security-fix only stage:
https://www.python.org/dev/peps/pep-0494/#schedule-last-bugfix-release
so even if this is a bug, it won't be fixed in 3.6.
I cannot reproduce this in 3.7, and Eric cannot reproduce in 3.6.9, so I&
Steven D'Aprano added the comment:
The documentation says:
"Allowing subclassing of enums that define members would lead to a violation of
some important invariants of types and instances."
but it isn't clear what those invariants are, or why it is more of a problem
Steven D'Aprano added the comment:
On Tue, Aug 11, 2020 at 07:16:20AM +, Ramesh Sahoo wrote:
> for i in stack:
> print("inside if Popped =",stack.pop(stack.index(i)))
You are mutating the list while you iterate over it. This is prone to
cause trouble. Her
Steven D'Aprano added the comment:
Hi Seth,
Surely you aren't relying on the behaviour that names in `__all__` *aren't*
normalised but others are?
Rather than a warning, I think the right solution here is to normalise the
names in `__all__`.
--
nosy:
Steven D'Aprano added the comment:
> I wrap a function's logic with `gc.disable()` to prevent GC from triggering
> some race condition.
If this race condition is a bug in gc, then we should fix that.
If it is a bug in your code, surely you should fix that rather than disable
Steven D'Aprano added the comment:
On Fri, Aug 14, 2020 at 02:03:37PM +, Seth Woodworth wrote:
> I'm exploring what unicode code points can be used as valid starting
> characters for identifiers.
I presume you have seen the documention here:
https://docs.python
Steven D'Aprano added the comment:
Works correctly for me in the Python interpreter.
Please check if it works for you in the Python interpreter, if it does, then it
is a bug in Jupyter and should be reported to them, we cannot do anything to
fix it.
--
nosy: +steven.da
Steven D'Aprano added the comment:
How very odd. I use the Python interactive interpreter extensively, and have
done so for years. My history file is only 500 lines.
Did you happen to inspect the file before deleting it to see if it contained
something odd?
What does this print fo
Steven D'Aprano added the comment:
> My history file is only 500 lines.
*slaps forehead*
Of course it is, I'm running a customer history hook that has a limit of 500
lines in the history file.
It looks to me that by default the history feature is set to unlimited lines,
so
Steven D'Aprano added the comment:
What are you actually reporting? What part of the documentation do you think
should be changed, why should it be changed, and what should it be changed to?
It is normal for different algorithms to perform with different speed. I'm not
sure what t
Steven D'Aprano added the comment:
If you know about timeit, why aren't you using it?
In any case, I have just ran your nested_lists.py file, and on my
computer, the last version with zip is the fastest version:
0 transpose1_0(lT) Time = 1.0627508163452149e-05
7 zip
Steven D'Aprano added the comment:
Vedran: you are quoting von Neumann out of context, he was talking about
generating random numbers, not rounding, and in the seven decades since he made
his famous witticism, we of course know that there is absolutely nothing wrong
with generating r
Steven D'Aprano added the comment:
Marco, it is better to give a description of the functionality required rather
than a simplistic and incorrect implementation :-)
(Not that I am likely to provide a better implementation without a lot of
study.)
Regardless of whether you or I agree
Steven D'Aprano added the comment:
One issue per ticket please.
Versions 3.9 and older are all in feature freeze, they will not get new
features.
Combining a global declaration with an assignment has been requested before,
and rejected. If you want to discuss that feature again, you s
Steven D'Aprano added the comment:
Okay Marco, I'm changing the title to reflect the new API (support for rounding
modes rather than new round functions) and pushed the version to 3.10, since
3.9 is in feature freeze (no new features).
This will probably need to be discussed on Py
Steven D'Aprano added the comment:
I don't think that Python, a computer language, IS an approach to OOP. A
programming language HAS an approach to OOP.
We would say "Python's approach to OOP is ..." so the approach is something
that belongs to Python, it isn
Steven D'Aprano added the comment:
"Unordered" means that the language doesn't promise any specific order, it
doesn't mean that there is no order at all.
Try strings:
py> set("abcdef")
{'b', 'f', 'c', 'e', &
Steven D'Aprano added the comment:
Here's another example:
py> set([1, 2**63, 4, -5, 6, 5])
{1, 9223372036854775808, 4, 6, 5, -5}
By the way, in the future, please don't post screen shots of text, copy the
code and output and paste it as text into your bug report. S
Steven D'Aprano added the comment:
I agree with xtreak. I guess you probably misspelled the initial word:
>>> 'Python'[2:5] # same as the tutorial
'tho'
>>> 'Pyhton'[2:5] # misspelling
'hto'
--
nosy: +steven.daprano
Steven D'Aprano added the comment:
You can't end a string with a bare backslash, not even an raw string.
--
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<h
Steven D'Aprano added the comment:
See the FAQ:
https://docs.python.org/3/faq/design.html#why-can-t-raw-strings-r-strings-end-with-a-backslash
Also documented here:
https://docs.python.org/dev/reference/lexical_analysis.html#string-and-bytes-literals
Previous issues: #1271 and #
Steven D'Aprano added the comment:
Generating a range of equally-spaced floats is tricky and the range builtin is
not the right solution for this.
For numerical work, we often need to specify the number of steps, not the step
size. For instance, in numeric integration, we often li
Steven D'Aprano added the comment:
As Marco says, the exception message is because the default value for start is
0, and you can't concatenate strings to the integer 0.
You get the same error if you try to concatenate lists:
py> sum([[], []])
TypeError: unsupported o
Steven D'Aprano added the comment:
Marco, sum should be as fast as possible, so we don't want to type check every
single element. But if it is easy enough, it might be worth checking the first
element, and if it fails, report:
cannot add 'type' to start value
wher
Steven D'Aprano added the comment:
Hello David,
I really don't think you speak for the entire LGBTQ community. You don't speak
for me or my wife.
You mention two issues here:
"First is that break and continue don't allow the programmer to do anything,
they cause
Steven D'Aprano added the comment:
On Tue, Sep 08, 2020 at 06:23:58PM +, David Williams wrote:
> Steven, it sounds like we agree to the change proposal, which is to
> remove gendered language from the documentation.
What?
Did you even read w
Steven D'Aprano added the comment:
This is not a bug, it is working as designed. Importing takes the module from
the cache. You can either delete the module from the cache:
del sys.modules['modulename']
import modulename # reloads from the module file
or possib
701 - 800 of 1942 matches
Mail list logo