On Sun, Nov 13, 2022 at 4:45 PM DFS wrote:
> In code, list.clear is just ignored.
> At the terminal, list.clear shows
>
>
>
> in code:
> x = [1,2,3]
> x.clear
> print(len(x))
> 3
>
> at terminal:
> x = [1,2,3]
> x.clear
>
> print(len(x))
> 3
>
>
> Caused me an hour of frustration before I notic
On Thu, 24 Nov 2022 at 06:26, Stefan Ram wrote:
>
> Jon Ribbens writes:
> >If you want to catch this sort of mistake automatically then you need
> >a linter such as pylint:
>
> output
>
> , line 1
> list.clear
> Warning: Attribute used as statement.
>
> , line 5
> list.clear
> Warning: Attribut
: Python-list On
Behalf Of Chris Angelico
Sent: Tuesday, November 15, 2022 6:16 PM
To: python-list@python.org
Subject: Re: In code, list.clear doesn't throw error - it's just ignored
On Wed, 16 Nov 2022 at 10:11, wrote:
>
> That is clear, Cameron, but on my python interpreter values
On Wed, 16 Nov 2022 at 10:11, wrote:
>
> That is clear, Cameron, but on my python interpreter values evaluated on the
> command line ARE saved:
>
> >>> numb = 5
> >>> 5 + numb
> 10
> >>> numb
> 5
> >>> _ + _ + 1
> 11
That's a REPL feature.
ChrisA
--
https://mail.python.org/mailman/listinfo/pyth
I grant generally a naked evaluation is generally an error. LOL!
-Original Message-
From: Python-list On
Behalf Of Cameron Simpson
Sent: Tuesday, November 15, 2022 4:13 AM
To: python-list@python.org
Subject: Re: In code, list.clear doesn't throw error - it's just ignored
On 15Nov
On 15Nov2022 00:45, avi.e.gr...@gmail.com wrote:
What would be the meaning of an ordering relation determining what is
MORE VALID?
Are you asking what criterion would rate:
clearx = x.clear
as "more" valid than:
x.clear
on its own?
I don't want to speak for the OP, but I'd think t
22 9:34 PM
To: python-list@python.org
Subject: Re: In code, list.clear doesn't throw error - it's just ignored
On 14Nov2022 19:15, Dennis Lee Bieber wrote:
> There is also the minor facet that "x.clear" can be bound to a
>different name...
>
>>>&g
On 14Nov2022 19:15, Dennis Lee Bieber wrote:
There is also the minor facet that "x.clear" can be bound to a
different name...
x = [1, 2, 3.145926536, "Pie"]
clearx = x.clear
x
[1, 2, 3.145926536, 'Pie']
clearx()
x
[]
I think the OP would take the stance that this:
clearx =
On Tue, 15 Nov 2022 09:11:10 +1100, Cameron Simpson
declaimed the following:
>On 13Nov2022 22:23, DFS wrote:
>>This is an easy check for the interpreter to make.
>
>It really isn't, given that (a) this isn't known by the interpreter to
>be a `list` until runtime and (b) that would need embeddin
On 13Nov2022 22:23, DFS wrote:
On 11/13/2022 9:11 PM, Chris Angelico wrote:
[ ... `x.clear` ... ]
No part of it is invalid, so nothing causes a problem. For instance,
you can write this:
If it wastes time like that it's invalid.
It's a valid expression.
It looks to your eye like a no-op, b
On Tue, 15 Nov 2022 at 05:57, Stefan Ram wrote:
>
> Michael Speer writes:
> >Python doesn't care what an expression returns.
>
> In my English, functions return values,
> expression are being evaluated to a value.
> The evaluation of a function yields or
> produces a value. Expressions do
On 2022-11-14, Stefan Ram wrote:
> Jon Ribbens writes:
>>"""Create an array and print its length"""
>>array = [1, 2, 3]
>>array.clear
>
> BTW: Above, there are /two/ expression statements
> with no effect; the other one is
>
> """Create an array and print its length"""
>
> . Apparently, lin
The terminal told you what x.clear was.
The Python documentation tells you how to call it:
https://docs.python.org/3/tutorial/datastructures.html
list.clear()
Remove all items from the list. Equivalent to del a[:].
An IDE (e.g. PyCharm) will try to autocomplete the parentheses and warn you if
Am Mon, Nov 14, 2022 at 02:13:34AM + schrieb MRAB:
> But if it's an expression where it's expecting a statement and it's not a
> call, then
> it's probably a bug.
That "probably" makes it suitable for a linter, as was pointed out.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4
Op 14/11/2022 om 4:23 schreef DFS:
On 11/13/2022 9:11 PM, Chris Angelico wrote:
On Mon, 14 Nov 2022 at 11:53, DFS wrote:
On 11/13/2022 5:20 PM, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
In code, list.clear is just ignored.
At the terminal, list.clear shows
in code:
x = [1,2,3]
x.clea
On 14/11/2022 12.12, DFS wrote:
On 11/13/2022 5:20 PM, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
In code, list.clear is just ignored.
At the terminal, list.clear shows
in code:
x = [1,2,3]
x.clear
print(len(x))
3
at terminal:
x = [1,2,3]
x.clear
print(len(x))
3
Caused me an hour of f
On Mon, 14 Nov 2022 at 18:00, Greg Ewing wrote:
>
> On 14/11/22 3:13 pm, MRAB wrote:
> > But if it's an expression where it's expecting a statement and it's not
> > a call, then it's probably a bug.
>
> The key word there is "probably". If there's any chance it
> could be not a bug, it can't be an
On 14/11/22 3:13 pm, MRAB wrote:
But if it's an expression where it's expecting a statement and it's not
a call, then it's probably a bug.
The key word there is "probably". If there's any chance it
could be not a bug, it can't be an error. At most it should
be a warning, and that's what linters
Python doesn't care what an expression returns.
You've written an expression that returns the value of the 'clear' function
that is bound to that particular list.
The interpreter doesn't know or care if accessing that 'clear' attribute on
the class returns a function or for some reason triggers a
On 11/13/2022 9:11 PM, Chris Angelico wrote:
On Mon, 14 Nov 2022 at 11:53, DFS wrote:
On 11/13/2022 5:20 PM, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
In code, list.clear is just ignored.
At the terminal, list.clear shows
in code:
x = [1,2,3]
x.clear
print(len(x))
3
at terminal:
x =
On 2022-11-14, Greg Ewing wrote:
> On 14/11/22 1:31 pm, Jon Ribbens wrote:
>> On 2022-11-13, DFS wrote:
>>> But why is it allowed in the first place?
>>
>> Because it's an expression, and you're allowed to execute expressions.
>
> To put it a bit more clearly, you're allowed to evaluate
> an exp
On Mon, 14 Nov 2022 at 13:18, MRAB wrote:
>
> On 2022-11-14 00:55, Greg Ewing wrote:
> > On 14/11/22 1:31 pm, Jon Ribbens wrote:
> >> On 2022-11-13, DFS wrote:
> >>> But why is it allowed in the first place?
> >>
> >> Because it's an expression, and you're allowed to execute expressions.
> >
> >
On 2022-11-14 00:55, Greg Ewing wrote:
On 14/11/22 1:31 pm, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
But why is it allowed in the first place?
Because it's an expression, and you're allowed to execute expressions.
To put it a bit more clearly, you're allowed to evaluate
an expression a
On Mon, 14 Nov 2022 at 11:53, DFS wrote:
>
> On 11/13/2022 5:20 PM, Jon Ribbens wrote:
> > On 2022-11-13, DFS wrote:
> >> In code, list.clear is just ignored.
> >> At the terminal, list.clear shows
> >>
> >>
> >>
> >> in code:
> >> x = [1,2,3]
> >> x.clear
> >> print(len(x))
> >> 3
> >>
> >> at
On 14/11/22 1:31 pm, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
But why is it allowed in the first place?
Because it's an expression, and you're allowed to execute expressions.
To put it a bit more clearly, you're allowed to evaluate
an expression and ignore the result.
--
Greg
--
https
On 2022-11-13, DFS wrote:
> On 11/13/2022 5:20 PM, Jon Ribbens wrote:
>> On 2022-11-13, DFS wrote:
>>> In code, list.clear is just ignored.
>>> At the terminal, list.clear shows
>>>
>>>
>>>
>>> in code:
>>> x = [1,2,3]
>>> x.clear
>>> print(len(x))
>>> 3
>>>
>>> at terminal:
>>> x = [1,2,3]
>>>
On 11/13/2022 5:20 PM, Jon Ribbens wrote:
On 2022-11-13, DFS wrote:
In code, list.clear is just ignored.
At the terminal, list.clear shows
in code:
x = [1,2,3]
x.clear
print(len(x))
3
at terminal:
x = [1,2,3]
x.clear
print(len(x))
3
Caused me an hour of frustration before I noticed list.
On 2022-11-13, DFS wrote:
> In code, list.clear is just ignored.
> At the terminal, list.clear shows
>
>
>
> in code:
> x = [1,2,3]
> x.clear
> print(len(x))
> 3
>
> at terminal:
> x = [1,2,3]
> x.clear
>
> print(len(x))
> 3
>
>
> Caused me an hour of frustration before I noticed list.clear() was
28 matches
Mail list logo