[issue33998] random.randrange completely ignores the step argument when stop is None

2018-06-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: "I have a really hard time believing that [...] others haven't noticed this rather glaring flaw in the code." *shrug* Easy or hard for you to believe, nevertheless this same quote-unquote "flaw" goes back to Python 1.5 or older

[issue33991] lib2to3 should parse f-strings

2018-06-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: > @Steven lib2to3 is no longer specifically for python 2 code, it also > parses python 3 code Ah, all good then. Thanks. -- ___ Python tracker <https://bugs.python.org/i

[issue33991] lib2to3 should parse f-strings

2018-06-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm curious how you are getting f-strings (introduced in Python 3.6) in Python 2 code that you are passing to 2to3. -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue33

[issue33893] Linux terminal shortcuts support in python shell

2018-06-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Terry asked: > I have a question about Linux consoles. [...] Does a Linux console retrieve > all 5 at once, as IDLE does? Not typically. Like the Windows console, Linux consoles are also line-oriented, and hitting up-arrow cycles through each lin

[issue33865] unknown encoding: 874

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please don't post screenshots of text, they make it difficult for the blind and visually impaired to contribute. Instead, please copy and paste the error message into the body of your bug report. (Which I see you have done, which makes the screenshot

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Eryk Sun says: > It has to be a ValueError since the error is an invalid parameter at the > Python level. How does the first follow from the second? Strings with NULs in them aren't errors or invalid parameters at the Python level, and they are lega

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: Eric wrote: > I don't know of any OS that supports NULs in filenames HFS, HFS Plus, and Apple File System all support NULs in filenames. HFS Plus volumes include a special special directory called the metadata directory, in the volume's root direct

[issue33856] Type "help" is not present on win32

2018-06-14 Thread Steven D'Aprano
New submission from Steven D'Aprano : What do you mean "type help"? help() is added by the site module, if you've done something to skip running the site module it won't be added. Can you give an example of what you are trying to do, what happens and what you expected? Are y

[issue33835] Too strong side effect?

2018-06-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Both names "v1" and "v2" refer to the same object. Python does not make copies of objects on assignment, so if you write: a = [] b = a then a and b both refer to the same list object, and the names "a" and "b" ar

[issue33814] exec() maybe has a memory leak

2018-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I decided to risk this "catastrophic" leak, and ran this: py> x = leaks() py> x ((2, 3), , 24) py> import gc py> gc.collect() 22 py> x ((2, 3), , 24) so I think Eric is correct, it is just a garbage collection issue. Possibl

[issue33814] exec() maybe has a memory leak

2018-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Perhaps a little less self-righteous anger and a little more detail on this alleged bug would be appropriate. Quote: I still think it's ridiculous that every item added to that dict has an "extra", non-obvious reference count that is

[issue33790] Decorated (inner/wrapped) function kwarg defaults dont pass through decorator.

2018-06-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think you have misunderstood where and when default arguments are assigned. When you call func() with no arguments, kwargs is empty, and it is correct that the output will be -> Decorator: In the following line, you call the original function

[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-06-02 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue33721> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33728] pandas.to_records can not be saved by numpy.savez

2018-06-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sorry, this tracker is for the interpreter and standard library. For bugs in third party code like numpy and pandas, you will have to report it on their own bug trackers. -- nosy: +steven.daprano resolution: -> third party stage: -> re

[issue33705] Unicode is normalised after keywords are checked for

2018-05-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: Possibly the correct term is canonicalisation rather than normalisation, although I think the two are interchangeable. -- ___ Python tracker <https://bugs.python.org/issue33

[issue33705] Unicode is normalised after keywords are checked for

2018-05-30 Thread Steven D'Aprano
New submission from Steven D'Aprano : There is a loophole in the Unicode normalisation which allows the creation of names matching keywords. class Spam: locals()['if'] = 1 Spam.퐢퐟# U+1D422 U+1D41F # returns 1 Those two characters are 'MATHEMATICAL BOLD SMALL I' and 'MATHEMATICAL BOLD

[issue33685] Instances bound methods with different memory addresses but sharing same id

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: ID numbers in Python are only guaranteed to be unique for the lifespan of the object. In CPython they can be re-used. (In other implementations, like Jython and IronPython, IDs are allocated as sequential numbers and won't be reused.) The other fact you

[issue33682] Optimize the bytecode for float(0) ?

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm sorry, it isn't clear what optimizations for float(X) and int(X) you are referring to. I can only guess that you want to optimize: float(0) to use LOAD_CONST 0.0 instead of calling the float() function. If that is what you want, we can't do

[issue33681] itertools.groupby() returned igroup is only callable once

2018-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is standard behaviour for all iterators. Once you have iterated over them once, they are consumed, and iterating over them again returns nothing: py> it = iter("abc") py> print(list(it)) ['a', 'b', 'c'] py> print(list(it))

[issue33636] Unexpected behavior with * and arrays

2018-05-24 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Nathan, the bug tracker is not the place to debate Python behaviour. For the purposes of the bug tracker, all we need say is that it is documented behaviour and not a bug. If you want to change that behaviour, there is a p

[issue33636] Unexpected behavior with * and arrays

2018-05-24 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This is not a bug, it is the documented behaviour: the * operator does not copy the lists, it duplicates references to the same list. There's even a FAQ for it: https://docs.python.org/3/faq/programming.html#how-do-i-

[issue33588] Unicode function arguments aren't preserved

2018-05-20 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This does seem to be a normalisation issue: py> unicodedata.normalize('NFKC', 'ϵαγϕ') == ''.join(func.__code__.co_varnames) True so I'm closing this as not a bug. Mike, thank you for copying and pasting the rele

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: What do you think of adding a note in the documentation for median? "If your data is ordinal (supports order operations) but not numeric (doesn't support addition), you should use ``median_low`` or ``median_hig

[issue33430] Import secrets module in secrets examples

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Unless I've mucked it up, I just committed your patch on Github so I'm closing this ticket. Thanks. -- stage: patch review -> resolved status: open -> closed ___ Python

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: By the way, this isn't a crash (that's for things which cause the interpreter to segfault). I'm marking this as Not a bug, but I'm open to suggestions to improve either the documentation or the median fun

[issue33573] statistics.median does not work with ordinal scale

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: For ordinal scales, you should use either median_low or median_high. I don't think the standard median function ought to choose for you whether to take the low or high median. It is better to be explicit about which yo

[issue33574] Conversion of Number to String(str(number))

2018-05-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Also note that shadowing builtins *deliberately* is a powerful and useful technique used for advanced programming. -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.p

[issue33501] split existing optimization levels into granular options

2018-05-14 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

[issue33494] random.choices ought to check that cumulative weights are in ascending order

2018-05-14 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Mon, May 14, 2018 at 11:54:32AM +, Paul Moore wrote: > Requiring a pre-check on cum_weights (for example, the obvious check > that the sequence is nondecreasing) would add an O(n) step, and so > signi

[issue33494] random.choices ought to check that cumulative weights are in ascending order

2018-05-14 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: As mentioned on the Python-List: https://mail.python.org/pipermail/python-list/2018-May/733061.html random.choices() silently returns the wrong values when cumulative weights are not given, i.e. if the user mi

[issue21592] Make statistics.median run in linear time

2018-05-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: How does the performance change with this patch? Quick-select is a nice idea in theory, but unless it is written in C, it is unlikely to beat sorting the list unless you have HUGE data sets. Its been nearly four years s

[issue33430] Import secrets module in secrets examples

2018-05-05 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I've always expected that documentation for a module can assume that the module itself, and/or the function being described, has been imported. On the other hand, I have no objection to making this explicit, espe

[issue33424] 4.4. break and continue Statements, and else Clauses on Loops

2018-05-04 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Joe, we have no idea what you think is the bug. It is intentional that the second argument for range is excluded. This is called an "half-open" range, and it helps avoid off-by-one and signpost errors. Your comm

[issue33411] All console message are in the error output in bash interpretor

2018-05-02 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Hello Quentin, and welcome. Please don't post screen shots of text. We don't edit our code with Photoshop, and using a screenshot makes it difficult to copy your code for testing, to verify the bug report, and prevents the

[issue33404] Phone Number Generator

2018-05-01 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Hi Braiden, and welcome! I see that the ticket has already been closed, but another note for the future: please don't paste screenshots of your code, copy and paste the relevant source code. We don't edit code with Pho

[issue33402] Change the fractions.Fraction class to convert to a unicode fraction string

2018-05-01 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Strings in Python 3 are already unicode. Looking at the patch, I see a lot of fractions which display as the missing glyph white square. For example, instead of seeing 1/9, which displays perfectly everywhere, I see a myst

[issue33390] matmul @ operator precedence

2018-04-29 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Precedence issues when dealing with units is unavoidable, I think. The units program on Linux/Unix has similar issues, and they write their own parser and choose their own precedence. https://www.gnu.org/software/units/

[issue33372] Wrong calculation

2018-04-27 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Ah sheesh I copied and pasted the wrong bits. After the division terms go to zero, you get -590072-200112-18-18-18-18-18-18-18-18+9998599835 which goes to 9997809507 as calculated by Ruby and Python 2, and I promise

[issue33372] Wrong calculation

2018-04-27 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: > Even Ruby gets the right answer (9997809507) for that :-) Oops, I forgot to say... Ruby 1.8 also does truncating division like Python 2. -- ___ Python tracker <rep...@bug

[issue33372] Wrong calculation

2018-04-27 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I agree with Tim that this is likely to be the difference between Python 2 truncating division and Python 3 division. For the record, I get the following results: 9997809507L Python 2.7 9997809307.0 Python 3.5 999780

[issue33362] string strip() strips extra characters that it shouldn't

2018-04-25 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: the argument to string.strip (also lstrip and rstrip) is not an exact substring to remove, but a set of characters to remove: py> 'zyxzz1234'.strip('xyz') '1234' -- nosy: +steven.daprano resolution: -> not

[issue33322] Overridden __getitem__ not called on use of slice syntax when inheriting from tuple

2018-04-21 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: In Python 2, you have to override __getslice__ as well as __getitem__. Try this instead: class MyTuple(tuple): def __getitem__(self, pos): print "get item {}".format(pos) return sup

[issue33304] Syntax Error on leading 0 in integer tokens

2018-04-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I've opened an issue to improve the error message: #33305 -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33305] Improve syntax error for numbers with leading zero

2018-04-17 Thread Steven D'Aprano
Change by Steven D'Aprano <steve+pyt...@pearwood.info>: -- type: behavior -> enhancement ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue33305] Improve syntax error for numbers with leading zero

2018-04-17 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: The Python 2.x syntax for octal integers is a syntax error in 3.x, but the error message is very uninformative: SyntaxError: invalid token Can this be improved? Perhaps to something like: invalid token, use 0o

[issue33304] Syntax Error on leading 0 in integer tokens

2018-04-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This is not a bug, it is intentional. In Python 2, numbers with a leading zero are interpreted as octal, leading to surprising results: py> 015 13 In Python 3, we use 0o15 to get octal, and 015 becomes a syn

[issue33292] Fix secrets.randbelow docstring

2018-04-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Possibly you may not be familiar with interval notation? https://www.mathsisfun.com/sets/intervals.html Since this is Python and not maths, maybe we should rethink the w

[issue33233] Suggest third-party cmd2 module as alternative to cmd

2018-04-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: (Previously posted on Python-Dev.) I think the documentation note is a good idea. But I disagree with deprecating "cmd" unless it is actively falling apart and no longer working, not just languishing with no feat

[issue32337] Dict order is now guaranteed, so add tests and doc for it

2018-04-03 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I started to add this comment to #33218 but Raymond closed that ticket while I was editing it. In 3.6, dicts preserving insertion order remains an implementation detail that cannot be relied on. It only becomes a guarantee

[issue33186] Memory corruption with urllib.parse

2018-03-30 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Alexey, I'm afraid I can't make heads or tails of your bug report. You've gone into a detailed description of the "bad results" you have, but you haven't explained *why* they're bad, or what you were expecting. I

[issue33157] Strings beginning with underscore not removed from lists - feature or bug?

2018-03-27 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: In addition to Xiang Zhang's comments, this is neither a feature nor a bug, but a misunderstanding. This has nothing to do with strings or underscores: py> L = [1, 2, 3, 4, 5] py> for item in L: ... L.remove(item)

[issue33108] Unicode char 304 in lowercase has len = 2

2018-03-20 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: It has never been the case that upper() or lower() are guaranteed to preserve string length in Unicode. For example, some characters decompose into a base plus combining characters. Ligatures are another example. See here fo

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Ah wait, I appear to have misunderstood Raymond's request. Sorry Raymond! (I've been spending too much time teaching Pythagoras' theorem and my mind was primed to go directly from Euclidean distance to hypo

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: The obvious work-around of calling hypot multiple times is not only tedious, but it loses precision. For example, the body diagonal through a 1x1x1 cube should be √3 exactly: py> from math import hypot, sqrt py> hypo

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This was requested once before, but rejected. I would like to see that decision re-considered. https://bugs.python.org/issue1880 Some months ago, there was a very brief discussion started by Lawrence D’Oliveiro

[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Fri, Mar 16, 2018 at 02:32:36PM +, Mark Dickinson wrote: > For what it's worth, NumPy gives a result of NaN for the median of an array > that contains NaNs: By default, R gives the median of a list containin

[issue32917] ConfigParser writes a superfluous final blank line

2018-03-10 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Sat, Mar 10, 2018 at 06:37:28AM +, TitanSnow wrote: > > TitanSnow <tttnns1...@gmail.com> added the comment: > > If we treat the original behavior as a bug, > it’s much easier to write a patch >

[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I think the difficulty here is that your perspective is backwards. It isn't that sorting a generator is *slower*, it is that sorting a list is *faster*, because there is more information available with a list

[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-23 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This is a truly awful name, there's nothing unsafe about the hash parameter. We rightly hesitate to label *actual* unsafe functions, like eval and exec, with that name. Are we committed to this name? -

[issue32917] ConfigParser writes a superfluous final blank line

2018-02-22 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Oh, I forgot... even if it is decided that this trim_final_blankline parameter was desirable, the patch isn't sufficient to be accepted. You would need to also supply documentation and

[issue32917] ConfigParser writes a superfluous final blank line

2018-02-22 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Its not a superfluous blank line. It is standard convention for Unix tools to end text files (of which ini files are a kind of text file) with a final newline \n. There are various reasons for this, but it doesn't matte

[issue32906] AttributeError: 'NoneType' object has no attribute 'sendall'

2018-02-21 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Hi, this is for tracking bugs in the Python interpreter and standard library, not asking for help debugging your own code. There's no reason (yet) to believe this error is a bug in Python, you need to debug it first to

[issue32876] HTMLParser raises exception on some inputs

2018-02-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: The stdlib HTML parser requires correct HTML. To parse broken HTML, as you find in the real world, you need a third-party library like BeautifulSoup. BeautifulSoup is much more complex (about 7-8 times as many LOC) but can

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

2018-02-18 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: What makes the minimum mode better than the maximum? -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: +1 Please also support using a one-element tuple: `for y in (f(x),)` -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Thanks for the link to the Stackoverflow discussion. Currently there are three answers: two (correctly) answer that the constant as given is the most accurate value for IEEE-754 floats. Tim Peters has answered that:

[issue32778] Hi

2018-02-05 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.

[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2018-01-26 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Dan, I don't understand what you think the code snippet shows: you're calling isclass on an object which *actually is a class* and show that it returns True. What did you expect it to return? How does the code snippet yo

[issue32657] Mutable Objects in SMTP send_message Signature

2018-01-25 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Thu, Jan 25, 2018 at 02:28:17PM +, R. David Murray wrote: > obviously I missed that mutation of the value > in the code review of the patch that added those lines :( The docstring for send_mess

[issue32657] Mutable Objects in SMTP send_message Signature

2018-01-24 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Hi Kenny, and thanks, but I'm not sure what your point is. Are you claiming this is a bug in the code or the documentation? For what it is worth... mutable defaults *are* a "gotcha", so the documentation isn't wr

[issue32619] multiplication error

2018-01-22 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This is not a bug, it is a FAQ to do with the properties of binary floating point numbers. https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate -- nosy: +steven.daprano reso

[issue32607] After Python Installation Error

2018-01-21 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: This looks like a broken or incorrectly configured Django installation. What happens when you run this from your operating system shell? python3.6 -E -S If you are on Windows, you might need to use this instead: py

[issue32589] Statistics as a result from timeit

2018-01-20 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Fri, Jan 19, 2018 at 11:48:46PM +, STINNER Victor wrote: > The timeit module of the stdlib computes 5 values by default... I'm > not sure that it's revelant to compute the standard deviation only on > 5

[issue32603] Deprecation warning on strings used in re module

2018-01-19 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I agree with Cheryl that it would be a good idea to mention this change in the re docs, since regexes are especially likely to run into this issue. -- nosy: +steven.daprano ___

[issue32590] Proposal: add an "ensure(arg)" builtin for parameter validation

2018-01-18 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Since this is intended for argument checking, i.e. testing preconditions, the Eiffel term "require" seems more appropriate. https://www.eiffel.org/doc/eiffel/ET:%20Design%20by%20Contract%20(tm),%20Assertions%20

[issue32590] Proposal: add an "ensure(arg)" builtin for parameter validation

2018-01-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Oh I can just imagine the bike-shedding on this one :-) I'm not really convinced this is needed, but for what it's worth I think that given the intended use-case (checking function parameters) ValueError would be

[issue32589] Statistics as a result from timeit

2018-01-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: > What sort of statistics...? I answered my own question... I see that in your PR, you return a dict with the mean, median, *population* variance and standard deviation, and total. Why the population variance/stdev ra

[issue32589] Statistics as a result from timeit

2018-01-17 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: What sort of statistics, and why do you think they are going to be meaningful? Measurement errors in the timings aren't two-sided, they are only one-sided, which means calculating the mean and standard deviation isn't appro

[issue32543] odd floor division behavior

2018-01-12 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: That does look at first glance like a bug in // to me. 0.9/0.1 is correctly rounded to 9.0 exactly, so flooring it should return 9 (as it does): # Python 3.5 on Linux py> 0.9/0.1 == 9 True py> math.floor(0.9/0.1) 9 So

[issue32510] Broken comparisons (probably caused by wrong caching of values)

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Oh, by the way... are you aware that the Recursor class defines a class attribute `branches` which is shared by all instances? You create multiple recursor objects, but they all share the same `branches` attribute. That

[issue32510] Broken comparisons (probably caused by wrong caching of values)

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: That is nearly two hundred lines of quite complex code. What results are you expecting and what results are you getting? I've just tried running it under Python 3.3 and 3.5 on a RedHat-based Linux, and after generating a

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-07 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Tim Peters said: > Right, "..." immediately after a ">>>" line is taken to indicate a code > continuation line, and there's no way to stop that short of rewriting the > parser.

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Oops, somehow managed to accidentally unsubscribe r.david.murray -- nosy: +r.david.murray ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Here's a simple demonstration of the issue: # --- cut %< --- import doctest def hash_files(): """ >>> hash_files() # doctest: +ELLIPSIS ... d41d8cd98f00b204e9800998ecf8427e __ini

[issue32508] Problem while reading back from a list of lists

2018-01-06 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: It isn't clear to me what bug you are reporting here: - What do you mean by "problem reading back from a list of lists"? What sort of problem? - What makes you think that there is a bug in the interpreter, rath

[issue32474] argparse nargs should support string wrapped integers too

2017-12-31 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: > Values like "1", "2", "3", should be supported. You mean you want to call parser.add_argument('--foo', nargs="2") inste

[issue32474] argparse nargs should support string wrapped integers too

2017-12-31 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: What do you mean by "string wrapped integers", and how should it support them? -- nosy: +steven.daprano ___ Python tracker <rep...@bugs.python.org> <https://b

[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: In British, Australian, New Zealander, and Indian English (and sometimes Canada), at least, "bracket" on its own typically means round brackets () and is rarely if ever used for square brackets [] or curly bra

[issue32413] Document that locals() may return globals()

2017-12-22 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: The obvious documentation for locals() fails to mention that when called from the top level of a module (outside of a function or class body) it returns the same dict as globals(). https://docs.python.org/2/l

[issue32412] help() of bitwise operators should mention sets as well

2017-12-22 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: If you ask for help on the set operators ^ & and | then help docs only talk about them as bitwise operators. Since sets and frozensets are important, built-in types, the help should mention them as well. -

[issue32321] functools.reduce has a redundant guard or needs a pure Python fallback

2017-12-14 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: The functools module imports reduce from _functools, using a guard in case it is not present: try: from _functools import reduce except ImportError: pass However, the documentation says nothing about reduce

[issue32301] Typo in array documentation

2017-12-13 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: The given version is correct: the comma is only required if the initializer is given. Your suggested version typecode, [initializer] implies that the comma is always required whether the initializer is given or not.

[issue32289] Glossary does not define "extended slicing"

2017-12-12 Thread Steven D'Aprano
New submission from Steven D'Aprano <steve+pyt...@pearwood.info>: Looking at issue 32288, I realised that the glossary doesn't define "extended slicing" or "extended slice", even though they are common terms. Although I thought I know what they meant, on closer refl

[issue32288] Inconsistent behavior with slice assignment?

2017-12-12 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Please don't report three issues under one ticket, unless they are so closely related that they cannot be separated. I don't understand what your second issue actually is. You refer to the docs that specify extended

[issue32285] In `unicodedata`, it should be possible to check a unistr's normal form without necessarily copying it

2017-12-12 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: Python 2.7 is in feature freeze, so this can only go into 3.7. I would find this useful, and would like this feature. However, I'm concerned by your comment that you fall back on creating a normalized copy and com

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Sun, Dec 10, 2017 at 10:00:27AM +, Camion wrote: > Understanding that, I suggest to simply add "(expected 'tuple')" at the end > of the message. > ex : TypeError: 'int' object is not

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: On Sun, Dec 10, 2017 at 09:15:16AM +, Serhiy Storchaka wrote: > My point is that the current error message is correct and is not misleading. With respect Serhiy, in this bug report you have TWO PEOPLE who h

[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-09 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I agree with Camion that the error message is misleading, and not just for beginners. It threw me for a loop too, when I first read it. Serhiy is right, the exception type cannot and should not be changed, but we can

[issue32242] loop in loop with with 'zip'ped object misbehaves in py3.6

2017-12-07 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I decided to run the code in 3.5 and 2.7, and now that I know what I'm looking for, I can see the results buried in the Anaconda notebook. This is not a bug, zip has been changed in Python 3 to return an iterator i

[issue32242] loop in loop with with 'zip'ped object misbehaves in py3.6

2017-12-07 Thread Steven D'Aprano
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment: I'm sorry, I have no idea how to read an Anaconda notebook file. In the browser it looks like some sort of nested dictionary. I can find the code: j = [1, 2, 3, 4] k = [5, 6, 7, 8] z = zip(j, k) for x, y in z: for m,

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