Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86592 > unrolled thread

Re: Python Worst Practices

Started byTravis Griggs <travisgriggs@gmail.com>
First post2015-02-27 13:21 -0800
Last post2015-03-01 13:29 +1300
Articles 7 on this page of 27 — 15 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python Worst Practices Travis Griggs <travisgriggs@gmail.com> - 2015-02-27 13:21 -0800
    Re: Python Worst Practices Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-28 12:09 +1100
      Re: Python Worst Practices sohcahtoa82@gmail.com - 2015-02-27 17:32 -0800
        Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-02-28 12:44 +1100
          Re: Python Worst Practices Christian Gollwitzer <auriocus@gmx.de> - 2015-03-03 09:51 +0100
            Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-03-03 22:12 +1100
              Re: Python Worst Practices Christian Gollwitzer <auriocus@gmx.de> - 2015-03-03 23:46 +0100
                Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-03-04 10:12 +1100
                  Re: Python Worst Practices Christian Gollwitzer <auriocus@gmx.de> - 2015-03-04 21:27 +0100
      Re: Python Worst Practices Dan Sommers <dan@tombstonezero.net> - 2015-02-28 04:42 +0000
        Re: Python Worst Practices Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-28 17:36 +1100
          Re: Python Worst Practices Dan Sommers <dan@tombstonezero.net> - 2015-02-28 07:50 +0000
            Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-02-28 19:55 +1100
          Re: Python Worst Practices Ethan Furman <ethan@stoneleaf.us> - 2015-02-27 23:51 -0800
            Re: Python Worst Practices Marko Rauhamaa <marko@pacujo.net> - 2015-02-28 10:50 +0200
        Re: Python Worst Practices Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-28 01:48 -0700
        Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-02-28 19:58 +1100
      Re: Python Worst Practices Tim Chase <python.list@tim.thechases.com> - 2015-02-27 21:50 -0600
        Re: Python Worst Practices Cousin Stanley <cousinstanley@gmail.com> - 2015-02-28 09:03 -0700
          Re: Python Worst Practices Rustom Mody <rustompmody@gmail.com> - 2015-02-28 08:16 -0800
          Re: Python Worst Practices MRAB <python@mrabarnett.plus.com> - 2015-02-28 17:56 +0000
          Re: Python Worst Practices Ethan Furman <ethan@stoneleaf.us> - 2015-02-28 10:13 -0800
          Re: Python Worst Practices Tim Chase <python.list@tim.thechases.com> - 2015-02-28 12:30 -0600
          Re: Python Worst Practices Tim Chase <python.list@tim.thechases.com> - 2015-02-28 12:39 -0600
      Re: Python Worst Practices BartC <bc@freeuk.com> - 2015-02-28 10:39 +0000
        Re: Python Worst Practices Chris Angelico <rosuav@gmail.com> - 2015-02-28 23:45 +1100
          Re: Python Worst Practices Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-03-01 13:29 +1300

Page 2 of 2 — ← Prev page 1 [2]


#86631

FromMRAB <python@mrabarnett.plus.com>
Date2015-02-28 17:56 +0000
Message-ID<mailman.19340.1425146201.18130.python-list@python.org>
In reply to#86625
On 2015-02-28 16:03, Cousin Stanley wrote:
>
>> From :  Tim Chase
>>
>> A quick google-and-tally for languages
>> and their corresponding number of keywords:
>> ....
>
>    re-sorted ....
>
>       21 :  Lua
>       31 :  Python2.x
>       33 :  Python3.x
>       33 :  C
>       37 :  Pike
>       40 :  Perl
>       40 :  Ruby
>       50 :  Java
>       54 :  Pascal
>       67 :  PHP
>       77 :  C#
>       86 :  C++
>
Does any language have more than COBOL? That has hundreds!

[toc] | [prev] | [next] | [standalone]


#86632

FromEthan Furman <ethan@stoneleaf.us>
Date2015-02-28 10:13 -0800
Message-ID<mailman.19341.1425147728.18130.python-list@python.org>
In reply to#86625

[Multipart message — attachments visible in raw view] — view raw

On 02/28/2015 09:56 AM, MRAB wrote:
> On 2015-02-28 16:03, Cousin Stanley wrote:
>>
>>> From :  Tim Chase
>>>
>>> A quick google-and-tally for languages
>>> and their corresponding number of keywords:
>>> ....
>>
>>    re-sorted ....
>>
>>       21 :  Lua
>>       31 :  Python2.x
>>       33 :  Python3.x
>>       33 :  C
>>       37 :  Pike
>>       40 :  Perl
>>       40 :  Ruby
>>       50 :  Java
>>       54 :  Pascal
>>       67 :  PHP
>>       77 :  C#
>>       86 :  C++
>>
> Does any language have more than COBOL? That has hundreds!

I think Visual FoxPro should get at least an (dis)honorable mention -- I didn't count, but there are several page-fulls [1].

--
~Ethan~


[1] https://msdn.microsoft.com/en-us/library/xztfc506%28v=vs.80%29.aspx

[toc] | [prev] | [next] | [standalone]


#86633

FromTim Chase <python.list@tim.thechases.com>
Date2015-02-28 12:30 -0600
Message-ID<mailman.19342.1425148170.18130.python-list@python.org>
In reply to#86625
On 2015-02-28 17:56, MRAB wrote:
> On 2015-02-28 16:03, Cousin Stanley wrote:
> >
> >> From :  Tim Chase
> >>
> >> A quick google-and-tally for languages
> >> and their corresponding number of keywords:
> >> ....
> >
> >    re-sorted ....
> >
> >       21 :  Lua
> >       31 :  Python2.x
> >       33 :  Python3.x
> >       33 :  C
> >       37 :  Pike
> >       40 :  Perl
> >       40 :  Ruby
> >       50 :  Java
> >       54 :  Pascal
> >       67 :  PHP
> >       77 :  C#
> >       86 :  C++
> >
> Does any language have more than COBOL? That has hundreds!

A quick check using [1] suggests that COBOL has 366, while according
to [2], MySQL's flavor of SQL has 825.

-tkc


[1]
http://cobol.404i.com/res.php

[2]
https://www.drupal.org/node/141051

[toc] | [prev] | [next] | [standalone]


#86635

FromTim Chase <python.list@tim.thechases.com>
Date2015-02-28 12:39 -0600
Message-ID<mailman.19344.1425149186.18130.python-list@python.org>
In reply to#86625
On 2015-02-28 10:13, Ethan Furman wrote:
> On 02/28/2015 09:56 AM, MRAB wrote:
> > On 2015-02-28 16:03, Cousin Stanley wrote:
> >>
> >>> From :  Tim Chase
> >>>
> >>> A quick google-and-tally for languages
> >>> and their corresponding number of keywords:
> >>> ....
> >>
> >>    re-sorted ....
> >>
> >>       21 :  Lua
> >>       31 :  Python2.x
> >>       33 :  Python3.x
> >>       33 :  C
> >>       37 :  Pike
> >>       40 :  Perl
> >>       40 :  Ruby
> >>       50 :  Java
> >>       54 :  Pascal
> >>       67 :  PHP
> >>       77 :  C#
> >>       86 :  C++
> >>
> > Does any language have more than COBOL? That has hundreds!
> 
> I think Visual FoxPro should get at least an (dis)honorable mention
> -- I didn't count, but there are several page-fulls [1].

That list has ~2405 entries, but it's been long enough since I've
used VFP (c. 2000) that I've successfully managed to repress the
nuances of whether those are actual reserved words, or whether, like
Python built-ins, they're more suggestions rather than enforced.

-tkc


[toc] | [prev] | [next] | [standalone]


#86617

FromBartC <bc@freeuk.com>
Date2015-02-28 10:39 +0000
Message-ID<5WgIw.887352$w_7.20106@fx38.am4>
In reply to#86604
On 28/02/2015 01:09, Steven D'Aprano wrote:

> Likewise:
>
> int = 23
> n = int("42")
>
> Isn't it obvious that the second use of int has to be the built-in function?
> I wish that the computer would understand from context which one I mean.

(People here would like PL/I then which apparently has *no* reserved 
words, so you can write: "if if=then then ...")

> Other newbie stylistic mistakes which can increase the chance of shadowing
> errors include:
>
> * Too many overly generic variable names like "int" and "str".

One thing I find annoying when looking at tutorial examples of an 
unfamiliar language is when they use identifier names such as 
"function", "array", "integer", "var" and so on, names which could 
conceivably be reserved words.

Because it's not clear if these *are* keywords that form part of the 
syntax, or built-ins, or actual made-up user identifiers.

-- 
Bartc


[toc] | [prev] | [next] | [standalone]


#86620

FromChris Angelico <rosuav@gmail.com>
Date2015-02-28 23:45 +1100
Message-ID<mailman.19333.1425127515.18130.python-list@python.org>
In reply to#86617
On Sat, Feb 28, 2015 at 9:39 PM, BartC <bc@freeuk.com> wrote:
> (People here would like PL/I then which apparently has *no* reserved words,
> so you can write: "if if=then then ...")

Likewise REXX has no reserved words; also, SQL went part-way there,
with the notion of "non-reserved keywords". For example, "ORDER" and
"BY" are reserved keywords, so they are unavailable as table/column
names, but "NULLS" is non-reserved. You could use it, if you wanted
to, but it's a syntactic element in some contexts. You can say "ORDER
BY some_column NULLS FIRST" or "NULLS LAST" to affect the ordering;
you can even say "ORDER BY NULLS NULLS FIRST", which will sort by a
column named NULLS, in ascending order, but counting NULL as lower
than everything (instead of higher than everything). Given the style
of SQL, it'd be insanely restrictive if it had to have everything be
either a keyword or nothing, so this is a good half-way-house.

ChrisA

[toc] | [prev] | [next] | [standalone]


#86638

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2015-03-01 13:29 +1300
Message-ID<clf4rqF4hh9U1@mid.individual.net>
In reply to#86620
Chris Angelico wrote:
> Likewise REXX has no reserved words; also, SQL went part-way there,
> with the notion of "non-reserved keywords".

Python sometimes has those, too. For example, the "as" in
"import as" was non-reserved when it was first introduced,
to avoid abruptly breaking code that used it as a name.

-- 
Greg

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web