[issue36549] str.capitalize should titlecase the first character not uppercase

2019-04-07 Thread Steven D'Aprano
New submission from Steven D'Aprano : str.capitalize appears to uppercase the first character of the string, which is okay for ASCII but not for non-English letters. For example, the letter NJ in Croatian appears as Nj at the start of words when the first character is capitalized: Njemačka

[issue36493] Add math.midpoint(a,b) function

2019-04-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: I see this has been rejected for the math module, but I wonder whether it should be considered for Decimal? I recall Mark Dickinson demonstrating this lovely little bit of behaviour: py> from decimal import getcontext, Decimal py> getcontext().prec

[issue36507] frozenset type breaks ZFC

2019-04-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: (Aside: that's interesting, normally if I try to post a comment to an issue, and somebody else edits it in the meantime, the message doesn't get posted and I get a error message saying that the page has been edited. This time I did

[issue36507] frozenset type breaks ZFC

2019-04-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Python is a programming language, and we're probably not going to care too much about compliance with ZFC set theory unless there is good *practical* and not theoretical reason to care. That's not to say that we want to break ZFC, only that if we do so, we

[issue35224] PEP 572: Assignment Expressions

2019-03-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: You are one person, who has used this feature for what, a month elapsed time? 300 person-hours actual experience with it? Allowing top-level unparenthisized walrus expressions will affect hundreds of thousands of people, for collectively millions of hours

[issue27181] Add geometric mean to `statistics` module

2019-03-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: > In the spirit of "perfect is the enemy of good", would it be > reasonable to start with a simple, fast implementation using > exp-mean-log? Then if someone wants to make it more accurate later, > they can do so. I think tha

[issue6422] timeit called from within Python should allow autoranging

2019-03-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Were you working on the additional functionality that you mentioned in > msg272704 or would that be open for someone else to do? Thanks! Please consider it open. I don't expect it to be difficult, it's just finding the Round Tuits. Perhaps an easy

[issue36324] Inverse cumulative normal distribution function

2019-03-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Tue, Mar 19, 2019 at 01:06:45AM +, Steven D'Aprano wrote: > Later I will do some spot checks against the results returned by the Nspire > calculator Looks good to me, they agree to 6 decimal places in my tests. Following Mark's earlier investi

[issue36324] Inverse cumulative normal distribution function

2019-03-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Looks good to me. Later I will do some spot checks against the results returned by the Nspire calculator, but in the meantime I think this can go in. Thanks for your efforts Raymond, I think this NormalDist is shaping up to be a great addition

[issue36314] Pivot_Table Docstring Error

2019-03-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: Prakhar, for future reference, please don't submit unnecessary screenshots to report bugs. Screen shots are hostile to the blind or visually impaired, who may be reading this with a screen-reader, and they make it impossible for us to copy your code to run

[issue36283] eval is needlessly limited

2019-03-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: > The footnote about why eval/exec cannot be used for arbitrary code Which footnote? I see nothing here: https://docs.python.org/3/library/functions.html#eval > On that point, I still don't understand why PyObject_GetItem doesn'

[issue36018] Add a Normal Distribution class to the statistics module

2019-03-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I'm assuming you meant 5.374 rather than 5.372 in the first Nspire result. Yes, that was a typo, sorry. Thanks for checking into the results. -- ___ Python tracker <https://bugs.python.org/issu

[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-03-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Looks good to me, I'm happy to accept it. Thank you for your efforts Raymond, can I trouble you to do the merge yourself please, I'm still having issues using the Github website. -- ___ Python tracker <ht

[issue36018] Add a Normal Distribution class to the statistics module

2019-03-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've done some spot checks of NormDist.pdf and .cdf and compared the results to those returned by my TI Nspire calculator. So far, the PDF has matched that of the Nspire to 12 decimal places (the limit the calculator will show), but the CDF differs

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

2019-03-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm closing this issue in favour of Raymond's #35892, thank you to everyone even if your PRs didn't get used, I appreciate your efforts. -- resolution: -> rejected stage: patch review -> resolved status: open -&g

[issue36259] exception text is being sourced from the wrong file

2019-03-10 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue36259> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36255] Provide a simple way to delete and edit python's welcome message

2019-03-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: Why do you want to disable the welcome message? > I just want to add a line after the first one to give system information. Sounds like you just want to print something extra, after the welcome message has been printed. -- nosy: +steven.dapr

[issue36248] document about `or`, `and` operator.

2019-03-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: Document *what* about the behaviour shown? I'm sure you don't mean to say that we should document the fact the *literally* `1 or 0 and 3` returns 1, but I don't know what you think we should document beyond what is already stated in the existing docs

[issue36243] Python os.listdir fails with FileNotFoundError when directory exists

2019-03-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: > How can this happen? Easily -- this looks like a "Time Of Check To Time Of Use" bug. You check for the existence of a directory, and then a fraction of a second later you attempt to use that directory. But on a multi-processing operatin

[issue36206] re.match() not matching escaped hyphens

2019-03-05 Thread Steven D'Aprano
Steven D'Aprano added the comment: You don't escape the text you are searching. Try this: py> re.match(re.escape('-'), "-") <_sre.SRE_Match object; span=(0, 1), match='-'> py> re.match(re.escape('a-c'), "a-c") <_sre.SRE_Match object; span=(0

[issue36178] type.__init__ called instead of cls.__init__ when inheriting from type.

2019-03-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: Your metaclass.__new__ method returns None instead of the new class. The rule for calling __init__ is: - if the constructor __new__ returns an instance of the type, then call the initializer __init__ - otherwise, don't call __init__ at all. https

[issue36173] BROTHER PRINTER CENTER

2019-03-03 Thread Steven D'Aprano
New submission from Steven D'Aprano : No details given and a spammy, irrelevant title. Closing. Dianmatang, if you are an actual person and not a spam bot, please try adding details of the bug, and using a more informative title. -- nosy: +steven.daprano resolution: -> not a

[issue36158] Regex search behaves differently in list comprehension

2019-03-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: > i want to apply a regex on a list of strings. The example you give doesn't include a list of strings, it has some unknown "entity" object with an unknown "trigger" attribute. Please refactor the code to remove the use of a cla

[issue36163] same object, same method, but the is keyword return false.

2019-03-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: The ``is`` operator returns False because the two objects are different objects. Methods are descriptors, and whenever you access an instance method, you get a brand-new method object. This is described in the documentation for descriptors: https

[issue36156] different method, but id function return same value.

2019-03-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: bugs.python.org seems to be down at the moment, so please forgive me if this ticket has already been closed and I'm repeating what has already been said. > This is guaranteed to be unique among simultaneously existing objects. Note the *simultaneou

[issue36151] Incorrect answer when calculating 11/3

2019-02-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: Aiden: in the future, please do not post unnecessary screenshots of text. They are hostile to the blind and slight-impaired, they make it impossible to copy your code and run it ourselves, and they cannot be searched for. Instead, copy and paste the text

[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-02-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Proposed spec: > ''' > Modify the API statistics.mode to handle multimodal cases so that the > first mode encountered is the one returned. If the input is empty, > raise a StatisticsError. Are you happy guaranteeing that it will always be

[issue36118] Cannot correctly concatenate nested list that contains more than ~45 entries with other nested lists.

2019-02-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: I cannot reproduce the behaviour you show. First problem: ``...`` is a legal Python object, Ellipsis, so your example code literally means: # x = [["a", "b", ... , "BZ"]] x is a list containing one sublist, which contains ex

[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-02-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: What do people think about leaving this as an "Easy First Issue" for the sprint? If others agree that it is sufficiently easy, we can assign the task to Cheryl. It should be fairly easy: mode calls an internal function _counts which is n

[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-02-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: Executive summary: - let's change the behaviour of mode to return a single mode rather than raise an exception if there are multimodes; - and let's do it without a depreciation period. Further comments in no particular order: I agree that in practice

[issue36111] Negative `offset` values are no longer acceptable with implementation of `seek` with python3; should be per POSIX

2019-02-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: I believe you will find that this is because you opened the file in text mode, which means Unicode, not bytes. If you open it in binary mode, the POSIX spec applies: py> fp = open("sample", "rb"); fp.seek(-100, os.SEEK_END

[issue36100] Document the differences between str.isdigit, isdecimal and isnumeric

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm re-opening the ticket with a change of subject, because I think this should be treated as a documentation enhancement: - improve the docstrings for str.isdigit, isnumeric and isdecimal to make it clear what each does (e.g. what counts as a digit

[issue36100] int() and float() should accept any isnumeric() digit

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Feb 24, 2019 at 11:07:41AM +, Karthikeyan Singaravelan wrote: > Is this worth an FAQ or an addition to the existing note on int that > specifies characters should belong to 'Nd' category to add a note that > str.isdecimal should re

[issue36100] int() and float() should accept any isnumeric() digit

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think that analysis is wrong. The Wikipedia page describes the meaning of the Unicode Decimal/Digit/Numeric properties: https://en.wikipedia.org/wiki/Unicode_character_property#Numeric_values_and_types and the characters you show aren't appropriate

[issue36099] Clarify the difference between mu and xbar in the statistics documentation

2019-02-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm happy with that doc change. If nobody objects, this might make an easy "Good first issue" for the upcoming sprint. Assigning to Cheryl to stop anyone else grabbing it. -- assignee: docs@python -> cheryl.sabella nosy: +c

[issue36018] Add a Normal Distribution class to the statistics module

2019-02-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: Davin: the chice of using mu versus xbar was deliberate, as they represent different quantities: the population mean versus a sample mean. But reading over the docs with fresh eyes, I can now see that the distinction is not as clear as I intended. I think

[issue36099] Clarify the difference between mu and xbar in the statistics documentation

2019-02-23 Thread Steven D'Aprano
New submission from Steven D'Aprano : The documentation isn't clear as to the difference between mu and xbar, and why one is used in variance and the other in pvariance. See #36018 for discussion. For the record: mu or μ is the population parameter, i.e. the mean of the entire population

[issue36018] Add a Normal Distribution class to the statistics module

2019-02-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: Karthikeyan: thanks for the hint about Github. Raymond: thanks for the diff. Some comments: Why use object.__setattr__(self, 'mu', mu) instead of self.mu = mu in the __init__ method? Should __pos__ return a copy rather than the instance itself? The rest

[issue36018] Add a Normal Distribution class to the statistics module

2019-02-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks Raymond. Apologies for commenting here instead of at the PR. While I've been fighting with more intermittedly broken than usual internet access, Github has stopped supporting my browser. I can't upgrade the browser without upgrading the OS, and I

[issue35904] Add statistics.fmean(seq)

2019-02-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: PR looks good to me, thanks Raymond. Just at the moment I'm having problems with my internet connection leading to technical difficulties with Github. Hopefully I can resolve this soon. -- ___ Python tracker

[issue36018] Add a Normal Distribution class to the statistics module

2019-02-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: I like this idea! Should the "examples" method be re-named "samples"? That's the word used in the docstring, and it matches the from_samples method. -- ___ Python tracker <https://bug

[issue36027] Consider adding modular multiplicative inverse to the math module

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

[issue36028] Integer Division discrepancy with float

2019-02-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Changing the title from referring to "decimal" to "float", since this has nothing to do with the decimal module or Decimal type. Like Raymond and Tim, I too cannot reproduce the claimed difference in behaviour between Python

[issue36026] Different error message when sys.settrace is used (regressions)

2019-02-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Do I correctly understand the reported problem here? set.add(0) correctly raises TypeError in each case, but: (1) the exception message changes between versions; (2) and also changes depending on whether or not sys.trace is active. I don't think

[issue36000] __debug__ is a keyword but not a keyword

2019-02-15 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm not sure that __debug__ is a proper keyword. Unlike None, if you monkey-patch builtins, you can modify it: py> builtins.__dict__['__debug__'] = 'Surprise!' py> __debug__ 'Surprise!' py> builtins.__dict__['None'] = 'Surprise!' py

[issue35986] print() documentation typo?

2019-02-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: Which documentation are you referring to? The docstring says: print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) which is clearly a space. The docs here: https://docs.python.org/3/library/functions.html#print say something very similar

[issue35980] Py3 BIF random.choices() is O(N**2) but I've written O(N) code for the same task

2019-02-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: What's "BIF" mean? You use that term multiple times but I have never heard it before. I'm sorry, I don't understand your code (and don't have time to study it in detail to decipher it). It would help if you factored out your new implementation

[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-02-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks Raymond for the interesting use-case. The original design of mode() was support only the basic form taught in secondary schools, namely a single unique mode for categorical data or discrete numerical data. I think it is time to consider a richer

[issue35904] Add statistics.fmean(seq)

2019-02-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Would you like me to submit a PR with docs and tests? Yes please! I'm happy with the name fmean. -- ___ Python tracker <https://bugs.python.org/issu

[issue21625] help()'s more-mode is frustrating

2019-02-09 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano versions: +Python 3.8 -Python 2.7, Python 3.5 ___ Python tracker <https://bugs.python.org/issue21

[issue35937] Add instancemethod to types.py

2019-02-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: I presume you aren't referring to this: from types import MethodType > There really isn't anything else to say about it How about starting with why you want this and what you will do with it? According to this post on StackOverflow: ht

[issue35904] Add statistics.fmean(seq)

2019-02-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oh, I seem to have accidentally reverted the change of title. Sorry, that was definitely not intended and I don't know how it happened. But now that it has, I'm not going to change it until we have a decision on a name

[issue35938] crash of METADATA file cannot be fixed by reinstall of python

2019-02-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: That's not a crash. You are trying to install a package using pip, pip sees that it is missing the METADATA file and reports a problem. That is working correctly, not a crash. There is no way for us to know how the metadata file got deleted. Maybe you

[issue35904] Add statistics.fmean(seq)

2019-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: > On my current 3.8 build, this code given an approx 500x speed-up On my system, I only get a 30x speed-up using your timeit code. Using ints instead of random floats, I only get a 9x speed-up. This just goes to show how sensitive these timing resu

[issue35904] Add statistics.fmean(seq)

2019-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: >def fmean(seq: Sequence[float]) -> float: >return math.fsum(seq) / len(seq) Is it intentional that this doesn't support iterators? -- ___ Python tracker <https://bugs.python.or

[issue35904] Add statistics.fmean(seq)

2019-02-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: In the PEP, I did say that I was making no attempt to compete with numpy for speed, and that correctness was more important than speed. That doesn't mean I don't care about speed. Nor do I necessarily care about absolute precision when given nothing

[issue22228] Adapt bash readline operate-and-get-next function

2019-02-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: If the licencing issue is resolved, can we reconsider this for 3.8? -- versions: +Python 3.8 -Python 3.6 ___ Python tracker <https://bugs.python.org/issue22

[issue35880] math.sin has no backward error; this isn't documented

2019-02-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: > sin(1<<500) is correctly computed as 0.42925739234242827 py> math.sin(1<<500) 0.9996230490249484 Wolfram Alpha says it is 0.429257392342428277735329299112473759079115476327819897... https://www.wolframalpha.com/input/?i=sin%282^500%29

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: > For information - all taken from docs and Lib/*.py I'm sorry Jonathon, I don't see how they are relevant or interesting to the topic in hand other than "they're used to print stack traces". Okay, they're used to print stack traces. An

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: There may be something we can do to improve the error reporting and make it less perplexing: https://mail.python.org/pipermail/python-ideas/2019-January/055041.html -- ___ Python tracker <ht

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: > It should instead show the lines from the file as it was when the code was > executed. How is Python supposed to do that without making a copy of every module and script it runs just in case it gets modified? (That's not a rhetorical question --

[issue35431] Add a function for computing binomial coefficients to the math module

2019-01-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: > This involved a few changes, which seem to reflect the consensus here: > - raise ValueError if k>n ; > - rename the function to math.combinations. I see at least four people (myself, Raymond, Mark and Tim) giving comb as first choice, and

[issue35431] Add a function for computing binomial coefficients to the math module

2019-01-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sorry for the late reply, I missed Tim's comment when it first came through. > Please resist pointless feature creep. The original report was about > comb(n, k) for integer n and k with 0 <= k <= n and that's all. > Everyone who com

[issue35836] ZeroDivisionError class should have a __name__ attr

2019-01-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: You are not looking at the class, you are looking at an instance: py> exc = ZeroDivisionError('divide by zero') py> type(exc).__name__ 'ZeroDivisionError' py> exc.__name__ Traceback (most recent call last): File "", line 1,

[issue35834] get_type_hints exposes an instance of ForwardRef (internal class) in its result, with `from __future__ import annotations` enabled

2019-01-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: Wait, I just noticed that PEP563 says: "Note: if an annotation was a string literal already, it will still be wrapped in a string." https://www.python.org/dev/peps/pep-0563/#id5 In 3.8.0a I get this: py> from __future__ import annotations

[issue35834] get_type_hints exposes an instance of ForwardRef (internal class) in its result, with `from __future__ import annotations` enabled

2019-01-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Since Undef is not defined, I should get an exception when calling > get_type_hints One of the motives of PEP-563 is to make it easier to use forward references. I'm not sure, but it seems to me that given that, we should not get an exception

[issue35830] building multiple (binary) packages from a single project

2019-01-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is a bug tracker for reporting bugs and enhancement requests, not a help desk. Do you have a *specific* feature request or a bug to report? If not, you should ask this on a community forum such as Stackoverflow, Reddit's r/learnpython, the Python

[issue35779] Print friendly version message in REPL

2019-01-22 Thread Steven D'Aprano
Steven D'Aprano added the comment: > We only print simplified message in official binary release, any > Linux/private builds still using the current message. We know enough > information about official binary release. Who is "we" in this sentence? Are you saying that th

[issue20479] Efficiently support weight/frequency mappings in the statistics module

2019-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: Here is some further information on weights in statistics in general, and SAS and Stata specifically: https://blogs.sas.com/content/iml/2017/10/02/weight-variables-in-statistics-sas.html Quote: use the FREQ statement to specify integer frequencies

[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

2019-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I'm off to write an ugly `next()` wrapper then. Wouldn't it be simpler to re-design the generators to yield the final result instead of returning it? To process the final item differently from the rest, you just need something like this: last = n

[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

2019-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: > steven your generator example is exactly what I wanted to do; looks > like I'm upgrading to Python 3.8 for the new assignment syntax. Sorry to have mislead you, but I don't think it will do what I thought. After giving it some more thought, I d

[issue35775] Add a general selection function to statistics

2019-01-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: Rémi. I've read over your patch and have some comments: (1) You call sorted() to produce a list, but then instead of retrieving the item using ``data[i-1]`` you use ``itertools.islice``. That seems unnecessary to me. Do you have a reason for using ``islice

[issue35748] urlparse library detecting wrong hostname leads to open redirect vulnerability

2019-01-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: > The “urllib.parse” module generally follows RFC 3986, which does not > allow a literal backslash in the “userinfo” part: And yet the parse() function seems to allow arbitrary unescaped characters. This is from 3.8.0a0: py> from urllib.par

[issue20479] Efficiently support weight/frequency mappings in the statistics module

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Is this proposal still relevant? Yes. As Raymond says, deciding on a good API is the hard part. Its relatively simple to change a poor implementation for a better one, but backwards compatibility means that changing the API is very difficult. I wo

[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Fri, Jan 18, 2019 at 12:31:51AM +, bryan.koch wrote: > Thank you both for the clarifications. I agree these's no bug in > `yield from` however is there a way to reference the return value when > a generator with a return is invoked using

[issue35748] urlparse library detecting wrong hostname leads to open redirect vulnerability

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: I believe that Python's behaviour here is correct. You are supplying a netloc which includes a username "www.google.com\" with no password. That might be what you intend to do, or it might be malicious data. That depends on context, and the urlpa

[issue35779] Print friendly version message in REPL

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: The version message doesn't look "too complicated" to me. It looks no more complicated as that which Python has always displayed, going back to Python 1.5 (the oldest version I still have access to). Python 1.5.2 (#1, Aug 27 2012, 09:09:18)

[issue35775] Add a general selection function to statistics

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Fri, Jan 18, 2019 at 11:13:41PM +, Rémi Lapeyre wrote: > Wouldn't be the 5-th percentile be select(data, round(len(data)/20)? Oh if only it were that simple! Using the method you suggest, the 50th percentile is not the same as the median unl

[issue35775] Add a general selection function to statistics

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm very interested in adding quartiles and general quantiles/fractiles, but I'm not so sure that this select(data, index) function would be useful. Can you explain how you would use this? -- ___ Python tracker

[issue35777] mismatched eval() and ast.literal_eval() behavior with unicode_literals

2019-01-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: Python 2.7 has long passed feature freeze, and this would be new behaviour appearing in a bug-fix release, which we don't normally do. I'm going to close this as Rejected, but if you think you can make a good case for why this enhancement is sufficiently

[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

2019-01-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I understood the PEP to include `return expr` in the iteration values > as per the first bullet of the proposal. > > > Any values that the iterator yields are passed directly to the caller. > > This bullet doesn't have any

[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

2019-01-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: You say: > The PEP reads as if returning a value via StopIteration was meant to signal > that the generator was finished and that StopIteration.value was the final > value. To me, the PEP is clear that `return expr` is equivalent to `raise Stop

[issue35698] [statistics] Division by 2 in statistics.median

2019-01-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree that for numeric data, it isn't worth changing the behaviour of median to avoid the division in the case of two equal middle values. Even if we did accept this feature request, it is not going to eliminate the change in type in all circumstances

[issue35725] Using for...in.. generator-iterator

2019-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, it is standard behaviour for all iterators, not just generators. For loops work by calling next() on the iterator object, if you call next() on the same object inside the loop, that has the effect of advancing the for loop. You say

[issue35712] Make NotImplemented unusable in boolean context

2019-01-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: > the canonical __ne__ delegation to __eq__ for any class should be implemented > as something like I disagree that your code snippet is the canonical way to write __ne__. I'd write it like this: def __ne__(self, other): return not

[issue35714] Document that the null character '\0' terminates a struct format spec

2019-01-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm not sure whether having NULLs terminate a struct format string is a feature or a bug. Given that nearly every other string in Python treat NULLs as ordinary characters, I'm inclined to say this is a bug. Or at least an unnecessary restriction

[issue35672] Error on divide

2019-01-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: There is no need to call int() on a literal int: 103 is already an int, calling int() on it is just wasting time and making confusing code. print (int(y1y2y3y4)) gives a NameError, since you don't have a variable "y1y2y3y4" defined. Ple

[issue35658] Reggie_Linear_Regression_Solution.ipynb devide by 10 diff with multiply by .1

2019-01-04 Thread Steven D'Aprano
Steven D'Aprano added the comment: Not a bug. 0.1 is a binary floating point value, please read the FAQs: https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate 1/10 = 0.1 in decimal cannot be represented *exactly* in binary floating point, so when you

[issue35431] Add a function for computing binomial coefficients to the math module

2019-01-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: > return (-1)**k * bincoeff(n+k+1, k) Oops, that's meant to be n+k-1. -- ___ Python tracker <https://bugs.python.org/issu

[issue35431] Add a function for computing binomial coefficients to the math module

2019-01-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: > should the function be expanded to calculate for negative > n or is the function expected to work only in combination sense? If this were my design, I would offer both but in separate functions: def comb(n, k): if n < 0: raise ValueError

[issue35654] Remove 'guarantee' that sorting only relies on __lt__ from sorting howto

2019-01-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: > That sort currently uses __lt__ only is, in my opinion, an implementation > detail. Its only an implementation detail until the language specification defines it as a guarantee of the language. Then it becomes part of the sorting API. Persona

[issue35639] Lowecasing Unicode Characters

2019-01-03 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue35639> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35645] Alarm usage

2019-01-02 Thread Steven D'Aprano
Change by Steven D'Aprano : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue35645] Alarm usage

2019-01-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: This bug report is incoherent. This has nothing to do with alarms or regular expressions, and I don't know what your code is supposed to do or what results you are expecting. What's "a calci programe"? You ask: "Do we have any ways to r

[issue35626] Python dictreader KeyError issue

2018-12-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: Can you please provide a *simple* and *complete* demonstration, including the *full* traceback? As given, we cannot run the supplied code and don't know what the contents of the csv file are supposed to be. See here for more detail: http://www.sscce.org

[issue35612] Text wrap over text containing tab character

2018-12-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think you may be misunderstanding what you are seeing. The documentation for textwrap.wrap says: By default, tabs in 'text' are expanded with string.expandtabs() which converts tabs to one or more spaces, enough to align to some multiple of column 8

[issue35604] Is python used more than Java Nowadays?

2018-12-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is spam. -- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue35600] Expose siphash

2018-12-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Steven, my requirement calls for same hash on multiple machines. > Python's hash (for strings) is keyed with a random value. Ah, of course it does, I forgot about that. The only problem with exposing siphash is that we are exposing a p

[issue35600] Expose siphash

2018-12-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: > In the old days I'd just `hash(some_variable)` but of course now I cannot. I'm sorry, I don't understand... why can't you? py> text = "NOBODY expects the Spanish Inquisition!" py> hash(text) 1245575277 There's also this: py> h

[issue35597] Bug in Python's compiler

2018-12-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: For future reference, please don't give screen shots when reporting bugs. Code is text, and we don't edit code with Photoshop. Copy and paste the text, don't take a screen shot. Screen shots make it impossible to run the code, and they are difficult

<    3   4   5   6   7   8   9   10   11   12   >