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


Groups > comp.lang.python > #58995

Re: New user's initial thoughts / criticisms of Python

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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; 'languages.': 0.04; 'explicitly': 0.05; 'subject:Python': 0.06; 'attribute': 0.07; 'expressions': 0.07; 'float': 0.07; 'function:': 0.09; 'internet:': 0.09; 'literal': 0.09; 'parsing': 0.09; 'python:': 0.09; 'to)': 0.09; 'python': 0.11; 'random': 0.14; 'analysing': 0.16; 'brackets.': 0.16; 'different?': 0.16; 'earlier.': 0.16; 'evaluating': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literal,': 0.16; 'literal.': 0.16; 'magic': 0.16; 'omitting': 0.16; 'operators,': 0.16; 'quirks': 0.16; 'rule.': 0.16; 'subject:user': 0.16; 'sat,': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'programming': 0.22; 'rules': 0.22; 'error': 0.23; '31,': 0.24; 'looks': 0.24; '(or': 0.24; 'least': 0.26; 'somewhere': 0.26; 'asking': 0.27; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; '[1]': 0.29; 'am,': 0.29; 'array': 0.29; 'returned': 0.30; 'said,': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'gives': 0.31; '(unless': 0.31; 'exceptions': 0.31; 'there.': 0.32; 'languages': 0.32; 'quite': 0.32; 'cases': 0.33; "can't": 0.35; 'common': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'similar': 0.36; 'subject:New': 0.37; 'two': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'von': 0.38; 'rather': 0.38; 'little': 0.38; 'recent': 0.39; 'does': 0.39; 'aside': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'according': 0.40; 'subject: / ': 0.60; 'break': 0.61; 'mentioned': 0.61; 'new': 0.61; 'name:': 0.61; 'john': 0.61; "you're": 0.61; 'such': 0.63; 'myself': 0.63; '30,': 0.65; 'here': 0.66; 'therefore': 0.72; '1960s.': 0.84; '5.4': 0.84; 'message)': 0.84; 'differences': 0.93; '2013': 0.98
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:to :content-type; bh=lqyen4nOscslwmQKGCgBaR7Od1ayK9rq0BgLGgLzjUw=; b=X/7gVBH0+3iYeVbYLdc7MpA1KNC9Alzze6lwB2Loiin9iu+Qc4D2dW3b4ZGddN0RaT FkWmXwwx5KT20CEZyK7peEQT2WZP8uGjRprbDVvq8LZ70YjytERw/i8A2nGeCF5VCU9J 1ShyvHwmTrrIdx2g2S6ADmPVDbxpaj0EWpVIhsGtcOgYdRhLUd8zCuahFPcgQlpag1sq bbQ+y+stm+FgTncXhqVS6Z3kAW8KnLTsgYGR3FM6AH1lKW0uItTFMW7CZDMW34fkhNWJ tab0uecQJsRlej1MRk7mG8sSAYjEvud/vUCc8S/a2XKj9mmDmEloIudXvdZsoTu7NcCE jAAA==
MIME-Version 1.0
X-Received by 10.68.99.99 with SMTP id ep3mr24290540pbb.107.1384075376296; Sun, 10 Nov 2013 01:22:56 -0800 (PST)
In-Reply-To <slrnl7ui1a.2m9.grahn+nntp@frailea.sa.invalid>
References <-JadnUirYuhUruPPnZ2dnUVZ8rSdnZ2d@bt.com> <mailman.2297.1384007240.18130.python-list@python.org> <slrnl7ui1a.2m9.grahn+nntp@frailea.sa.invalid>
Date Sun, 10 Nov 2013 20:22:56 +1100
Subject Re: New user's initial thoughts / criticisms of Python
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.2326.1384075379.18130.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384075379 news.xs4all.nl 15976 [2001:888:2000:d::a6]:37636
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:58995

Show key headers only | View raw


On Sun, Nov 10, 2013 at 7:47 PM, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
> On Sat, 2013-11-09, Chris Angelico wrote:
>> On Sun, Nov 10, 2013 at 12:08 AM, John von Horn <j.h69@btinternet.com> wrote:
> ...
>>> * Why not allow floater=float(int1/int2) - rather than floater=float
>>> (int1)/float(int2)?
>>>
>>> Give me a float (or an error message) from evaluating everything in the
>>> brackets. Don't make me explicitly convert everything myself (unless I
>>> want to)
>>
>> As others have said, what you're asking for is actually magic. One of
>> the rules of Python - one for which I'm not aware of any exceptions -
>> is that you can always take a subexpression out and give it a new
>> name:
>
> And it's not just Python: programming languages have been designed
> that way since at least the 1960s.  People are used to analysing
> expressions inside and out according to rules common for almost all
> languages.

That's true to at least some extent, but quite a few languages have
differences here and there. In C, there's no such thing as an array
literal, only an initializer list, so:

/* This works: */
int month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int this_month_days = month_days[this_month];

/* This doesn't: */
int three = {1, 2, 3, 4, 5}[2];

PHP had similar issues up until a *very* recent version (5.3 or 5.4 or
something), where you couldn't dereference an array returned by a
function:

//Works:
$arr = func();
$val = $arr[5];

//Didn't work until recently, and therefore can't be trusted for
//deployment to random systems across the internet:
$val = func()[5];

JavaScript has magic around the dot and function-call operators, as I
mentioned earlier. Lots of other languages have some little quirk
somewhere that breaks this rule; some have a LOT of quirks that break
this rule. Does Python have any? Aside from parsing oddities like
attribute access on a literal integer[1], are there any cases where
two expressions yielding the same object are in any way different?

ChrisA
[1] You can write "(1234).to_bytes(2,'big')" but omitting the parens
gives a SyntaxError because it looks like the start of a float
literal.

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


Thread

New user's initial thoughts / criticisms of Python John von Horn <j.h69@btinternet.com> - 2013-11-09 07:08 -0600
  Re: New user's initial thoughts / criticisms of Python Ned Batchelder <ned@nedbatchelder.com> - 2013-11-09 05:22 -0800
  Re: New user's initial thoughts / criticisms of Python Joshua Landau <joshua@landau.ws> - 2013-11-09 13:27 +0000
    Re: New user's initial thoughts / criticisms of Python Jonathan <jtcegh@gmail.com> - 2013-11-09 14:44 -0800
      Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-10 10:29 +1100
      Re: New user's initial thoughts / criticisms of Python MRAB <python@mrabarnett.plus.com> - 2013-11-10 00:50 +0000
      Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-10 11:54 +1100
      Re: New user's initial thoughts / criticisms of Python Neil Cerutti <neilc@norwich.edu> - 2013-11-11 15:30 +0000
    Re: New user's initial thoughts / criticisms of Python Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-11-10 13:24 +0100
  Re: New user's initial thoughts / criticisms of Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-09 13:41 +0000
  Re: New user's initial thoughts / criticisms of Python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-11-09 16:24 +0200
  Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-10 01:27 +1100
    Sandboxing Python [was Re: New user's initial thoughts / criticisms of Python] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-09 15:25 +0000
      Re: Sandboxing Python [was Re: New user's initial thoughts / criticisms of Python] Chris Angelico <rosuav@gmail.com> - 2013-11-10 02:32 +1100
    Re: New user's initial thoughts / criticisms of Python Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-11-10 08:47 +0000
      Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-10 20:22 +1100
      Re: New user's initial thoughts / criticisms of Python Ian Kelly <ian.g.kelly@gmail.com> - 2013-11-10 04:39 -0700
      Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-10 22:43 +1100
      Re: New user's initial thoughts / criticisms of Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-10 12:12 -0500
      Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-11 10:29 +1100
      Re: New user's initial thoughts / criticisms of Python Terry Reedy <tjreedy@udel.edu> - 2013-11-10 19:13 -0500
  Re: New user's initial thoughts / criticisms of Python rusi <rustompmody@gmail.com> - 2013-11-09 07:38 -0800
    Re: New user's initial thoughts / criticisms of Python Roy Smith <roy@panix.com> - 2013-11-09 10:56 -0500
      Re: New user's initial thoughts / criticisms of Python rusi <rustompmody@gmail.com> - 2013-11-09 08:30 -0800
        Re: New user's initial thoughts / criticisms of Python Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-10 21:36 -0800
          Re: New user's initial thoughts / criticisms of Python Roy Smith <roy@panix.com> - 2013-11-11 09:01 -0500
            Re: New user's initial thoughts / criticisms of Python rusi <rustompmody@gmail.com> - 2013-11-11 07:14 -0800
            Re: New user's initial thoughts / criticisms of Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-11 21:05 -0500
            Re: New user's initial thoughts / criticisms of Python Ethan Furman <ethan@stoneleaf.us> - 2013-11-12 14:38 -0800
  Re: New user's initial thoughts / criticisms of Python John von Horn <j.h69@btinternet.com> - 2013-11-09 14:19 -0600
  Re: New user's initial thoughts / criticisms of Python Tim Chase <python.list@tim.thechases.com> - 2013-11-09 14:39 -0600
  Re: New user's initial thoughts / criticisms of Python Mark Janssen <dreamingforward@gmail.com> - 2013-11-09 12:33 -0800
    Re: New user's initial thoughts / criticisms of Python Ned Batchelder <ned@nedbatchelder.com> - 2013-11-09 12:54 -0800
      Re: New user's initial thoughts / criticisms of Python Mark Janssen <dreamingforward@gmail.com> - 2013-11-09 13:21 -0800
  Re: New user's initial thoughts / criticisms of Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-09 21:01 +0000
  Re: New user's initial thoughts / criticisms of Python Tim Chase <python.list@tim.thechases.com> - 2013-11-09 15:20 -0600
  Re: New user's initial thoughts / criticisms of Python lorenzo.gatti@gmail.com - 2013-11-11 02:09 -0800
    Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-11 21:39 +1100
      Re: New user's initial thoughts / criticisms of Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-11 11:17 +0000
        Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-11 22:32 +1100
        Re: New user's initial thoughts / criticisms of Python Mark Janssen <dreamingforward@gmail.com> - 2013-11-11 14:29 -0800
    Re: New user's initial thoughts / criticisms of Python Robert Kern <robert.kern@gmail.com> - 2013-11-11 11:53 +0000
    Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-11 23:07 +1100
    Re: New user's initial thoughts / criticisms of Python Joshua Landau <joshua@landau.ws> - 2013-11-11 20:50 +0000
    Re: New user's initial thoughts / criticisms of Python Chris Angelico <rosuav@gmail.com> - 2013-11-12 09:21 +1100
    Re: New user's initial thoughts / criticisms of Python Joshua Landau <joshua@landau.ws> - 2013-11-12 01:53 +0000

csiph-web