Re: [Python-ideas] Null coalescing operator

2016-10-13 Thread Mark E. Haase
(Replying to multiple posts in this thread) Guido van Rossum: > Another problem is PEP 505 -- it > is full of discussion but its specification is unreadable due to the > author's idea to defer the actual choice of operators and use a > strange sequence of unicode characters instead. Hi, I wrote

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Mark E. Haase
On Fri, Oct 14, 2016 at 9:37 AM, Gustavo Carneiro wrote: > > I see. short-circuiting is nice to have, sure. > > But even without it, it's still useful IMHO. > It's worth mentioning that SQL's COALESCE is usually (always?) short circuiting: https://www.postgresql.org/docs/9.5/static/functions-

Re: [Python-ideas] Null coalescing operator

2016-10-14 Thread Mark E. Haase
On Fri, Oct 14, 2016 at 12:10 PM, Guido van Rossum wrote: > I propose that the next phase of the process should be to pick the > best operator for each sub-proposal. Then we can decide which of the > sub-proposals we actually want in the language, based on a combination > of how important the fun

Re: [Python-ideas] Null coalescing operator

2016-10-28 Thread Mark E. Haase
On Fri, Oct 14, 2016 at 11:36 PM, Guido van Rossum wrote: > I'm not usually swayed by surveys -- Python is not a democracy. Maybe > a bunch of longer examples would help all of us see the advantages of > the proposals. I understand. You said the next phase should be to pick the best operator fo

Re: [Python-ideas] Null coalescing operator

2016-10-31 Thread Mark E. Haase
Stephen J. Turnbull wrote: > I gather you think you have a deadlock here. The way to break it is > to just do it. Pick a syntax and do the rewriting. My memory of some > past instances is that many of the senior devs (especially Guido) will > "see through the syntax" to evaluate the benefits of

Re: [Python-ideas] Null coalescing operator

2016-10-31 Thread Mark E. Haase
ribute of None. Therefore, if "foo?.bar" evaluates to None, then ".baz" is short circuited — that attribute is not looked up. [1] https://en.wikipedia.org/wiki/Null_coalescing_operator#SQL On Mon, Oct 31, 2016 at 12:33 PM, Paul Moore wrote: > On 31 October 2016 at 15:51, Ma

Re: [Python-ideas] Null coalescing operator

2016-11-02 Thread Mark E. Haase
Zero Piraeus writes: > If I write something like obj.attr, the failure mode I care about is that > obj has no attribute attr, rather than that obj is specifically None (or > one of a defined group of somewhat Nonelike objects). > > Clearly, in such a circumstance, obj is not what I expected it to

Re: [Python-ideas] PEP 532: A circuit breaking operator and protocol

2016-11-12 Thread Mark E. Haase
, the definition of conditional expressions > could be updated to also make the ``else`` clause optional:: > > test: else_test ['if' or_test ['else' test]] | lambdef > else_test: or_test ['else' test] > > (We would avoid the apparent simplification to ``

Re: [Python-ideas] Things that won't change (proposed PEP)

2017-01-12 Thread Mark E. Haase
I don't think an informational PEP would make threads like Python Review shorter and/or more productive. The OP clearly didn't do much research, so it seems unlikely he would read an informational PEP. Moreover, the bikeshedding about what goes into this PEP will inevitably lead to a troll who isn'

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-12 Thread Mark E. Haase
On Sun, Feb 12, 2017 at 11:51 AM, Markus Meskanen wrote: > > 2. To register callbacks to objects, i.e. plain out set an attribute for > an instance. I've used the menu example above: > > class Menu: > def __init__(self, items=None, select_callback=None): > self.items = items if i

[Python-ideas] String Format Callable Flag (Was: Efficient Debug Logging)

2017-02-17 Thread Mark E. Haase
In the debug logging thread, somebody suggested the "%r" format specifier and a custom __repr__. This is a neat solution because Python logging already includes a "delayed" evaluation of sorts: it formats the logging string *after* it determines that the message's log level is greater than or equal

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-17 Thread Mark E. Haase
On Fri, Feb 17, 2017 at 1:55 PM, Joshua Morton wrote: > but I'm wondering how common async and await were when that was proposed > and accepted? Actually, "async" and "await" are backwards compatible due to a clever tokenizer hack. The "async" keyword may only appear in a few places (e.g. async

Re: [Python-ideas] Another use case for the 'lazy' (aka 'delayed') keyword

2017-02-28 Thread Mark E. Haase
This could be solved with a null-coalescing operator, e.g. PEP-505. >>> val = conf.get('setting_name') ?? load_from_db('setting_name') The right side isn't evaluated unless the left side is None. It's similar to this: >>> val = conf.get('setting_name') or load_from_db('setting_name') Exce

Re: [Python-ideas] Another use case for the 'lazy' (aka 'delayed') keyword

2017-02-28 Thread Mark E. Haase
> > -Joseph > > On Feb 28, 2017, at 10:21 AM, Mark E. Haase wrote: > > This could be solved with a null-coalescing operator, e.g. PEP-505. > >>>> val = conf.get('setting_name') ?? load_from_db('setting_name') > > The right side is

Re: [Python-ideas] Proposal: Query language extension to Python (PythonQL)

2017-03-25 Thread Mark E. Haase
Hi Pavel, This is a really impressive body of work. I had looked at this project in the past but it is great to get back up to speed and see all the progress made. I use Python + databases almost every day, and the major unanswered question is what benefit does dedicated language syntax have over

Re: [Python-ideas] Way to repeat other than "for _ in range(x)"

2017-03-30 Thread Mark E. Haase
Your example is really repeating two things: d = [ [0 for _ in range(5)] for _ in range(10) ] But since list() uses * for repetition, you could write it more concisely as: d = [[0] * 5] * 10] I'm not picking on your specific example. I am only pointing out that Python gives you the tools you ne

Re: [Python-ideas] Allow function to return multiple values

2017-06-09 Thread Mark E. Haase
On Thu, Jun 8, 2017 at 4:27 PM, Abe Dillon wrote: > >>> a, *b = 1, 2, 3, 4, 5 # NOTE: Most itterables unpack starred > variables as a list > >>> type(b) > > > >>> a, *b = "except strings" > >>> type(b) > > I was just playing around with this, and on Python 3.5.3, I see strings unpacked as li

Re: [Python-ideas] Arguments to exceptions

2017-07-06 Thread Mark E. Haase
On Wed, Jul 5, 2017 at 9:22 PM, Chris Angelico wrote: > For what it's worth, I'm in favour of Steven's "too negative" approach > - or rather, I don't think his style is too negative. Yes, it's a bit > rough and uncomfortable to be on the receiving end of it, but it's > exactly correct. All three

Re: [Python-ideas] Arguments to exceptions

2017-07-06 Thread Mark E. Haase
On Thu, Jul 6, 2017 at 5:58 AM, Paul Moore wrote: > To use the (already > over-used) NameError example, Ken's proposal doesn't include any > change to how NameError exceptions are raised to store the name > separately on the exception. > Maybe I'm misunderstanding you, but the proposal has a cle

Re: [Python-ideas] Arguments to exceptions

2017-07-06 Thread Mark E. Haase
On Thu, Jul 6, 2017 at 2:56 PM, Steven D'Aprano wrote: > > Maybe I'm misunderstanding you, but the proposal has a clear example of > > raising NameError and getting the name attribute from the exception > > instance: > > > > try: > > raise NameError(name=name, template="name '{name}'

Re: [Python-ideas] Enabling Event.set to notify all waiters with an exception

2017-07-19 Thread Mark E. Haase
On Wed, Jul 19, 2017 at 2:37 AM, Pau Freixes wrote: > Not at all, the idea is taking into advantage the Event principle, > having a set of Futures waiting to be awakened and returning either a > value or exception. That's not the principle of Event. You are describing a Future. Regarding the p

Re: [Python-ideas] Make map() better

2017-09-14 Thread Mark E. Haase
On Wed, Sep 13, 2017 at 5:05 PM, Jason H wrote: > Python is weird in that there are these special magical globals that > operate on many things. Jason, that weirdness is actually a deep part of Python's philsophy. The language is very protocol driven. It's not just the built-in functions that u

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-25 Thread Mark E. Haase
Explicit yield points makes reasoning about multitasking much easier. The author of Twisted wrote an excellent post about this.[1] I agree that the Python documentation doesn't do justice to the question, "when should I use asyncio instead of threads?" [1] https://glyph.twistedmatrix.com/2014/02/

Re: [Python-ideas] Make asyncio.get_event_loop a builtin

2018-05-25 Thread Mark E. Haase
asyncio.coroutine and async def are slightly different—not synonyms. The former defines a generator function and the latter defines a coroutine function. Generators and coroutines are very similar in Python (they share lots of code in the CPython implementation) but coroutines are preferred for asy

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Mark E. Haase
On Thu, Jul 19, 2018 at 2:36 PM Brendan Barnwell wrote: > People keep saying that this null-coalescing behavior is so common > and > useful, etc., but that hasn't been my experience at all. In my > experience, the desire to shortcut this kind of logic is more often a > sign of corner-cut

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-23 Thread Mark E. Haase
On Mon, Jul 23, 2018 at 2:23 AM Nicholas Cole wrote: > One issue for me is that the trivial case is already a one-liner: > > if a is None: a = 10 > Yes, if you have no indentation and a 1-character name, then it fits on a single line. If you have a longer expression and/or side effects, then it'

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-23 Thread Mark E. Haase
On Mon, Jul 23, 2018 at 11:34 AM Robert Vanden Eynde wrote: > The default could be at the end with an argument to unboxing : > > favorite = NoneAware(cfg).user.profile.food.unbox("Spam") > That's what PyMaybe does: https://pymaybe.readthedocs.io/en/latest/readme.html#examples-use-cases PyMaybe

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-23 Thread Mark E. Haase
On Mon, Jul 23, 2018 at 2:12 PM Rhodri James wrote: > > How are you supposed to do method calling, the equivalent of > "foo?.bar()" ? "NoneAware(foo).bar.unbox()()" looks downright weird. > Is there more magic in NoneAware to cover this case? (Not that I think > we should be encouraging people

Re: [Python-ideas] Executable space protection: NX bit,

2018-09-04 Thread Mark E. Haase
Hey Wes, the checksec() function in PEDA that you cited has a standalone version as well: https://github.com/slimm609/checksec.sh Running this on my Python (installed from Ubuntu package): $ checksec --output json -f /usr/bin/python3.6 | python3 -m json.tool { "file": { "relro": "par

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-13 Thread Mark E. Haase
On Thu, Sep 13, 2018 at 10:49 AM Rhodri James wrote: More importantly, this whole idea of banning and/or changing terminology is > psychologically and sociologically wrong-headed. The moment you say "You > may not use that word" you create a taboo, and give the word a power that > it did not hav

Re: [Python-ideas] Moving to another forum system where moderation is possible

2018-09-20 Thread Mark E. Haase
On Thu, Sep 20, 2018 at 8:09 AM Oleg Broytman wrote: > On Thu, Sep 20, 2018 at 01:46:10PM +0400, Abdur-Rahmaan Janhangeer < > arj.pyt...@gmail.com> wrote: > > i miss a +1 button > >It's absence is a big advantage. We're not a social network with > "likes". We don't need a bunch of argumentles

Re: [Python-ideas] Moving to another forum system where moderation is possible

2018-09-20 Thread Mark E. Haase
On Thu, Sep 20, 2018 at 10:33 AM Ethan Furman wrote: > On 09/20/2018 07:23 AM, Oleg Broytman wrote: > > We're proposing and *discussing* things here not "likes" each other. > > Write your arguments or be silent. > > The number of people who have the same argument is also a factor. I would >

Re: [Python-ideas] "while:" for the loop

2018-09-26 Thread Mark E. Haase
On Tue, Sep 25, 2018 at 8:47 PM Mikhail V wrote: > As for statistics - IIRC someone gave statistics once, but the only > thing I can remember - > "while 1/True" is used quite a lot in the std lib, so the numbers > exceeded my expectation > (because I expected that it's used mostly in algorithms).

Re: [Python-ideas] gevent-like Coroutines in Python

2018-10-30 Thread Mark E. Haase
Python's coroutines are designed to make suspension points visible, which enhances "local reasoning" about code. This concept has been written up very well over here: https://glyph.twistedmatrix.com/2014/02/unyielding.html On Tue, Oct 30, 2018 at 8:37 AM Ron Reiter wrote: > You are right that th