problem with exam task for college

Chris Angelico rosuav at gmail.com
Fri Jan 4 15:36:14 EST 2013


On Sat, Jan 5, 2013 at 7:01 AM,  <jeltedeproft at hotmail.com> wrote:
> woow jeezes, thanks for the amazingly fast and detailed response, you guys are amazing.
>
> thanks again, are you guys getting paid for this or is this voluntarily? either way i really appreciate it

We're all volunteers (and it's now 7:30AM Saturday and I've been up
all night, so this post quite probably doesn't carry the hallmarks of
intelligence). To be more strictly correct, we are members of a
community - people helping people. Far as I know, there's not one
person here who has never asked a question. I tend to join a mailing
list to ask one or more questions, and hang around answering them long
after my personal needs are satisfied, kinda like seeding back a
torrent after you've downloaded it.

We answer questions for a variety of reasons. Partly, because this is
one of the best forms of help that the Python community can offer,
which means that supporting Python in this way strengthens the
language. Partly, because our names are connected to our posts, and we
are seen to be helpful people (and, since the list/newsgroup is
archived on the web, potential employers who search the web for our
names will see us being helpful and knowledgeable). Partly, because
we're repaying the community for the benefits we've gained from it.
Partly, because in answering questions, we ourselves learn. And there
are other reasons too.

> 2) sorry for the dutch names :)

No probs; as was said in several follow-ups, those are well-chosen names.

> b) the problem i originally described in my first post was not resolved, by means of elimination i could conclude that the problem situates itself in this lines :
>
>                 c = list(self.frame.axis)
>                 c[2] -= 0.1
>                 c = tuple(c)
>                 c = self.frame.axis

This code is looking quite messy, here. But the most obvious problem
is that you're setting up 'c' to be the modified axis, and then...
overwriting c with the old axis. Try doing the assignment the other
way in the last line:

self.frame.axis = c

Alternatively, you could do the whole thing more cleanly by unpacking
and then repacking the tuple:

(x, y, z) = self.frame.axis
self.frame.axis = (x, y, z-0.1)

Two lines that do the job of the above four. Note that the parentheses
are optional here; they look nice since axis is holding coordinates,
but Python doesn't care.

Hope that helps!

ChrisA



More information about the Python-list mailing list