osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implement C's Switch in Python 3


On Sun, Feb 3, 2019 at 8:09 PM DL Neil <PythonList at danceswithmice.info> wrote:
>
> On 3/02/19 9:45 PM, Chris Angelico wrote:
> > Which is why I always write dates in sorted format, usually eschewing
> > delimiters:
> >
> > //CJA 20160511: Is this still happening? I don't remember seeing it in
> > three parts of forever.
>
> Sure is. It is an acceptable alternative under the ISO standard.

Not sure if you're responding to the content of the comment there;
that was just one that I lifted straight from some of my source code.
It's part of a bug note regarding something that happens *extremely*
sporadically, and all I could do was to write down everything I knew
and then wait for the next occurrence. Back in May of 2016, I added
that comment, and it's still there to this day, because I haven't
actually proven the bug gone.

> Some would say it is more sensible to use when storing data because it
> removes the dash/hyphen separators in exchange for implying the
> fixed-format. (more bytes/characters saved if extend to include the time)
>
> I'm not going there - recalling folk from these memory-is-cheap times
> being less able to understand why we used to save 'expensive' storage
> space by using yy-years (instead of ccyy) and thus 'causing' "the
> millennium bug" aka Y2K!

Skipping the delimiter isn't about saving space, it's about
consistency. If I say "non-delimited sorted date", you can almost
certainly write out a character-for-character identical date - handy
if you want to search a bunch of files, for instance. Having
delimiters leaves people free to dispute whether they should be
slashes, hyphens, dots, or maybe something else.

> I wouldn't use it in a 'visible' situation though, eg a fileNM. Yes, it
> is shorter, but as my eyes age (they are already older than my teeth!),

Guess your teeth better work on catching up...

> I find it much slower to decode than reading the same with embedded
> separators!

Sure. I mainly use it in contexts where the most important information
is simply "that's a date", rather than actually caring what the date
*is*.

> > That said, I am aware that I am not in any way a "normal person".
> > Using month names as per your other example is probably a fair
> > compromise with other humans.
>
> There's normal and there's normal - like it's tomato or tomato?
>

I dunno. I'm the kind of normal that likes tomatoes (not to be
confused with tomatoes). Does that help?

ChrisA