[Python-ideas] Re: PEP8 mandatory-is rule

2021-08-31 Thread Matthias Bussonnier
teresting example to argue against my claim that == None is reliable. > > Best, > > Nick > > On Mon, Aug 30, 2021 at 12:06 PM Matthias Bussonnier > wrote: >> >> From my point of view as someone who sometimes help Scientist write >> Python, this is a no

[Python-ideas] Re: PEP8 mandatory-is rule

2021-08-30 Thread Matthias Bussonnier
>From my point of view as someone who sometimes help Scientist write Python, this is a no go, there are too many cases where == and is are different. $ ipython Python 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:43:11) Type 'copyright', 'credits' or 'license' for more information I

[Python-ideas] Re: list.extend() should return self

2021-03-03 Thread Matthias Bussonnier
Methods that mutate their argument typically return None, to avoid confusing them with methods that return copies; If you both mutate and return a copy it is easy to end up with shared objects in place you actually don't want them >>> even = [2,4,6] >>> odd = [1,3,5] >>> all = odd.extend(even) .

[Python-ideas] Re: Arrow functions polyfill

2021-02-13 Thread Matthias Bussonnier
Works well with 0 parameters and currying, read almost like a haskell function definition. f = () => ((b) => b) g = (a) => (b) => b+a h = (a) => (b) => (b, a) i = (a,b) => a print(f()(2)) print(g(1)(2)) print(h(1)(2)) print(i(1, 2)) On Sat, 13 Feb 2021 at 06:35, Paul Sokolovsky wrote: > > He

[Python-ideas] Re: Top Level Await in Python like in Deno

2021-02-06 Thread Matthias Bussonnier
If it's for the REPL, it's already there, you simply need to start the async REPL. $ python -m asyncio asyncio REPL 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:43:11) [Clang 10.0.1 ] on darwin Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "

[Python-ideas] Re: Upstream Patch to inherit virtual environment ?

2020-10-20 Thread Matthias Bussonnier
Chris Said: > If I'm understanding you correctly, this means I could do something like: > > $ python3 -m venv env --see-also ../master-env > > and then any packages installed in master-env would be visible inside > this environment too? Seems pretty useful to me. Yes, it does allows multiple p

[Python-ideas] Upstream Patch to inherit virtual environment ?

2020-10-20 Thread Matthias Bussonnier
Hello Python Ideas, Would there be any interest in upstreaming a patch allowing virtualenv to be inherited in core python ? I'm working with a company that uses such an internal patch and would be ok with me spending some time trying to upstream it. When creating a venv, this let you point

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-13 Thread Matthias Bussonnier
Oh, well, but stdlib json already emit (and parse) invalid json by default... $ ipython Python 3.8.3 (default, May 19 2020, 13:54:14) Type 'copyright', 'credits' or 'license' for more information IPython 7.15.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: import json In [2]: jso

[Python-ideas] Re: still more use for pathlib.Path ....

2020-08-26 Thread Matthias Bussonnier
Many of the tempfile modules' classes and utils could maybe return Path instead of str. I'm not sure how disruptive that would be, but I would definitely welcome something that avoids having to wrap everything in Path. I think they might need to return a "StrPath" for compatibility, but IMHO only

[Python-ideas] Re: basic matrix object

2020-08-13 Thread Matthias Bussonnier
numpy arrays are ... arrays, if you want * to do matmul, use numpy.matrix (which is soft deprecated since now we have @), and will do what you expect with square matrix times vector. broadcasting is the natural extension of array `op` scalar on... arrays. Say you have an array Pressure with 3 coo

[Python-ideas] Re: await outside async function could map to asyncio.run ?

2020-06-12 Thread Matthias Bussonnier
> Do you mean that it's not possible to implement this at the syntax level > because we don't know until runtime if this is being call from a loop (async > calling sync code) ? No. I'm saying you should clarify the semantics you want if you have if your sync `test()` is called from within an asy

[Python-ideas] Re: await outside async function could map to asyncio.run ?

2020-06-12 Thread Matthias Bussonnier
See some of the previous discussions on asyncio reentrancy. https://mail.python.org/pipermail/async-sig/2019-March/thread.html I do think there is some case for non rentrency and nested loop where what you define here would block an outer loop, but most people suggesting what you ask actually wan

[Python-ideas] Re: Bringing the print statement back

2020-06-09 Thread Matthias Bussonnier
Hi Guido, Excited about the possibilities of the new PEG parser ! Have there been any consideration to allow this new call syntax to actually quote the expression given as parameter ? Or have a different meaning than a normal call ? In IPython/Jupyter we use the fact that this is not valid syntax

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Matthias Bussonnier
On Tue, 31 Mar 2020 at 10:18, Gerrit Holl wrote: > the command ``cat $(find . -name '*.py') | grep -oi term | wc -l`` was used. I'm quite concern in the lack of mention of proper forms and procedure to perform experiment with domestic felines. -- Mathias

[Python-ideas] Re: More descriptive error message than "too many values to unpack"

2020-03-06 Thread Matthias Bussonnier
> > > In general Python error messages don't include the relevant values or much > information about them, although I often wish they would. For example when I > get a KeyError I wish I could see which keys are present, unless there's too > many for it to be practical. I'm speculating, but I thi

[Python-ideas] Re: lowercase exception names trip-up .

2019-12-06 Thread Matthias Bussonnier
> I'm torn -- on the one hand, these very old modules may as well stay frozen in time (please double check that they aren't listed in PEP 594) And > I expect that will be quite common — older code commonly uses lower case class names Thank, checking 594 is a good idea; I understand why you are

[Python-ideas] Re: lowercase exception names trip-up .

2019-12-05 Thread Matthias Bussonnier
Thanks for pointing those out. At least when the alias is `error = OtherName` the text is the stack trace are informative. -- M ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org ht

[Python-ideas] lowercase exception names trip-up .

2019-12-05 Thread Matthias Bussonnier
I've been tripped up a couple of time by a few Exception names being lower case both in code and tracebacks. In particular `error` (all lower case) I tend to read `error` as a function instead of a class. According to my non-scientific grep-foo, I find that ~ 300 descendant from Exceptions st

Re: [Python-ideas] Arguments to exceptions

2017-07-05 Thread Matthias Bussonnier
Hi all, I want to point out that if it's not common to dispatch on values of exceptions it might be **because** it is hard to do or to know wether an exception will be structured or not. If Exceptions were by default more structured, if CPython would provide a default "StructuredException", or we

Re: [Python-ideas] π = math.pi

2017-06-02 Thread Matthias Bussonnier
> (Btw IPython just supports normal TeX notations like \pi, \lambda etc, so it > is very easy to remember) IPython dev here. I am the one who implemented (most of) that. We do support it, but it's not easy to remember unless you know how to write latex, and know said character. Question, how wou

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
if bk: break vs for i in outer: bk = False for j in inner: if cond: bk = True break # this. if bk: break Sorry if I'm mis expressing myself. -- M On Fri, Mar 3, 2017 at 10:52 AM, Chris Angelico wrote: > On Sat, Mar 4, 2017 at 5:5

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
Hi Brice, On Fri, Mar 3, 2017 at 10:00 AM, Brice PARENT wrote: > Thanks Matthias for taking the time to give your opinion about it. > > Just to set the focus where I may have failed to point it: > the main purpose of this proposal is the creation of the object itself, an > object representing the

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
Hi Brice, On Fri, Mar 3, 2017 at 1:14 AM, Brice PARENT wrote: > > A word about compatibility and understandability before: > "as" is already a keyword, so it is already reserved and easy to parse. It > couldn't be taken for its other uses (context managers, import statements > and > exceptions)

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread Matthias Bussonnier
On Thu, Mar 2, 2017 at 9:13 PM, Mike Miller wrote: > > It is a built-in singleton so rarely known that you will almost never > encounter code with it, so you'll have it all to yourself. Even on a python > mailing list, in a thread about sentinels/singletons, it will not be > mentioned. Some may

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Matthias Bussonnier
> I just noticed a module on PyPI to implement this behaviour on Python > functions: > https://pypi.python.org/pypi/positional This library seem to do the opposite of what you ask and force kwarg only. In [11]: @positional.positional(1) ...: def foo(a=1,b=2): ...: print(a,b) .

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Matthias Bussonnier
I think that was started as pep 457: https://www.python.org/dev/peps/pep-0457/ (Syntax For Positional-Only Parameters) Still informal. +1, it's likely possible to backport it to previous version using a decorator and faking __signature__. -- M On Tue, Feb 28, 2017 at 2:03 PM, Yury Selivanov

Re: [Python-ideas] Is it Python 3 yet?

2017-01-26 Thread Matthias Bussonnier
On Thu, Jan 26, 2017 at 7:20 PM, Nathaniel Smith wrote: > I also don't know why your numbers are so much larger than mine... That's because copy/pasting from the html table prepend the row number to the download count. >> Also % seem swapped depending on python2 vs Python3, and quite different.

Re: [Python-ideas] Is it Python 3 yet?

2017-01-26 Thread Matthias Bussonnier
On Thu, Jan 26, 2017 at 5:23 PM, Nathaniel Smith wrote: > It's also relatively common to need a 64-bit Python, e.g. if running > programs that need more than 4 GiB of address space. (Data analysts > run into this fairly often.) > > I don't know enough about Windows to have an informed opinion abo

Re: [Python-ideas] Python reviewed

2017-01-09 Thread Matthias Bussonnier
On Mon, Jan 9, 2017 at 2:50 PM, Simon Lovell wrote: > Hmm, Thanks Chris. I thought I was posting this to the correct place. > > I've never seen that "for line in open ..." after googling it many times! > Why is this question so often asked then? > The distinction and the explanation of this is th

Re: [Python-ideas] incremental hashing in __hash__

2016-12-30 Thread Matthias Bussonnier
On Fri, Dec 30, 2016 at 5:24 PM, Nick Coghlan wrote: > > I understood the "iterhash" suggestion to be akin to itertools.accumulate: > > >>> for value, tally in enumerate(accumulate(range(10))): print(value, ... It reminds me of hmac[1]/hashlib[2], with the API : h.update(...) before a .diges

Re: [Python-ideas] Better error messages [was: (no subject)]

2016-11-29 Thread Matthias Bussonnier
There are a couple of project that tried to improved heuristic on some error messages. Two I can think off are: https://github.com/SylvainDe/DidYouMean-Python and https://github.com/dutc/didyoumean I think that better error messages could be implemented only in the repl, and/or by alternati

Re: [Python-ideas] Technical possibilities for a syntax [was: Reverse assignment operators ...]

2016-11-16 Thread Matthias Bussonnier
On Wed, Nov 16, 2016 at 6:50 PM, Stephen J. Turnbull wrote: > Replying to Paul Moore when > deprecating "sarcastic" replies is just bad manners; Paul is never > intentionally sarcastic that I can remember. Apologies, if my message looked like targetting Paul, and was a reply to Paul. Paul answe

Re: [Python-ideas] Technical possibilities for a syntax [was: Reverse assignment operators ...]

2016-11-16 Thread Matthias Bussonnier
Hi all, Please be mindful when replying, even if some of the lurker know who some of you are and can figure out that some of the reply to this thread below this message are sarcastic, not all readers can. Your messages can also be cited out of context. Thus many messages in this thread can be misi

Re: [Python-ideas] Alternative to PEP 532: delayed evaluation of expressions

2016-11-06 Thread Matthias Bussonnier
On Sun, Nov 6, 2016 at 5:32 PM, Nathaniel Smith wrote: > > If we're considering options along these lines, then I think the local > optimum is actually a "quoted-call" operator, rather than a quote > operator. So something like (borrowing Rust's "!"): > > eval_else!(foo.bar, some_func()) > >

Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-10-30 Thread Matthias Bussonnier
Hi all, For those of you not aware, the Julia Programming Language [1] does make extensive use of (mathematical) unicode symbols in its standard library, even document a method of input [2] (hint tab completion). They go even further by recognizing some characters (like \oplus) that parse as opera