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


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

Re: Python Worst Practices

Started byMRAB <python@mrabarnett.plus.com>
First post2015-02-25 23:34 +0000
Last post2015-02-26 20:04 +0000
Articles 3 — 3 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 MRAB <python@mrabarnett.plus.com> - 2015-02-25 23:34 +0000
    Re: Python Worst Practices alister <alister.nospam.ware@ntlworld.com> - 2015-02-26 19:32 +0000
      Re: Python Worst Practices Grant Edwards <invalid@invalid.invalid> - 2015-02-26 20:04 +0000

#86447 — Re: Python Worst Practices

FromMRAB <python@mrabarnett.plus.com>
Date2015-02-25 23:34 +0000
SubjectRe: Python Worst Practices
Message-ID<mailman.19221.1424907273.18130.python-list@python.org>
On 2015-02-25 22:59, Joel Goldstick wrote:
 > On Wed, Feb 25, 2015 at 4:28 PM, MRAB <python@mrabarnett.plus.com> wrote:
 > > On 2015-02-25 20:45, Mark Lawrence wrote:
 > >>
 > >> http://www.slideshare.net/pydanny/python-worst-practices
 > >>
 > >> Any that should be added to this list?  Any that be removed as not 
that
 > >> bad?
 > >>
 > > We don't have numeric ZIP codes in the UK, but the entire world has
 > > numeric telephone numbers, so that might be a better example of numbers
 > > that aren't really numbers.
 >
 > US zip codes get messed up with ints because many have a leading zero.
 > I use strings

Telephone numbers can also start with zero.

 > >
 > > Numeric dates can be ambiguous: dd/mm/yyyy or mm/dd/yyyy? The ISO
 > > standard is clearer: yyyy-mm-dd.
 > >
 > > Handling text: "Unicode sandwich".
 > >
 > > UTF-8 is better than legacy encodings.
 > >

[toc] | [next] | [standalone]


#86533

Fromalister <alister.nospam.ware@ntlworld.com>
Date2015-02-26 19:32 +0000
Message-ID<mcnscj$815$1@speranza.aioe.org>
In reply to#86447
On Wed, 25 Feb 2015 23:34:29 +0000, MRAB wrote:

> On 2015-02-25 22:59, Joel Goldstick wrote:
>  > On Wed, Feb 25, 2015 at 4:28 PM, MRAB <python@mrabarnett.plus.com>
>  > wrote:
>  > > On 2015-02-25 20:45, Mark Lawrence wrote:
>  > >>
>  > >> http://www.slideshare.net/pydanny/python-worst-practices
>  > >>
>  > >> Any that should be added to this list?  Any that be removed as not
> that
>  > >> bad?
>  > >>
>  > > We don't have numeric ZIP codes in the UK, but the entire world has
>  > > numeric telephone numbers, so that might be a better example of
>  > > numbers that aren't really numbers.
>  >
>  > US zip codes get messed up with ints because many have a leading
>  > zero.
>  > I use strings
> 
> Telephone numbers can also start with zero.

unless you are performing maths on it data that is made up of numbers 
(zip code, tel number, house number etc) is still only text & should be 
stored as a string.

> 
 >  > > Numeric dates can be ambiguous: dd/mm/yyyy or mm/dd/yyyy? The ISO
>  > > standard is clearer: yyyy-mm-dd.
>  > >
>  > > Handling text: "Unicode sandwich".
>  > >
>  > > UTF-8 is better than legacy encodings.
>  > >





-- 
To save a single life is better than to build a seven story pagoda.

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


#86539

FromGrant Edwards <invalid@invalid.invalid>
Date2015-02-26 20:04 +0000
Message-ID<mcnu7u$dod$1@reader1.panix.com>
In reply to#86533
On 2015-02-26, alister <alister.nospam.ware@ntlworld.com> wrote:
> On Wed, 25 Feb 2015 23:34:29 +0000, MRAB wrote:
>> On 2015-02-25 22:59, Joel Goldstick wrote:
>>> On Wed, Feb 25, 2015 at 4:28 PM, MRAB <python@mrabarnett.plus.com> wrote:
>>>> On 2015-02-25 20:45, Mark Lawrence wrote:
>>>>>
>>>>> http://www.slideshare.net/pydanny/python-worst-practices
>>>>>
>>>>> Any that should be added to this list?  Any that be removed as not
>>>>> that bad?
>>>>
>>>> We don't have numeric ZIP codes in the UK, but the entire world has
>>>> numeric telephone numbers, so that might be a better example of
>>>> numbers that aren't really numbers.
>>>
>>> US zip codes get messed up with ints because many have a leading
>>> zero.
>>> I use strings

I should hope so, because US zip codes can also contain a hyphen.

>> Telephone numbers can also start with zero.
>
> unless you are performing maths on it data that is made up of numbers 
> (zip code, tel number, house number etc) is still only text & should be 
> stored as a string.

And if you _are_ performing maths on postal codes, telephone numbers
and house numbers, something is seriously wrong and it probably
doesn't matter how you represent things.

-- 
Grant Edwards               grant.b.edwards        Yow! I am covered with
                                  at               pure vegetable oil and I am
                              gmail.com            writing a best seller!

[toc] | [prev] | [standalone]


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


csiph-web