[ANN] Datatest 0.11.1 Released

2021-01-03 Thread Shawn Brown
I'm pleased to announce version 0.11.1 of Datatest: Test driven
data-wrangling and data validation.

Test driven data-wrangling is a process for taking data from a source of
unverified quality or format and producing a verified, well-formatted
dataset. It repurposes software testing practices for data preparation and
quality assurance projects.

* GitHub: https://github.com/shawnbrown/datatest
* PyPI: https://pypi.org/project/datatest/
* Docs: https://datatest.readthedocs.io/en/stable/

This is a bug-fix release and should be a drop-in replacement for 0.11.0.
Changes include:

* Fixed validation, predicate, and difference handling of non-comparable
  objects.
* Fixed bug in normalization of queries from `squint` package.
* Changed failure output to improve error reporting with `pandas` accessors.
* Changed predicate failure message to quote code objects using backticks.
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[issue42584] Upgrade macOS and Windows installers to use SQLite 3.34.0

2021-01-03 Thread Ned Deily


Ned Deily  added the comment:


New changeset c94ee13ad596d26d1859078bc09806aa59bb by Erlend Egeberg 
Aasland in branch 'master':
bpo-42584: Update macOS installer to use SQLite 3.34.0 (GH-23674)
https://github.com/python/cpython/commit/c94ee13ad596d26d1859078bc09806aa59bb


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy:  -rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread Guido van Rossum

Guido van Rossum  added the comment:

This issue probably needs a new champion. There is broad agreement but some
bike shedding, so a PEP isn’t needed.--
--Guido (mobile)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread karl


Change by karl :


--
nosy: +karlcow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42820] Sphinx conf.py needs_version entry is outdated

2021-01-03 Thread Tim Hoffmann


New submission from Tim Hoffmann :

The sphinx conf.py entry `needs_version=1.8` 
(https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/conf.py#L48)

is not in sync with the doc build requirements 
(https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/requirements.txt#L6)

Possible solutions:
a) Drop the `needs_version` config value. It's optional.
b) Make sure to update both places.
c) Or at minimum add a comment that `needs_version` is only a safeguard against 
very old sphinx versions but is not necessarily sufficient to build.

--
assignee: docs@python
components: Documentation
messages: 384305
nosy: docs@python, timhoffm
priority: normal
severity: normal
status: open
title: Sphinx conf.py needs_version entry is outdated

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] Incorrect range checks/documentation in curses

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:

> This change seems to broke some buildbots.

Yep, see also bpo-42789.

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:

> Buildbot failure: ARM Raspbian 3.x: (...)

As expected, the 3.8 and 3.9 change also broke 11 buildbots (3.8 and 3.8) ;-) I 
understand that bpo-42681 will fix buildbots.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] Incorrect range checks/documentation in curses

2021-01-03 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This change seems to broke some buildbots. For instance:

https://buildbot.python.org/all/#/builders/119/builds/153


==
ERROR: test_colors_funcs (test.test_curses.TestCurses)
--
Traceback (most recent call last):
  File 
"/home/dje/cpython-buildarea/3.8.edelsohn-rhel8-z/build/Lib/test/test_curses.py",
 line 310, in test_colors_funcs
curses.pair_content(min(curses.COLOR_PAIRS - 1, 0x7fff))
_curses.error: Argument 1 was out of range. (1..COLOR_PAIRS-1)
--
Ran 28 tests in 0.337s
FAILED (errors=1)
1 test failed again:
test_curses
== Tests result: FAILURE then FAILURE ==

--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] Incorrect range checks/documentation in curses

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22913
pull_request: https://github.com/python/cpython/pull/24079

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] Incorrect range checks/documentation in curses

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset b0ee2b492dbf550fbd2a63b82de0a4dc9d67f32e by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-42681: Fix range checks for color and pair numbers in curses 
(GH-23874). (GH-24077)
https://github.com/python/cpython/commit/b0ee2b492dbf550fbd2a63b82de0a4dc9d67f32e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 645174abe0d13cce2cb339cc80b095ad484428ea by Serhiy Storchaka in 
branch '3.8':
[3.8] [3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) 
(GH-24076) (GH-24078)
https://github.com/python/cpython/commit/645174abe0d13cce2cb339cc80b095ad484428ea


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Eric makes a pretty good point about how that ends up looking with days 
included and backward compatibility.

Thanks everyone for humouring me and talking me through this one I'm going to 
close the issue as "not a bug".

--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] Incorrect range checks/documentation in curses

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: mistake in curses documentation -> Incorrect range checks/documentation 
in curses

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22912
pull_request: https://github.com/python/cpython/pull/24078

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] mistake in curses documentation

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22911
pull_request: https://github.com/python/cpython/pull/24077

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0303008ebceb6ac6035cd9722d1393267304171d by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) (GH-24076)
https://github.com/python/cpython/commit/0303008ebceb6ac6035cd9722d1393267304171d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42819] readline 8.1 bracketed paste

2021-01-03 Thread Dustin Rodrigues


New submission from Dustin Rodrigues :

Readline 8.1 enables bracketed paste by default. Package managers like Homebrew 
for macOS and distributions like Arch Linux which use the latest version of 
readline (released December 2020) now have new behavior when pasting multiline 
strings into the python REPL. Disabling bracketed paste on 8.1 reverts to the 
expected behavior, and enabling bracketed paste on 8.0 also reproduces the 
behavior. Further information in 
https://github.com/Homebrew/homebrew-core/issues/68193

Example with bracketed paste on:
$ cat in
1+2
3+4
5+6

$ pbcopy < in
$ /usr/local/Cellar/python\@3.9/3.9.1_3/bin/python3
Python 3.9.1 (default, Dec 28 2020, 11:22:14) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2
3+4
5+6

  File "", line 1
1+2
3+4
5+6


   ^
SyntaxError: multiple statements found while compiling a single statement
>>> 



Example with it off:
$ /usr/local/bin/python3
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec  7 2020, 12:10:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2
3
>>> 3+4
7
>>> 5+6
11
>>>

--
messages: 384297
nosy: dtrodrigues
priority: normal
severity: normal
status: open
title: readline 8.1 bracketed paste
type: behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42681] mistake in curses documentation

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 1470edd6131c29b8a09ce012cdfee3afa269d553 by Serhiy Storchaka in 
branch 'master':
bpo-42681: Fix range checks for color and pair numbers in curses (GH-23874)
https://github.com/python/cpython/commit/1470edd6131c29b8a09ce012cdfee3afa269d553


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

In a date, hours are zero-padded probably because that's a common standard for 
military time dates. But there is no such standard for time periods, therefore 
timedelta don't have to match date display in respect to zero-padding, in my 
opinion.

--
nosy: +andrei.avk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: A random word from one of two lists

2021-01-03 Thread Mats Wichmann

On 1/3/21 11:34 AM, Richard Damon wrote:


It depends on what distribution of results you want. Since the example
had two equal length list is doesn't matter, but if, say, there were
many more animals then fruit, your method would produce an animal more
often than a fruit, but the two level method will make the distribution
50% fruits, 50% animals independent on the number in each category.

Which is the right answer is problem specific.


quite true!


--
https://mail.python.org/mailman/listinfo/python-list


[issue41463] Avoid duplicating jump information from opcode.py in compile.c

2021-01-03 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, unless you still want to backport?

--
nosy: +iritkatriel
resolution:  -> fixed
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ok, perhaps we should leave a comment about that? It already has a comment 
about multi-phase init.

What about Modules/_testbuffer.c and the xx-modules?

$ grep -E 'static PyTypeObject .* =' $(find . -name "*.c"|grep -vE 
'(Doc/|Modules/_testcapimodule)') | wc -l
94

$ grep -E 'PyType_Spec .* =' $(find . -name "*.c")|wc -l

(master)cpython.git
95

We're almost halfway there.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Copying column values up based on other column values

2021-01-03 Thread Codeliner
On Sunday, January 3, 2021 at 8:17:16 PM UTC+2, Codeliner wrote:
> On Sunday, January 3, 2021 at 7:08:49 PM UTC+2, Jason Friedman wrote: 
> > > 
> > > import numpy as np 
> > > import pandas as pd 
> > > from numpy.random import randn 
> > > df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z']) 
> > > 
> > > W X Y Z 
> > > A -0.183141 -0.398652 0.909746 0.332105 
> > > B -0.587611 -2.046930 1.446886 0.167606 
> > > C 1.142661 -0.861617 -0.180631 1.650463 
> > > D 1.174805 -0.957653 1.854577 0.335818 
> > > E -0.680611 -1.051793 1.448004 -0.490869 
> > > 
> > > is there a way to create a column S - which will copy column column Y 
> > > values UP- if values in column Y are above 1 - otherwise return new value 
> > > above zero?.I made this manually: 
> > > 
> > > S: 
> > > 
> > > A 1.446886 
> > > B 1.446886 
> > > C 1.854577 
> > > D 1.854577 
> > > E 1.448004 
> > > 
> > Here's one solution. No consideration to performance. 
> > import numpy as np 
> > import pandas as pd 
> > from numpy.random import randn 
> > df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z']) 
> > print(df) 
> > 
> > y_series = df["Y"] 
> > for i in range(len(y_series)): 
> > if i == len(y_series) - 1: 
> > # Last one, nothing to copy 
> > break 
> > if y_series[i+1] > 1: 
> > y_series[i] = y_series[i+1] 
> > 
> > df["Y"] = y_series 
> > print(df)
> Thank you Jason for this lovely for loop - is there a way to make this with 
> pandas series or numpy arrays? for maximum speed?


can something done along these lines?

df['run2'] = df['b'].apply(lambda x: df['b'].shift(1) if x > 1 else df['b'])
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A random word from one of two lists

2021-01-03 Thread Richard Damon
On 1/3/21 12:38 PM, Mats Wichmann wrote:
> On 1/3/21 5:30 AM, Bischoop wrote:
>> On 2021-01-02, Stefan Ram  wrote:
>>> Bischoop  writes:
 On 2021-01-02, Stefan Ram  wrote:
> Otherweise, I'd go this way without a dictionary.
> import random
> animal = ['koala', 'kangaroo']
> fruit = ['banana', 'apple']
> kinds = [animal,fruit]
> kind = random.choice( kinds )
> result = random.choice( kind )
> print( result )
 I had that solution in mind but I thought that one is not good
 programming style or not Pythonin :-)
>>>
>>>    I do not see any stylistic problem when you use this approach
>>>    with "nested lists". List indexing by a number should even be
>>>    faster than indexing a dictionary.
>>>
>>>
>> Now I know that's ok, seems I was ovethingking while solution was so
>> simply.
>>
>> -- 
>> Thanks
>>
>
> You don't really need to do this as a two-level selection:
>
> import random
> animal = ['koala', 'kangaroo']
> fruit = ['banana', 'apple']
> result = random.choice(animal + fruit)
> print(result)

It depends on what distribution of results you want. Since the example
had two equal length list is doesn't matter, but if, say, there were
many more animals then fruit, your method would produce an animal more
often than a fruit, but the two level method will make the distribution
50% fruits, 50% animals independent on the number in each category.

Which is the right answer is problem specific.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

Thanks for your perspective.

To summarize here is how my proposed enhancement might look in practice:

class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Copying column values up based on other column values

2021-01-03 Thread Codeliner
On Sunday, January 3, 2021 at 7:08:49 PM UTC+2, Jason Friedman wrote:
> > 
> > import numpy as np 
> > import pandas as pd 
> > from numpy.random import randn 
> > df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z']) 
> > 
> > W X Y Z 
> > A -0.183141 -0.398652 0.909746 0.332105 
> > B -0.587611 -2.046930 1.446886 0.167606 
> > C 1.142661 -0.861617 -0.180631 1.650463 
> > D 1.174805 -0.957653 1.854577 0.335818 
> > E -0.680611 -1.051793 1.448004 -0.490869 
> > 
> > is there a way to create a column S - which will copy column column Y 
> > values UP- if values in column Y are above 1 - otherwise return new value 
> > above zero?.I made this manually: 
> > 
> > S: 
> > 
> > A 1.446886 
> > B 1.446886 
> > C 1.854577 
> > D 1.854577 
> > E 1.448004 
> >
> Here's one solution. No consideration to performance.
> import numpy as np 
> import pandas as pd 
> from numpy.random import randn 
> df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z'])
> print(df) 
> 
> y_series = df["Y"] 
> for i in range(len(y_series)): 
> if i == len(y_series) - 1: 
> # Last one, nothing to copy 
> break 
> if y_series[i+1] > 1: 
> y_series[i] = y_series[i+1] 
> 
> df["Y"] = y_series 
> print(df)


Thank you Jason for this lovely for loop - is there a way to make this with 
pandas series or numpy arrays? for maximum speed?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42817] timedelta zeropadding hh

2021-01-03 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think zero padding makes sense. For example:

>>> td = datetime.timedelta(hours=100)
>>> str(td)
'4 days, 4:00:00'

I think '4 days, 04:00:00' would not be very user friendly.

In any event, backward compatibility would prevent us from changing this.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

> What is better?

Sorry, I can't answer this question.

I am a regular python user and I just tried to help with your issue.

I believe we should wait for someone from core team to answer this question.


> In your example, does Child foo call Parent foo? Because the intent is to use 
> the parent's foo method.

Sorry, I made a mistake, it definitely should call a parent method. A correct 
example will look like this:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
def foo(self, a, b):
super().foo(a=a, b=b)
```

But, the example above require more code to write, so a better option will be:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

@overload
def foo(self, **kwargs):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

I am not sure is it the perfect solution to solve your issue.

Let's wait for someone from core team, so we can hear their opinion.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

In your example, does Child foo call Parent foo? Because the intent is to use 
the parent's foo method.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

What is better?

A. Keeping Python as is, with four separate signature declarations (1x Parent, 
2x @overload Child, and 1x actual signature in Child), and a second method call 
overhead at runtime (to satisfy mypy as it exists now).

--or--

B. Simplify Python to allow just two signature declarations and no extra 
overhead? 

--or--

C. Something else? Please specify.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: A random word from one of two lists

2021-01-03 Thread Mats Wichmann

On 1/3/21 5:30 AM, Bischoop wrote:

On 2021-01-02, Stefan Ram  wrote:

Bischoop  writes:

On 2021-01-02, Stefan Ram  wrote:

Otherweise, I'd go this way without a dictionary.
import random
animal = ['koala', 'kangaroo']
fruit = ['banana', 'apple']
kinds = [animal,fruit]
kind = random.choice( kinds )
result = random.choice( kind )
print( result )

I had that solution in mind but I thought that one is not good
programming style or not Pythonin :-)


   I do not see any stylistic problem when you use this approach
   with "nested lists". List indexing by a number should even be
   faster than indexing a dictionary.



Now I know that's ok, seems I was ovethingking while solution was so
simply.

--
Thanks



You don't really need to do this as a two-level selection:

import random
animal = ['koala', 'kangaroo']
fruit = ['banana', 'apple']
result = random.choice(animal + fruit)
print(result)
--
https://mail.python.org/mailman/listinfo/python-list


[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

I think the simplest solution in your case is not to use `@overload`, as far as 
I understand you want to override the signature of base method.

This code won't produce any error when used with `mypy`:
```
class Parent:
def foo(**kwargs):
"""Argument names of foo vary depending on the child class."""

class Child(Parent):
def foo(self, a, b):
pass
``

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

Interesting. PyCharm has no problem with this code. It also autocompletes the 
argument names for me, which is very useful, especially since there a dozen 
different Child classes.

Isn't "Simple is better than complex", and doesn't "...practicality beat 
purity"?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

`mypy` will produce an error on such code:

```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

Result
```
temp.py:10: error: Single overload definition, multiple required
temp.py:10: error: Signature of "foo" incompatible with supertype "Parent"
Found 2 errors in 1 file (checked 1 source file)
```

In case if you want to add an overload for method I would recommend to use such 
pattern:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

@overload
def foo(self, **kwargs):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

So signature of `foo` will still match to parent class signature, but it will 
also have an overloaded variant.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Copying column values up based on other column values

2021-01-03 Thread Jason Friedman
>
> import numpy as np
> import pandas as pd
> from numpy.random import randn
> df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z'])
>
> W X Y Z
> A -0.183141 -0.398652 0.909746 0.332105
> B -0.587611 -2.046930 1.446886 0.167606
> C 1.142661 -0.861617 -0.180631 1.650463
> D 1.174805 -0.957653 1.854577 0.335818
> E -0.680611 -1.051793 1.448004 -0.490869
>
> is there a way to create a column S - which will copy column column Y
> values UP- if values in column Y are above 1 - otherwise return new value
> above zero?.I made this manually:
>
> S:
>
> A 1.446886
> B 1.446886
> C 1.854577
> D 1.854577
> E 1.448004
>

Here's one solution. No consideration to performance.

import numpy as np
import pandas as pd
from numpy.random import randn
df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z'])
print(df)

y_series = df["Y"]
for i in range(len(y_series)):
if i == len(y_series) - 1:
# Last one, nothing to copy
break
if y_series[i+1] > 1:
y_series[i] = y_series[i+1]

df["Y"] = y_series
print(df)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy: build script not finding correct python version [UPDATE]

2021-01-03 Thread Rich Shepard

On Sun, 3 Jan 2021, Rich Shepard wrote:


I'm trying to rebuild numpy-1.18.2 using the newly installed Python-3.9.1.
The script fails when running setup.py:
Traceback (most recent call last):
 File "setup.py", line 32, in 
   raise RuntimeError("Python version >= 3.5 required.")
RuntimeError: Python version >= 3.5 required.


Okay. Further research taught me that setup.py has been replaced with
setuptools so I need to learn how to convert the build script to setuptools
rather than setup.py.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

To clarify, this is how it's being done now a dozen times in actual production 
code:

class Child(Parent):
@overload foo(a, b): ...
def overload(**kwargs):
return super().foo(**kwargs)

The goal of this proposed enhancement is to remove two extra lines of code per 
Child class.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Copying column values up based on other column values

2021-01-03 Thread Codeliner
Hello,

I have this dataframe

import numpy as np
import pandas as pd
from numpy.random import randn
df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z'])


W X Y Z
A -0.183141 -0.398652 0.909746 0.332105
B -0.587611 -2.046930 1.446886 0.167606
C 1.142661 -0.861617 -0.180631 1.650463
D 1.174805 -0.957653 1.854577 0.335818
E -0.680611 -1.051793 1.448004 -0.490869

is there a way to create a column S - which will copy column column Y values 
UP- if values in column Y are above 1 - otherwise return new value above 
zero?.I made this manually:

S:

A 1.446886
B 1.446886
C 1.854577
D 1.854577
E 1.448004


thanks a lot!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

"The purpose of `@overload` is quite different." So, this would overload the 
@overload decorator. Hmmm...

Is there a better way to accomplish this goal? What would you suggest, a new 
decorator?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Question:
Why should it be zeropadded to 2?

Answer:
Why wouldn't it be zeropadded to match the rest of the library?

Honestly it just seemed like an inconsistency with the rest of the datetime 
module.

It caught me off guard when I went I tried to pull __str__ of a timedelta and 
the padding was different than what I saw elsewhere.

I figured it could potentially be a quick fix if the current behaviour is not 
desired.

I'm curious why that would have been rejected if it was even considered/noticed 
before.

Do you know of any good way to figure out if this was discussed before? So far 
all I have done for searching was a search of issues that were already brought 
up and I didn't find anything at first glance.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7c83eaa536d2f436ae46211ca48692f576c732f0 by Hai Shi in branch 
'master':
bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)
https://github.com/python/cpython/commit/7c83eaa536d2f436ae46211ca48692f576c732f0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Does windows edit .py file shebangs?

2021-01-03 Thread Barry Scott



> On 3 Jan 2021, at 15:13, Eryk Sun  wrote:
> 
> On 1/3/21, Barry Scott  wrote:
>> 
>> I've been doing some more investigation and found that the change happened
>> at 01/01/2021 16:16. The shebang is pointing to a 0 length PYTHON3.EXE.
> 
> The files in "%LocalAppData%\Microsoft\WindowsApps" are AppExec
> reparse points. NT filesystem reparse points are a generalized form of
> filesystem link, with registered handlers indentified by a tag value
> in the reparse data buffer. Various reparse-point types implement
> Unix-style mountpoints and symlinks, as well as dynamic offline and
> virtual files such as OneDrive.
> 
> AppExec reparse points (aka app execution aliases) have no handler in
> the kernel, so they can only be accessed by directly opening them.
> WinAPI CreateProcessW uses information in the link to locate the app
> and create an access token that allows executing it. The app itself is
> usually installed in a directory in "%ProgramFiles%\WindowsApps".
> 
> You can view the raw contents of a reparse point using `fsutil.exe
> reparsepoint query `.

Aha a reparse point! I've cleaned up too much to do this. 
I had to get back to a working state.

If it breaks again I'll use fsutils to investigate.

> 
>> Thinking back to the 1st I did run Visual Studio 2019 Community edition at
>> that time. It was first time on a long time and I had to login and update it.
> 
> You could try to reproduce the scenario to see whether it modifies
> your files. I wouldn't expect it to do something like that
> automatically, but it does seem like the kind of 'helpful' thing a
> full-service IDE would do when saving a script.

The only time I every use the IDE is when I run the debugger everything
else I do from the command line. The only reason I ran the IDE at all is
that is the way to get it to update itself.

In other words its not that it "fixed" a file I was editing. I can only think
that it was part of the updating of Visual Studio that did this.

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Does windows edit .py file shebangs?

2021-01-03 Thread Eryk Sun
On 1/3/21, Barry Scott  wrote:
>
> I've been doing some more investigation and found that the change happened
> at 01/01/2021 16:16. The shebang is pointing to a 0 length PYTHON3.EXE.

The files in "%LocalAppData%\Microsoft\WindowsApps" are AppExec
reparse points. NT filesystem reparse points are a generalized form of
filesystem link, with registered handlers indentified by a tag value
in the reparse data buffer. Various reparse-point types implement
Unix-style mountpoints and symlinks, as well as dynamic offline and
virtual files such as OneDrive.

AppExec reparse points (aka app execution aliases) have no handler in
the kernel, so they can only be accessed by directly opening them.
WinAPI CreateProcessW uses information in the link to locate the app
and create an access token that allows executing it. The app itself is
usually installed in a directory in "%ProgramFiles%\WindowsApps".

You can view the raw contents of a reparse point using `fsutil.exe
reparsepoint query `.

> Thinking back to the 1st I did run Visual Studio 2019 Community edition at
> that time. It was first time on a long time and I had to login and update it.

You could try to reproduce the scenario to see whether it modifies
your files. I wouldn't expect it to do something like that
automatically, but it does seem like the kind of 'helpful' thing a
full-service IDE would do when saving a script.
-- 
https://mail.python.org/mailman/listinfo/python-list


NumPy: build script not finding correct python version

2021-01-03 Thread Rich Shepard

I'm trying to rebuild numpy-1.18.2 using the newly installed Python-3.9.1.
The script fails when running setup.py:
Traceback (most recent call last):
  File "setup.py", line 32, in 
raise RuntimeError("Python version >= 3.5 required.")
RuntimeError: Python version >= 3.5 required.

When I invoke python3 from the command line the version is correctly
indentified:
$ python3
Python 3.9.1 (default, Dec 29 2020, 15:09:15) 
[GCC 5.5.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

import sys
sys.version_info[:2]

(3, 9)




Ignoring the large explanatory comment the lines above that throwing the
error are:
from __future__ import division, print_function

DOCLINES = (__doc__ or '').split("\n")

import os
import sys
import subprocess
import textwrap
import sysconfig


if sys.version_info[:2] < (3, 5):
raise RuntimeError("Python version >= 3.5 required.")

I'm not seeing why sys.version_info is not finding the installed version
within the script and need insight from others with greater Python knowledge
than I have.

TIA,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Mauritius Usergroup - End of Year report 2020

2021-01-03 Thread Alex Kaye
Super report, need more like it from others !

A.K.

On Sun, Jan 3, 2021 at 2:06 AM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Greetings,
>
> ^^ Thanks!
>
> Kind Regards,
>
> Abdur-Rahmaan Janhangeer
> about  | blog
> 
> github 
> Mauritius
>
>
> On Sun, Jan 3, 2021 at 8:12 AM dn via Python-list 
> wrote:
>
> > On 1/3/21 5:01 PM, Abdur-Rahmaan Janhangeer wrote:
> > > Greetings list,
> > >
> > > Here's our usergroup's end of year report for 2020:
> > > Happy reading!
> > >
> > > https://www.pymug.com/assets/pymug_end_of_year_2020_v2.pdf
> >
> >
> > Well done @A-R!
> > --
> > Regards =dn
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17343] Add a version of str.split which returns an iterator

2021-01-03 Thread Martin Winks


Martin Winks  added the comment:

> Perhaps the use case is already served by re.finditer()

def split_whitespace_ascii(s: str):
return (pt.group(0) for pt in re.finditer(r"[A-Za-z']+", s))

solution above does not cover all possible data and is incorrect for bytes-like 
objects.

writing regular expressions for different separators/data would be a quite 
overheadish, so the idea of one-case solution doesn't seem to go very far and 
requires a bigger change in code for different separators.

let's try to revive this one :)

--
nosy: +uwinx

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22910
pull_request: https://github.com/python/cpython/pull/24076

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42818] AttributeError: 'zipimporter' object has no attribute 'find_spec'

2021-01-03 Thread Klaus Ethgen


New submission from Klaus Ethgen :

I encountered the bug when installing a package with `python3 setup.py install 
--user`. After that, a second installation failed with this stack trace:
```
Traceback (most recent call last):  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2191, 
in _handle_ns   
loader = importer.find_spec(packageName).loader 
  
AttributeError: 'zipimporter' object has no attribute 'find_spec'   
  

During handling of the above exception, another exception occurred: 
  

Traceback (most recent call last):  
  
  File "/home/klaus/devel/upstream/pass-git-helper/setup.py", line 1, in 

 
from setuptools import setup
  
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 16, in 

  
import setuptools.version   
  
  File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in 


import pkg_resources
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3239, 
in  
def _initialize_master_working_set():   
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3222, 
in _call_aside  
f(*args, **kwargs)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3264, 
in _initialize_master_working_set   
tuple(  

  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3265, 
in 
dist.activate(replace=False)
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2780, 
in activate 
declare_namespace(pkg)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2279, 
in declare_namespace
_handle_ns(packageName, path_item)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2196, 
in _handle_ns   
loader = importer.find_spec(packageName)
  
AttributeError: 'zipimporter' object has no attribute 'find_spec'
```

This error happens now also with different tools.

Solution is to `rm -fr ~/.local/lib`. But the next installation triggers the 
bug again.

The only solution is to install via `python3 setup.py install --user 
--old-and-unmanageable`.

When I look into the code of zipimport(er), I do not see any find_spec only the 
old find_loader.

Despite it is a core library, this must be fixed! And with that the name should 
match the name of the py file to make it able to find the relevant file.

--
components: Library (Lib)
messages: 384279
nosy: mowgli
priority: normal
severity: normal
status: open
title: 

[issue42817] timedelta zeropadding hh

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Why should it be zeropadded to 2?

It is likely this option was considered when that code was added, and rejected.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Current behaviour:

```
# python
Python 3.9.1 (default, Dec 18 2020, 05:16:04) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> td = datetime.timedelta(hours=3)
>>> str(td)
'3:00:00'
>>> dt = datetime.datetime.strptime(str(td), "%H:%M:%S")
>>> dt.strftime("%H:%M:%S")
'03:00:00'
>>> 
```

Expected behaviour:

```
# python
Python 3.9.1 (default, Dec 18 2020, 05:16:04) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> td = datetime.timedelta(hours=3)
>>> str(td)
'03:00:00'
>>> dt = datetime.datetime.strptime(str(td), "%H:%M:%S")
>>> dt.strftime("%H:%M:%S")
'03:00:00'
>>> 
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42816] Add str.split_iter function

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Issue17343 mentions also a separate method str.itersplit, so I close this issue 
as a duplicate.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Add a version of str.split which returns an iterator

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Does windows edit .py file shebangs?

2021-01-03 Thread Barry Scott



> On 1 Jan 2021, at 17:03, Eryk Sun  wrote:
> 
> On 1/1/21, Barry Scott  wrote:
>> I found python scripts have had their shebang lines edited behind my back.
>> 
>> The shebang line I'm seeing is:
>> 
>>#!C:\Users\barry\AppData\Local\Microsoft\WindowsApps\python3.EXE
>> 
>> Is this Microsoft being "helpful"?
>> Does anyone know what I will have done to best with this "help"?
>> 
>> What do I need to do to prevent this happening?
> 
> Shebang lines may be localized to the current interpreter when
> installing a package. Otherwise I don't know what's causing that.

These are personal scripts not installed from PyPI for example.

> 
> Regarding Windows, the system doesn't support shebang lines in any
> way. Python's installer associates .py files with the py.exe launcher,
> which looks for a shebang line in a script in order to determine which
> executable to run. It supports shebangs with fully-qualified Windows
> paths, as well as virtual commands for registered installations, such
> as "python", "python3", "python3.9-32", "/usr/bin/python3", and
> "/usr/bin/env python".

Indeed since py.exe is the only tool that supports the shebang this is very 
strange
that the change was made. I rely on py.exe handling shebang for my cross 
platform
scripts.

I've been doing some more investigation and found that the change happened
at 01/01/2021 16:16. The shebang is pointing to a 0 length PYTHON3.EXE.

The files that where changed where all in my %USERPROFILE%\bin
folder that is on my PATH. I manage the files in that folder with tools that
sync the files from an SVN repo. The version of the files in the repo do not
have the edit.

My PATH does not have a PYTHON.EXE or PYTHON3.EXE on it as
I use py.exe.

Is that the path used by the Microsoft store for the python alias?

I have now turned off the alias in the "Manage App execution aliases"
in settings.

I did find this blog post from Steve Dower about the app store python.

https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/ 


I have also scanned the Windows logs for events at the time stamp from the
file and could not see anything. 

Thinking back to the 1st I did run Visual Studio 2019 Community edition at that 
time.
It was  first time on a long time and I had to login and update it.

Is Visual Studio doing the change? If so why?

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42816] Add str.split_iter function

2021-01-03 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

See also discussion here: #17343

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42816] Add str.split_iter function

2021-01-03 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I am pretty sure this has been discussed and rejected on the Python-Ideas 
mailing list before.

If not rejected, the idea didn't go very far. You may wish to search the 
mailing list archives for previous discussions.

Either way, I think this should be discussed on Python-Ideas, to see if there 
is a consensus on this, and whether or not this is a large enough change that 
it needs a PEP.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Change by Kevin Rasmussen :


--
keywords: +patch
pull_requests: +22908
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24075

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


New submission from Kevin Rasmussen :

It looks like hh should be zeropadded to 2 and isn't for timedelta.

--
messages: 384273
nosy: krasmussen
priority: normal
severity: normal
status: open
title: timedelta zeropadding hh
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Petr Viktorin


Petr Viktorin  added the comment:

Yes, please keep _testcapimodule.c as it is. Static types are still supported 
and need to be tested.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset b8eb3765908c0063f0739595ba4b296cc8863d19 by Erlend Egeberg 
Aasland in branch 'master':
bpo-40077: Add traverse/clear/free to arraymodule (GH-24066)
https://github.com/python/cpython/commit/b8eb3765908c0063f0739595ba4b296cc8863d19


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42816] Add str.split_iter function

2021-01-03 Thread Martin Winks


New submission from Martin Winks :

Split string by given separator and return iterator as a result.

The naive and not very efficient solution would be using current str.split:

def split_iter(self: str, sep: str) -> 'Iterator[str]':
return iter(self.split(sep))

Probably, need we'll some better solution without allocating new list.

--
components: Unicode
messages: 384270
nosy: ezio.melotti, uwinx, vstinner
priority: normal
severity: normal
status: open
title: Add str.split_iter function
type: enhancement
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42455] Add decorator_factory function to functools module

2021-01-03 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I also agree with Raymond's opinion, and from the point that it didn't get much 
attention I'd assume not many people need it. So count me as -1

--
nosy: +BTaskaya

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38308] Add optional weighting to statistics.harmonic_mean()

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 66136768615472a8d1a18b5018095b9737dbab8c by Zackery Spytz in 
branch 'master':
bpo-38308: Fix the "versionchanged" for the *weights* of harmonic_mean() 
(GH-23919)
https://github.com/python/cpython/commit/66136768615472a8d1a18b5018095b9737dbab8c


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: A random word from one of two lists

2021-01-03 Thread Bischoop
On 2021-01-02, Stefan Ram  wrote:
> Bischoop  writes:
>>On 2021-01-02, Stefan Ram  wrote:
>>>Otherweise, I'd go this way without a dictionary.
>>>import random
>>>animal = ['koala', 'kangaroo']
>>>fruit = ['banana', 'apple']
>>>kinds = [animal,fruit]
>>>kind = random.choice( kinds )
>>>result = random.choice( kind )
>>>print( result )
>>I had that solution in mind but I thought that one is not good
>>programming style or not Pythonin :-)
>
>   I do not see any stylistic problem when you use this approach
>   with "nested lists". List indexing by a number should even be
>   faster than indexing a dictionary.
>
>
Now I know that's ok, seems I was ovethingking while solution was so
simply.

--
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for the fix!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 5d3553b0a8959e7505bbec4de03077dbf135ee4b by Zackery Spytz in 
branch 'master':
bpo-42814: Fix undefined behavior in Objects/genericaliasobject.c (GH-24073)
https://github.com/python/cpython/commit/5d3553b0a8959e7505bbec4de03077dbf135ee4b


--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

The purpose of `@overload` is quite different. I believe you thought that this 
is smth like `@override` in Java world but it different.

Basically, the correct usage of `@overaload` is:
```
@overload
def process(response: None) -> None:
...
@overload
def process(response: int) -> tuple[int, str]:
...
@overload
def process(response: bytes) -> str:
...
def process(response):

```

Please, follow this link for more information 
https://docs.python.org/3/library/typing.html#typing.overload

--
nosy: +uriyyo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38946] IDLE on macOS 10.15 Catalina does not open double-clicked files if app already launched

2021-01-03 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

As another datapoint: This works for me on macOS 11.1 with the universal2 
installer for Python 3.9.1 (which includes Tk 8.6.10).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42455] Add decorator_factory function to functools module

2021-01-03 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

What we should do with this issue?

There was no much discussion at python-ideas.

I have received only one -1 opinion.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
keywords: +patch
pull_requests: +22907
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24074

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread Yurii Karabas


New submission from Yurii Karabas <1998uri...@gmail.com>:

New thread doesn't copy context of the parent thread.

The minimal example to reproduce the issue:
```
from threading import Thread
from contextvars import ContextVar

foo: ContextVar[str] = ContextVar("foo")


def temp():
print(foo.get())


foo.set("bar")

t = Thread(target=temp)
t.start()
t.join()
```

Is it expected behavior?

PEP 567 I didn't find anything regarding this case.

--
components: Library (Lib)
messages: 384262
nosy: uriyyo
priority: normal
severity: normal
status: open
title: new thread doesn't copy context of the parent thread
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +22906
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24073

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread Zackery Spytz


New submission from Zackery Spytz :

In is_typing_name(), va_end() is not always called before the function returns. 
 It is undefined behavior to call va_start() without also calling va_end().

--
components: Interpreter Core
messages: 384261
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: Undefined behavior in Objects/genericaliasobject.c
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I guess I should merge a PR for issue42681 first.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Python Mauritius Usergroup - End of Year report 2020

2021-01-03 Thread Abdur-Rahmaan Janhangeer
Greetings,

^^ Thanks!

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

github 
Mauritius


On Sun, Jan 3, 2021 at 8:12 AM dn via Python-list 
wrote:

> On 1/3/21 5:01 PM, Abdur-Rahmaan Janhangeer wrote:
> > Greetings list,
> >
> > Here's our usergroup's end of year report for 2020:
> > Happy reading!
> >
> > https://www.pymug.com/assets/pymug_end_of_year_2020_v2.pdf
>
>
> Well done @A-R!
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


Change by karl :


--
keywords: +patch
pull_requests: +22904
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/24072

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread Ezio Melotti


Ezio Melotti  added the comment:

Writing tests that verify the expected behavior is a great first step. The 
expected output in the tests should match the behavior described by the HTML 5 
specs (which should also correspond to the browsers' behavior), and should 
initially fail. You can start creating a PR with only the tests, clarifying 
that it's a work in progress, or wait until you have the fix too.

The next step would be tweaking the regex and the code until both the new tests 
and all the other ones work (excluding the one with the commas you are fixing). 
 You can then commit the fix in the same branch and push it -- GitHub will 
automatically update the PR.


> Do you have a suggestion to fix it?

If you are familiar enough with regexes, you could try to figure out whether it 
matches the invalid attributes or not, and if not why (I took a quick look and 
I didn't see anything immediately wrong in the regexes).

Since the output of the failing test is [('data', '')], 
it's likely that the parser doesn't know how to handle it and passes it to one 
of the handle_data() in the goahead() method.  You can figure out which one is 
being called and see which are the if-conditions that are leading the 
interpreter down this path rather than the usual path where the attributes are 
parsed correctly.

If you have other questions let me know :)

--
type: crash -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


karl  added the comment:

Ah!

This is fixing it

diff --git a/Lib/html/parser.py b/Lib/html/parser.py
index 6083077981..790666 100644
--- a/Lib/html/parser.py
+++ b/Lib/html/parser.py
@@ -44,7 +44,7 @@
   (?:\s*=+\s*# value indicator
 (?:'[^']*'   # LITA-enclosed value
   |"[^"]*"   # LIT-enclosed value
-  |(?!['"])[^>\s]*   # bare value
+  |(?!['"])[^>]*   # bare value
  )
  (?:\s*,)*   # possibly followed by a comma
)?(?:\s|/(?!>))*




Ran 48 tests in 0.175s

OK

== Tests result: SUCCESS ==

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42813] Extra spaces cause unexpected EOF error in "compile" function with mode "single"

2021-01-03 Thread Xinmeng Xia


New submission from Xinmeng Xia :

Running the following program will lead to an unexpected EOF error. If we 
delete the space before  triple-quotation mark("""), the error will gone. If we 
replace the content of snippet with "a = 1", the program will work well. 
However, if we replace the content of snippet with "if a:pass" in a single 
line, the program cause an error again. This is weird. 

Spaces in the end of a statement should not affect the compilation of program 
in "single" mode. Besides, the error messages are different in Python2 and 
Python3. Indentation error are reported in Python 2 for snippet" if a:pass" 
while SyntaxError are reported in Python 3. 
  
==
import math
def check_stack_size( code):
# To assert that the alleged stack size is not O(N), we
# check that it is smaller than log(N).
if isinstance(code, str):
code = compile(code, "", "single")
max_size = math.ceil(math.log(len(code.co_code)))
# self.assertLessEqual(code.co_stacksize, max_size)

def test_if_else():
snippet ="""
if x:
a
elif y:
b
else:
c 
"""
check_stack_size(snippet)

test_if_else()
=
Behavior in Python 3.10:
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in 
test_if_else()
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 20, in test_if_else
check_stack_size(snippet)
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in 
check_stack_size
code = compile(code, "", "single")
  File "", line 8

SyntaxError: unexpected EOF while parsing

Behaviors in Python2: 
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in 
test_if_else()
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 27, in test_if_else
check_stack_size(snippet)
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in 
check_stack_size
code = compile(code, "", "single")
  File "", line 3

^
IndentationError: unexpected indent

--
components: Interpreter Core
messages: 384257
nosy: xxm
priority: normal
severity: normal
status: open
title: Extra spaces cause unexpected EOF error in "compile" function with mode 
"single"
type: compile error
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


Change by karl :


--
title: HTMLParser: parsing error -> HTMLParser: comma in attribute values 
with/without space

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41748] HTMLParser: parsing error

2021-01-03 Thread karl

karl  added the comment:

Ezio,

TL,DR: Testing in browsers and adding two tests for this issue. 
   Should I create a PR just for the tests?

https://github.com/python/cpython/blame/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/test/test_htmlparser.py#L479-L485


A: comma without spaces
---


Tests for browsers:
data:text/html,text

Serializations:
* Firefox, Gecko (86.0a1 (2020-12-28) (64-bit)) 
* Edge, Blink (Version 89.0.752.0 (Version officielle) Canary (64 bits))
* Safari, WebKit (Release 117 (Safari 14.1, WebKit 16611.1.7.2))

Same serialization in these 3 rendering engines
text


Adding:

def test_comma_between_unquoted_attributes(self):
# bpo 41748
self._run_check('',
[('starttag', 'div', [('class', 'bar,baz=asd')])])


❯ ./python.exe -m test -v test_htmlparser

…
test_comma_between_unquoted_attributes 
(test.test_htmlparser.HTMLParserTestCase) ... ok
…

Ran 47 tests in 0.168s

OK

== Tests result: SUCCESS ==

1 test OK.

Total duration: 369 ms
Tests result: SUCCESS


So this is working as expected for the first test.


B: comma with spaces


Tests for browsers:
data:text/html,text

Serializations:
* Firefox, Gecko (86.0a1 (2020-12-28) (64-bit)) 
* Edge, Blink (Version 89.0.752.0 (Version officielle) Canary (64 bits))
* Safari, WebKit (Release 117 (Safari 14.1, WebKit 16611.1.7.2))

Same serialization in these 3 rendering engines
text


Adding
def test_comma_with_space_between_unquoted_attributes(self):
# bpo 41748
self._run_check('',
[('starttag', 'div', [
('class', 'bar'),
(',baz', 'asd')])])


❯ ./python.exe -m test -v test_htmlparser


This is failing.

==
FAIL: test_comma_with_space_between_unquoted_attributes 
(test.test_htmlparser.HTMLParserTestCase)
--
Traceback (most recent call last):
  File "/Users/karl/code/cpython/Lib/test/test_htmlparser.py", line 493, in 
test_comma_with_space_between_unquoted_attributes
self._run_check('',
  File "/Users/karl/code/cpython/Lib/test/test_htmlparser.py", line 95, in 
_run_check
self.fail("received events did not match expected events" +
AssertionError: received events did not match expected events
Source:
''
Expected:
[('starttag', 'div', [('class', 'bar'), (',baz', 'asd')])]
Received:
[('data', '')]

--


I started to look into the code of parser.py which I'm not familiar (yet) with.

https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/html/parser.py#L42-L52

Do you have a suggestion to fix it?

--
nosy: +karlcow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com