[issue32172] Add length counter for iterables

2017-11-29 Thread Steven D'Aprano
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

[issue32163] getattr() returns None even when default is given

2017-11-28 Thread Steven D'Aprano
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. -

[issue32006] multiprocessing.Array 'c' code is not documented

2017-11-10 Thread Steven D'Aprano
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

[issue32005] multiprocessing.Array misleading error message in slice assignment

2017-11-10 Thread Steven D'Aprano
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

[issue32005] mutliprocessing.Array misleading error message in slice assignment

2017-11-10 Thread Steven D'Aprano
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

[issue32003] multiprocessing.Array("b", 1), multiprocessing.Array("c", 1 ) wrong value returned

2017-11-10 Thread Steven D'Aprano
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

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Steven D'Aprano
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

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Steven D'Aprano
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

[issue31915] (list).insert() not working

2017-10-31 Thread Steven D'Aprano
Change by Steven D'Aprano <steve+pyt...@pearwood.info>: -- stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <https://bugs.

[issue31915] (list).insert() not working

2017-10-31 Thread Steven D'Aprano
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

[issue31895] Native hijri calendar support

2017-10-29 Thread Steven D'Aprano
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

[issue31797] Python 3.6.3: JSON loop fails using elif

2017-10-16 Thread Steven D'Aprano
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

[issue31797] Python 3.6.3: JSON loop fails using elif

2017-10-16 Thread Steven D'Aprano
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

[issue31757] Tutorial: Fibonacci numbers start with 1, 1

2017-10-11 Thread Steven D'Aprano
Change by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue31514] There is a problem with the setdefault type conversion in the tuple

2017-09-19 Thread Steven D'Aprano
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

[issue31322] SimpleNamespace deep copy

2017-09-01 Thread Steven D'Aprano
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

[issue31283] Inconsistent behaviours with explicit and implicit inheritance from object

2017-08-26 Thread Steven D'Aprano
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

[issue31283] Inconsistent behaviours with explicit and implicit inheritance from object

2017-08-26 Thread Steven D'Aprano
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

[issue31222] datetime.py implementation of .replace inconsistent with C implementation

2017-08-16 Thread Steven D'Aprano
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

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-12 Thread Steven D'Aprano
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

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-10 Thread Steven D'Aprano
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

[issue31141] Start should be a keyword argument of the built-in sum

2017-08-08 Thread Steven D'Aprano
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

[issue31142] python shell crashed while input quotes in print()

2017-08-08 Thread Steven D'Aprano
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

[issue30717] Add unicode grapheme cluster break algorithm

2017-08-03 Thread Steven D'Aprano
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

[issue31085] Add option for namedtuple to name its result type automatically

2017-07-30 Thread Steven D'Aprano
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

[issue31063] List Comprehension Bug

2017-07-27 Thread Steven D'Aprano
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

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread Steven D'Aprano
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

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread Steven D'Aprano
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

[issue31012] suggestion: allow termination argument in argparse to be specified as argument

2017-07-24 Thread Steven D'Aprano
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

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-23 Thread Steven D'Aprano
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

[issue30957] pathlib: Path and PurePath cannot be subclassed

2017-07-18 Thread Steven D'Aprano
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

[issue30932] Identity comparison ("is") fails for floats in Python3 but works in Python2

2017-07-14 Thread Steven D'Aprano
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

[issue30717] str.center() is not unicode aware

2017-07-13 Thread Steven D'Aprano
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

[issue30895] Decimal arithmetic sum error

2017-07-10 Thread Steven D'Aprano
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

[issue30894] Python 3.6.1 String Literal Error Not Going to sys.stderr

2017-07-10 Thread Steven D'Aprano
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

[issue30887] Syntax checking confuses Try: class_instance_name as ... is used before glabal declaration

2017-07-09 Thread Steven D'Aprano
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

[issue30887] Syntax checking confuses Try: class_instance_name as ... is used before glabal declaration

2017-07-09 Thread Steven D'Aprano
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

[issue30875] round(number[, digits]) does not return value with >12 decimal places

2017-07-07 Thread Steven D'Aprano
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 > ...

[issue30810] Germany made the upper case ß official. 'ß'.upper() should now return ẞ.

2017-06-30 Thread Steven D'Aprano
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

[issue30772] Normalise non-ASCII variable names in __all__

2017-06-29 Thread Steven D'Aprano
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

[issue30792] Add contextlib.convert_exception manager

2017-06-28 Thread Steven D'Aprano
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

[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-27 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue30753] not able to execute print command on page 16 of documentation

2017-06-25 Thread Steven D'Aprano
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

[issue30736] Support Unicode 10.0

2017-06-22 Thread Steven D'Aprano
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

[issue30717] str.center() is not unicode aware

2017-06-20 Thread Steven D'Aprano
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

[issue30717] str.center() is not unicode aware

2017-06-20 Thread Steven D'Aprano
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

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Steven D'Aprano
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

[issue30608] argparse calculates string widths incorrectly

2017-06-09 Thread Steven D'Aprano
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

[issue30608] argparse calculates string widths incorrectly

2017-06-09 Thread Steven D'Aprano
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

[issue30503] It should be possible to use a module name with the same name as a package name

2017-05-29 Thread Steven D'Aprano
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

[issue30444] Add ability to change "-- more --" text in pager module

2017-05-23 Thread Steven D'Aprano
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

[issue30413] Add fnmatch.filter_false function

2017-05-21 Thread Steven D'Aprano
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

[issue30413] Add fnmatch.filter_false function

2017-05-20 Thread Steven D'Aprano
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

[issue9584] fnmatch, glob: Allow curly brace expansion

2017-05-20 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.pytho

[issue30408] [defaultdict] default_factory should accept a "key" default parameter (which can be passed my __missing__)

2017-05-19 Thread Steven D'Aprano
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

[issue30352] The 'in' syntax should work with any object that implements __iter__

2017-05-12 Thread Steven D'Aprano
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

[issue30352] The 'in' syntax should work with any object that implements __iter__

2017-05-12 Thread Steven D'Aprano
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

[issue30311] random.shuffle pointlessly shuffles dicts

2017-05-08 Thread Steven D'Aprano
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

[issue23702] docs.python.org/3/howto/descriptor.html still refers to "unbound methods"

2017-05-07 Thread Steven D'Aprano
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

[issue30296] Remove unnecessary tuples, lists, sets, and dicts from Lib

2017-05-07 Thread Steven D'Aprano
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

[issue30153] lru_cache should support invalidations

2017-04-24 Thread Steven D'Aprano
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

[issue30137] Equivalent syntax regarding List returns List objects with non-similar list elements.

2017-04-22 Thread Steven D'Aprano
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

[issue30135] default value of argument seems to be overwritten

2017-04-22 Thread Steven D'Aprano
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

[issue30085] Discourage operator.__dunder__ functions

2017-04-16 Thread Steven D'Aprano
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

[issue30084] starred tuple expression vs list display and function call

2017-04-16 Thread Steven D'Aprano
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

[issue30071] Duck-typing inspect.isfunction()

2017-04-14 Thread Steven D'Aprano
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

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Steven D'Aprano
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

[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread Steven D'Aprano
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

[issue29848] Cannot use Decorators of the same class that requires an instance of itself to change variables in that class.

2017-03-18 Thread Steven D'Aprano
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

[issue25478] Consider adding a normalize() method to collections.Counter()

2017-03-15 Thread Steven D'Aprano
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

[issue29756] Improve documentation for list methods that compare items by equality

2017-03-12 Thread Steven D'Aprano
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

[issue29794] Incorrect error message on invalid __class__ assignments

2017-03-11 Thread Steven D'Aprano
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.

[issue29790] Optional use of /dev/random on linux

2017-03-10 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +haypo, ncoghlan, steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue29756] Improve documentation for list methods that compare items by equality

2017-03-08 Thread Steven D'Aprano
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

[issue29756] Improve documentation for list methods that compare items by equality

2017-03-08 Thread Steven D'Aprano
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

[issue29724] Itertools docs propose a harmful “speedup” without any explanation

2017-03-05 Thread Steven D'Aprano
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

[issue29724] Itertools docs propose a harmful “speedup” without any explanation

2017-03-05 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue29602] complex() on object with __complex__ function loses sign of zero imaginary part

2017-02-19 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue29532] functools.partial is not compatible between 2.7 and 3.5

2017-02-11 Thread Steven D'Aprano
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

[issue29511] Add 'find' as build-in method for lists

2017-02-10 Thread Steven D'Aprano
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

[issue29518] 'for' loop not automatically breaking (index error on line of loop header)

2017-02-10 Thread Steven D'Aprano
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

[issue29511] Add 'find' as build-in method for lists

2017-02-09 Thread Steven D'Aprano
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

[issue29506] Incorrect documentation for the copy module

2017-02-08 Thread Steven D'Aprano
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

[issue12741] Add function similar to shutil.move that does not overwrite

2017-02-08 Thread Steven D'Aprano
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

[issue12741] Add function similar to shutil.move that does not overwrite

2017-02-08 Thread Steven D'Aprano
Changes by Steven D'Aprano <steve+pyt...@pearwood.info>: -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue29433] any, all and sum should accept variadic args

2017-02-03 Thread Steven D'Aprano
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

[issue29433] any, all and sum should accept variadic args

2017-02-03 Thread Steven D'Aprano
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

[issue29388] regex mismatch in the simple cases

2017-01-29 Thread Steven D'Aprano
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

[issue18842] Add float.is_finite is_nan is_infinite to match Decimal methods

2017-01-29 Thread Steven D'Aprano
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.

[issue29290] argparse breaks long lines on NO-BREAK SPACE

2017-01-16 Thread Steven D'Aprano
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

[issue29290] argparse breaks long lines on NO-BREAK SPACE

2017-01-16 Thread Steven D'Aprano
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

[issue29290] argparse breaks long lines on NO-BREAK SPACE

2017-01-16 Thread Steven D'Aprano
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

[issue29061] secrets.randbelow(-1) hangs

2016-12-30 Thread Steven D'Aprano
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

[issue29018] Misinformation when showing how slices work in The Tutorial

2016-12-19 Thread Steven D'Aprano
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

[issue28956] return minimum of modes for a multimodal distribution instead of raising a StatisticsError

2016-12-13 Thread Steven D'Aprano
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 >

[issue28956] return minimum of modes for a multimodal distribution instead of raising a StatisticsError

2016-12-13 Thread Steven D'Aprano
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

[issue13290] get vars for object with __slots__

2016-12-13 Thread Steven D'Aprano
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

[issue28956] return minimum of modes for a multimodal distribution instead of raising a StatisticsError

2016-12-13 Thread Steven D'Aprano
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

[issue28880] range(i, j) doesn't work

2016-12-05 Thread Steven D'Aprano
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

[issue28869] __module__ attribute is not set correctly for a class created by direct metaclass call

2016-12-04 Thread Steven D'Aprano
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__

<    6   7   8   9   10   11   12   13   14   15   >