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


Groups > comp.lang.python > #196984

Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From dn <PythonList@DancesWithMice.info>
Newsgroups comp.lang.python
Subject Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)
Date Sat, 9 Nov 2024 08:09:49 +1300
Organization DWM
Lines 71
Message-ID <mailman.88.1731092996.4695.python-list@python.org> (permalink)
References <seven-20241106014329@ram.dialup.fu-berlin.de> <vgg5dn$ij48$1@solani.org> <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green> <vgjoe9$2stii$2@dont-email.me> <vgjq77$aj8c$1@solani.org> <59a78893-d96a-4f5b-921f-5ad862449ca2@DancesWithMice.info>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de pXyIfVUMRYsM1vPbYiwnYgKNR0TifK3tpNo/tc1v/yUQ==
Cancel-Lock sha1:iNyr6IJ6MkXpZCRfJOOZA7Ih3PQ= sha256:817aUs8eluDNI1m96sK7qeDosS5yw4JpeoRcle9IEz0=
Return-Path <PythonList@DancesWithMice.info>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
Authentication-Results mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=danceswithmice.info header.i=@danceswithmice.info header.b=A8DhJFWa; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'python:': 0.05; '=dn': 0.09; 'adapt': 0.09; 'browser,': 0.09; 'expression': 0.09; 'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist': 0.09; 'pre': 0.09; 'python"': 0.09; 'question:': 0.09; 'shock': 0.09; 'subject:Python': 0.12; 'possible,': 0.15; 'alias': 0.16; 'applied:': 0.16; 'message- id:@DancesWithMice.info': 0.16; 'received:51.254': 0.16; 'received:51.254.211': 0.16; 'received:51.254.211.219': 0.16; 'received:cloud': 0.16; 'received:rangi.cloud': 0.16; 'wrote:': 0.16; 'python': 0.16; 'probably': 0.17; 'to:addr:python-list': 0.20; 'languages': 0.22; 'code': 0.23; 'python,': 0.25; 'local': 0.27; '>>>': 0.28; 'header:User-Agent:1': 0.30; 'review,': 0.31; 'question': 0.32; 'driving': 0.32; 'python-list': 0.32; 'header:Organization:1': 0.32; 'but': 0.32; 'header:In-Reply- To:1': 0.34; 'trying': 0.35; '"the': 0.35; 'fine': 0.35; 'submitted': 0.35; '...': 0.37; 'could': 0.37; 'received:192.168': 0.37; 'way': 0.38; 'use': 0.39; 'define': 0.40; 'learn': 0.40; 'something': 0.40; 'should': 0.40; 'above': 0.62; 'to:': 0.62; 'your': 0.64; 'received:51': 0.64; 'well': 0.65; 'rules': 0.70; 'subject:List': 0.71; 'left': 0.83; '1);': 0.84; 'subject:Posting': 0.84; 'zen': 0.84; 'badly': 0.91
DKIM-Filter OpenDKIM Filter v2.11.0 vps.rangi.cloud 282C54415
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info; s=staff; t=1731092993; bh=vlCCdtRDjUSNFboG7tOfNoVCNXSTsG6ZohVlsNUSlXA=; h=Date:From:Subject:To:References:In-Reply-To:From; b=A8DhJFWaRM8KSIMKE2gaj+5YgjfgJJl97JfFA5jmkAlFibxvIMdF6X/jlIlwYuOJc 8q7NGFhg5BEoUYTupDXOXgc0ae0wRbO6EB1RSsA4LFjX8T9eooNmWzUiaq5xZY5pjy NdN59DytwWJGQ/h6ccHkWvvUksAeZzANmSxr4/+6peFCyrs3h6TuhoQLnW73HI2C9M sSHUUVr2gEyfel5vOMu672qLYXYIrmup3cbQ3/yyq9kJeK5BZJWJZQsQI1po7+MDOs acn1U06bzbOnLJB0ZEfwMNnbYQDL1a0zkLPvQM+puOYsutzVXIqbLYdniClxlg8zZH p1QN7bc1eZsrQ==
User-Agent Mozilla Thunderbird
Content-Language en-US
In-Reply-To <vgjq77$aj8c$1@solani.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.39
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 <https://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>
X-Mailman-Original-Message-ID <59a78893-d96a-4f5b-921f-5ad862449ca2@DancesWithMice.info>
X-Mailman-Original-References <seven-20241106014329@ram.dialup.fu-berlin.de> <vgg5dn$ij48$1@solani.org> <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green> <vgjoe9$2stii$2@dont-email.me> <vgjq77$aj8c$1@solani.org>
Xref csiph.com comp.lang.python:196984

Show key headers only | View raw


On 8/11/24 14:40, Mild Shock via Python-list wrote:
> Well you can use your Browser, since
> JavaScript understand post and pre increment:

Question: are we talking Python or JavaScript?


> So we have x ++ equals in Python:

Trying to find a word-for-word translation serves as badly in 
computer-programming languages as it does in human spoken-languages. 
Learn how to adapt and embrace the differences...


>      x + = 1
>      x - 1

The above probably only 'works' (the way you expect) in the REPL.


> But I don't know how to combine an
> assignment and an expression into one
> expession. In JavaScript one can use

Again!

"Everything should be made as simple as possible, but no simpler."

Check out "The Zen of Python" and PEP-0008 for Python idioms.


> the comma:
> 
>  > x = 5
> 5
>  > y = (x += 1, x - 1)
> 5
>  > x = 5
> 5
>  > y = (x += 1, x)
> 6
> 
> But in Python the comma would create a tuple.

Exactly, just as driving on the left side of the road will be fine in 
some countries but cause a crash in others. Learn the local rules FIRST!


The 'walrus operator' could be applied:

 >>> x = 5
 >>> y = (x := x + 1); x
6
 >>> x, y
(6, 6)

However, if such were submitted for Code Review, unhappiness would result.


Was the question re-phrased to: how to ... in Python, we'd end-up with 
something more like this:

 >>> x = 5  # define
 >>> x += 1  # increment
 >>> y = x  # alias
 >>> x, y
(6, 6)

-- 
Regards,
=dn

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


Thread

Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-06 17:27 +0100
  Re: Two aces up Python's sleeve Annada Behera <annada@tilde.green> - 2024-11-07 12:55 +0530
    Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-07 15:04 +0100
      Re: Two aces up Python's sleeve Greg Ewing <greg.ewing@canterbury.ac.nz> - 2024-11-08 11:15 +1300
        Re: Two aces up Python's sleeve dn <PythonList@DancesWithMice.info> - 2024-11-08 13:07 +1300
        Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:25 +0100
          Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:29 +0100
            Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:47 +0100
    Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-11-08 01:10 +0000
      Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 02:40 +0100
        Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) dn <PythonList@DancesWithMice.info> - 2024-11-09 08:09 +1300
          Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 20:49 +0100
        Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Thomas Passin <list1@tompassin.net> - 2024-11-08 17:00 -0500

csiph-web