[Tutor] Building Starships -- object of type 'int' has no len()
Terry--gmail
terry.kemmerer at gmail.com
Wed Aug 20 00:41:37 CEST 2014
The down side of setting the python.org domain to be mailed to as plain
text, appears to be that Thunderbirdy has changed all my email to plain
text, instead of just the email going to this domain....which is weird.
Leam Hall:
I have just one additional function to create in the User Design section
where the the user designs his own starship, to complete, before I move
on to the Alien Design section where the computer semi-intelligently and
randomly designs the unknown Alien ship we are going to meet out in
interstellar space. That will be in 1 dimensional space to start with.
You can either try to run away, charge right in and try to match
relative direction and speed, or sweep in and fly right past the enemy
blasting away at it. As the program gets worked out, I will alter for
more dimensions....eventually, as I learn graphics. Right now, it is
about the combat against an unknown enemy of unknown strength and
capabilities. I figure it's a fun way to acquire pythonic skills and
manage to remember all the commands possible. It's what I did when I
first learned BASIC. So...it's going to be traditional with me...
If you want, and if it doesn't violate any rules for this mailing list,
I could post the User Design section for you to look over to see what my
basic concepts are, just after I add and test this last section.
Ultimately, I want this design section to be really easy to add
additional capabilities to later and it is sort of written for the most
part that way right now....although necessity also requires some custom
filtering for different catagories of parts - like, you can only
purchase one Hull for your ship!
( :) I probably wouldn't try to learn my techniques though....my python
skills and vocabulary are a real work in progress and I read so much
that I am forgetting what I have read. And I have no doubt I have
probably broken pythonic rules and slaughtered proper methodology to
high heaven in the layout and implementation. Ha Ha Ha)
But this section does work....at least until I discover a bug in some
untested possible combination of choices. The way I broke it was by
adding additional functions.
Just let me know if you want me to post it for you to look over.
DaveA:
The bare 'except' was a throw away. By bare 'except' I am assuming you
mean without defining the type of error 'except' is to act upon?
try:
something
except ValueError:
do something
-Or does bare 'except' mean something else?
Alan Guald:
I have been trying out the different ways you suggested for doing this,
and have ran into a problem on making the very last one work. I stuck a
print statement in it to help, but I am not sure what the error
statement is telling me:
for row in catalog2:
print(row)
for col, item in row:
lens[col].append(len(item))
lens = [max(col) for col in lens]
and I get the following error in 'for col, item in row:'
'ValueError: too many values to unpack (expected 2)':
I don't see why it would possibly say there are too many values to
unpack or why it would expect only 2!
Also, the list comprehension you have used on the final line reminds me
that I would really like to understand comprehensions better. Is there
some info on the Internet that starts very basic concerning
comprehensions and explains step by step in complexity how they are
structured and what the computer is doing?
Just looking at the code setting there inside the list brackets and know
what the output is going to be, reminds me of a programmed cell of a
spreadsheet....kind of.
Mark Tompkins:
"Does (x) have Buddha-nature?"
In college, in a Psychology of Communications class, I spent a lot of
time studying, writing about, and contemplating "The Is-ness of IS!"
Does that count?
I hand typed all of the above code in, except the error portion.
This is pasted from Ninja-IDE and it comes out in smaller letters and is
impossible to make larger...
for row in catalog2:
for col, item in row:
lens[col].append(len(item))
lens = [max(col) for col in lens]
Mark Lawrence gave me the idea to copy from Ninja-IDE to gedit and then
copied it from gedit here: (actually I saved it in gedit and then
re-grabbed it with gedit )
for row in catalog2:
print(row)
for col, item in row:
lens[col].append(len(item))
lens = [max(col) for col in lens]
Boy! It looks far better on my page than the straight Ninja-ide paste
above! And it is now manipulatable, I can enlarge and shrink
it...whereas, the Ninja paste resists things like trying to delete the
extra lines of white space below it and I have even saw it collapse to
flat right before my eyes!
So, I guess the best route is to paste from Ninja to gedit and then to
my email....assuming this is good on your end.
On 08/19/2014 02:29 PM, Marc Tompkins wrote:
> On Tue, Aug 19, 2014 at 1:04 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
>> I'm not aware of any problem with Thunderbird or any (semi-)decent mail
>> client.
> The original poster uses NinjaIDE and Thunderbird, and his code was
> being persistently flattened when he copied/pasted. I believe I've
> just tracked it down to an incompatibility between the two (which also
> happens to extend to Ninja/Gmail.) I'm not sure how Google Groups
> enters into it.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list