[Tutor] Building Starships -- object of type 'int' has no len()
Marc Tompkins
marc.tompkins at gmail.com
Mon Aug 18 03:37:56 CEST 2014
On Sun, Aug 17, 2014 at 4:48 PM, Terry--gmail <terry.kemmerer at gmail.com> wrote:
> WOW! There is a lot of help on this mailing list! I want to thank everyone
> for their valuable input! Thanks! (I am working my way through the
> replies.)
>
> Sorry about the HTML. I think I have it turned off now in Thunderbirdy for
> this address. If so, then what follows should not be flat. If it is flat,
> please tell me.
It's not only flat, but appears in a confusing array of sizes and
styles - VERY SHOUTY bold 18-point for most of the text; 12.8 regular
for code; 15.8 regular for the text that appears after the code. Hard
to read the prose, never mind that it wiped out the indentation of
your code.
>
> Mark:
>
> You commented on the non-Pythonic nature of my program. HA HA HA! I don't
> doubt it!
What I was getting at is a sort of feeling. Taking the length of a
list, then using that length as the end value for range(), then
counting up to the end of that range to step through the list... does
it not feel like you've got unnecessarily far from the subject at
hand? The Pythonic way would be to step through the list itself - or,
if you must have a numeric index, to get it from enumerate()ing the
list.
As for a general theory of Pythonicity... it's a bit like all of those
Zen koans where a novice monk asks the master "Does (x) have
Buddha-nature?" (Not _quite_ as impossible to grasp as that, though!)
More information about the Tutor
mailing list