Re: [Python-ideas] Allow not in lambda expressions

2019-03-26 Thread Abdur-Rahmaan Janhangeer
please discard, it should maybe be proposed under "is not" and "not" directly ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Allow not in lambda expressions

2019-03-26 Thread Inada Naoki
Do you mean "is not"? On Wed, Mar 27, 2019 at 3:24 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Suppose i have > > (lambda x: x if x != None else '')(someVar) > > returning an empty string if none > > but, if "not" was allowed > > (lambda x: x if x not None else '')(someVar) > > i

[Python-ideas] Allow not in lambda expressions

2019-03-26 Thread Abdur-Rahmaan Janhangeer
Suppose i have (lambda x: x if x != None else '')(someVar) returning an empty string if none but, if "not" was allowed (lambda x: x if x not None else '')(someVar) it might have been more elegant PROPOSAL: Allow "not" in lambda expressions -- Abdur-Rahmaan Janhangeer Mauritius

Re: [Python-ideas] singledispatch for methods

2019-03-26 Thread Michael Selik
On Tue, Mar 26, 2019, 1:09 PM Tim Mitchell wrote: > Is it time to add singledispatch for methods to the core library? > What's the motivation for it, beyond the fact that it's possible? Regarding jargon, aren't Python's instance methods are already single-dispatch, because they receive the inst

Re: [Python-ideas] The Mailing List Digest Project

2019-03-26 Thread Abdur-Rahmaan Janhangeer
#agree ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] The Mailing List Digest Project

2019-03-26 Thread Christopher Barker
On Tue, Mar 26, 2019 at 8:32 AM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Great! will see sphinx but if i find the html hard to customise, i'll drop > it. > Sphinx has theming support, plus you can do custom CSS if you want. But Highly discourage you from worrying about formattin

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Ben Rudiak-Gould
On Tue, Mar 26, 2019 at 2:40 AM Richard Whitehead wrote: > Using Python’s Condition class is error-prone and difficult. After looking at your example, I think the problem is just that you aren't using condition variables the way they're intended to be used. To write correct condition-variable co

[Python-ideas] singledispatch for methods

2019-03-26 Thread Tim Mitchell
Hi All, functools.singledispatch does not work on methods. There are 2 packages that do this for methods one on GitHub only https://gist.github.com/adamnew123456/9218f99ba35da225ca11 and my pypi package https://pypi.org/project/methoddispatch/. There are also a couple of stack overflow posts abou

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Richard Whitehead
Nathaniel, You’re quite right, I can’t work out the race condition myself now... Is it possible that an AutoResetEvent is just an Event with a two-line wait() overload??? Richard From: Nathaniel Smith Sent: Tuesday, March 26, 2019 5:10 PM To: Richard Whitehead Cc: Python-Ideas Subject: Re:

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Nathaniel Smith
On Tue, Mar 26, 2019, 09:50 Richard Whitehead wrote: > Nathaniel, > > Thanks very much for taking the time to comment. > > Clearing the event after waiting for it will introduce a race condition: > if > the sender has gone around its loop again and set the semaphore after we > have woken but befo

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Richard Whitehead
Nathaniel, Thanks very much for taking the time to comment. Clearing the event after waiting for it will introduce a race condition: if the sender has gone around its loop again and set the semaphore after we have woken but before we've cleared it. As you said, this stuff is tricky! The only

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Nathaniel Smith
These kinds of low-level synchronization primitives are notoriously tricky, yeah, and I'm all in favor of having better higher-level tools. But I'm not sure that AutoResetEvent adds enough to be worth it. AFAICT, you can get this behavior with an Event just fine – using your pseudocode: def sende

Re: [Python-ideas] The Mailing List Digest Project

2019-03-26 Thread Abdur-Rahmaan Janhangeer
Great! will see sphinx but if i find the html hard to customise, i'll drop it. Search feature and tags coming. also, currently i'm formatting the mails rather than an article, i don't know if a real summary of the topic preferable ... Abdur-Rahmaan Janhangeer Mauritius __

Re: [Python-ideas] The Mailing List Digest Project

2019-03-26 Thread Christopher Barker
On Mon, Mar 25, 2019 at 10:01 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > As proposed on python-ideas, i setup a repo to turn mail threads into > articles. > Thanks for doing this — I find myself frequently telling people about past relevant threads on this list - it will be grea

Re: [Python-ideas] A directive for indentation type, stricter indentation parsing.

2019-03-26 Thread Christopher Barker
> > So my point was that it would be cool to have a dedicated statement for > this Look in the archives of this list — therewasa rejected proposal for dedented strings as s language feature fairly recently. -CHB > > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scienti

Re: [Python-ideas] New explicit methods to trim strings

2019-03-26 Thread Christopher Barker
> And this really is simple enough that I don't want to reach for regex's >> for it. That is, I'd write it by hand rather than mess with that. >> > > Well, with re.escape it's not messy at all : > > You could do a ltrim function in one line : > > def ltrim(s, x): > return re.sub("^" + re.escape

Re: [Python-ideas] New explicit methods to trim strings

2019-03-26 Thread Anders Hovmöller
> And this really is simple enough that I don't want to reach for regex's for > it. That is, I'd write it by hand rather than mess with that. > > Well, with re.escape it's not messy at all : > > import re > def trim_mailto(s): > regex = re.compile("^" + re.escape("mailto:";)) > return regex

Re: [Python-ideas] New explicit methods to trim strings

2019-03-26 Thread Robert Vanden Eynde
> And this really is simple enough that I don't want to reach for regex's > for it. That is, I'd write it by hand rather than mess with that. > Well, with re.escape it's not messy at all : import re def trim_mailto(s): regex = re.compile("^" + re.escape("mailto:";)) return regex.sub('', s) W

Re: [Python-ideas] A directive for indentation type, stricter indentation parsing.

2019-03-26 Thread Mikhail V
On Tue, Mar 26, 2019 at 2:02 PM Chris Angelico wrote: > > On Tue, Mar 26, 2019 at 9:49 PM Mikhail V wrote: > > Procedural removal is not cool, because it does not know the parent > > indentation > > [...] > > E.g. this: > > s = """ > > Hello > > world""" > > >

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Richard Whitehead
can enhance some html later -- Abdur-Rahmaan Janhangeer Mauritius -- next part -- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190326/ab8ee7e8/attachment-0001.html> -- Message: 2

Re: [Python-ideas] A directive for indentation type, stricter indentation parsing.

2019-03-26 Thread Chris Angelico
On Tue, Mar 26, 2019 at 9:49 PM Mikhail V wrote: > Procedural removal is not cool, because it does not know the parent > indentation > of the statement that contains the text block, thus it can't resolve > automatically > string indents that were intentionally indented to include extra space. >

Re: [Python-ideas] A directive for indentation type, stricter indentation parsing.

2019-03-26 Thread Mikhail V
On Tue, Mar 26, 2019 at 7:04 AM fhsxfhsx wrote: > > Just as to your example, you can try `textwrap.dedent` > Procedural removal is not cool, because it does not know the parent indentation of the statement that contains the text block, thus it can't resolve automatically string indents that were

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Antoine Pitrou
On Tue, 26 Mar 2019 09:27:18 - "Richard Whitehead" wrote: > Problem: > > Using Python's Condition class is error-prone and difficult. For example, > the following pseudo-code would be quite typical of its use: [...] Nowadays, I would recommend to always use `Condition.wait_for()` rather tha

[Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Richard Whitehead
Problem: Using Python's Condition class is error-prone and difficult. For example, the following pseudo-code would be quite typical of its use: condition = threading.Condition() def sender(): while alive(): wait_for_my_data_from_hardware() with condition: