Steven D'Aprano added the comment:
Perhaps what you want is inspect.isroutine ?
https://docs.python.org/3/library/inspect.html#inspect.isroutine
I agree with Dennis that the isfunction test is for **Python** (def or lambda)
functions, not builtins. The docstring for the inspect.is* me
Steven D'Aprano added the comment:
I came here from #47221.
If I am reading this correctly, it concerns me that stack operations (which
should be fast) are apparently slow?
If we can't reduce the number of stack operations, can we speed them up?
--
nosy: +steven.dapr
Steven D'Aprano added the comment:
Isn't this just a quality of implementation issue?
math.isfinite should return True for all ints, since all ints are finite.
(There are no int infinities or NANs). There is no need to coerce them to float
to know that they are finite.
Li
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue47234>
___
___
Python-bugs-list mailing list
Unsubscr
Steven D'Aprano added the comment:
It would be nice if the class creation process was documented a bit
better. Here is my experiment to see what is going on:
```
# the global `__name__` is normally the module's name.
__name__ = "something"
class Meta_default_prepare(ty
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue47259>
___
___
Python-bugs-list mailing list
Unsubscr
Steven D'Aprano added the comment:
On Wed, Aug 21, 2019 at 10:51:02AM +, STINNER Victor wrote:
> Rather than adding a new function, why not adding a parameter like
> sort(key=func, reverse=True)? Something like fnmatch.filterfalse(pat,
> invert=True)?
Guido argues tha
Steven D'Aprano added the comment:
On Sat, Aug 24, 2019 at 10:09:40AM +, Serhiy Storchaka wrote:
> Could you please explain what is wrong in adding a helper function
> which will help to convert different types of numbers to integer ratio
> correctly?
>
> Currently
Steven D'Aprano added the comment:
If they are provided by the C lib, I would love to see them exposed by Python.
If they aren't, I don't know if they should be treated as optional/platform
dependent, or if we should provide an independent implementation. I guess the
easy
Steven D'Aprano added the comment:
It may help if you read this:
http://sscce.org/
It is written for Java programmers but it applies to Python as well.
Don't expect us to re-type your code from a hard-to-read, out-of-focus,
low-resolution photo of your monitor. Copy and paste the
Steven D'Aprano added the comment:
Further to Karthikeyan Singaravelan comment, the behaviour you see is
absolutely correct. The operator isn't behaving differently, it is reporting
precisely the truth.
The ``is`` operator tests for object identity, not equality. Python makes no
Steven D'Aprano added the comment:
Hi Gaurav,
It is very unlikely that you have "discovered a bug in Python". Millions of
people use Python every day, and the chances that you will have noticed
something that everyone else has missed is tiny.
More likely you have misunder
Steven D'Aprano added the comment:
Before proposing a third party module for inclusion in the standard library,
you should check:
- is the module mature and stable?
- does it have an FOSS licence compatible with Python, and if not, are the
authors willing to re-licence it?
- ar
Steven D'Aprano added the comment:
Tim is correct, the behaviour is right, however the docs could be clearer.
I think what you are missing is that ``or`` and ``and`` are short-circuiting
operators. So in the expression
9 or (anything)
the "anything" expression never
Steven D'Aprano added the comment:
I think that the problem is that the precedence table may be technically
correct, but it doesn't describe the actual behaviour of expressions
including the boolean operators ``or`` and ``and`` for exactly the
reason Tim gives:
> Precedence ru
Steven D'Aprano added the comment:
"The implementation adds a few special read-only attributes to several object
TYPES" [emphasis added]
py> class MyType:
... pass
...
py> MyType.__dict__ = {}
Traceback (most recent call last):
File "", line 1, in
Attr
Steven D'Aprano added the comment:
Oh, another point...
Python is a little more complicated than some other languages, like Java,
because Python classes (types) are themselves instances (objects) of yet
another class (the so called "metaclass"). Ultimately, all classes ar
Steven D'Aprano added the comment:
Here's a possibly simpler version which nevertheless still shows multiple calls
to __eq__ (in this case, only 6, not 13):
class C(object):
def __eq__(self, other):
print('eq')
return super().__eq__(other)
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue37168>
___
___
Python-bugs-list mailing list
Unsubscr
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue38171>
___
___
Python-bugs-list mailing list
Unsubscr
Steven D'Aprano added the comment:
This is not a bug. ``sys.maxsize`` is just an int instance, and it has no
docstring itself. When you look up ``sys.maxsize.__doc__``, or call
``help(sys.maxsize)``, the ordinary inheritance rules apply and you get the
class docstring.
There is no
Steven D'Aprano added the comment:
Are your tests so huge that you need to gzip them before uploading? That makes
them extremely difficult to read from the browser, and makes me extremely
suspicious that this could be some form of zip bomb or other malware. Couldn't
you upload a
Steven D'Aprano added the comment:
I took the health of my PC into my hands *smiles* and unzipped your test cases.
I don't know .sh scripts well, so I didn't run that (and Windows users won't be
able to run it), but I looked at the Python scripts, and I think I have
Steven D'Aprano added the comment:
I'm not an expert on super and multiple inheritance, but let me see if I can
explain what is going on. (Hopefully an expert will correct me if I get
something wrong.)
1. The class C(A_With_Arg, B_With_Arg) is straight-forward: the super call
Steven D'Aprano added the comment:
Apologies for the Python 2.7 incompatible syntax, I hadn't noticed that you had
selected 2.7. But since 2.7 (and 3.8) are in feature freeze, any behavoural
changes can only apply to 3.9 or later.
I'm afraid that you haven't explained wh
Steven D'Aprano added the comment:
On Tue, Sep 24, 2019 at 08:54:49PM +, Arno-Can Uestuensoez wrote:
> Or reduced to the focus of the actual issue and depicted the actual
> passed parameters. See the following "Case 4 - same as
> mixin_C_is_B0A1" for the essen
Steven D'Aprano added the comment:
What `readmodule` are you referring to?
3.6 is in feature-freeze. The earliest that any enhancement could be added is
version 3.9.
Can you explain how having an ending line number as well as the starting line
number can be used to check which import
Steven D'Aprano added the comment:
Sounds like a great idea to me.
Thanks,
Steven
--
___
Python tracker
<https://bugs.python.org/issue38308>
___
___
Pytho
Steven D'Aprano added the comment:
This is nothing to do with platform.system. You can see the same behaviour with
any string comparison, or ints.
The `is` operator is not a cute way of spelling `==`, it tests for object
identity, not equality. It tests whether the two arguments ar
Steven D'Aprano added the comment:
Please don't create a *second* bug report to say that your previous bug report
was erroneous. Just go and close the first one.
--
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status
Steven D'Aprano added the comment:
False alarm, see Stephen Tucker's message here
https://bugs.python.org/issue38365#msg353854
File name has a trailing space which is why it wasn't found.
--
nosy: +steven.daprano
resolution: -> works for me
stage: ->
Steven D'Aprano added the comment:
I agree with Ned closing this issue, but just glancing at the logs, it looks to
me like buildozer has shadowed your Python's ctypes with a broken ctypes in
/home/yzw/Desktop/Test/.buildozer/android/platform/build/build/other_builds/hostpytho
Steven D'Aprano added the comment:
Thanks Warren, the resistance example is excellent, would you like to write up
a PR to add it to the docs?
In the original design, I prohibited negative numbers because that seems to be
what everyone says you should do, but as far as I can tell
Steven D'Aprano added the comment:
Importing the second and subsequent times reloads the module from the system
cache. Instead, you can:
- run ``del sys.modules['hexdump']`` and then ``import hexdump``;
- call ``importlib.reload(hexdump)``; or
- restart the REPL.
Remember
Steven D'Aprano added the comment:
All versions below 3.9 are in feature freeze, so they cannot get new features.
This requested feature is already supported by subclassing ``dict`` and giving
it a ``__missing__`` method. See issue #38315
--
nosy: +steven.daprano
resol
Steven D'Aprano added the comment:
This is not a bug, this is the design of function default arguments.
Default arguments in Python use *early binding*, which means they are
calculated once, when the function is declared, rather than *late binding*,
which means they are calculated each
Steven D'Aprano added the comment:
Oh, I forgot to mention that this is discussed in one of the FAQs:
https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects
--
___
Python tracker
<https://bugs.py
Steven D'Aprano added the comment:
This is not a bug, it is part of the design of the language. Assignment in
Python does not make a copy of lists, or any other object. In your sample code,
p and l are two names for the same list, like "Devor Blake Daniels" and
"dev4057
Change by Steven D'Aprano :
--
nosy: +pablogsal
___
Python tracker
<https://bugs.python.org/issue38458>
___
___
Python-bugs-list mailing list
Unsubscr
Steven D'Aprano added the comment:
Define "malfunction". Are we supposed to know what your code is meant to do, as
well as what it actually does?
Please don't use the bug tracker as a help desk for your own scripts. There are
many forums where you can ask for help, such
Steven D'Aprano added the comment:
I can't speak for other countries, but in Australia, secondary school
mathematics teaches correlation coefficient and linear regression from
Year 11 onwards (typically ages 16 or 17). Covariance is not itself
taught, and as far as I can tell neit
Steven D'Aprano added the comment:
I believe that the interpreter only requires that each block is consistent, not
that all blocks in a module are consistent.
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
What is this a screen shot of?
What error occurs? The picture doesn't show any errors that I can see.
Please COPY and PASTE the code you are running, as text, and the FULL EXCEPTION
(the traceback and error message), if there is one. We cannot
Steven D'Aprano added the comment:
Why would they give the same result when the code is different?
#1 assign c, d, e and everything left over goes into b
*b, c, d, e, = [1, 2, 3, 4]
#2 assign c, d and everything left over goes into b
*b, c, d, = [1, 2, 3, 4]
#3 ass
Change by Steven D'Aprano :
--
title: Provide Class' end line in readmodule module -> Provide Class' end line
in pyclbr module
___
Python tracker
<https://bugs.
Steven D'Aprano added the comment:
The documentation doesn't mention ``__set_name__``, but it does say that
cached_property is useful for properties which are "effectively immutable".
The ``__set_name__`` error message is pretty cryptic, that seems to have
something
Steven D'Aprano added the comment:
We're not mind-readers, how do you expect us to know what you tried if you
don't tell us?
The walrus operator works for me:
>>> [spam for c in "hello world" if (spam:=c.upper()) in 'AEIOU']
['E
Change by Steven D'Aprano :
--
components: +Interpreter Core
type: enhancement -> behavior
___
Python tracker
<https://bugs.python.org/issue38556>
___
_
Steven D'Aprano added the comment:
Also, next time I suggest that you try running the code at least once before
submitting it, as your code contains a syntax error that prevents it from
running.
--
nosy: +steven.daprano
___
Python tracker
&
Steven D'Aprano added the comment:
This is an intentional feature: identifiers are normalised using NFKC
normalization.
py> from dis import dis
py> dis(compile('ฯ=1', '', 'single'))
1 0 LOAD_CONST 0 (1)
Steven D'Aprano added the comment:
Its also documented here:
https://docs.python.org/3/reference/lexical_analysis.html#identifiers
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https:
Steven D'Aprano added the comment:
Please explain the bug here on the bug tracker, people shouldn't have to drill
down into the PR to find out what it means.
Before fixing the bug, you should find out whether or not it actually is a bug.
In my testing, the comment is approximate
Steven D'Aprano added the comment:
Thank you for your comments, but accepting non-floats like Decimal and
Fraction (and int, of course!) is a hard requirement for the statistics
module. fmean will naturally convert any data to float for speed, but
the other means will attempt to kee
Steven D'Aprano added the comment:
Have you read the rest of the thread? There is a compelling reason to
support harmonic mean including zero (resistors in parallel) but not yet
any compelling reason to support negative values.
If you have a good use-case for harmonic mean of neg
Steven D'Aprano added the comment:
I agree with Serhiy that using mutable defaults is not automatically a bad
idea. This is unnecessary code churn that fixes no bugs and adds no new
functionality and doesn't make the code "better".
The PR removes one harmless use of a
Steven D'Aprano added the comment:
> Also, if some new Python coders saw `[]` or `{}` being used as default
> values in the standard library, they might think โIโll do it too since
> the standard library does itโ.
Great! Having Python coders learn good progamming skills from
Steven D'Aprano added the comment:
Possibly even easier than using Decimal:
py> '%.17f' % 0.95
'0.94996'
BTW, this is a FAQ:
https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate
Steven D'Aprano added the comment:
I'm reopening this as an enhancement, because I think Mikeli is onto something
here. I'd like to propose making the messages:
"False is not a truthy value."
"True is not a falsey value."
to make it expli
Steven D'Aprano added the comment:
Since error messages aren't part of the API and backwards-compatibility doesn't
apply to them, this could still go into 3.8.
--
stage: resolved ->
versions: +Python 3.8 -Python 3.9
___
Pyth
Steven D'Aprano added the comment:
I have tried sending this message by email twice, and both times it seems to
have disappeared. So I'm commenting via the web, and my apologies in advance if
the message shows up later.
*
> There are almost 500 occurrences of "is tr
Steven D'Aprano added the comment:
This seems to be the difference between Universal Newlines or not. In Python 2,
you have to set it explicitly with a U in the open mode:
$ python2.7 -c 'import sys; print("Linecount=", sum(1 for x in
open(sys.argv[1], "U
Steven D'Aprano added the comment:
Please don't ask us to guess what you are doing.
Where are you getting "both installer downloads" from? What installers are they?
How are you running the installers?
What is the actual error message please, not "something to th
Steven D'Aprano added the comment:
This is not a bug, it is working as intended.
Python does not really support "private" attributes, except by convention.
Names that begin with a single leading underscore are no different than any
other name to the interpreter, but the rea
Steven D'Aprano added the comment:
Yann,
Eric is correct -- this isn't a help desk. Please ask your question on one of
the many forums available for asking help, but before you do, please read:
http://www.sscce.org/
https://stackoverflow.com/help/minimal-reproducible-example
an
Steven D'Aprano added the comment:
This is normal, expected behaviour and has nothing to do with defaultdicts
specifically. Any mutable object would behave the same way.
Function default parameters are evaluated only once, when the function is
defined. They are not re-evaluated on each
Steven D'Aprano added the comment:
> the result is different from other languages which is why it can be
> surprising.
Maybe the other languages should be documenting their surprising result, which
fails to preserve the identity?
> Do we - add a warning to the [tutorial] page
Steven D'Aprano added the comment:
The behaviour of `is` is correct.
The `is` operator tests for object identity, not equality. The reason that
`slice(None) is slice(None)` returns False is that the two calls to the slice
function return two different objects.
You say that using the e
Steven D'Aprano added the comment:
Hello Santosh,
In future, please don't post images or screen shots of text, please copy and
paste the text of your code.
You have something similar to this:
>>> text = "short line\rvery long line of text"
>>> print(
Steven D'Aprano added the comment:
What do you mean? It works as I expected. Can you explain what you expected,
and why?
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
Before replying please read:
https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate
https://duckduckgo.com/?q=python+why+are+floating+point+so+inaccurate
--
___
P
Steven D'Aprano added the comment:
Sorry Nathan, I worded my first response awkwardly, of course mathematically we
should expect a result of 1j, by why do you expect it in a floating point
calculation? Do you have an alternative?
(I promise this is my last comment until you have
Steven D'Aprano added the comment:
> There isn't any mention of variables. While not operators, probably worth
> mentioning that they (effectively?) have higher precedence than any of the
> operators.
I'm sorry, I don't understand what that means.
---
Steven D'Aprano added the comment:
Hi John, you said:
> it seems that sorted built-in always return floats before int if they appear
> to be equal
But that's not correct:
>>> sorted([5.0, 5])
[5.0, 5]
>>> sorted([5, 5.0])
[5, 5.0]
Python's sort is
Steven D'Aprano added the comment:
I concur with Eric that this should be closed.
They're not "incorrect results", they are correct results, or at least *better*
results. We did not invent the so-called Banker's Rounding technique, it has
been the standard used by
New submission from Steven D'Aprano :
You have a bug in your code.
This is a bug tracker for bugs in Python, not a help desk for solving errors in
your own code. In this case, the problem is that you have created a file called
"turtle.py" which is shadowing the original turtle
Steven D'Aprano added the comment:
I'm closing this as "Works for me".
rafihassan190041234, if you still think it is a bug in the language, rather
than a bug in your code or a mistake in your understanding, you can re-open
this with more details. As Zach already comment
Steven D'Aprano added the comment:
This is not a bug fix, it is a change of behaviour ("enhancement"). All of 3.6
through 3.9 are in feature freeze. 3.10 is probably in feature freeze, but if
not it is extremely close to it. So this can only go into 3.11 and (maybe) 3.10.
Bu
Steven D'Aprano added the comment:
I believe that this may be the same issue as this thread
https://mail.python.org/archives/list/python-...@python.org/thread/35NECLGFIVAHWTIPAYDBJOJJX3FSY233/
in particular this comment:
https://mail.python.org/archives/list/python-...@python.org/me
Steven D'Aprano added the comment:
This is a behaviour change not a simple bug fix. 3.6 through 3.9 are all in
feature-freeze, and we're days away from the same for 3.10.
Not that I don't believe you about the _netrc convention on Windows, but do you
have a link to a
Steven D'Aprano added the comment:
> loading the entire game or DNN (from STDIN) can be simply put into one line
> as `locals().update(eval(sys.stdin.read()))`
This is how you get command injection attacks.
https://owasp.org/www-community/attacks/Command_Injection
https://cw
Steven D'Aprano added the comment:
This is not a bug. It is *literally correct* that the int 9007199254740993 is
not equal to the float 9007199254740992.0 so I really don't know why you would
desire a different result. If you want to compare two floats, compare two
floats, not an
Steven D'Aprano added the comment:
I doubt it is a memory issue. Tell us what investigation you did that lead you
to that conclusion.
Python code doesn't normally just stop working for no reason. I expect that you
changed your code in some way and introduced a bug.
This is not a
Steven D'Aprano added the comment:
On Sun, May 09, 2021 at 10:04:29PM +, Mohamed wrote:
> As I mentioned, It seems that the recent update of Windows has affected
> Tkinter,
> so that mainloop is not working after the first time
That isn't what it looks like to me.
Steven D'Aprano added the comment:
On Sun, May 09, 2021 at 11:55:56PM +, Mohamed wrote:
> Please find attached, the demo with dummy data. As I mentioned, it was
> working fine until May 1st.
If it was working fine until May 1st, I would start my investigation by
look
Steven D'Aprano added the comment:
I agree with you that "regressor" is too obscure and should be changed.
I disagree about the "y = mx + c". Haven't we already discussed this? That form
is used in linear algebra, but not used in statistics. Quoting from Yale:
Steven D'Aprano added the comment:
> The named tuple should be called Line because that is what it describes.
> Also, a Line class would be reusuable for other purposes that linear
> regression.
I think that most people would expect that a Line class would represent a
straig
Steven D'Aprano added the comment:
> The ML world has collapsed on the terms X and y. (With that
> capitalization).
I just googled for "ML linear regression" and there is no consistency in
either the variable used or the parameters. But most seem to use
lowercase x,y. O
Steven D'Aprano added the comment:
This is not a bug, this is working as the language is designed, and the
behaviour occurs for all functions, not just class methods. Default values are
only evaluated once, when the function is defined, not every time the function
is called.
This is
Steven D'Aprano added the comment:
The smiley emoji ๐ is U+1F600 which is outside of the Unicode Basic
Multilingual Plane (BMP). IDLE's underlying graphical toolkit, Tcl/Tk, has
problems with Unicode characters outside of the BMP, so this may not be fixable
by us.
If all you
Steven D'Aprano added the comment:
Correct, sys has no attribute 'original_stdout'.
Do you have a file called `sys.py`? Rename it.
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.pyt
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
match-case has not even reached a stable version of Python yet, it is only
available in Python 3.10 which is still in beta. Are we sure that it is faster
in all cases and how do you know it is more intuitive when the vast majority of
Python users
Steven D'Aprano added the comment:
How did you do the timing?
--
___
Python tracker
<https://bugs.python.org/issue44276>
___
___
Python-bugs-list m
Steven D'Aprano added the comment:
I think you have missed something important here:
>>> data = b'foo\bar'
>>> len(data)
6
>>> print(data)
b'foo\x08ar'
If you want bytes including a backslash followed by a b, you need t
Steven D'Aprano added the comment:
Remember that backslash escapes are only a Python syntactic feature. If you
read data from a file, or from the input() builtin, that contains a backslash,
it remains a backslash:
>>> s = input()
a\b
>>> print(len(s),
Steven D'Aprano added the comment:
This is not a bug, it is intentional design and has been since Python 1.
You are incorrect about x consuming memory "always". If the value bound to x is
in use elsewhere, deleting x will save no memory. If the value is not in use
elsewh
Steven D'Aprano added the comment:
By the way, loop variables are not considered to be "temporary" in Python. They
are no more temporary than any other local variable -- they *are* local
variables with exactly the same scope and lifetime as all other
Steven D'Aprano added the comment:
`match` is a soft keyword. Which means that the interpreter should still
recognise `match 'str': ...` even if the *name* "match" is defined.
--
nosy: +steven.daprano
___
Python tracker
New submission from Steven D'Aprano :
Format strings should allow spaces around keys and indices. This might be as
simple as running str.strip() on the contents of curly braces?
Aside from indentation and newlines, in most other contexts whitespace is
insignificant. E.g. in subscripting
Change by Steven D'Aprano :
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/issue44339>
___
___
Python-bugs-list mailing list
Unsubscr
101 - 200 of 1443 matches
Mail list logo