Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread dn
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Chris Angelico
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Greg Ewing
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Michael Speer
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread 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.clear print(len(x)) 3 at terminal: x =

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-list
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Chris Angelico
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. > > > >

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread MRAB
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Chris Angelico
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Greg Ewing
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 --

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-list
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] >>>

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread DFS
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

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-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

In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread DFS
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 what I needed. x = [1,2,3] x.clear() print(len(x)) 0

Re: Python 3.7+ cannot print unicode characters when output is redirected to file - is this a bug?

2022-11-13 Thread Eryk Sun
On 11/13/22, Jessica Smith <12jessicasmit...@gmail.com> wrote: > Consider the following code ran in Powershell or cmd.exe: > > $ python -c "print('└')" > └ > > $ python -c "print('└')" > test_file.txt > Traceback (most recent call last): > File "", line 1, in > File "C:\Program

Re: Need max values in list of tuples, based on position

2022-11-13 Thread DFS
On 11/13/2022 7:37 AM, Pancho wrote: On 11/11/2022 19:56, DFS wrote: Edit: found a solution online: - x = [(11,1,1),(1,41,2),(9,3,12)] maxvals = [0]*len(x[0]) for e in x:  maxvals = [max(w,int(c)) for w,c in zip(maxvals,e)]

Re: Need max values in list of tuples, based on position

2022-11-13 Thread Pancho via Python-list
On 11/11/2022 19:56, DFS wrote: Edit: found a solution online: - x = [(11,1,1),(1,41,2),(9,3,12)] maxvals = [0]*len(x[0]) for e in x: maxvals = [max(w,int(c)) for w,c in zip(maxvals,e)] print(maxvals) [11,41,12]

Re: Strange UnicodeEncodeError in Windows image on Azure DevOps and Github

2022-11-13 Thread Jessica Smith
On Fri, Nov 11, 2022 at 8:16 PM Eryk Sun wrote: > If sys.std* are console files, then in Python 3.6+, sys.std*.buffer.raw will > be _io._WindowsConsoleIO > io.TextIOWrapper uses locale.getpreferredencoding(False) as the default > encoding Thank you for your replies - checking the

Re: Python 3.7+ cannot print unicode characters when output is redirected to file - is this a bug?

2022-11-13 Thread Thomas Passin
On 11/13/2022 9:49 AM, Jessica Smith wrote: Consider the following code ran in Powershell or cmd.exe: $ python -c "print('└')" └ $ python -c "print('└')" > test_file.txt Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python38\lib\encodings\cp1252.py", line

Re: Python 3.7+ cannot print unicode characters when output is redirected to file - is this a bug?

2022-11-13 Thread Barry
> On 13 Nov 2022, at 14:52, Jessica Smith <12jessicasmit...@gmail.com> wrote: > > Consider the following code ran in Powershell or cmd.exe: > > $ python -c "print('└')" > └ > > $ python -c "print('└')" > test_file.txt > Traceback (most recent call last): > File "", line 1, in > File

Python 3.7+ cannot print unicode characters when output is redirected to file - is this a bug?

2022-11-13 Thread Jessica Smith
Consider the following code ran in Powershell or cmd.exe: $ python -c "print('└')" └ $ python -c "print('└')" > test_file.txt Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode return

Re: Superclass static method name from subclass

2022-11-13 Thread Axy via Python-list
On 11/11/2022 16:21, Ian Pilcher wrote: Is it possible to access the name of a superclass static method, when defining a subclass attribute, without specifically naming the super- class? Contrived example:   class SuperClass(object):   @staticmethod   def foo():   pass   class