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


Groups > comp.lang.python > #85286

Re: meaning of: line, =

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'patterns': 0.04; '(of': 0.07; 'assign': 0.07; 'assignment': 0.07; 'literal': 0.09; 'way:': 0.09; 'yeah,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'missed': 0.12; '(1,': 0.16; '(2,': 0.16; '(x,': 0.16; 'exceptions,': 0.16; 'imo.': 0.16; 'statement.': 0.16; 'syntaxerror:': 0.16; 'x,y,z': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'matching': 0.30; 'message- id:@mail.gmail.com': 0.30; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; 'sense': 0.34; "can't": 0.35; 'late': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'should': 0.36; 'does': 0.39; 'skip:n 10': 0.64; 'to:addr:gmail.com': 0.65; 'side': 0.67; 'miss': 0.74; 'hand': 0.80; '2015': 0.84; 'sorely': 0.84; 'reply,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Ypynu58X6HuqezgJ/HcgoJYXheN8XuDsvzEm15QP8Ao=; b=lFAutnuXeEK2aqZjiCoDlrhlmYBpRU2+dLN4Jq3DUtkBgmhvVS00wzrKlrorJklJ2O x0HHaUxh/St7eiu4XXQ1CeADvp3ZkmbjS0FdqT1xuryPVdIPvAK7l9RHNC9oRKWbDzCL 76j2azyR0ulx2rKl4MpwIo97hv9ptviMoFmZV8c8S/evn9fZ1uvijrzAg9iETLqqisjU 3x9Xvonq+sTGPq4jOhWDowmv5aVYeLGW698Kp88r1dNR7eJ4daio3VRknyKXbmrhafFx CCX0eXTzvuwAxGesFdUqdaf6LEF0BZg9Qc0TepyYX692bqaCM1dPJ3WXp46wI90N1EyB c+hg==
X-Received by 10.224.37.72 with SMTP id w8mr8099998qad.58.1423228185628; Fri, 06 Feb 2015 05:09:45 -0800 (PST)
MIME-Version 1.0
In-Reply-To <98777b0d-8f6c-4e2d-965f-0ef875e962b0@googlegroups.com>
References <CAPTjJmpqx1Cmm89Lg6-XL4-xdM+xD6=GHKvWb2zYTe4=11ZPPg@mail.gmail.com> <mailman.18464.1423061056.18130.python-list@python.org> <07f4498c-7917-4315-85d4-73283a830f2d@googlegroups.com> <matlbh$r0s$1@ger.gmane.org> <CAPTjJmp=b2ZA8eqvyf3tqK+0MHqOgS-PAG+ELNNOwuKKPq4FJQ@mail.gmail.com> <mailman.18488.1423127457.18130.python-list@python.org> <54d33aa6$0$13003$c3e8da3$5496439d@news.astraweb.com> <mailman.18491.1423152554.18130.python-list@python.org> <6304fe65-0606-40eb-8732-c9ba9ae168e7@googlegroups.com> <98777b0d-8f6c-4e2d-965f-0ef875e962b0@googlegroups.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Fri, 6 Feb 2015 05:09:05 -0800
Subject Re: meaning of: line, =
To Rustom Mody <rustompmody@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc "comp.lang.python" <python-list@python.org>
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.18507.1423228193.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423228193 news.xs4all.nl 2874 [2001:888:2000:d::a6]:53415
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85286

Show key headers only | View raw


Sorry for late reply, I somehow missed this email.

On Thu, Feb 5, 2015 at 8:59 AM, Rustom Mody <rustompmody@gmail.com> wrote:
> The reason I ask: I sorely miss haskell's pattern matching in python.
>
> It goes some way:
>
>>>> ((x,y),z) = ((1,2),3)
>>>> x,y,z
> (1, 2, 3)
>
> But not as far as I would like:
>
>>>> ((x,y),3) = ((1,2),3)
>   File "<stdin>", line 1
> SyntaxError: can't assign to literal
>>>>
>
> [Haskell]
>
> Prelude> let (x, (y, (42, z, "Hello"))) = (1, (2, (42, 3, "Hello")))
> Prelude> (x,y,z)
> (1,2,3)

Yeah, but Haskell is ludicrous.

Prelude> let (x, 2) = (1, 3)
Prelude>

Only non-falsifiable patterns really make sense as the left hand side
of an assignment in a language without exceptions, IMO. Otherwise you
should use a match/case statement. (Of course, Python does have
exceptions...)

-- Devin

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


Thread

Re: meaning of: line, = Albert-Jan Roskam <fomcl@yahoo.com> - 2015-02-04 14:38 +0000
  Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-04 07:09 -0800
    Re: meaning of: line, = Peter Otten <__peter__@web.de> - 2015-02-04 18:36 +0100
    Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-05 08:18 +1100
    Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 01:10 -0800
      Re: meaning of: line, = Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-05 20:40 +1100
        Re: meaning of: line, = Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-05 09:08 -0700
          Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:45 -0800
            Re: meaning of: line, = Skip Montanaro <skip.montanaro@gmail.com> - 2015-02-05 10:56 -0600
            Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 11:00 -0600
            Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:59 -0800
              Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-06 05:09 -0800
                Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 05:20 -0800
                Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 06:03 -0800
        Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 10:21 -0600
        Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 17:12 -0800
        Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-06 12:17 +1100
          Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 17:52 +1300
      Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 12:30 +1300

csiph-web