[Zope3-dev] service names

Guido van Rossum guido@python.org
Mon, 03 Feb 2003 15:00:27 -0500


[Jim]
> > I really fail to see the benefit of a variable or a marker interface here.

[Shane]
> I've been pondering this for a few days.  I like to use global variables 
> as constants to shield myself from certain typos.  In the example below, 
> 'Id' is sometimes misspelled 'ID':
> 
> queryService(context, HubIds) -> hub IDs service
> queryService(context, HubIDs) -> NameError
> queryService(context, 'HubIds') -> hub IDs service
> queryService(context, 'HubIDs') -> None
> 
> In the last case, the error might go undetected.  So there is at least 
> one benefit to using a variable.  It's not terribly important, but I 
> thought it was worth mentioning. :-)

I'm with Shane.  This argument for avoiding literal constants in large
programs is as valid in Python as it is in other lanugages.

Also note that PyChecker can find the typo in the variable name, but
not the typo in the string.

--Guido van Rossum (home page: http://www.python.org/~guido/)