Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
Marko Rauhamaa wrote: > What's the inherent difference between an attribute and a key. Here is my bucket. The handle of the bucket is part of the bucket: bucket.handle The pieces of coal I carry in the bucket is part of its content: bucket['coal'] Of course, we can blur the distinction betw

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread MRAB
On 2014-08-05 14:19, Marko Rauhamaa wrote: Skip Montanaro : On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes ≠ keys. When you see something.somethingelse anywhere else in Python

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Marko Rauhamaa
Skip Montanaro : > On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: >> I wonder if that should be built into dict. > > Short answer, no. I'm sure it's been proposed before. Attributes ≠ > keys. When you see something.somethingelse anywhere else in Python, > "somethingelse" is an attribute re

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Chris Angelico
On Tue, Aug 5, 2014 at 10:43 PM, Steven D'Aprano wrote: > Because it's horrible and a bad idea. > > d = {'this': 23, 'word': 42, 'frog': 2, 'copy': 15, 'lunch': 93} > e = d.copy() > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'int' object is not callable > > > Confl

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Chris Angelico
On Tue, Aug 5, 2014 at 10:31 PM, Skip Montanaro wrote: > JavaScript objects have that feature. I find it mildly confusing > because whenever I see it I have to pause to consider whether the name > I am looking at is an attribute or a key. This little JS code I just > typed at my console prompt was

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Why can't I have: > >>>> d = {} >>>> d.x = 3 >>>> d >{'x': 3} Because it's horrible and a bad idea. d = {'this': 23, 'word': 42, 'frog': 2, 'copy': 15, 'lunch': 93} e = d.copy() Traceback (most recent call last): File "", line 1, in ? TypeError: 'int'

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Skip Montanaro
On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: > > I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes ≠ keys. When you see something.somethingelse anywhere else in Python, "somethingelse" is an attribute reference. When you see som

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Marko Rauhamaa
Brian Blais : > class Struct(dict): > > def __getattr__(self,name): > > try: > val=self[name] > except KeyError: > val=super(Struct,self).__getattribute__(name) > > return val > > def __setattr__(self,name,val): > > self[name]=val Co

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Brian Blais
On Sat, Aug 2, 2014 at 2:45 AM, Mark Summerfield wrote: > Last week I spent a couple of days teaching two children (10 and 13 -- too > big an age gap!) how to do some turtle graphics with Python. Neither had > programmed Python before -- one is a Minecraft ace and the other had done > Scratch.

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Terry Reedy
On 8/2/2014 4:03 AM, Mark Summerfield wrote: On Saturday, 2 August 2014 08:46:04 UTC+1, Mark Lawrence wrote: On 02/08/2014 07:45, Mark Summerfield wrote: Summarizing my responses on the tracker... Suggestion #1: Make IDLE start in the user's home directory. Entirely agree. Please raise a

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Terry Reedy
On 8/2/2014 3:46 AM, Mark Lawrence wrote: On 02/08/2014 07:45, Mark Summerfield wrote: Last week I spent a couple of days teaching two children (10 and 13 -- too big an age gap!) how to do some turtle graphics with Python. Neither had programmed Python before -- one is a Minecraft ace and the ot

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Marko Rauhamaa
Mark Lawrence : > On 02/08/2014 18:07, Marko Rauhamaa wrote: >> And the newest Python releases let you replace that with: >> >> import types >> Object = types.SimpleNamespace > > With the latter being part of suggestion #3 in the original post. Not quite. Even though Sugg. #3 would allow

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Lawrence
On 02/08/2014 18:07, Marko Rauhamaa wrote: Steven D'Aprano : Marko Rauhamaa wrote: __setattr__ could create __dict__ belatedly. Are we designing Son Of PHP, or a sensible language? *wink* If object.__setattr__ did this, then we're left with two equally horrible choices: Not a huge issue.

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Marko Rauhamaa
Steven D'Aprano : > Marko Rauhamaa wrote: >> __setattr__ could create __dict__ belatedly. > > Are we designing Son Of PHP, or a sensible language? *wink* > > If object.__setattr__ did this, then we're left with two equally > horrible choices: Not a huge issue. Only mildly annoying to have to crea

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Mark Summerfield : > >> object() returns a minimal featureless object with no dictionary (no >> __dict__ attribute). This makes sense for efficiency since not all >> objects need a dictionary. > > __setattr__ could create __dict__ belatedly. Are we designing Son Of PHP,

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Expanding #3: > >>>> o = object() >>>> o.x = 3 >Traceback (most recent call last): > File "", line 1, in >AttributeError: 'object' object has no attribute 'x' > > Why? There are two intended uses for object and its instances: - as the base class fo

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Summerfield
On Saturday, 2 August 2014 08:46:04 UTC+1, Mark Lawrence wrote: > On 02/08/2014 07:45, Mark Summerfield wrote: > [snip] > > > Suggestion #1: Make IDLE start in the user's home directory. > > Entirely agree. Please raise an enhancement request on the bug tracker > if there isn't already one.

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Marko Rauhamaa
Mark Summerfield : > object() returns a minimal featureless object with no dictionary (no > __dict__ attribute). This makes sense for efficiency since not all > objects need a dictionary. __setattr__ could create __dict__ belatedly. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Lawrence
On 02/08/2014 07:45, Mark Summerfield wrote: Last week I spent a couple of days teaching two children (10 and 13 -- too big an age gap!) how to do some turtle graphics with Python. Neither had programmed Python before -- one is a Minecraft ace and the other had done Scratch. Suggestion #1: Mak

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Summerfield
On Saturday, 2 August 2014 08:14:08 UTC+1, Marko Rauhamaa wrote: > Mark Summerfield: > > > Suggestion #1: Make IDLE start in the user's home directory. > > > Suggestion #2: Make all the turtle examples begin "from turtle import > > *" so no leading turtle. is needed in the examples. > > > > Sugge

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Marko Rauhamaa
Mark Summerfield : > Suggestion #1: Make IDLE start in the user's home directory. > > Suggestion #2: Make all the turtle examples begin "from turtle import > *" so no leading turtle. is needed in the examples. > > Suggestion #3: Make object(key=value, ...) legal and equiv of > types.SimpleNamespac