Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Not every trivial one-liner needs to be in the standard library. In this case,
there are two easy (and obvious) ways to do it:
sum(1 for x in iterator)
len(list(iterator))
(The first probably saves memory; the second pr
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
That's not a bug. That's because the file object does have an encoding
attribute, which is set to None.
getattr only returns the default when the attribute doesn't exist, not if it
exists but is None.
-
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>:
multiprocessing.Array is documented as taking the same character codes as
array.array, but it also takes 'c' which is not documented.
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Array
Change by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
title: mutliprocessing.Array misleading error message in slice assignment ->
multiprocessing.Array misleading error message in slice assignment
___
Python tracker <rep...@bug
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>:
multiprocessing.Array slice assignment claims to require a single character
even if it requires more than one:
py> arr = multiprocessing.Array('c', 3)
py> arr[:] = b'xyz' # works
py> arr[:] = 'xyz'
Traceback (m
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
I don't understand why you think they are the wrong values. What values were
you expecting?
You have a byte array, you set the value to the byte b's', which is 115, and
you get 115. You have a (byte) character array, y
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
I don't have Python 3.7 available to me, but in 3.5 the behaviour of
u.startswith(v) with an empty v seems consistent to me:
py> "alpha".startswith("", 20, 30)
True
py> "alpha"[20:30].sta
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Thank you for the bug report Ronan, but I'm afraid that I have no idea what you
think the problematic behaviour is. I'm not going to spend the time installing
the third-party hypothesis module, and learning how to use it
Change by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
stage: -> resolved
status: open -> closed
___
Python tracker <rep...@bugs.python.org>
<https://bugs.
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Thank you for taking the time to report what you thought was a bug, but your
example is way too complicated for a bug report. We shouldn't have to study
your entire program to understand what the problem is.
I can see at
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Python 2.7 is in feature freeze, so 3.7 is the absolute earliest this could be
introduced. Given how close we are to 3.7 feature freeze, 3.8 is more likely.
I don't think we would have any objections to supporting hijri ca
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Oops, accidentally messed up the status. Fixing now.
Francesco, if you simplify your code and come back with a detailed description
of what you think the bug is, then we will investigate.
--
nosy: +eric.smith
reso
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
What are you claiming is the bug? I don't understand what you think the problem
is.
Don't dump a large script in our laps and expect us to get a Google API key to
run it. Forget that, it isn't going to happen. Simplify you
Change by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python
Steven D'Aprano added the comment:
The demo code you give seems to be working perfectly correctly. I don't think
anything here is a bug.
(1) You are working with a dict, not a tuple.
(2) The potint.__repr__ method does NOT have a bug.
(3) de['four'] is NOT an int, it is a potint object, just
Steven D'Aprano added the comment:
> When using nested SimpleNamespaces, a making a copy by using
>
> new_NS=SimpleNamespace(**namespace.__dict__.copy())
In general, you shouldn't call or directly access dunder attributes.
There are exceptions, but generally they're for Python's
Steven D'Aprano added the comment:
> the documentation states that the two examples I gave should yield identical
> results.
Got a link to the specific documentation that says this? And a suggested
improvement?
--
assignee: -> docs@python
components: +Documentation
no
Steven D'Aprano added the comment:
I don't think this is a bug, I think it is standard behaviour which should be
expected if you think about Python's execution model. If you inherit from
object implicitly:
class Spam: ...
then the interpreter gets to pick the base class, and it uses
Steven D'Aprano added the comment:
I agree that returning type(self) or self.__class__ (not sure which is better)
is the right thing to do.
It might be possible to argue that the Python version is buggy, if the C
version is treated as the reference implementation and the Python version has
Steven D'Aprano added the comment:
> > Perhaps the check needs to be limited to just the exact type.
> Looks reasonable to me. Do you want to provide a PR Martijn?
You realise that is making the current traceback *less* informative
instead of more informative? I think that's going
Steven D'Aprano added the comment:
I'm not sure whether this is a bug or a feature.
In the examples you show, we have *both* an IndentationError/TabError and
missing parentheses around print. So I'm almost inclined to say that this is
right:
- you get an IndentationError (or TabError
Steven D'Aprano added the comment:
This seems like a reasonable enhancement to `sum` to me.
Since 2.7 is in feature freeze, this can only apply to 3.7.
--
nosy: +steven.daprano
type: behavior -> enhancement
versions: -Python 2.7
___
Python trac
Steven D'Aprano added the comment:
I'm afraid your error report isn't completely clear. What do you mean "input
single quote in print"? Do you mean this?
print(')
You say IDLE "crashed". What do you mean? Do you mean the IDLE application put
up an error message
Steven D'Aprano added the comment:
On Thu, Aug 03, 2017 at 11:21:38AM +, Serhiy Storchaka wrote:
> Should iterators provide just substrings or their positions?
[...]
I think we're breaking new ground here and I'm not sure what the right
API should be. Should we follow Perl 6?
ht
Steven D'Aprano added the comment:
If you don't care about the name, just pass '_' for it.
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Steven D'Aprano added the comment:
In the future, please do not post screenshots, please copy and paste the text.
Screenshots are hard or impossible for the blind or visually impaired to see,
but they can use a screen reader to work with text.
--
nosy: +steven.daprano
Steven D'Aprano added the comment:
I've given this some more thought, and I think that a "key" argument
would make sense for a general selection function.
The general selection problem is: given a set of items A, and a number k
between 1 and the number of items, return the
Steven D'Aprano added the comment:
Thanks for explaining your use-case.
Although the median_* functions don't perform arithmetic on their data,
they are still conceptually mathematical functions that operate on
numbers and I'm reluctant to support arbitrary objects with a key
function
Steven D'Aprano added the comment:
> This means that a user who wishes to use '--' in some other way is out of
> luck.
I think that's a feature, not a limitation.
Command line arguments should use broadly consistent conventions. I don't want
one program to use '--' for "end
Steven D'Aprano added the comment:
Apart from being "cool", what is the purpose of this key argument?
For the example shown, where you extract an item from tuple data:
>>> median_low([(1, 2), (3, 3), (4, 1)], key=lambda elem: elem[0])
(3, 3)
I'm not sure I understand
Steven D'Aprano added the comment:
Python 3.4, 3.5 and 3.6 are in feature-freeze, so this enhancement can only
apply to 3.7.
You say that pathlib.Path "can't be subclassed", but then immediately show an
example of subclassing it:
>>> class MyPath(pathlib.Path):
... pas
Steven D'Aprano added the comment:
This is not a bug. Whether Python allocates one, or two, float objects for a
particular floating point value is dependent on the implementation and not a
language guarantee. The language does not promise that two floats with the
value 7.3 will be the same
Steven D'Aprano added the comment:
Thank you, but I cannot review your C code.
Can you start by telling us what the two functions:
unicodedata.grapheme_cluster_break()
unicodedata.break_graphemes()
take as arguments, and what they return? If we were to call
help(function), what would we see
Steven D'Aprano added the comment:
Also, for the future, please do not post screen shots of text. Copy and Paste
the text from the console. Thank you.
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.p
Steven D'Aprano added the comment:
Before Python runs your code, it compiles it to byte-code. A SyntaxError means
that the code cannot be compiled, and so it does not run.
So the SyntaxError is raised *before* any of the code runs, and standard error
is not re-directed. This is expected
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker <rep...@bugs.python.org>
<http://bu
Steven D'Aprano added the comment:
Please copy and paste (don't retype from memory!) the *exact* error you are
getting.
You should be seeing something like:
SyntaxWarning: name 'current_user' is used prior to global declaration
(at least that's the warning I'm getting in Python 3.5), which
Steven D'Aprano added the comment:
> Using "round(number[, digits])" in a program I get no rounding
It works for me. Can you show an example of it not working?
py> round(1.23456789012345, 3)
1.235
> Using the same command in the terminal interpreter it returns
> ...
Steven D'Aprano added the comment:
Although I'm not German, I'm rather pleased by this. Nevertheless I don't think
we actually need to do anything yet.
I think it is more important that Python follows the standard Unicode
behaviour. If and when Unicode recommend that 'ß'.upper() returns '\N
Steven D'Aprano added the comment:
I think that the names in __all__ should have the same NFKC normalisation
applied as the identifiers.
Re-opening for 3.7.
--
resolution: not a bug ->
stage: resolved ->
status: closed -> open
title: If I make an attribute " -> No
New submission from Steven D'Aprano:
As discussed on Python-Ideas, there's some interest in a context manager that
can convert an exception from one type to another (similarly to the way PEP 479
has StopIteration converted to RuntimeError.
See the thread starting here:
https://mail.python.org
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Steven D'Aprano added the comment:
This is a bug in your code, not Python, and the error tells you how to fix it.
You have to indent the block.
>>> while b < 1000:
... print(b, end=',')
... a, b = b, a+b
Remember to press TAB or spacebar inside indented blocks.
You
New submission from Steven D'Aprano:
Unicode 10.0 is now finalized:
http://blog.unicode.org/2017/06/announcing-unicode-standard-version-100.html
It would be good if Python 3.7 would support it. (I think that Python currently
supports Unicode 8?)
--
messages: 296630
nosy
Steven D'Aprano added the comment:
http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
talks about *grapheme clusters*, not "graphemes" alone, and it seems clear to
me that they are language dependent. For example, it says:
The Unicode Standard provides default
Steven D'Aprano added the comment:
I don't think graphemes is the right term here. Graphemes are language
dependent, for instance "dž" may be considered a grapheme in Croatian.
https://en.wikipedia.org/wiki/D%C5%BE
http://www.unicode.org/glossary/#grapheme
I believe you are
Steven D'Aprano added the comment:
I don't understand what you actually are requesting here.
Are you requesting a way to tell whether or not the filename is too long?
You've already been told that the way to do that is to check errno, and you say
that you already knew that.
exc.errno
Steven D'Aprano added the comment:
By the way, perhaps a simpler demonstration which is more likely to render
correctly on most people's systems would be to use Latin-1 combining characters:
py> s1 = 'àéîõü'
py> s2 = unicodedata.normalize('NFD', s1) # decompose into combining chars
py&g
Steven D'Aprano added the comment:
I don't really understand your example code. What result did you expect? The
output shown in Github seems correct to me:
optional arguments:
-h, --helpshow this help message and exit
--language1 XX
Lanugage
Steven D'Aprano added the comment:
This is just module shadowing in action. If you have two or more modules, or
packages, in the module search path, the first one found will block access to
the others.
> this is a bad design in my opinion.
*shrug* It is what it is.
Often it is inconveni
Steven D'Aprano added the comment:
Can you please explain why you need to change the --more-- text in the pager?
I haven't been able to find any way to change the "--more--" prompt in the
shell commands `less` and `more`, and remember that the pager will under some
circumstanc
Steven D'Aprano added the comment:
I'm happy for you to change the name to filterfalse.
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
New submission from Steven D'Aprano:
There has been some discussion on Python-Ideas about adding
fnmatch.filter_false to complement filter, for when you want to ignore matching
files rather than non-matching ones.
https://mail.python.org/pipermail/python-ideas/2017-May/045694.html
I don't
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.pytho
Steven D'Aprano added the comment:
I think this should be closed. For backwards compatibility, the defaultdict
default_factory function must remain as it is. There is lots of code that uses
something like `int` or `list` as the factory, and if the missing key was to be
passed, the code would
Steven D'Aprano added the comment:
A further thought... looking at your example code, I believe that part of the
__getattr__ is redundant.
def __getattr__(self, item):
try:
return self.__getattribute__(item)
except AttributeError:
return self.f
Steven D'Aprano added the comment:
This is not a small change, and will need careful thought.
The problem is that in Python 3 (and in Python 2 for new-style classes), dunder
methods are only called by the interpreter if they are defined on the class
itself, not on the instance. That's
New submission from Steven D'Aprano:
According to the documentation, random.shuffle() should accept a sequence. But
it also accepts dicts, in which case it does nothing, expensively:
py> x = dict.fromkeys(range(10**6))
py> random.shuffle(x)
py> str(x)[:55] + "...}"
'{0: Non
Steven D'Aprano added the comment:
Be careful with the documentation patch. Although unbound method as an object
type is gone, unbound method as a concept is not.
Conceptually, something like ``MyClass.spam`` is an unbound method: it is a
method of the MyClass type, but bound to no instance
Steven D'Aprano added the comment:
Is this unnecessary code churn?
That's not a rhetorical question. Fixing code that isn't broken is not always a
good idea.
``func()`` is not always identical to ``func()``, there are situations where there is a significant performance
difference between
Steven D'Aprano added the comment:
Perhaps the existing ``cache_clear`` method could take optional arguments?
def cache_clear(self, *args, **kw):
if not (args or kw):
# clear the entire cache
else:
# clear just the cache entry for *args, **kw
--
components
Steven D'Aprano added the comment:
The behaviour is as documented and is not a bug. When you have a three-argument
extended slice, the starting and stopping values depend on whether the stride
(step) is positive or negative. Although that's buried in a footnote to the
table.
https
Steven D'Aprano added the comment:
In the future please don't post binary files containing source code, especially
something as non-standard as 7z. That just makes it difficult for people to
review the code. Either paste your code snippet directly into the bug report,
or attach it as a .py
New submission from Steven D'Aprano:
As discussed on the Python-Ideas mailing list, it is time to discourage the use
of operator.__dunder__ functions. Not to remove them or deprecate them, just
change the documentation to make it clear that the dunderless versions are
preferred.
Guido +1'ed
Steven D'Aprano added the comment:
> list expression pass starred expression, the other hand
> tuple expression cannot pass starred expression.
You are misinterpreting what you are seeing.
( ) is not a tuple expression (except for the special case of empty brackets,
which makes an empty
Steven D'Aprano added the comment:
Duck typing is not something that "Python" does, it is a style of programming
done by Python programmers. You wouldn't expect isinstance() to try to "duck
type", and likewise the inspect module should be precise about what it is
in
Steven D'Aprano added the comment:
Before writing a patch that may be rejected, can you explain in detail what
change you propose? Example(s) will be good.
For example:
py> from operator import attrgetter
py> f = attrgetter('keys')
py> f({})
I don't see a tuple here, so what (if
Steven D'Aprano added the comment:
Why is the name flagged as a private implementation detail? I.e. a single
leading underscore. I'd be reluctant to rely on this in production code, given
how strong the _private convention is.
Suggest just `sys.raw_args` instead.
--
nosy
Steven D'Aprano added the comment:
Its not clear what you are asking for here. Do you think the current behaviour
is a bug? Are you asking for a new feature? What do you want?
When the decorator is called, "self" doesn't exist, so of course
@self.decorator *must* fail. What else c
Steven D'Aprano added the comment:
It seems to me that the basic Counter class should be left as-is, and if there
are specialized methods used for statistics (such as normalize) it should go
into a subclass in the statistics module.
The statistics module already uses Counter internally
Steven D'Aprano added the comment:
I'm afraid I don't know what SUT means.
But 3 == 3.0 is the correct and expected behaviour. If you need to
check that two values are both the same type and the same value, you
have to validate the type and value separately.
Changing the behaviour
Steven D'Aprano added the comment:
Your example works because random is a module:
py> from types import ModuleType
py> import random
py> type(random) is ModuleType
True
Since random is an instance of ModuleType, your class M is a subclass of
ModuleType, and assigning to random.
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +haypo, ncoghlan, steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Steven D'Aprano added the comment:
To be clear, I'm referring to the docs in the tutorial:
https://docs.python.org/3.7/tutorial/datastructures.html
and the docstrings as well as the library reference:
https://docs.python.org/3.7/library/stdtypes.html#sequence-types-list-tuple-range
Steven D'Aprano added the comment:
Further to Barry's explanation, you see the same result with any values which
compare equal:
py> from decimal import Decimal as D
py> [1, 1.0, D(1), True, 1+0j].count(D(1))
5
This is standard behaviour for methods `count`, `remove`, and
Steven D'Aprano added the comment:
On my computer, running Python 3.5 and continuing to do other tasks while the
tests are running, I get a reproducible 5% speedup by using the "default
values" trick. Here's my code:
import operator
def dotproduct(vec1, vec2):
return sum(map(op
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Steven D'Aprano added the comment:
Confirmed that in Python 2.7 calling g() before and after modifying the dict
prints 3 both times; calling g() before modifying the dict prints 3, then after
modifying it prints 5.
Python 3.3 behaves like 2.7, so this sounds like a regression in 3.5 or maybe
Steven D'Aprano added the comment:
Terry, I'm not sure if you've read this enhancement request correctly or not,
because your reply when closing covers over a lot of detail which is not
relevant to this feature request.
> Extending this idea to 'subsequence in sequence' or
> sequence
Steven D'Aprano added the comment:
I agree with Josh: the exception you are giving doesn't seem possible with the
code snippet shown. Please COPY AND PASTE (not a screen shot) the text of the
entire traceback, starting with the line "Traceback..."
I suspect that you may hav
Steven D'Aprano added the comment:
Only 3.7 can receive new functionality.
Here is a pure Python implementation of a subsequence test:
https://code.activestate.com/recipes/577850-search-sequences-for-sub-sequence/
It appears to be reasonably popular on Activestate: it has about 7000 views
Steven D'Aprano added the comment:
What about "administrative data structures" that should be copied?
I think that "administrative data structures" is a red herring: there could be
data that needs copying, and data that needs sharing and shouldn't be copied,
independ
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
versions: +Python 3.7 -Python 3.3
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
--
nosy: +steven.daprano
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Steven D'Aprano added the comment:
> Do you think I should send a mail to the ideas list?
Personally, I don't think so. You want to write any(a, b, c, d),
but you can get the same effect now by writing any([a, b, c, d]).
There is unlikely to be any significant performance differe
Steven D'Aprano added the comment:
Serhiy, that doesn't generalise to code like:
any(a, b, c, *extras)
which is hard to write out by hand. You would have to say
bool(a or b or c or any(extras))
I think this might be worth considering on Python-Ideas. It will probably be
rejected
Steven D'Aprano added the comment:
re.match only matches at the start of the string. If you use re.search instead,
you will get the results you are expecting.
--
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -&g
Steven D'Aprano added the comment:
On Sun, Jan 29, 2017 at 08:23:05AM +, Martin Panter wrote:
> Why do you name the methods is_finite() etc with underscores, when the
> existing methods math.isfinite() etc do not have underscores? Seems it
> would add unnecessary confusion.
Steven D'Aprano added the comment:
Here's a slightly simpler demo, without the (fortunately harmless) typo.
--
Added file: http://bugs.python.org/file46311/argparse_nobreak.py
___
Python tracker <rep...@bugs.python.org>
<http://bugs.p
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>:
Removed file: http://bugs.python.org/file46310/argparse_nobreak.py
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
New submission from Steven D'Aprano:
argparse help incorrectly breaks long lines on U+u00A0 NO-BREAK SPACE.
The attached script has been run on Python 3.5.3rc1 in a terminal window 80
columns wide, and it produces output::
usage: argparse_nobreak.py [-h] [--no-condensed]
optional
Steven D'Aprano added the comment:
> _randbelow is a private api and it is not broken, it is just being
> misused by the secrets module.
"Misused" seems a bit strong. Should I understand that you dislike the
wrapper around _randbelow? The implementation was given in the P
Steven D'Aprano added the comment:
You haven't given any reason to explain why you think the existing docs are
wrong, nor any reason why you think your version is better. Just stating that
the docs give "misinformation" is not good enough.
By your matrix, 'Python'[0:-1] should ta
Steven D'Aprano added the comment:
On Tue, Dec 13, 2016 at 10:17:21AM +, Srikanth Anantharam wrote:
>
> Srikanth Anantharam added the comment:
>
> @steven:
>
> data = [1, 2, 3, 4, 4, 4, 5, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9]
> is clearly unimodal with mode 8
>
Steven D'Aprano added the comment:
On Tue, Dec 13, 2016 at 10:08:10AM +, Srikanth Anantharam wrote:
> Please see the updated pull request PR 50, with the changes.
I'm rejecting that pull request. As I said, mode() intentionally
returns only the single, unique mode. I may add a m
Steven D'Aprano added the comment:
I independently raised this on Python-Ideas and the initial responses are that
vars() should support objects with slots too.
https://mail.python.org/pipermail/python-ideas/2016-December/043965.html
--
nosy: +steven.daprano
versions: +Python 3.7
Steven D'Aprano added the comment:
On Tue, Dec 13, 2016 at 09:35:22AM +, Srikanth Anantharam wrote:
>
> Srikanth Anantharam added the comment:
>
> A better choice would be to return a tuple of values (sliced from the
> table). And let the user decide which one to use.
T
Steven D'Aprano added the comment:
Hi John, and thanks for the bug report. If only they were all as easily
resolved as this one :-)
With respect, if you're just getting started with Python, you shouldn't get
into the habit of hitting the bug tracker every time you find something
Steven D'Aprano added the comment:
I had a brief look at the source for ABCMeta, and it seems to me that the
__module__ behaviour is coming from `type`. I'm not sure whether it can, or
should, can be fixed in type, but I think that the correct behaviour for
ABCMeta is to set __module__
1001 - 1100 of 1436 matches
Mail list logo