Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Let the machine do the dirty work. -- "Elements of Programming Style", Kernighan and Ritchie


devel / comp.lang.python / RE: =- and -= snag

SubjectAuthor
o RE: =- and -= snag<avi.e.gross

1
RE: =- and -= snag

<mailman.2295.1678756197.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22392&group=comp.lang.python#22392

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: =- and -= snag
Date: Mon, 13 Mar 2023 21:09:52 -0400
Lines: 81
Message-ID: <mailman.2295.1678756197.20444.python-list@python.org>
References: <CAEtLV=oHw_VEWd2WEqtD2Xv+Yp0WYeOh_3YgNvfG8ZW69UmXqg@mail.gmail.com>
<009901d95611$aea10040$0be300c0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de zH1KaZWaBhFB8UVvyDK7EAt54oH7Ji72YD7cw8PXGWiw==
Return-Path: <avi.e.gross@gmail.com>
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=gmail.com header.i=@gmail.com header.b=SQcTym68;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'looks': 0.02; 'argument':
0.04; 'is.': 0.05; 'random': 0.05; '2023': 0.07; 'lets': 0.07;
'spaces': 0.07; 'that?': 0.07; '"new': 0.09; 'expression': 0.09;
'language,': 0.09; 'meant.': 0.09; 'received:108': 0.09;
"shouldn't": 0.09; 'url:mailman': 0.15; 'avi': 0.16;
'calculations': 0.16; 'confusion': 0.16; 'flag': 0.16;
'interpreter': 0.16; 'opinion,': 0.16; 'pythonic': 0.16; 'turns':
0.16; 'problem': 0.16; 'python': 0.16; 'instead': 0.17; 'message-
id:@gmail.com': 0.18; 'bug': 0.19; 'calls': 0.19; 'to:addr:python-
list': 0.20; 'languages': 0.22; 'code': 0.23; 'skip:- 10': 0.25;
'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'object': 0.26;
"isn't": 0.27; 'asked': 0.29; 'received:209.85.160': 0.31; 'url-
ip:188/8': 0.31; '13,': 0.32; 'negative': 0.32; 'python-list':
0.32; 'url-ip:91/8': 0.32; 'but': 0.32; 'there': 0.33; 'march':
0.33; 'able': 0.34; "didn't": 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'trying': 0.35;
'from:addr:gmail.com': 0.35; 'really': 0.37; 'received:209.85':
0.37; 'hard': 0.37; 'way': 0.38; 'could': 0.38; 'received:209':
0.39; 'quite': 0.39; 'valid': 0.39; 'use': 0.39; 'rest': 0.39;
'wrote': 0.39; 'something': 0.40; 'want': 0.40; 'url-ip:216/8':
0.60; 'provide': 0.60; 'url-ip:142.250.179/24': 0.61; 'above':
0.62; 'from:': 0.62; 'to:': 0.62; 'today,': 0.62; 'url:user':
0.62; 'here': 0.62; 'url-ip:142.250.179.174/32': 0.63; 'down':
0.64; 'music': 0.64; 'requirement': 0.64; 'your': 0.64; 'url-
ip:198/8': 0.65; 'url:instagram': 0.65; 'well': 0.65; 'let': 0.66;
'now,': 0.67; 'numbers': 0.67; 'right': 0.68; 'playing': 0.69;
'instagram': 0.70; 'rules': 0.70; 'you.': 0.71; 'url:info': 0.71;
'head': 0.73; 'sent:': 0.78; 'catch': 0.84; 'cut': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1678756194;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=W/5IbMMQewRwBMF95Z0bx760r9S+3FDMWuMpm8kS1rs=;
b=SQcTym68m22yTjA9HLJFgWUyc7ajFkCY7BOt8929S6pkKZHT3tlIq8R/17QtmZA+f2
sBwP5SqbbbdaAUKwCukXKHCo1rJEeiuAF8PvyJnVd6rUGxF+/N/DO+LEI5S6nUDNl3wc
fQAC7At8V/KdfFr9NFfx/T8x+jMSU3flIJyg85lvj6sdjbYI2JqoWape9IOoAfYv3Ttt
4MeNyoG0yvhVl6TFco9uPiUEwzF7FTPRdblXx/77yxuen5+6Tpjc+mCOHEnAF3jG+2Cw
MeqFcEcCwkCmJiSjjYUPa6NPlWYRfHr2pTn0O5ASivwNbTbBx20UkwIQ/WDzTThUt7jY
yeAQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1678756194;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=W/5IbMMQewRwBMF95Z0bx760r9S+3FDMWuMpm8kS1rs=;
b=NEyLHXK34QzGXIQwyaDmcTpXON4Jp1NK7KbVo1ovASoTbhqFTDuL27IQOflko5NezC
TtTJ6wyVSgttWKP3rPC9DFan2mvczzUjkXQNCcpGJO1Du4XxCbeLLraZESZePeaILEAw
u0VFD6ezFoVQ0Yfc5EGemU0RvKdxr2euw1x4pCuGFsKNGjobVfrO+vWZS9/cwjv4uSX7
38yVALOTOLcR9S5UhqXzzWT7ibEItLDsmLjC0bDqJf+zbojFo4wmDjnU8kSa1HKISHQs
LVMRJyfjDQ2ZfZ+6A4i2ufDMEcpMG8Nx2LU82jRPStgxvnOIAj/d3KuMSIUD9wX/9wA+
JKBg==
X-Gm-Message-State: AO0yUKWqfumYiyWbBsSq3MKzOqZpMc/MiztU/940p4lvjd6KRSGHbu0d
hatbUY9KhwZSkFYGlqwGCxrOUFlCKPw=
X-Google-Smtp-Source: AK7set/gRqePaW9oUwAd5BTInwvgHyS9jG6TnTTc/XwxqIkOrBdFR0DWOujuklHE/QU5G1A86JOW8A==
X-Received: by 2002:ac8:5955:0:b0:3bf:c30d:101a with SMTP id
21-20020ac85955000000b003bfc30d101amr67478952qtz.34.1678756194059;
Mon, 13 Mar 2023 18:09:54 -0700 (PDT)
In-Reply-To: <CAEtLV=oHw_VEWd2WEqtD2Xv+Yp0WYeOh_3YgNvfG8ZW69UmXqg@mail.gmail.com>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQJRCIKAGpgkHcNksmLuXcPUET1Kr64KDnBQ
Content-Language: en-us
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: <009901d95611$aea10040$0be300c0$@gmail.com>
X-Mailman-Original-References: <CAEtLV=oHw_VEWd2WEqtD2Xv+Yp0WYeOh_3YgNvfG8ZW69UmXqg@mail.gmail.com>
 by: - Tue, 14 Mar 2023 01:09 UTC

Morten,

Suggesting something is UNPYTHONIC is really not an argument I take
seriously.

You wrote VALID code by the rules of the game and it is not a requirement
that it guesses at what you are trying to do and calls you an idiot!

More seriously, python lets you do some completely obscure things such as
check whether some random object or expression is truthy or not. There is no
way in hell the language, as defined, can catch all kinds of mistakes.

Now some languages or their linters have chosen to provide warnings of code
that may be valid but is often an error.

Consider:

x = 1
y = 0
x = y

Do I want to rest x to the value of y? Maybe. Or do I want the interpreter
to print out whether x == y perhaps?

Well what if the third line above was

x == y

Is that too a warning?

To add to the confusion some languages have an ===, :=, +=, -=, /=, |= or
oddities like %=% and many of these are all variations on meanings vaguely
related to equality before or after ...

So, no, it is not only not unpythonic, in my opinion, but quite pythonic to
let the interpreter interpret what you wrote and not know what you meant.

Is there possible a flag that would require your code to use spaces in many
places that might cut down on mistakes? There could be and so your example
of something like "new =- old" might be asked to be rewritten as "new = -
old" or even "new = (-old)" but for now, you may want to be more careful.

I do sympathize with the problem of a hard to find bug because it LOOKS
RIGHT to you. But it is what it is.

Avi

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Morten W. Petersen
Sent: Monday, March 13, 2023 5:26 PM
To: python-list <Python-list@python.org>
Subject: =- and -= snag

Hi.

I was working in Python today, and sat there scratching my head as the
numbers for calculations didn't add up. It went into negative numbers,
when that shouldn't have been possible.

Turns out I had a very small typo, I had =- instead of -=.

Isn't it unpythonic to be able to make a mistake like that?

Regards,

Morten

--
I am https://leavingnorway.info
Videos at https://www.youtube.com/user/TheBlogologue
Twittering at http://twitter.com/blogologue
Blogging at http://blogologue.com
Playing music at https://soundcloud.com/morten-w-petersen
Also playing music and podcasting here:
http://www.mixcloud.com/morten-w-petersen/
On Google+ here https://plus.google.com/107781930037068750156
On Instagram at https://instagram.com/morphexx/
--
https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor