"as" keyword woes

James Mills prologic at shortcircuit.net.au
Thu Dec 4 05:53:38 EST 2008


One of the things I'd like to point out here is
what we've been learning in new job during
Induction Training...

That is, it's part of the coding standard and
design standards to name variables sensibly.

For instance, naming a variable "db" when it's
really a "database" object is a no no. Instead
you should be naming it "db".

Another example, "db_id" vs. "database_id".

So my point here is that you should not really/ideally
be naming variables with such short un-meaningful
names such as "as", "if", "id", "xs" or what not.

Readability of your code becomes very important
especially if you're working with many developers
over time.

1. Use sensible meaningful names.
2. Don't use abbreviations.

cheers
James

On Thu, Dec 4, 2008 at 8:43 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On Thu, 4 Dec 2008 01:28:56 -0800, "Warren DeLano" <warren at delsci.com>
> declaimed the following in comp.lang.python:
>
>> In addition, note that my choice of a concise method identifier affects
>> only my users.  Python's introduction of a new keyword affects the
>> entire Python world code base, so perhaps you should be directing your
>> "choose better names" criticism in another direction?
>>
>        Dropping in...
>
>        If a "chosen name" mirrors a syntactic element -- whether reserved
> or not -- I'd consider that name potentially ambiguous or conflicted.
>
>        While "if" has been long a reserved word, I can as easily see
> someone using "if" as a shorthand name for "interface". And if "if" were
> not a reserved word, one might encounter code on the lines of
>
>        if = if + 1
>
> which is quite obnoxious to my eyes... or maybe
>
>        if if.connected:
>                if.close()
>
>
>        Since
>
>        import x as y
>
> has been a syntactic capability for some time, even if not reserved, I'd
> have avoided using "as" as anything other than that usage...
> --
>        Wulfraed        Dennis Lee Bieber               KD6MOG
>        wlfraed at ix.netcom.com           wulfraed at bestiaria.com
>                HTTP://wlfraed.home.netcom.com/
>        (Bestiaria Support Staff:               web-asst at bestiaria.com)
>                HTTP://www.bestiaria.com/
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list