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

2018-08-14 Thread Steve Barnes



On 14/08/2018 20:42, Michael Selik wrote:
> 
> Good comparisons can be found in other fields:
> * Driving -- brakes vs stoppers
> * Sailing -- starboard vs right-side
> * Medicine -- postprandial vs after-meal
> * Biology -- dinosaur vs direlizard
> 
While NOT wanting to start another fight I feel that I must put my 
pedant hat on & point out that the above highlights why domain specific 
words are used and their specificity actually highlights important 
concepts, i.e.:

  * Brakes are used to apply breaking, (i.e. to slow the vehicle, 
possibly to a stop), while stoppers STOP something.
  * Starboard = to the right when facing the bow (front of the vessel) 
not "my right", "your right" or "their right" (which depends on which 
way you, I & they are facing).
  * postprandial = after Lunch (not after eating any meal or after a snack).
  * A dinosaur is specifically an extinct terrible (formerly considered) 
lizard where as a Gila Monster is definitely a scary & dangerous (dire) 
lizard.

In all of these cases there is a specificity to the word used that is 
missing from the alternative offered that will, hopefully, be raised by 
the use of that word. Unfortunately many people, when trying to explain 
what the word means fail to highlight where it is different (the number 
of times that I have heard people "explain" port and starboard as left 
and right without mentioning the word bow or forward is countless).

Using a slightly unfamiliar word can cause people to ask, or think 
about, why this is different & what the difference is while also drawing 
a parallel that can help the user/student to understand & remember the 
concept.

Also, picking a label for something, and using it consistently, can 
vastly simplify things like manual searches (or on-line searches).

The English language has, historically, always borrowed, co-opted and 
sometimes perverted words from other languages to allow distinct 
concepts to be expressed concisely - which I personally, (admittedly as 
a native speaker), find rather useful.

-- 
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect 
those of my employer.

---
This email has been checked for viruses by AVG.
https://www.avg.com

___
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] Python docs: page: In what ways in None special

2018-08-14 Thread Chris Angelico
On Wed, Aug 15, 2018 at 9:09 AM, Chris Barker via Python-ideas
 wrote:
> no, it's not -- None is keyword, and just like any other keyword, it can't
> be re-bound. However, every other keyword I tried to rebind results in a
> generic:
>
> SyntaxError: invalid syntax
>
> (except None, True, and False)
>
> which I suppose is because while None is a keyword, it can be used pretty
> much anywhere any other name can be used (as opposed to say, def)

Yeah. That's the difference between "keywords that are syntactically
special" and "keywords that represent specific values". Most keywords
define syntax (you mention "def", and similarly "if", "global",
"import") or are operators ("and", "if", "is not"); the ones that
could theoretically be assigned to are defined in the grammar as forms
of atom.

atom: ('(' [yield_expr|testlist_comp] ')' |
   '[' [testlist_comp] ']' |
   '{' [dictorsetmaker] '}' |
   NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')

>>> ... = 1
  File "", line 1
SyntaxError: can't assign to Ellipsis
>>> None = 2
  File "", line 1
SyntaxError: can't assign to keyword
>>> True = 3
  File "", line 1
SyntaxError: can't assign to keyword
>>> False = 4
  File "", line 1
SyntaxError: can't assign to keyword

Interestingly, even though the first example specifically says
"Ellipsis", it's perfectly acceptable to assign to that name:

>>> Ellipsis = 5
>>> print(Ellipsis)
5

Note also that the rules are slightly different in Python 2; True and
False are ordinary builtins, and "..." has meaning only inside a
subscript, so trying to assign to it makes as much sense as "<> = 1".

The special non-assignable status of None is therefore shared by three
other values; it's still special, but it's not unique. The same is
true of the behaviour of "if None:" - since it's a keyword and cannot
be assigned to, it will always have the same value, and since it's an
immutable value, it will always have the same truthiness, and since
the 'if' statement is always false, the bytecode can be optimized
away. So that's also not unique to None, but is behaviour shared by
other literals. (Only literals though - neither "if []:" nor "if {}:"
is optimized out, at least in CPython 3.7.)

ChrisA
___
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] Python docs: page: In what ways in None special

2018-08-14 Thread Chris Barker via Python-ideas
On Tue, Aug 14, 2018 at 10:45 AM, Rhodri James  wrote:

> On 'None is a constant':
>
> Erm.  I think you've got carried away with simplifying this and gone down
> a blind alley.  None is a literal, and like any other literal can't be
> rebound.


no, it's not -- None is keyword, and just like any other keyword, it can't
be re-bound. However, every other keyword I tried to rebind results in a
generic:

SyntaxError: invalid syntax

(except None, True, and False)

which I suppose is because while None is a keyword, it can be used pretty
much anywhere any other name can be used (as opposed to say, def)


Either this entire section is irrelevant or you meant to explain that there
> is only one "NoneType" object.
>
> Constant is a bit of a loaded term in Python, and I think you've fallen
> foul of it here.
>

yes, I think "singleton" is the word you want here, though it is a bi CS-y
:-(

-CHB

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
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] Python docs page: In what ways is None special

2018-08-14 Thread Chris Barker via Python-ideas
On Tue, Aug 14, 2018 at 10:25 AM, David Mertz  wrote:

> Great work! There are a few typos, I'll try to get to a PR on those.
>
> I wonder if it's worth noting that None is a singleton, while 42 is just a
> value. I.e. there might be several distinct objects that happen to be the
> int 42, but not so with None.
>

very much worth nothing -- and I think re-wording that example. The fact
that you can't assign to None is orthogonal to the fact that it's immutable.

in fact, [42] is a llteral for a list with one element, the integer with
the value of 42 in it. It is very much a mutable. and yet:

In [7]: [42] = 34
  File "", line 1
[42] = 34
SyntaxError: can't assign to literal

whereas:

[5].append(3)

works -- at least it does not result in an error -- even though it's
useless.

And the reason this matters is that name binding (and rebinding) is very
much a different operation than mutating -- we should not conflate those.

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
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] Does jargon make learning more difficult?

2018-08-14 Thread Michael Selik
The conversation about syntactic sugar for ``functools.partial`` led to a
question about whether jargon like "lambda" makes the concept of an
anonymous function more difficult to learn.

In my own experience teaching, I find that many concepts are easier to
introduce if I avoid the Python jargon until after I've explained what it
does. This is supported by education research. Some light Googling found a
study on the topic [0] that is consistent with my own observations.

Picking good names is hard [1]. It's tempting to use terms based on the
origin of the concept, historical odds and ends, or even jokes. This can
help someone remember the concept when someone is familiar with the origin,
history, or joke, but makes the concept more confusing and hard to remember
for others. I recommend trying to buck tradition and pick terms that are as
simple as possible, requiring the least context to make sense.

Jargon can be useful for allowing an expert to quickly identify the context
of a term [2]. Plain language phrases can easily create namespace
collisions. However, someone searching for or reading about Python concepts
already knows that the context is Python programming.

Good comparisons can be found in other fields:
* Driving -- brakes vs stoppers
* Sailing -- starboard vs right-side
* Medicine -- postprandial vs after-meal
* Biology -- dinosaur vs direlizard

In the last case, it turns out direbird might have been a better term. I'm
not sure if that supports or detracts from my argument.

[0] https://iubmb.onlinelibrary.wiley.com/doi/full/10.1002/bmb.20922
[1] https://martinfowler.com/bliki/TwoHardThings.html
[2] https://www.nngroup.com/articles/specialized-words-specialized-audience/



On Mon, Aug 13, 2018 at 9:00 PM Chris Angelico  wrote:

> On Tue, Aug 14, 2018 at 7:58 AM, Greg Ewing 
> wrote:
> > Chris Angelico wrote:
> >> No, lambda calculus isn't on par with brakes - but anonymous functions
> are, and if they're called "lambda", you just learn that.
> >
> > It's like saying that people would find it easier to learn to
> > drive if "brakes" were called "stoppers" or something. I don't
> > think that's true.
>
> Reminds me of this:
> "So, there's some buttons on the floor. Pedals. Uhh That's the
> "go" pedal... That, I believe, is the stopper... and this... this
> doesn't do anything"
> -- Wreck It Ralph, trying to figure a car out.
>
> I'm pretty certain he didn't do any better that way than if he'd used
> words like "accelerator" and "brake". In fact, this supports my
> assertion that it's not the terminology that bites you - it's the
> concepts behind it. Even if he'd known that the other pedal was called
> the "clutch", it wouldn't have helped him much without knowing how to
> use it...
>
> Whether you spell it "function(arg) {...}" or "lambda arg: ...", it's
> the semantics that are hardest to learn.
>
___
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] Python docs: page: In what ways in None special

2018-08-14 Thread Rhodri James
(Sorry to break threading on this.  In a fit of idiocy I deleted the 
original email before realising I wanted to reply.)


First off, thanks for doing this Jonathan.  Documentation is usually a 
thankless task, so we ought to start by thanking you!


I have a few comments on both content and style, good and bad.  Starting 
with style, I notice you tend to write in short sentences.  This is 
generally a good thing, but sometimes you make them too short.  This 
gets really visible when you start sentences with "And" or "But"; my old 
English teacher would have menaced you with a ruler for such bad 
grammar.  You can start a sentence with a conjunction, but it adds extra 
emphasis that you don't usually want.  The start of the "Why None?" 
section is a good example.  It reads like:


"Sometimes a value is required.  But (pay careful attention to this, 
it's important and there will be a quiz later) we're not able to provide 
one."


I exaggerate for effect, of course, but it would read more easily as:

"Sometimes a value is required but we're not able to provide one."

On 'None is a constant':

Erm.  I think you've got carried away with simplifying this and gone 
down a blind alley.  None is a literal, and like any other literal can't 
be rebound.  Either this entire section is irrelevant or you meant to 
explain that there is only one "NoneType" object.


Constant is a bit of a loaded term in Python, and I think you've fallen 
foul of it here.


On 'None is the default return value':

I really dislike the term "falls off the bottom".  I can't think of 
anything similarly short and expressive, but I grimaced when I saw it. 
The 'list gotcha' is a good example of how None is used as the default 
return value and why programmers should pay attention, but it doesn't 
deserve it's own subsection.  It's a direct consequence of None being 
the return value.


On 'None can signal failure':

Here's where I think None stops being special in the document.  None can 
signal failure.  So False, 0, an empty string, a negative number or 
pretty much anything else.  If you want to have a section on how None is 
used, that great, but having this in the section "How None is special" 
is just wrong.


On 'None as a placeholder default':

Ditto.  It's common to use None as a placeholder for a mutable type; 
explaining that common gotcha here would be good.


Epigraphs:

If you're going to quote Sherman, you need to expand on the uniqueness 
of None.  Not doing that just makes it look irrelevant.  It's not 
irrelevant, it's a tigger [1]


[1] Misquoting Michael Flanders from the introduction to "The 
Hippopotamus Song" on "At The Drop Of A Hat".


--
Rhodri James *-* Kynesim Ltd
___
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] Python docs page: In what ways is None special

2018-08-14 Thread David Mertz
Great work! There are a few typos, I'll try to get to a PR on those.

I wonder if it's worth noting that None is a singleton, while 42 is just a
value. I.e. there might be several distinct objects that happen to be the
int 42, but not so with None.

Of course, in CPython, small integers are cached as the same object, but
larger integers are not necessarily cached. This has varied in details
between Python implementations and even versions, it's not a semantic
promise like None carries.

Maybe that's too far in the weeds for an intro though.

On Tue, Aug 14, 2018, 6:29 AM Jonathan Fine  wrote:

> Hi
>
> I'm pleased to announce that I've completed the first draft of my
> page. It's viewable on gitub.
>
> https://github.com/jfine2358/py-jfine2358/blob/master/docs/none-is-special.md
>
> To quote from that page:
>
> This page arose from a thread on the python-ideas list. I thank Steve
> Dower, Paul Moore, Steve D'Aprano, Chris Barker, David Mertz, Jörn
> Heissler, Anthony Risinger, Michael Selik, Chris Angelico for their
> contributions and encouragement.
>
> Apologies for anyone I've missed. Comments either on python-ideas, or
> perhaps better, by raising an issue on github.
>
> --
> Jonathan
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
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] Python docs page: In what ways is None special

2018-08-14 Thread Brice Parent

Nice work, very usefull.

Is it interesting enough to note that the negation of None is True? 
(probably just because when it's casted to bool, it becomes False).


Also,  even if None is seen as the value for the lack of value, it is 
still hashable and can be used as a key to a dict (I'm not saying it's 
always good practice!):


>>> def f():
... pass
...
>>> {None: 5, not None: 6}
{None: 5, True: 6}
>>> {f(): 4}
{None: 4}

Also, I would probably have added an example of how (and why) to use a 
sentinel value for when None has a meaning other than [not provided] in 
a function's signature.



You'll see if any of these is worth integrating.

- Brice


Le 14/08/2018 à 12:28, Jonathan Fine a écrit :

Hi

I'm pleased to announce that I've completed the first draft of my
page. It's viewable on gitub.
https://github.com/jfine2358/py-jfine2358/blob/master/docs/none-is-special.md

To quote from that page:

This page arose from a thread on the python-ideas list. I thank Steve
Dower, Paul Moore, Steve D'Aprano, Chris Barker, David Mertz, Jörn
Heissler, Anthony Risinger, Michael Selik, Chris Angelico for their
contributions and encouragement.

Apologies for anyone I've missed. Comments either on python-ideas, or
perhaps better, by raising an issue on github.



___
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] Syntactic sugar to declare partial functions

2018-08-14 Thread Chris Barker - NOAA Federal via Python-ideas
>
> Do we often call functools.partial on arbitrary callable objects that we
> don't know in advance?

For my part, I don’t think I’ve ever used partial in production code.
It just seems easier to simply fo it by hand with a closure ( Am I
using that term right? I still don’t quite get the terminology)

And if I had a callable class instance I wanted to “customize”, I’d
likely use an OO approach — parameterize the instance, or subclass.

So yeah, partial is probably used primarily with “regular” functions.

But then, I don’t know that we need any easier syntax anyway — maybe
I’d be more likely to use it, but it kind of feels like a feature
that’s there so we can write more functional code for the sake of
writing more functional code.

If someone’s really interested in this, a search on gitHub or
something to see how it’s used in the wild could be enlightening.

-CHB
___
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] Conduct on python-ideas

2018-08-14 Thread Jonathan Fine
Hi Everyone

Brett Cannon wrote:

> I shouldn't be having to explain to adults on how to communicate among
> strangers of different cultures, but here we are. I did an entire PyCon US
> keynote on why we need to treat open source as a series of kindnesses and
> react as such: https://youtu.be/tzFWz5fiVKU?t=49m29s . If we don't treat
> everything as a kindness then open source simply doesn't work and people end
> up walking way from open source and the Python community.

Well, I've just watched that video. Did anyone else? Recommended -
it's only 30 minutes.

Is that too long? Well, here's two extracts.

Video at https://youtu.be/tzFWz5fiVKU?t=4450

> If I had to give guidelines on how to communicate online:

> 1. Assume that you are asking *me* for a *favour*.
> 2. Assume your *boss* will read what you say.
> 3. Assume *your family* will read what you say.

Video at https://youtu.be/tzFWz5fiVKU?t=4094

> *If this sounds biased towards maintainers, that's because it is.*

> Simply based on scale, maintainers are abused much more
> often than contributors.

Once again, recommended. I hope you'll watch the video.

-- 
Jonathan
___
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] Python docs page: In what ways is None special

2018-08-14 Thread Jonathan Fine
Hi

I'm pleased to announce that I've completed the first draft of my
page. It's viewable on gitub.
https://github.com/jfine2358/py-jfine2358/blob/master/docs/none-is-special.md

To quote from that page:

This page arose from a thread on the python-ideas list. I thank Steve
Dower, Paul Moore, Steve D'Aprano, Chris Barker, David Mertz, Jörn
Heissler, Anthony Risinger, Michael Selik, Chris Angelico for their
contributions and encouragement.

Apologies for anyone I've missed. Comments either on python-ideas, or
perhaps better, by raising an issue on github.

-- 
Jonathan
___
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] Syntactic sugar to declare partial functions

2018-08-14 Thread Steven D'Aprano
On Mon, Aug 13, 2018 at 07:46:49PM +0200, Stefan Behnel wrote:
> Michel Desmoulin schrieb am 09.08.2018 um 18:59:
> > I'd rather have functools.partial() to be added as a new method on
> > function objects.
[...]
> > add_2 = add.partial(2)
> 
> Except that this only works for functions, not for other callables.
> Meaning, code that uses this for anything but its self-defined functions
> will break as soon as someone passes in a callable object that is not a
> function.

That's an excellent point.

If it were important to cover those use-cases, we could add a partial 
method to types, methods, builtin-functions etc. But I suspect that 
doing that would increase the cost of this proposed feature past the 
point where it is worthwhile.

Do we often call functools.partial on arbitrary callable objects that we 
don't know in advance? (Not a rhetorical question.) I know I don't -- 
all the times I've called partial, I've known what the callable was, and 
it was always a function I created with def. But maybe others do 
something differently.

I don't mind writing this:

# only a minor inconvenience
spam = func.partial(arg)
eggs = functools.partial(callable, arg)

given that I knew upfront that func was a function and callable was not. 
But if I didn't know, the utility of a partial method would be hugely 
reduced, and I'd just use functools.partial for everything.



-- 
Steve
___
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] Toxic forum

2018-08-14 Thread Jacco van Dorp
I'm perhaps the newest and most ignorant subscriber here - I daresay
everyone here has superior python knowledge to me, and all my other
computing knowledge is inferior to what I can do with python. (and so far,
I've had no influence at all on python)

However, this mailing list, generally, does not seem toxic to me at all. I
haven't experienced any condescension about my lack of knowledge. While I
can acknowledge that there might be superior alternatives to email, I do
think the threshold of subscribing and listening in is lower than a lot of
other options, like for example subreddits. I for example would have never
come if it'd been one of those.

2018-08-14 10:53 GMT+02:00 Jonathan Fine :

> Hi All
>
> Here's something that's at the core of my approach.
>
> Faced with this sort of problem, I read again
> https://www.python.org/psf/codeofconduct/. And then I compare my
> intentions, words and actions to the guidelines in this, the Python
> Community Code of Conduct. Only when I have, so to speak, regained my
> purpose and composure do I consider the conduct of others.
>
> At least, this is what I aspire to do.
>
> --
> Jonathan
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
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] Toxic forum

2018-08-14 Thread Jonathan Fine
Hi All

Here's something that's at the core of my approach.

Faced with this sort of problem, I read again
https://www.python.org/psf/codeofconduct/. And then I compare my
intentions, words and actions to the guidelines in this, the Python
Community Code of Conduct. Only when I have, so to speak, regained my
purpose and composure do I consider the conduct of others.

At least, this is what I aspire to do.

-- 
Jonathan
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/