Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Stephen J. Turnbull
Chris Angelico writes: > I have to defer to someone who knows in more detail here, but the > parser will look ahead one "token", whatever a token is. (Technically > it doesn't backtrack, it looks ahead - same difference.) Tokens are basically keywords, identifiers, most single punctuation

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Abe Dillon
[Chris Angelico] > Though... it's insignificant when the function header precedes the > expression/body. With the proposal to move the header to the end, that > might become problematic, which makes it yet another cost to the > proposal. I don't think it would be a problem because, like ternary

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 12:57 PM, Abe Dillon wrote: > [Chris Angelico] >> >> If you have a use-case for a lambda function that takes a callback and >> has a default value for that callback, please submit it to The Daily >> WTF. In Steve's example, the main function was created with a >>

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Abe Dillon
[Chris Angelico] > If you have a use-case for a lambda function that takes a callback and > has a default value for that callback, please submit it to The Daily > WTF. In Steve's example, the main function was created with a > statement. Fair enough, but I still think D'Aprano may have

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 12:48 PM, Abe Dillon wrote: > [Steven D'Aprano] >> >> Replacing the keyword: >> results = map(def a, b=2, c=3: a ** b / c, sequence) >> widget.register(callback=def: spam.eggs()) >> Doesn't look so attractive now, I wager. Using "def" inside an >> expression looks

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Abe Dillon
[Steven D'Aprano] > most importantly, "def" with "fun", which will have the > advantage of making Python programming more fun! I'm sold. Make the change and SHIP IT! No need for committee approval. [Steven D'Aprano] > If we're going to break people's code by > changing keywords, let's do it

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
On 2018-08-22 02:38, Elazar wrote: I don't think this change makes sense, but if it's done, there should be another change, with actual implications: There is no way to express the types of the parameters in a lambda - `lambda x: int : x` is obviously a syntax error. Replacing the colon with a

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Abe Dillon
[Jonathan Fine] > one of the messages had a link to still live and excellent page > > https://wiki.python.org/moin/AlternateLambdaSyntax > This page lists over 100 suggestions, mostly variants. So far as I can > see, my simple proposal isn't listed on that page. The page also says Awesome!

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Stephen J. Turnbull
Abe Dillon writes: > What I've found so far is this unreassuring post from Guido back in > 2006 > IIRC, early drafts of PEP 3000 (the PEP that was the planning document for the Python 3 project) removed lambda

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Steven D'Aprano
On Tue, Aug 21, 2018 at 10:27:20PM +0100, Jonathan Fine wrote: > Here is my simple proposal. Enhance Python to allow > > >>> hn = def a, b=2, c=3: a ** b / c Enhancements ought to allow us to write new code that we couldn't do before, or open up new kinds of algorithms that weren't easy or

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Elazar
I don't think this change makes sense, but if it's done, there should be another change, with actual implications: There is no way to express the types of the parameters in a lambda - `lambda x: int : x` is obviously a syntax error. Replacing the colon with a different symbol, such as "=>" will

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
On 2018-08-22 01:25, Jonathan Fine wrote: Hi Abe Summary: You've done good work here. I've skim read the 2006 discussion you found. You wrote: I'm trying to dig up past threads about alternatives to lambda because I would be astonished if "def" hadn't been considered and rejected for some

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Jonathan Fine
Hi Abe Summary: You've done good work here. I've skim read the 2006 discussion you found. You wrote: > I'm trying to dig up past threads about alternatives to lambda because I > would be astonished if "def" hadn't been considered and rejected for some > reason. What I've found so far is this

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Abe Dillon
I'm trying to dig up past threads about alternatives to lambda because I would be astonished if "def" hadn't been considered and rejected for some reason. What I've found so far is this unreassuring post from Guido back in 2006

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Chris Angelico] > I have to defer to someone who knows in more detail here, but the > parser will look ahead one "token", whatever a token is. (Technically > it doesn't backtrack, it looks ahead - same difference.) In order for > the ternary-if to work, the expression before the if has to be of

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 8:45 AM, Abe Dillon wrote: > [Chris Angelico] >> >> Python's parser is *deliberately* incapable of backtracking this far >> in its definition of syntax. > > > Can you explain how far the parser is capable of backtracking? > It seems like with would require a similar

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Chris Angelico] > Python's parser is *deliberately* incapable of backtracking this far > in its definition of syntax. Can you explain how far the parser is capable of backtracking? It seems like with would require a similar amount of backtracking to ternary expressions: if else If the

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
Hi Greg You (and a reddit user) wrote: >> Matlab says: "Here, copy paste this and it'll work". >> To the point that the workspace is designed to automatically strip >>> >> from any copy and pasted commands. > Maybe this is something Python's REPL should do? Good idea. Maybe this is something

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Jonathan Fine] > I have reservations about the name lambda. But there's a lot of > code out there that uses lambda, and I'd like that code to continue to > run. Yes. I'm under no delusion that lambda will be replaced any time soon. Nor do I believe any alternative I suggest will be enough of

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Greg Ewing
Jonathan Fine wrote: Matlab says: "Here, copy paste this and it'll work". To the point that the workspace is designed to automatically strip >>> from any copy and pasted commands. Maybe this is something Python's REPL should do? -- Greg ___

[Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Jonathan Fine
Here's what I call a simple proposal. Some people might find it outrageous. Today is not 1st April. BACKGROUND Many Python users don't like the name lambda. But many Python users don't want any change here. This is true because there are millions of Python users, and even 100 is

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Jonathan Fine
Hi Abe First, I have reservations about the name lambda. But there's a lot of code out there that uses lambda, and I'd like that code to continue to run. You wrote: > func = value[card.suit] if card not in wilds else wild_value with card I thought I'd try this, and variants, in the Python

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 6:33 AM, Abe Dillon wrote: > [Chris Angelico] >> >> I use decks of cards primarily for non-game >> usage (for instance, teaching data structures and algorithms - cards >> laid out on a table can represent a tree, heap, array, etc) > > > I do too. They're a great tool for

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Chris Angelico] > I use decks of cards primarily for non-game > usage (for instance, teaching data structures and algorithms - cards > laid out on a table can represent a tree, heap, array, etc) I do too. They're a great tool for visualizing and physically trying out different techniques.

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 6:24 AM, Abe Dillon wrote: > [Chris Angelico] >> >> That right there is unacceptable. You should not have to know the >> destination to understand what something fundamentally is. > > > You don't *have* to know what the parameter "key" is to know that > (value[card.suit]

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Chris Angelico] > That right there is unacceptable. You should not have to know the > destination to understand what something fundamentally is. You don't *have* to know what the parameter "key" is to know that (value[card.suit] ... with card) is a function. You can identify that it's a

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-21 Thread Kirill Balunov
пн, 20 авг. 2018 г. в 17:23, Steven D'Aprano : > On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: > [...] > [Kirill] > > Let me disagree with you. While CPython is only one of the > implementations > > of the Python language, it is the most common one and defacto is > considered >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 4:56 AM, Abe Dillon wrote: > [Chris Angelico] >> >> In English, "card is not wild" can >> be interpreted as a membership check, but in Python, it is only an >> identity check; you're capitalizing on false readability by using this >> notation. > > > I promise that wasn't

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Chris Angelico] > Okay, let's read that. > hand = # we're assigning this to the name 'hand' > sorted( # calling the function named 'sorted' > cards, # positional argument, whatever's in the 'cards' variable > by= # keyword argument, what comes next is the 'by' argument > value[card.suit] #

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
I wrote: > No mention here, or elsewhere on the page, that [>>>] at the top > right of a code example toggles the presence or absence of prompts. Now raised, and cross-referenced as an issue. https://bugs.python.org/issue34451 docs: tutorial/introduction doesn't mention toggle of prompts

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
Hi Steve You wrote: > I would just like to point out that the ipython %paste magic very > handily strips leading >, ... & + characters from the pasted block, > (there is also some clever dedenting done). [useful example, snipped] > Which is ideal. I personally find that many beginners get on a

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
Chris Angelico wrote > Where in the linked-to What's New page is there an example of that? > There are several code blocks that ARE copy/pasteable, even into the > vanilla interpreter. Good question. The reddit user wrote.

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 2:55 AM, Jonathan Fine wrote: > Nick Loadholtes wrote (elsewhere, quoted in this thread - by me). > >> Make your docs work as hard as your code does. Clear examples will >> make your code stand out in a good way. > > With a bit more searching I found: > >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 3:56 AM, Abe Dillon wrote: > I've never hears someone say, "My child's name will be if it's a girl Sally > otherwise Billy." "My child's name depends on gender - if it's a girl, Sally, otherwise Billy." Seems fine to me. You can always come up with something awkward in a

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Abe Dillon
[Stephen Turnbull] > I was an economist then, and I'm an economist still, but I met lambda > in 1977. Surely lambda has had that role in computer languages since > shortly before I was born. According to Wikipedia Lisp was the first language

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Steve Barnes
On 21/08/2018 17:55, Jonathan Fine wrote: > Nick Loadholtes wrote (elsewhere, quoted in this thread - by me). > >> Make your docs work as hard as your code does. Clear examples will >> make your code stand out in a good way. > > With a bit more searching I found: > >

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
Nick Loadholtes wrote (elsewhere, quoted in this thread - by me). > Make your docs work as hard as your code does. Clear examples will > make your code stand out in a good way. With a bit more searching I found:

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Steven D'Aprano
On Tue, Aug 21, 2018 at 02:07:33PM +0900, Stephen J. Turnbull wrote: > I was an economist then, and I'm an economist still, but I met lambda > in 1977. Surely lambda has had that role in computer languages since > shortly before I was born. I would guess anybody above a certain age > would

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Jonathan Fine
Hi Earlier today, I did a search for 'documentation by example python' and found Example of great documentation in Python: Nick Loadholtes (copied) https://ironboundsoftware.com/blog/2017/12/11/great-documentation-python/ The example is:

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-21 Thread Paul Moore
On Tue, 21 Aug 2018 at 11:27, Steven D'Aprano wrote: > > On Tue, Aug 21, 2018 at 09:06:54AM +0200, Marko Ristin-Kaufmann wrote: > > > Is there any chance to introduce these constructs in the language or is it > > too small a feature for such a big change? > > I don't think contracts is a small

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-21 Thread INADA Naoki
On Thu, Aug 16, 2018 at 4:19 PM Elazar wrote: > > You might also be interested in pep-563. although it is not intended for > design by contract, it can help (syntactically). > FYI, PEP 563 doesn't help it. Read this section:

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-21 Thread Steven D'Aprano
On Tue, Aug 21, 2018 at 09:06:54AM +0200, Marko Ristin-Kaufmann wrote: > Is there any chance to introduce these constructs in the language or is it > too small a feature for such a big change? I don't think contracts is a small feature. I think it is a HUGE feature, but under-appreciated by

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-21 Thread Marko Ristin-Kaufmann
Hi, I had a look at the messages related to the PEP in question (PEP 316) in the archive. As far as I can tell, the main objection is that you can achieve contracts by implementing it with decorators. I think that these objections miss what actually Daniel Moisset wrote in his message: contracts