On 3/13/23 2:26 PM, morphex@gmail.com wrote:
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
These all mean the same thing, but I don't see a good way to designate
the second or third as an error.
x = -5
x=-5
x =- 5
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
On 3/13/23 2:26 PM, morphex@gmail.com wrote:
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
These all mean the same thing, but I don't see a good way to designate
the second or third as an error.
x = -5
x=-5
x =- 5
Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.
Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.
On 3/13/2023 9:07 PM, Chris Angelico wrote:
Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.
Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.
This is the kind of thing that unit tests can catch.
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?
On Tue, 14 Mar 2023 at 12:38, Thomas Passin <list1@tompassin.net> wrote:
On 3/13/2023 9:07 PM, Chris Angelico wrote:
Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.
Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.
This is the kind of thing that unit tests can catch.
Maybe, but that's quite orthogonal. The linter would highlight the
exact line of code with the odd whitespace; a unit test would merely
point out that the overall behaviour is incorrect, which would have
been no further information beyond what the OP already knew (the
numbers weren't adding up).
ChrisA
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?
On 2023-03-13, Morten W. Petersen <morphex@gmail.com> wrote:
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?
Why would it be? How could it be? Mandating white-space between
operators would be unpythonic.
That's nothing anyway - yesterday I had an issue in TypeScript which
confused me for a while which turned out to be because 1 + 1 = 11.
(I thought the whole point of TypeScript was to prevent things like
that...)
--
https://mail.python.org/mailman/listinfo/python-list
2Var = 1
Var -=-1
Var
On 2023-03-13, Morten W. Petersen <morphex@gmail.com> wrote:
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?
Why would it be? How could it be? Mandating white-space between
operators would be unpythonic.
That's nothing anyway - yesterday I had an issue in TypeScript which
confused me for a while which turned out to be because 1 + 1 = 11.
(I thought the whole point of TypeScript was to prevent things like
that...)
--
https://mail.python.org/mailman/listinfo/python-list
On 3/14/23 18:50, Rob Cliffe wrote:
On 14/03/2023 21:28, avi.e.gross@gmail.com wrote:
TThere are people now trying to in some ways ruin the usability by putting in type hints that are ignored and although potentially helpful as in a linter evaluating it, instead often make it harder to read and write code if required to use it.+1
numbers for calculations didn't add up. It went into negative numbers,
when that shouldn't have been possible.
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?
On Mon, 13 Mar 2023 22:26:20 +0100, Morten W. Petersen wrote:
numbers for calculations didn't add up. It went into negative numbers,
when that shouldn't have been possible.
We have all written code that makes us wonder why the compiler even
bothered with it and didn't give up on the first line.
On Mon, 13 Mar 2023 22:26:20 +0100, Morten W. Petersen wrote:
numbers for calculations didn't add up. It went into negative numbers, when that shouldn't have been possible.
We have all written code that makes us wonder why the compiler even
bothered with it and didn't give up on the first line.
--
Gilmeh
If this fortune didn't exist, somebody would have invented it.
--
https://mail.python.org/mailman/listinfo/python-list
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 66:42:14 |
Calls: | 6,712 |
Files: | 12,244 |
Messages: | 5,356,315 |