[Tutor] mnemonics to better learn Python
Luke Paireepinart
rabidpoobear at gmail.com
Thu Jul 23 19:11:36 CEST 2009
I approach these things more along the lines of objects rather than looking
at the raw source code to remember what I'm doing.For example, I see (x, y,
z) and I think "ah, it's a little pre-packaged goodie of delicious
variables"
and when I see [x, y, z] I think "ah, it's a box with some candy at the
bottom, but there's plenty of room for me to put more.
I'm guessing all the candy is interrelated somehow because people usually
keep things that are similar in the same container"
and for dictionaries I think "hey, it's just a list that's indexed with
anything you want, instead of only integers."
I wouldn't call it "rote learning" because that would be more along the
lines of
x = {"hello": 1} # dictionary with a string as key and an integer as valuex
= {1: "hello"} # dictionary with an integer as key and a string as value
x = {1: 1} # dictionary with an integer as key and value
x = {"hello": "hello"} # dictionary with a string as key and value
.... etc.
I.E. I'm not forcing myself to learn every possibility. I learn what
"mutability" is and then I learn what dictionaries are,
and then I understand how to use them. I don't need mnemonics to remember
them.
I guess my point is that I see syntax more as a means for defining a
specific behavior I want, rather than as an
actual representation of the behavior. Like, I think "I need a dictionary
here. Oh, that's the {} thing, right?"
rather than "Oh, there needs to be {} here, I think. Oh yeah, that's
called a dictionary"
so it doesn't really help to relate syntax to actual behavior.
I think of things on the conceptual level and translate down to Python when
I need to tell the computer how to do it.
And when I read Python code, I translate it up to conceptual level as well.
I don't see "series = form.getvalue('series').strip()" and think "okay,
there's an object called "form". it has a method called "getvalue" and it's
getting passed "series".
Then the return value is being stripped of whitespace on both ends."
I see it and I think "okay, 'series' was passed to the program in a
user-submitted form and now it's stored in a local variable so I can
manipulate it."
On Thu, Jul 23, 2009 at 1:05 AM, David <ldl08 at gmx.net> wrote:
> Dear List,
>
> in order to memorize which Python sequences are mutable or immutable, I
> focused on the SHAPE of the brackets that are associated with each type
> of sequence.
>
> For instance, a *list* is characterised by square brackets, [].
> My mnemonic device to memorize that lists are mutable is this: "the
> brackets have sharp edges, they could be trimmed, taking their edges off".
>
> The same thing happens with *dictionaries* (which, okay, are not
> sequences). Anyway, their brackets, {}, have sharp edges, hence they are
> mutable.
>
> *Tuples*, in turn, have perfectly 'round' brackets, (), and these
> brackets obviously can't be improved upon by taking anything off them.
> Hence: tuples are immutable.
>
> That leaves us with *strings*, which are also not mutable. Here we have
> no brackets, and this particular mnemonic device breaks down.
>
> What I am interested in is finding out whether you use similar
> techniques, and if so, which ones? How, for examples, do you make sense
> of all those special characters that make regular expressions powerful?
> Do you rely on rote learning, or do you employ some other technique?
>
> I reckon that if we could come up with some tips and techniques as to
> how to uncloud the thick information fog that any beginning programmer
> has to wade through, the very first steps in learning Python could be
> made more easy.
>
> What insights can you share?
>
> Curious,
>
> David
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090723/cfb303dd/attachment-0001.htm>
More information about the Tutor
mailing list