New statement proposal for Python

phil hunt philh at comuno.freeserve.co.uk
Fri Jun 15 07:18:40 EDT 2001


On 15 Jun 2001 02:37:51 GMT, David LeBlanc <whisper at oz.nospamnet> wrote:
>
>Creating an inherent means of creating constants (or my preferred 
>aliases) is good computer science as someone else mentioned in a reply 
>post. Magic numbers are bad - they're sloppy programming and a source of 
>errors if they must be used in several places etc. OTOH, aliases clarify 
>program meaning and imho make things more comprensible to newbies.

Surely a newbie can understand that if you assign a variable to a 
value, and then never change it, then it is working as a constant.

I have no problem having cxonstants like this, e.g.

   programVersion = "0.2.7"

it seems to me that:

   alias programVersion: "0.2.7"

is no clearer, and is an extra something for a learner to have to learn.
Entities should not be multiplied unnecessarily!

> I 
>think all would agree that "if something is true:" is clearer then "if 
>something is not 0:".

What's wrong with:

   if something:

which is what I would use here.

> Likewise, "userpermissions" is much more meaningful 
>then 0677

Indeed so. And in python, one can say:

   userPermissions = 0677

(Personally I prefer the way Smalltalk handles non-decimal radixes,
i.e. 8r677)

>One can certainly argue that this is syntactical sugar. It does however 
>serve a multitude of good purposes among which are: maintainability; 
>clarity;  consistancy; correctness; good programming habbits;

When I hear that phrase, I reach for my gun. Go and use Pascal or
Eiffel if you're into bondage-and-discipline.

-- 
##  Philip Hunt                   ##
##  philh at comuno.freeserve.co.uk  ##






More information about the Python-list mailing list