On Thu, Feb 21, 2008 at 8:49 AM, Tyler Smith <[EMAIL PROTECTED]> wrote:
>
>  Not shorter, but definitely clearer would be to replace your magic
>  numbers with variables:
>
>  entrance = 6
>  exit = 11
>  death_room = 13
>
>  Replacing each occurrence of those numbers in your code with the
>  variables means you only have to make one change that propagates
>  through the entire program if you change the map layout. It also
>  means that if you're reading your code in a year you won't have to
>  remember that '6' means something special in this context.
>
>  I'm just a novice python programmer, but it's a good rule of thumb to
>  avoid magic numbers in any language.
>
>  Tyler

Your suggestion is clear and to the point. Noted.

I'm also aware of this 'rule of thumb', but simply forgot
to implement it due to being so familiar with what the
'magic numbers' mean, that I just didn't remember
to do it. But will I remember what it is six months from
now? Probably not. This is, indeed, a good rule of thumb!

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance. Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to