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


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

Idiosyncratic python

Started bySteven D'Aprano <steve+comp.lang.python@pearwood.info>
First post2015-09-24 16:02 +1000
Last post2015-09-25 10:08 +1000
Articles 4 on this page of 24 — 15 participants

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


Contents

  Idiosyncratic python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-09-24 16:02 +1000
    Re: Idiosyncratic python Paul Rubin <no.email@nospam.invalid> - 2015-09-23 23:16 -0700
      Re: Idiosyncratic python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-09-24 16:35 +1000
        Re: Idiosyncratic python Ben Finney <ben+python@benfinney.id.au> - 2015-09-24 16:54 +1000
          Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 11:08 +1000
        Re: Idiosyncratic python Terry Reedy <tjreedy@udel.edu> - 2015-09-24 02:54 -0400
    Re: Idiosyncratic python wxjmfauth@gmail.com - 2015-09-24 00:06 -0700
      Re: Idiosyncratic python Laurent Pointal <laurent.pointal@free.fr> - 2015-09-24 19:50 +0200
        Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-24 21:05 +0100
    Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 11:12 +0200
    Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-24 14:09 +0100
    Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 16:07 +0200
    Re: Idiosyncratic python Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 08:26 -0600
    Re: Idiosyncratic python Chris Angelico <rosuav@gmail.com> - 2015-09-25 02:57 +1000
    Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 20:04 +0200
    Re: Idiosyncratic python Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 12:19 -0600
    Re: Idiosyncratic python Ned Batchelder <ned@nedbatchelder.com> - 2015-09-24 13:46 -0700
      Re: Idiosyncratic python Laura Creighton <lac@openend.se> - 2015-09-24 23:08 +0200
      Re: Idiosyncratic python Chris Angelico <rosuav@gmail.com> - 2015-09-25 07:49 +1000
      Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 10:55 +1000
    Re: Idiosyncratic python sohcahtoa82@gmail.com - 2015-09-24 15:32 -0700
    Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-25 00:40 +0100
    Re: Idiosyncratic python Akira Li <4kir4.1i@gmail.com> - 2015-09-25 03:04 +0300
    Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 10:08 +1000

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


#97101

Fromsohcahtoa82@gmail.com
Date2015-09-24 15:32 -0700
Message-ID<d432b866-e652-4170-937e-4a52a6b4ace8@googlegroups.com>
In reply to#97060
On Wednesday, September 23, 2015 at 11:02:38 PM UTC-7, Steven D'Aprano wrote:
> I was looking at an in-house code base today, and the author seems to have a 
> rather idiosyncratic approach to Python. For example:
> 
> 
> for k, v in mydict.items(): 
>     del(k)
>     ...
> 
> 
> instead of the more obvious
> 
> for v in mydict.values(): 
>     ...
> 
> 
> 
> What are your favorite not-wrong-just-weird Python moments?
> 
> 
> 
> -- 
> Steve

I used to work with a guy that would put the verb at the END of a function name, rather than the beginning.  For example, rather then "GetSupportedVersion", he'd use "SupportedVersionGet".  Of course, I know plenty of people here will say it should be "get_supported_version", but that's another discussion entirely.

Another guy would frequently use "Grab" instead of "Get".  The fact that he used a different verb than the common convention though wasn't NEARLY as infuriating as the fact that he was inconsistent about it.

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


#97104

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-09-25 00:40 +0100
Message-ID<mailman.155.1443138046.28679.python-list@python.org>
In reply to#97060
On 24/09/2015 07:02, Steven D'Aprano wrote:
> I was looking at an in-house code base today, and the author seems to have a
> rather idiosyncratic approach to Python. For example:
>
> for k, v in mydict.items():
>      del(k)
>      ...
>
> instead of the more obvious
>
> for v in mydict.values():
>      ...
>
> What are your favorite not-wrong-just-weird Python moments?
>

My favourite was from a guy I worked with years ago.  In C but I'm sure 
you'll enjoy it.  In all functions, something like:-

int flag = 0;
if flag {
     printf("\nthe string");
}
else{
     printf("the string");
     flag = 1;
}

At least I think I've got it correct, too lazy to check, sorry :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


#97105

FromAkira Li <4kir4.1i@gmail.com>
Date2015-09-25 03:04 +0300
Message-ID<mailman.156.1443139449.28679.python-list@python.org>
In reply to#97060
Mark Lawrence <breamoreboy@yahoo.co.uk> writes:

> On 24/09/2015 07:02, Steven D'Aprano wrote:
>> I was looking at an in-house code base today, and the author seems to have a
>> rather idiosyncratic approach to Python. For example:
>>
>> for k, v in mydict.items():
>>      del(k)
>>      ...
>>
>> instead of the more obvious
>>
>> for v in mydict.values():
>>      ...
>>
>> What are your favorite not-wrong-just-weird Python moments?
>>
>
> My favourite was from a guy I worked with years ago.  In C but I'm
> sure you'll enjoy it.  In all functions, something like:-
>
> int flag = 0;
> if flag {
>     printf("\nthe string");
> }
> else{
>     printf("the string");
>     flag = 1;
> }
>
> At least I think I've got it correct, too lazy to check, sorry :)

It looks like a sys.stdout.softspace hack in Python 2:

  print line, # comma!

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


#97106

FromSteven D'Aprano <steve@pearwood.info>
Date2015-09-25 10:08 +1000
Message-ID<5604906f$0$1597$c3e8da3$5496439d@news.astraweb.com>
In reply to#97060
On Fri, 25 Sep 2015 02:54 am, Todd wrote:

> Using list indexing with booleans in place of a ternary operator.
> 
> a = False
> b = [var2, var1][a]
> 
> Instead of:
> 
> b = var1 if a else var2

Ah, you youngsters...  :-)

Using a bool to index into a list used to be the standard idiom, before the
ternary if was added to the language. So I don't consider it "weird",
especially as a lot of my code still supports Python 2.4 which doesn't
include the ternary if.

Sometimes, instead of a list, I'll use a dict:

    {True: value1, False: value2}[flag]

to emulate ternary if.



-- 
Steven

[toc] | [prev] | [standalone]


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

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


csiph-web