On 24/10/15 00:15, Mark Lawrence wrote:

Looking more at the code...

     > for x in range(len(drama_actor)):

This looks unusual...

A better question IMHO is "where did you learn to write code like that
in the first place", as I've seen so many examples of this that I cannot
understand why people bother writing Python tutorials, as they clearly
don't get read?


I think its just a case of bad habits from other languages being
hard to shake off. If your language doesn't have a for-each operator then its hard to wrap your brain around any other kind of for loop
than one based on indexes.

It's a bit like dictionaries. They are super powerful but beginners coming from other languages nearly always start out using
arrays(ie lists) and trying to "index" them by searching which
is hugely more complex, but it's what they are used too.

JavaScript programmers tend to think the same about Python
programmers who insist on writing separate functions for
call backs rather than just embedding an anonymous function.
But Python programmers are used to brain dead lambdas with
a single expression so they don't tend to think about
embedding a full function. Familiarity with an idiom makes
it easier to stick with what you know than to try something new.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to