Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 1:20 PM Rob Cliffe via Python-list wrote: > > > > On 21/11/2021 01:02, Chris Angelico wrote: > > > > If you have a number with a finite binary representation, you can > > guarantee that it can be represented finitely in decimal too. > >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 12:56 PM Avi Gross via Python-list wrote: > > Not at all, Robb. I am not intending to demean Mathematicians as one of my > degrees is in that subject and I liked it. I mean that some things in > mathematics are not as intuitive to people when they first encounter them,

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 11:39 AM Avi Gross via Python-list wrote: > > Can I suggest a way to look at it, Grant? > > In base 10, we represent all numbers as the (possibly infinite) sum of ten > raised to some integral power. Not infinite. If you allow an infinite sequence of digits, you create

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 10:55 AM Ben Bacarisse wrote: > > Grant Edwards writes: > > > On 2021-11-20, Ben Bacarisse wrote: > > > >> You seem to be agreeing with me. It's the floating point part that is > >> the issue, not the base itself. > > > > No, it's the base. Floating point can't

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 10:01 AM Avi Gross via Python-list wrote: > Computers generally use finite methods, sometimes too finite. Yes, the > problem is not Mathematics as a field. It is how humans often generalize or > analogize from one area into something a bit different. I do not agree with >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 9:22 AM Grant Edwards wrote: > > On 2021-11-20, Chris Angelico wrote: > > > But you learn that it isn't the same as 1/3. That's my point. You > > already understand that it is *impossible* to write out 1/3 in > > decimal. Is it such a stretch

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 8:32 AM Avi Gross via Python-list wrote: > > This discussion gets tiresome for some. > > Mathematics is a pristine world that is NOT the real world. It handles > near-infinities fairly gracefully but many things in the real world break > down because our reality is not

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Chris Angelico
On Sun, Nov 21, 2021 at 6:51 AM Ben Bacarisse wrote: > > Chris Angelico writes: > > > On Sat, Nov 20, 2021 at 3:41 PM Ben Bacarisse wrote: > >> > >> Chris Angelico writes: > >> > >> > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 3:41 PM Ben Bacarisse wrote: > > Chris Angelico writes: > > > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse wrote: > >> > >> Chris Angelico writes: > >> > >> > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse wrote: > > Chris Angelico writes: > > > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: > >> > >> Chris Angelico writes: > >> > >> > On Sat, Nov 20, 2021 at 5:08 AM ast wrote:

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: > > Chris Angelico writes: > > > On Sat, Nov 20, 2021 at 5:08 AM ast wrote: > > >> >>> 0.3 + 0.3 + 0.3 == 0.9 > >> False > > > > That's because 0.3 is not 3/10. It's not because

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 7:39 AM dn via Python-list wrote: > >> >>> 0.3 + 0.3 + 0.3 == 0.9 > >> False > > > > That's because 0.3 is not 3/10. It's not because floats are > > "unreliable" or "inaccurate". It's because the ones you're entering > > are not what you think they are. > > > > When will

Re: frozenset can be altered by |=

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 8:16 AM Chris Angelico wrote: > > On Sat, Nov 20, 2021 at 8:13 AM Marco Sulla > wrote: > > > > (venv_3_10) marco@buzz:~$ python > > Python 3.10.0 (heads/3.10-dirty:f6e8b80d20, Nov 18 2021, 19:16:18) > > [GCC 10.1.1 20200718] on linux >

Re: frozenset can be altered by |=

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 8:13 AM Marco Sulla wrote: > > (venv_3_10) marco@buzz:~$ python > Python 3.10.0 (heads/3.10-dirty:f6e8b80d20, Nov 18 2021, 19:16:18) > [GCC 10.1.1 20200718] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> a = frozenset((3, 4)) > >>>

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Chris Angelico
On Sat, Nov 20, 2021 at 5:08 AM ast wrote: > > Le 19/11/2021 à 03:51, MRAB a écrit : > > On 2021-11-19 02:40, 2qdxy4rzwzuui...@potatochowder.com wrote: > >> On 2021-11-18 at 23:16:32 -0300, > >> René Silva Valdés wrote: > >> > >>> Hello, I would like to report the following issue: > >>> > >>>

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 3:00 PM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: >> >> On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: >> > >> > >> > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrot

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> If you're trying to make a Python-in-Python sandbox, I recommend not. >> Instead, use an OS-level sandbox (a chroot, probably some sort of CPU >&

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 7:09 AM lucas wrote: > > hello one and all, > > are there any other ways to import a module or package other then the > "import" or "from...import..." statements? i ask because i'm allowing > programming on my web2py website and i don't want any accessing packages like

Re: Proliferation of Python packaging formats

2021-11-17 Thread Chris Angelico
On Thu, Nov 18, 2021 at 12:20 AM Skip Montanaro wrote: > > Is the proliferation of packaging formats in Python as nutzo as this author > believes? > > https://drewdevault.com/2021/11/16/Python-stop-screwing-distros-over.html > > Asking because I've never been in the business of releasing "retail"

Re: One line sort

2021-11-15 Thread Chris Angelico
On Tue, Nov 16, 2021 at 5:58 AM ast wrote: > > A curiosity: > > q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i > for i in x[1:] if i >= x[0]]) > > >>> q([7, 5, 9, 0]) > [0, 5, 7, 9] A nicely obfuscated quicksort. Although the "one line" part falls down a bit if it has to

Re: Avoid nested SIGINT handling

2021-11-13 Thread Chris Angelico
On Sun, Nov 14, 2021 at 4:42 AM Mladen Gogala via Python-list wrote: > > On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote: > > > Threads aren't the point here - signals happen immediately. > > Actually, signals are not delivered immediately. Signals are deli

Re: Unable to compile my C Extension on Windows: unresolved external link errors

2021-11-12 Thread Chris Angelico
On Sat, Nov 13, 2021 at 7:01 AM Marco Sulla wrote: > On Fri, 12 Nov 2021 at 17:38, Chris Angelico wrote: > > Are you sure that you really need Py_BUILD_CORE? > > Yes, because I need the internal functions of `dict`. So I need to > compile also dictobject.c and include it. S

Re: Unable to compile my C Extension on Windows: unresolved external link errors

2021-11-12 Thread Chris Angelico
On Sat, Nov 13, 2021 at 3:28 AM Marco Sulla wrote: > > On Fri, 12 Nov 2021 at 15:55, Gisle Vanem wrote: > > Marco Sulla wrote: > > > Error LNK2001: unresolved external symbol PyErr_SetObject > > > > > > and so on. > > > > > > I post the part of my setup.py about the C Extension: > > > > > >

Re: Avoid nested SIGINT handling

2021-11-10 Thread Chris Angelico
On Thu, Nov 11, 2021 at 5:01 PM Jon Ribbens via Python-list wrote: > > On 2021-11-10, Paulo da Silva wrote: > > Hi! > > > > How do I handle a SIGINT (or any other signal) avoid nesting? > > I don't think you need to. Python will only call signal handlers in > the main thread, so a handler can't

Re: Breaking new relic format on a new line character in FileHandler appender

2021-11-10 Thread Chris Angelico
On Thu, Nov 11, 2021 at 5:00 PM Vijay Karavadra via Python-list wrote: > > Hello Team, > > I'm trying to add logs in the new relic platform from a python application. > For that, I've to add logs in a local file in a specific format which is > > '{"log.level":"%(levelname)s",

Re: Strange Change Of Module Name

2021-11-05 Thread Chris Angelico
On Sat, Nov 6, 2021 at 8:42 AM Betty Hollinshead wrote: > > python3-3.10.0-1.fc35.x86_64 > alacarte-3.36.0-6.fc35.noarch > > Someone in the Python world changed the name of an import. > Once upon a time the import (in alacarte) it looked like this: > from collections import Sequence > > In a

Re: Syntax not understood

2021-11-04 Thread Chris Angelico
On Fri, Nov 5, 2021 at 6:45 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > But since it says "box", I would start by assuming that it has four > > elements. (They might be x1,y1,x2,y2 or x,y,w,h but it'll almost > > always be four.) So it's not TOO fragile, when working with boxes, but > > it

Re: Syntax not understood

2021-11-04 Thread Chris Angelico
On Fri, Nov 5, 2021 at 6:23 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-11-04 at 14:36:48 -0400, > David Lowry-Duda wrote: > > > > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:]) > > > > > > (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single >

Re: System, configuration and Python performance

2021-11-01 Thread Chris Angelico
On Tue, Nov 2, 2021 at 11:21 AM Shaozhong SHI wrote: > > On Tue, 2 Nov 2021 at 00:09, MRAB wrote: > > > On 2021-11-01 23:02, Shaozhong SHI wrote: > > > How to configure to improve Python performance in a system like the > > > following: > > > > > > Windows 10 > > > > > > System > > > > > >

Re: Why so fast a web framework?

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 3:49 PM Dan Stromberg wrote: > > I care, and I suspect the OP does too. Usually machine time doesn't matter > as much as developer time, but API overhead Can matter - especially on a > busy server. > > I wonder if Pypy would do any better? Or Micropython? Or Cython? > >

Re: Get a Joke in Python

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 12:29 PM Jon Ribbens via Python-list wrote: > > On 2021-10-28, Greg Ewing wrote: > > On 29/10/21 11:34 am, Chris Angelico wrote: > >> On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse > >> wrote: > >>> QA engineer walks

Re: Get a Joke in Python

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse wrote: > > QA engineer walks into a bar. Orders a beer. Orders 0 beers. > Orders 9 beers. Orders a lizard. Orders -1 beers. > Orders a sfdeljknesv. > Orders 1 пиво and is served a пиво. QA engineer sighs "not again". ChrisA --

Re: Why so fast a web framework?

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 6:17 AM Calvin Spealman wrote: > > I don't think there's anything meaningful being compared in that so-called > "benchmark" at all. There is no evidence that its worth even the smallest > bit of attention. > > You want to write a web service? Do it. Use Python or PHP, or

Re: walrus with a twist :+= or ...

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 5:53 AM Avi Gross via Python-list wrote: > Is there a reasonable extension to a keyboard that might be reasonable, > perhaps with an accommodation to those without such a keyboard so that > entering some sequence gets it converted into what you want on the screen > but

Re: New assignmens ...

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 4:37 AM Avi Gross via Python-list wrote: > Now for a dumb question. Many languages allow a form of setting a variable to > a value like: > > assign(var, 5+sin(x)) > > If we had a function that then returned var or the value of var, cleanly, > then would

Re: The task is to invent names for things

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 11:55 AM Eli the Bearded <*@eli.users.panix.com> wrote: > The choice of a non-sensical is perfectly fine _when_ it's a major > component. Kafka, Python, Java, Rust. Those are all non-sensically named, > in that the name doesn't fit what it is, by pun, initials, or

Re: walrus with a twist :+= or ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 11:58 AM Avi Gross via Python-list wrote: > On a serious note, if it was ever considered a good idea, what would be an > acceptable sequence of symbols that might not break or confuse existing > programs and what would we call it? I mean what animal, of course. > > > >

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 11:08 AM Avi Gross via Python-list wrote: > > Dave, > > You make me wonder about unintended side effects. Are we allowing the ++ and > --- operations into Python through a side door? > class IncrementableInteger(int): def __pos__(self): return HalfIncremented(self)

Re: The task is to invent names for things

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 7:54 AM Karsten Hilbert wrote: > > Am Wed, Oct 27, 2021 at 10:00:16PM +1100 schrieb Chris Angelico: > > > > Am Wed, Oct 27, 2021 at 10:20:19AM +1100 schrieb Chris Angelico: > > > > > > > Many operations in computing are fully reversib

Re: Why so fast a web framework?

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 6:52 AM Abdur-Rahmaan Janhangeer wrote: > > See this: > https://github.com/walkor/webman > > Why similar frameworks do not exist in Python. Is it because > of lack of lib contributors or due to an inherent difference in Py > and PHP? Thanks! > It depends entirely on what

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 4:34 AM Christman, Roger Graydon wrote: > Do you put special code in next_couple() to recognize that the provided > arguments > are actually the first couple so it can return those unmodified, but then > require its > own mental note not to give you an infinite loop

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 4:03 AM Antoon Pardon wrote: > > So suppose I have an arbitrary number of simple statements. The > latter possible using results from previous assignment and at the > end a condition to control the one and a half loop. How do you write > the python code so that the one and

Re: The task is to invent names for things

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 9:41 PM Karsten Hilbert wrote: > > Am Wed, Oct 27, 2021 at 10:20:19AM +1100 schrieb Chris Angelico: > > > Many operations in computing are fully reversible. After you do > > something, you can undo it. After you assign, you can unassign. And >

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 8:20 PM Antoon Pardon wrote: > > > > Op 27/10/2021 om 10:49 schreef Chris Angelico: > > On Wed, Oct 27, 2021 at 7:46 PM Antoon Pardon wrote: > >>> So if you want this added, show a use-case that makes it look way > >>> better th

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 7:39 PM dn via Python-list wrote: > Accordingly: is this a job for the walrus operator at all? Let's "talk > of many [other] things"*. +1 > Could we use a data structure to continue to keep things straight-forward? > > class my_class(): > def __init__( self, a, b

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 7:46 PM Antoon Pardon wrote: > > So if you want this added, show a use-case that makes it look way > > better than the alternatives (including a generator, a mid-loop break, > > etc). > > Way better according to which criteria? IMO to realy make something like > this you

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon wrote: > > > > Op 26/10/2021 om 00:24 schreef Chris Angelico: > > TBH, I don't think there's a lot of value in multiple-assignment, > > since it has a number of annoying conflicts of syntax and few viable > > use-cases.

Re: The task is to invent names for things

2021-10-26 Thread Chris Angelico
On Wed, Oct 27, 2021 at 10:16 AM dn via Python-list wrote: > Programmers of the world unite! > You have nothing to lose but your 0 > - or your 1 Many operations in computing are fully reversible. After you do something, you can undo it. After you assign, you can unassign. And after you ite, you

Re: Create a contact book

2021-10-26 Thread Chris Angelico
On Tue, Oct 26, 2021 at 5:30 PM anders Limpan wrote: > > i would like to create a contact book were you can keep track of your > friends. With this contact book you will both be able to add friends and view > which friends that you have added. anyone interested in helping me out with > this

Re: Beginner in python

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 9:23 AM Kian Kwame wrote: > > hi buddie > am new to python somebody kindly advice the coding which will count odd > number from 1 to 10 , and counting number from 1 tp 100 Sounds like homework. What have you written so far? ChrisA --

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 9:19 AM dn via Python-list wrote: > Back on-topic, I am slightly curious:- > > aside from 'starting small' with an option to widen/'open-up' later, is > there a particular reason why 'the walrus' has not been made available > (could not be ...?) for use with

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 8:42 AM Avi Gross via Python-list wrote: > Personally, I don't care what is done and suspect I will rarely feel much > need to use the current walrus operator, let alone an enhanced Odobenus > rosmarus operator like ::== ... > . wait what? Ah. Had to look that one

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 7:18 AM Antoon Pardon wrote: > > Op 25/10/2021 om 20:39 schreef Chris Angelico: > > On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: > >> By putting limits on the walrus code, you are not reducing complexity, you > >> are increasi

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: > By putting limits on the walrus code, you are not reducing complexity, you > are increasing it. > You are increasing complexity because you can't just reuse the code that > handles an ordinary > assignment. You now need specific code to

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 3:07 AM Avi Gross via Python-list wrote: > I will end with this. If someone wants to design a new language from scratch > and with a goal of starting with as general a set of concepts as they can, > fine. Design it carefully. Build it and if it works well enough, use it.

Re: New assignmens ...

2021-10-24 Thread Chris Angelico
On Mon, Oct 25, 2021 at 2:13 AM Alan Bawden wrote: > > It seemed weird to me that only an identifier was allowed to be the > target of an assignment expression. Then it occurred to me that > function definitions are another place where only identifiers are > allowed, but where I could imagine an

Re: New assignmens ...

2021-10-23 Thread Chris Angelico
On Sun, Oct 24, 2021 at 7:48 AM Jon Ribbens via Python-list wrote: > > On 2021-10-23, Chris Angelico wrote: > > On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list > > wrote: > >> On 2021-10-23, Chris Angelico wrote: > >> > In what situations do y

Re: New assignmens ...

2021-10-23 Thread Chris Angelico
On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list wrote: > > On 2021-10-23, Chris Angelico wrote: > > I've never used ctr:=ctr-1 either, though, so I don't know the actual > > use cases. Why is this being used in an assignment expression? Is it > > an ersatz

Re: New assignmens ...

2021-10-22 Thread Chris Angelico
On Sat, Oct 23, 2021 at 12:24 PM Paulo da Silva wrote: > > Às 20:34 de 22/10/21, Chris Angelico escreveu: > > On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list > > wrote: > >> > >> On 2021-10-22, Stefan Ram wrote: > >>> Paul

Re: New assignmens ...

2021-10-22 Thread Chris Angelico
On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list wrote: > > On 2021-10-22, Stefan Ram wrote: > > Paulo da Silva writes: > >>Why doesn't this work > >> if (self.ctr:=self.ctr-1)<=0: > >>while this works > >> if (ctr:=ctr-1)<=0: > > > > assignment_expression ::=

Re: importing a module from a file without the '.py' suffix

2021-10-22 Thread Chris Angelico
On Fri, Oct 22, 2021 at 10:36 PM Antoon Pardon wrote: > > I have a file with python code but the name doesn't end with the '.py' > suffix. > > What is the easiest way to import this code as a module without changing > its name? > It should be possible to use importlib for this:

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 4:45 AM hongy...@gmail.com wrote: > > On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote: > > On 18Oct2021 01:43, Hongyi Zhao wrote: > > >I've written the following python code snippet in pycharm: > > >```python > > >import numpy as np > > >from

Re: Re: sum() vs. loop

2021-10-12 Thread Chris Angelico
On Wed, Oct 13, 2021 at 12:36 PM Avi Gross via Python-list wrote: > > Alan, > > I am also wondering about that zip() function call to bind the two lists > into a sort of iterator object. Presumably that calls the iterator N times. > I did a test where I made two list called A and B and used zip

Re: Beginner problem, please help. Building a simple menu + lists , cannot print list

2021-10-11 Thread Chris Angelico
On Tue, Oct 12, 2021 at 9:13 AM Felix Kjellström wrote: > > Hello! Please see the link to the code I have uploaded to my account at > replit.com > > https://replit.com/join/lftxpszwrv-felixkjellstrom Unfortunately, it's not public. Are you able to put the code on GitHub as a repository or gist,

Re: Assign a value to a var content in an object

2021-10-11 Thread Chris Angelico
On Tue, Oct 12, 2021 at 9:03 AM Paulo da Silva wrote: > > Hello! > > Is there a better way of doing this? > Why didn't setattr (as commented) work? > > Thanks for an help/comments. > > class C: > def f(self,v): > #setattr(self,n,v) > self.__dict__['n']=v > > c=C() > c.f(3) >

Re: sum() vs. loop

2021-10-11 Thread Chris Angelico
On Tue, Oct 12, 2021 at 9:02 AM Stefan Ram wrote: > > Steve Keller writes: > >Now completely surprised. > > I have observed that here the generator-based sum() call > is slower if both seq1 and seq2 have a length of 1000, but > faster if both seq1 and seq2 have 1000 entries each >

Re: sum() vs. loop

2021-10-11 Thread Chris Angelico
On Tue, Oct 12, 2021 at 8:55 AM Steve Keller wrote: > > I have found the sum() function to be much slower than to loop over the > operands myself: > > def sum_products(seq1, seq2): > return sum([a * b for a, b in zip(seq1, seq2)]) > > def sum_products2(seq1, seq2): > sum = 0 > for a,

Re: spyder does not work under root! [linux]

2021-10-11 Thread Chris Angelico
On Tue, Oct 12, 2021 at 8:52 AM Paulo da Silva wrote: > > Hi! > > I need to debug a python3 script under root. I tried spyder but it does > not work. > > Running as root without --no-sandbox is not supported. See > https://crbug.com/638180. > > Thanks for any comments including alternative

Re: Confusing error message: lambda walruses

2021-10-06 Thread Chris Angelico
On Thu, Oct 7, 2021 at 8:51 AM Thomas Jollans wrote: > > On 03/10/2021 01:39, Chris Angelico wrote: > > Using assignment expressions in lambda functions sometimes works, but > > sometimes doesn't. > > Does this commit by a certain Chris Angelico help clear things up? >

Re: Understanding the working mechanis of python unary arithmetic operators.

2021-10-05 Thread Chris Angelico
On Wed, Oct 6, 2021 at 7:52 AM hongy...@gmail.com wrote: > > On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote: > > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote: > > > See the following testings: > > > > > > In [24]:

Re: McCabe complexity for just changed files in a commit?

2021-10-04 Thread Chris Angelico
On Tue, Oct 5, 2021 at 3:44 PM Kushal Kumaran wrote: > > On Sat, Oct 02 2021 at 09:05:47 PM, Dan Stromberg wrote: > > Hi folks. > > > > Is there a way of getting the McCabe Complexity of just the functions and > > methods (in Python) changed in a git commit? > > > > I found radon, and it looks

Re: McCabe complexity for just changed files in a commit?

2021-10-02 Thread Chris Angelico
On Sun, Oct 3, 2021 at 3:18 PM Chris Angelico wrote: > git diff-tree 1af743 > 1af743f411aa2b7278d1f1b3c30b447555ea55b8 > :100644 100644 b5908b5a36a4749e0bef2a16a2733a7461a818dc > e00ba8738dbf3421288d31c60de9ee42a085c148 M auto-volume.py > > The first line is the commit h

Re: McCabe complexity for just changed files in a commit?

2021-10-02 Thread Chris Angelico
On Sun, Oct 3, 2021 at 3:07 PM Dan Stromberg wrote: > > Hi folks. > > Is there a way of getting the McCabe Complexity of just the functions and > methods (in Python) changed in a git commit? > > I found radon, and it looks good. But I think it wants to do entire files, > no? No idea about the

Confusing error message: lambda walruses

2021-10-02 Thread Chris Angelico
Using assignment expressions in lambda functions sometimes works, but sometimes doesn't. Python 3.11.0a0 (heads/main:dc878240dc, Oct 3 2021, 10:28:40) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. # Fine if it's a parameter to the lambda function

Re: OT: AttributeError

2021-09-28 Thread Chris Angelico
On Wed, Sep 29, 2021 at 12:06 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > ... Or, even better, to be able to read off a hex dump and see E8 03 > > and instantly read it as "1,000 little-endian". > > 59535 big endian. Warningm flamebait ahead: Who thinks in little > endian? (I was raised

Re: OT: AttributeError

2021-09-28 Thread Chris Angelico
On Wed, Sep 29, 2021 at 11:59 AM dn via Python-list wrote: > If I hold up two fingers, am I insulting you, or asking for three of > something? > A Roman soldier walked into a bar holding up two fingers. "Five beers, please" ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: AttributeError

2021-09-28 Thread Chris Angelico
On Wed, Sep 29, 2021 at 10:06 AM Greg Ewing wrote: > > On 29/09/21 12:21 pm, Chris Angelico wrote: > > to the extent that you automatically read 65 and 0x41 as the same > > number. > > Am I too geeky for reading both of them as 'A'? > Not even slightly, and I did deli

Re: OT: AttributeError

2021-09-28 Thread Chris Angelico
On Wed, Sep 29, 2021 at 9:10 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-09-29 at 11:38:22 +1300, > dn via Python-list wrote: > > > For those of us who remember/can compute in binary, octal, hex, or > > decimal as-needed: > > Why do programmers confuse All Hallows'/Halloween for

Re: XML Considered Harmful

2021-09-28 Thread Chris Angelico
On Wed, Sep 29, 2021 at 8:00 AM Stefan Ram wrote: > JSON is a kind of a subset of JavaScript for JavaScript > programmers. In Python, we can use JSON too, or we can > use Python itself. > > When some external requirement to use a data exchange > notation like JSON should appear, one can

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 10:40 AM Skip Montanaro wrote: > > Woo hoo! It's installed. The ultimate error was a missing turbojpeg.h > file. Thank goodness for the apt-file command. I was able to track > that down to the libturbojpeg0-dev package, install that, and after a > bit more fussing around

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 8:09 AM Skip Montanaro wrote: >> >> For the most part, a proper colorizing compiler can make the >> errors stand out among the spam of warnings, but it's hard when people >> copy and paste just the text. > > > In my defense, the entire traceback was red. :-) It's quite

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 4:46 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > I agree that the standard shouldn't regulate warnings. I'm also saying > that sometimes, it's a pain that it doesn't, and that not every warning > is the package maintainer's fault. :-) Agreed. For the most part, a

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 4:04 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-09-28 at 03:23:53 +1000, > Chris Angelico wrote: > > > On Tue, Sep 28, 2021 at 3:11 AM Skip Montanaro > > wrote: > > >> > > >> Those a

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 3:11 AM Skip Montanaro wrote: >> >> Those are all warnings. Are there any errors that follow them? > > > Maybe I just missed the actual errors, but the compiler exit status was 1, so > there must have been. I'll give it another try. Yeah, one of the annoying things of

Re: XML Considered Harmful

2021-09-27 Thread Chris Angelico
On Tue, Sep 28, 2021 at 2:30 AM Michael F. Stemper wrote: > As far as power is concerned, this is utility-level generating fleets, > so it's always going to be MW -- even in the US, where we still use > BTUs for heat. > It's easy for *you* to know, and therefore assume, that it's always MW. But

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Chris Angelico
On Mon, Sep 27, 2021 at 10:49 PM Skip Montanaro wrote: > > I'd like to use the jpegdupes package > but > can't seem to get past compilation issued related to jpegtrans-cffi. > Attempts to install any available versions on my XUbuntu system crap out > with

Re: Posts from gmane no longer allowed?

2021-09-26 Thread Chris Angelico
On Mon, Sep 27, 2021 at 1:10 AM Grant Edwards wrote: > > On 2021-09-26, Chris Angelico wrote: > > > Not sure what the significance of the "application" is - Google has > > different services for where you're using it with your own domain, but > > that shou

Re: Posts from gmane no longer allowed?

2021-09-26 Thread Chris Angelico
On Sun, Sep 26, 2021 at 11:37 PM Grant Edwards wrote: > > I've been trying to figure out how to set up mutt with oauth2 for > gmail, but have run into a wall there too: Google doesn't want to let > me create an "application" unless I have my own domain pre-registered > with Google. > > Perhaps

Re: XML Considered Harmful

2021-09-25 Thread Chris Angelico
On Sun, Sep 26, 2021 at 9:09 AM Eli the Bearded <*@eli.users.panix.com> wrote: > > In comp.lang.python, Chris Angelico wrote: > > Eli the Bearded <*@eli.users.panix.com> wrote: > >> I'd use one of the netpbm formats instead of JPEG. PBM for one bit > >&g

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Chris Angelico
On Sun, Sep 26, 2021 at 2:27 AM Dieter Maurer wrote: > > Stefan Ram wrote at 2021-9-24 16:48 GMT: > >"Dieter Maurer" writes: > >>A list is ordered. Therefore, it is important where > >>in this order an element is added. Thus, for a list, > >>`append` is a better name than `add` -- because it

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 11:11 AM Oscar Benjamin wrote: > > On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote: >> >> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin >> wrote: >> > >> > On Sat, 25 Sept 2021 at 00:37, Greg Ewing >> > wrote: >

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin wrote: > > On Sat, 25 Sept 2021 at 00:37, Greg Ewing > wrote: > > > On 25/09/21 10:15 am, Steve Keller wrote: > > > BTW, I like how the min() and max() functions allow both ways of being > > > called. > > > > That wouldn't work for set.union and

Re: XML Considered Harmful

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 8:53 AM dn via Python-list wrote: > > On 25/09/2021 06.59, Peter J. Holzer wrote: > > There are a gazillion formats and depending on your needs one of them > > might be perfect. Or you may have to define you own bespoke format (I > > mean, nobody (except Matt Parker) tries

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 3:42 AM Stefan Ram wrote: > > "Dieter Maurer" writes: > >A list is ordered. Therefore, it is important where > >in this order an element is added. Thus, for a list, > >`append` is a better name than `add` -- because it already > >tells us in the name where it adds the new

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Fri, Sep 24, 2021 at 11:47 PM Steve Keller wrote: > > Why do some built-in Python functions feel so differently: > > For example sum(), all(), any() expect exactly one argument which is a > sequence to operate on, i.e. a list, an iterator or a generator etc. > > sum([1,2,3,4]) >

Re: Type annotation pitfall

2021-09-24 Thread Chris Angelico
On Fri, Sep 24, 2021 at 11:43 PM Peter Saalbrink wrote: > > I don't think this has anything to do with typing or providing type hints. > The type hint is the `: set` part, not the `= set()` part. > You can declare the type without assigning to the variable. > Indeed, as you already said, `x` is a

Re: XML Considered Harmful

2021-09-23 Thread Chris Angelico
On Fri, Sep 24, 2021 at 1:44 PM Dan Stromberg wrote: > > > On Thu, Sep 23, 2021 at 8:12 PM Chris Angelico wrote: >> >> One good hybrid is to take a subset of Python syntax (so it still >> looks like a Python script for syntax highlighting etc), and then >> p

Re: XML Considered Harmful

2021-09-23 Thread Chris Angelico
On Fri, Sep 24, 2021 at 12:22 PM Stefan Ram wrote: > > dn writes: > >With that, why not code it as Python expressions, and include the module? > > This might create a code execution vulnerability if such > files are exchanged between multiple parties. > > If code execution vulnerabilities

Re: XML Considered Harmful

2021-09-23 Thread Chris Angelico
On Fri, Sep 24, 2021 at 7:11 AM Eli the Bearded <*@eli.users.panix.com> wrote: > > In comp.lang.python, Christian Gollwitzer wrote: > > Am 22.09.21 um 16:52 schrieb Michael F. Stemper: > >> On 21/09/2021 19.30, Eli the Bearded wrote: > >>> Yes, CSV files can model that. But it would not be my

Re: XML Considered Harmful

2021-09-23 Thread Chris Angelico
On Thu, Sep 23, 2021 at 10:55 PM Mats Wichmann wrote: > > On 9/22/21 10:31, Dennis Lee Bieber wrote: > > > If you control both the data generation and the data consumption, > > finding some format ... > > This is really the key. I rant at people seeming to believe that csv is > THE data

<    3   4   5   6   7   8   9   10   11   12   >