Re: The split() function of Python's built-in module has changed in a puzzling way - is this a bug?

2021-04-23 Thread Thomas Jollans

On 23/04/2021 01:53, Andy AO wrote:

Upgrading from Python 3.6.8 to Python 3.9.0 and executing unit tests
revealed a significant change in the behavior of re.split().

but looking at the relevant documentation — Changelog  and re - Regular expression
operations - Python 3.9.4 documentation

yet no change is found.

number = '123'def test_Asterisk_quantifier_with_capture_group(self):
 resultList = re.split(r'(\d*)', self.number)
 if platform.python_version() == '3.6.8':
 self.assertEqual(resultList,['', '123', ''])

 else:
 self.assertEqual(resultList,['', '123', '', '', ''])



Hi Andy,

That's interesting. The old result is less surprising, but of course 
both are technically correct as the 4th element in the result matches 
your regexp.


The oldest version of Python I had lying around to test is 3.7; that has 
the same behaviour as 3.9.


I suspect that this behaviour is related to the following note in the 
docs for re.split:



Changed in version 3.7: Added support of splitting on a pattern that 
could match an empty string.



(your pattern can match an empty string, so I suppose it wasn't 
technically supported in 3.6?)



-- Thomas





I feel that this is clearly not in line with the description of the
function in the split documentation, and it is also strange that after
replacing * with +, the behavior is still the same as in 3.6.8.

1. why is this change not in the documentation? Is it because I didn’t
find it?
2. Why did the behavior change this way? Was a bug introduced, or was it
a bug fix?


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


Re: do ya still use python?

2021-04-23 Thread David Lowry-Duda
> Are there reasons why someone might prefer StackOverflow to this list?
> Are they more to do with the person, or something the Python Community
> should address?

I think general discoverability is a driving force. A beginner has a 
problem, goes to google, types in their problem, and sees some links to 
the documentation and stackoverflow first (typically). And that's where 
they are.

SO also ranks responses to a question, which the list doesn't do. There 
are lots of things that I think SO is better suited for than mailing 
lists --- but of course I also think there are lots of things the list 
is better suited for than fora like SO.

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


Re: do ya still use python?

2021-04-23 Thread David Lowry-Duda
> You wouldn't see Tim Peters or even Guido here nowadays, and
> Steven D'Aprano was IMO forced out for no good reason ... you see
> the results here every day...

What happened to Steven D'Aprano?

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


Re: do ya still use python?

2021-04-23 Thread J. Pic
CPython powers Mars Ingenuity Helicopter:
https://github.com/readme/nasa-ingenuity-helicopter

All CPython contributors got a new GitHub badge to show off.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fun Generators

2021-04-23 Thread Travis Griggs



> On Apr 23, 2021, at 05:55, Frank Millman  wrote:
> 
> On 2021-04-23 7:34 AM, Travis Griggs wrote:
>> Doing an "industry experience" talk to an incoming class at nearby 
>> university tomorrow. Have a couple points where I might do some "fun things" 
>> with python. Said students have been learning some python3.
>> I'm soliciting any *fun* generators people may have seen or written? Not so 
>> much the cool or clever ones. Or the mathematical ones (e.g. fib). Something 
>> more inane and "fun". But still showcasing generators uniqueness. Short and 
>> simple is good.
>> Thanks in advance!
> 
> Have you looked at this?
> 
> http://www.dabeaz.com/generators/
> 
> Frank Millman
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list


I hadn't. But now I have. These are really cool. But not as whimsical/simple as 
I would have hoped. They're actually useful :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fun Generators

2021-04-23 Thread Dan Stromberg
On Fri, Apr 23, 2021 at 10:30 AM Travis Griggs 
wrote:

> > On Apr 23, 2021, at 05:55, Frank Millman  wrote:
> >
> > On 2021-04-23 7:34 AM, Travis Griggs wrote:
> >> Doing an "industry experience" talk to an incoming class at nearby
> university tomorrow. Have a couple points where I might do some "fun
> things" with python. Said students have been learning some python3.
> >> I'm soliciting any *fun* generators people may have seen or written?
> Not so much the cool or clever ones. Or the mathematical ones (e.g. fib).
> Something more inane and "fun". But still showcasing generators uniqueness.
> Short and simple is good.
> >> Thanks in advance!
> >
> > Have you looked at this?
> >
> > http://www.dabeaz.com/generators/
> >
> > Frank Millman
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>
> I hadn't. But now I have. These are really cool. But not as
> whimsical/simple as I would have hoped. They're actually useful :)
>

Perhaps not the best example, but a bit whimsical - there's a "Daffy Duck"
bidirectional generator in this presentation:
https://stromberg.dnsalias.org/~dstromberg/Intro-to-Python/Python%20Generators,%20Iterators%20and%20Comprehensions.pdf

Full Disclosure: I created the presentation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The split() function of Python's built-in module has changed in a puzzling way - is this a bug?

2021-04-23 Thread Dan Stromberg
On Thu, Apr 22, 2021 at 8:53 PM Andy AO  wrote:

> Upgrading from Python 3.6.8 to Python 3.9.0 and executing unit tests
> revealed a significant change in the behavior of re.split().
>
> but looking at the relevant documentation — Changelog  python.org/3/whatsnew/changelog.html> and re - Regular expression
> operations - Python 3.9.4 documentation
> 
> yet no change is found.
>
> number = '123'def test_Asterisk_quantifier_with_capture_group(self):
> resultList = re.split(r'(\d*)', self.number)
> if platform.python_version() == '3.6.8':
> self.assertEqual(resultList,['', '123', ''])
>
> else:
> self.assertEqual(resultList,['', '123', '', '', ''])
>
> I feel that this is clearly not in line with the description of the
> function in the split documentation, and it is also strange that after
> replacing * with +, the behavior is still the same as in 3.6.8.
>
>1. why is this change not in the documentation? Is it because I didn’t
>find it?
>2. Why did the behavior change this way? Was a bug introduced, or was it
>a bug fix?
> --
> https://mail.python.org/mailman/listinfo/python-list


Interesting, and make sure to check out the FutureWarning:

$ pythons --command 'import re; number = "123"; print(re.split(r"(\d*)",
number))'
below cmd output started 2021 Fri Apr 23 10:48:32 AM PDT
/usr/local/cpython-0.9/bin/python (unknown) good skipped
/usr/local/cpython-1.0/bin/python (1.0.1) bad
  File "", line 1
import re; number = "123"; print(re.split(r"(\d*)", number))
 ^
SyntaxError: invalid syntax
/usr/local/cpython-1.1/bin/python (1.1) bad
  File "", line 1
import re; number = "123"; print(re.split(r"(\d*)", number))
 ^
SyntaxError: invalid syntax
/usr/local/cpython-1.2/bin/python (1.2) bad
  File "", line 1
import re; number = "123"; print(re.split(r"(\d*)", number))
 ^
SyntaxError: invalid syntax
/usr/local/cpython-1.3/bin/python (1.3) bad
  File "", line 1
import re; number = "123"; print(re.split(r"(\d*)", number))
 ^
SyntaxError: invalid syntax
/usr/local/cpython-1.4/bin/python (1.4) bad
  File "", line 1
import re; number = "123"; print(re.split(r"(\d*)", number))
 ^
SyntaxError: invalid syntax
/usr/local/cpython-1.5/bin/python (1.5.2) good ['', '123', '']
/usr/local/cpython-1.6/bin/python (1.6.1) good ['', '123', '']
/usr/local/cpython-2.0/bin/python (2.0.1) good ['', '123', '']
/usr/local/cpython-2.1/bin/python (2.1.0) good ['', '123', '']
/usr/local/cpython-2.2/bin/python (2.2.0) good ['', '123', '']
/usr/local/cpython-2.3/bin/python (2.3.0) good ['', '123', '']
/usr/local/cpython-2.4/bin/python (2.4.0) good ['', '123', '']
/usr/local/cpython-2.5/bin/python (2.5.6) good ['', '123', '']
/usr/local/cpython-2.6/bin/python (2.6.9) good ['', '123', '']
/usr/local/cpython-2.7/bin/python (2.7.16) good ['', '123', '']
/usr/local/cpython-3.0/bin/python (3.0.1) good ['', '123', '']
/usr/local/cpython-3.1/bin/python (3.1.5) good ['', '123', '']
/usr/local/cpython-3.2/bin/python (3.2.5) good ['', '123', '']
/usr/local/cpython-3.3/bin/python (3.3.7) good ['', '123', '']
/usr/local/cpython-3.4/bin/python (3.4.8) good ['', '123', '']
/usr/local/cpython-3.5/bin/python (3.5.5) good
['', '123', '']
/usr/local/cpython-3.5/lib/python3.5/re.py:203: FutureWarning: split()
requires a non-empty pattern match.
  return _compile(pattern, flags).split(string, maxsplit)
/usr/local/cpython-3.6/bin/python (3.6.0) good
['', '123', '']
/usr/local/cpython-3.6/lib/python3.6/re.py:212: FutureWarning: split()
requires a non-empty pattern match.
  return _compile(pattern, flags).split(string, maxsplit)
/usr/local/cpython-3.7/bin/python (3.7.0) good ['', '123', '', '', '']
/usr/local/cpython-3.8/bin/python (3.8.0) good ['', '123', '', '', '']
/usr/local/cpython-3.9/bin/python (3.9.0) good ['', '123', '', '', '']
/usr/local/cpython-3.10/bin/python (3.10.0a6) good ['', '123', '', '', '']
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper
(file:/usr/local/jython-2.7/jython.jar) to method
sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of
jnr.posix.JavaLibCHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflective access operations
WARNING: All illegal access operations will be denied in a future release
/usr/local/jython-2.7/bin/jython (2.7.0) good
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper
(file:/usr/local/jyth

async watch directory for new files

2021-04-23 Thread Zoran
Hi,

I need to watch for new files in directory, and when it shows up, I should 
create async task with file's full path for it, and wait for new file.

If anyone here used a library for such task, please share which one.

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