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


Groups > comp.lang.python > #86869

Re: Python Worst Practices

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: Python Worst Practices
Date 2015-03-03 23:46 +0100
Organization A noiseless patient Spider
Message-ID <md5djb$rtf$1@dont-email.me> (permalink)
References (2 earlier) <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> <mailman.11.1425381138.21433.python-list@python.org>

Show all headers | View raw


Am 03.03.15 um 12:12 schrieb Chris Angelico:
> On Tue, Mar 3, 2015 at 7:51 PM, Christian Gollwitzer <auriocus@gmx.de> wrote:
>
>> 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.

I can agree with the argument that operator precedence can make
problems; e.g. this

	cout<<a==b;

does not output the truth value of a==b, but instead outputs a and
compares the stream to b (which will usually fail to compile, but still).

But the argument that << is a left-shift and nothing else is silly. <<
for bitshift is nothing more intuitive than % for modulus (where in math
does this symbol occur?) or [] for indexing. We just got used to it, and
to me << as an arrow for putting someting into a stream seems pretty
obvious.

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

Maybe just sub-optimal? With today's C++ one could use a variadic
template and still have type-safe compile-time bound output formatting.
This hasn't been possible in the original iostream library back then.

	Christian

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