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


Groups > comp.lang.python > #86837

Re: Python Worst Practices

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'string.': 0.05; 'subject:Python': 0.06; 'class,': 0.07; 'indicating': 0.07; 'socket': 0.07; 'string': 0.09; 'bits': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'being,': 0.16; 'binary.': 0.16; 'complain,': 0.16; 'formatted': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'output?': 0.16; 'precedence': 0.16; 'silly': 0.16; 'tuple,': 0.16; 'sat,': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'examples': 0.20; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'code': 0.31; 'consequence': 0.31; 'yes.': 0.31; 'another': 0.32; 'sense': 0.34; 'could': 0.34; 'created': 0.35; 'anybody': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'c++': 0.36; 'edge': 0.36; 'opposed': 0.36; 'error.': 0.37; 'example,': 0.37; 'being': 0.38; 'christian': 0.38; 'problems': 0.38; 'pm,': 0.38; 'how': 0.40; 'success': 0.61; 'simple': 0.61; 'first': 0.61; 'pick': 0.64; 'here': 0.66; 'mar': 0.68; '2015': 0.84; 'divide': 0.84; 'overloading': 0.84; 'subject:Practices': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=CctNpBRy3J7o6fdCJHWYlLO5KTnbjq3Or824g0I8Bkc=; b=uQma3EJ/PT9SZxUAAoL+ztOQffY8tCdRum87kqVeq98vHy6FIRQzutq85ELT/oRTeC u/MG249IiFg98IoUmEqJ/ojkPMJ7Kev0+g6kLnn2m381dDKULFv15FB4TRBc9ODAc3le 2AYMrOSgXX3dYb41t7ezvHwTWJWOqJvE1YZFVaUH2xUTDyliFbemQXA6Y8U83XplAtdQ 3Hr+/XhZrrXGYb/Bwcidp8N4Yzv5IAuWprhH/Pvh7dI4zeGP7q5sK4EqvDuR+lJTUzYb 9YGhwg2rZpY6CEY1ylGMw+sgbwtdp2ks84qkwhO/T6auYQQykvD7emCuS6dwSzlsAppG TQ4A==
MIME-Version 1.0
X-Received by 10.43.171.2 with SMTP id ns2mr876939icc.26.1425381130151; Tue, 03 Mar 2015 03:12:10 -0800 (PST)
In-Reply-To <md3sk8$4p8$1@dont-email.me>
References <mclca6$iie$1@ger.gmane.org> <mailman.19318.1425072098.18130.python-list@python.org> <54f1154c$0$12985$c3e8da3$5496439d@news.astraweb.com> <d975f577-03e4-4125-97ee-853a8e177e0f@googlegroups.com> <mailman.19327.1425087893.18130.python-list@python.org> <md3sk8$4p8$1@dont-email.me>
Date Tue, 3 Mar 2015 22:12:09 +1100
Subject Re: Python Worst Practices
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11.1425381138.21433.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425381138 news.xs4all.nl 2922 [2001:888:2000:d::a6]:36397
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86837

Show key headers only | View raw


On Tue, Mar 3, 2015 at 7:51 PM, Christian Gollwitzer <auriocus@gmx.de> wrote:
> Am 28.02.15 um 02:44 schrieb Chris Angelico:
>> On Sat, Feb 28, 2015 at 12:32 PM,  <sohcahtoa82@gmail.com> wrote:
>>> For example, I've seen someone create a Socket class, then created an operator overload that allowed you to "add" a string to your socket to make the socket send the string, with the result being a status code indicating success or an error.
>>>
>>
>> Why not left shift the socket by that string, the result being the
>> original socket? At least that has precedent...
>>
>
> Are you trying to pick on C++ streams? I could never understand why
> anybody has problems with an arrow << that means "put into the left
> thing" instead of "shift the bits to the left". How often do you use
> bitshift operations in your programs as opposed to output? Ot would be
> equally silly to complain, that in Python you divide a string by a
> tuple, and the modulus gives you a formatted string.

I am, yes. Both your examples seem lovely and simple when you first
look at them, but operator precedence means you get weird edge cases.
In the case of string modulo, there's another edge case as a
consequence of the operator being, by necessity, binary. A function
call makes better sense here.

Operator overloading in each case here is "cute", not optimally practical.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web