Re: xor operator

2023-11-13 Thread Axel Reichert via Python-list
be short circuited. Me neither, but that could be related to the meaning of n (which I did not get) in the OP's question. Maybe he can clarify. Best regards Axel -- https://mail.python.org/mailman/listinfo/python-list

Re: xor operator

2023-11-13 Thread Chris Angelico via Python-list
On Tue, 14 Nov 2023 at 08:57, Axel Reichert via Python-list wrote: > > Barry writes: > > > I do not understand how xor(iterator) works. > > I thought xor takes exactly 2 args. > > See > > https://mathworld.wolfram.com/XOR.html > > for some background (I w

Re: xor operator

2023-11-13 Thread Dom Grigonis via Python-list
: xor_new(test2), # 0.0074 lambda: all(test1), # 0.0016 lambda: all(test2) # 0.0046 ]) Your first function is fairly slow. Second one deals with short-circuiting, but is super slow on full search. `xor_new` is the best what I could achieve using python builtins. But builtin `all` has

Re: xor operator

2023-11-13 Thread Grant Edwards via Python-list
On 2023-11-13, Dom Grigonis via Python-list wrote: > Hi All, > > I think it could be useful to have `xor` builtin, which has API similar to > the one of `any` and `all`. > > * Also, it could have optional second argument `n=1`, which > * indicates how many positives indicate

Re: xor operator

2023-11-13 Thread Dom Grigonis via Python-list
applied to many bits. This is more in line with cases that `any` and `all` builtins are used. > On 14 Nov 2023, at 00:51, Grant Edwards via Python-list > wrote: > > On 2023-11-13, Dom Grigonis via Python-list wrote: >> Hi All, >> >> I think it could be useful to

Re: xor operator

2023-11-13 Thread Chris Angelico via Python-list
On Tue, 14 Nov 2023 at 10:00, Dom Grigonis via Python-list wrote: > > I am not asking. Just inquiring if the function that I described could be > useful for more people. > > Which is: a function with API that of `all` and `any` and returns `True` if > specified number o

Re: xor operator

2023-11-13 Thread Dom Grigonis via Python-list
some time to even convey what I mean. Bad naming didn’t help ofc, but if it was something that is needed I think it would have clicked much faster. Thanks, DG > On 14 Nov 2023, at 01:12, Chris Angelico via Python-list > wrote: > > On Tue, 14 Nov 2023 at 10:00, Dom Grigonis via

Re: xor operator

2023-11-13 Thread Grant Edwards via Python-list
On 2023-11-13, Dom Grigonis via Python-list wrote: > I am not asking. Just inquiring if the function that I described > could be useful for more people. > > Which is: a function with API that of `all` and `any` and returns > `True` if specified number of elements is True. I'

Re: xor operator

2023-11-13 Thread Dom Grigonis via Python-list
n Number of True values. Fair point. Have you ever encountered the need for xor for many bits (the one that I am NOT referring to)? Would be interested in what sort of case it could be useful. -- https://mail.python.org/mailman/listinfo/python-list

Re: xor operator

2023-11-13 Thread Mats Wichmann via Python-list
On 11/13/23 16:24, Dom Grigonis via Python-list wrote: I am not arguing that it is a generalised xor. I don’t want anything, I am just gauging if it is specialised or if there is a need for it. So just thought could suggest it as I have encountered such need several times already. It is

Re: xor operator

2023-11-13 Thread Michael Speer via Python-list
>AFAICT, it's not nothing at all to do with 'xor' in any sense. As much as I agree that the function needn't be in the base of python, I can easily follow the OP's logic on the function name. With two items in the iterator, it is a standard binary exclusive or. It is

Re: xor operator

2023-11-13 Thread Chris Angelico via Python-list
On Tue, 14 Nov 2023 at 11:29, Dom Grigonis via Python-list wrote: > > > > Except the 'any' and 'all' builtins are _exactly_ the same as bitwise > > or and and applided to many bits. To do something "in line" with that > > using the 

Re: xor operator

2023-11-13 Thread Dom Grigonis via Python-list
thing. DG > On 14 Nov 2023, at 02:33, Mats Wichmann via Python-list > wrote: > > On 11/13/23 16:24, Dom Grigonis via Python-list wrote: >> I am not arguing that it is a generalised xor. >> I don’t want anything, I am just gauging if it is specialised or if there is >

Re: xor operator

2023-11-13 Thread Chris Angelico via Python-list
On Tue, 14 Nov 2023 at 12:02, Dom Grigonis via Python-list wrote: > As I am here, I will dare to ask if there is no way that `sign` function is > going to be added to `math` or `builtins`. > https://docs.python.org/3/library/math.html#math.copysign ChrisA -- https://mail.python.or

Re: xor operator

2023-11-13 Thread Alan Gauld via Python-list
On 14/11/2023 00:33, Mats Wichmann via Python-list wrote: > Hardware and software people may have somewhat different views of xor I've come at it from both sides. I started life as a telecomms technician and we learned about xor in the context of switching and relays and xor was

Re: xor operator

2023-11-13 Thread Chris Angelico via Python-list
eo is well worth watching. More modern error correction systems are slightly different, but will still be built on many of the same principles. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: xor operator

2023-11-13 Thread Grant Edwards via Python-list
On 2023-11-14, Dom Grigonis via Python-list wrote: > >> Except the 'any' and 'all' builtins are _exactly_ the same as bitwise >> or and and applided to many bits. To do something "in line" with that >> using the 'xor' operator would ret

RE: xor operator

2023-11-13 Thread AVI GROSS via Python-list
other functions can easily be cobbled together. -----Original Message- From: Python-list On Behalf Of Grant Edwards via Python-list Sent: Monday, November 13, 2023 8:19 PM To: [email protected] Subject: Re: xor operator On 2023-11-14, Dom Grigonis via Python-list wrote: > >> Exc

Re: xor operator (DEPRECATED)

2023-11-13 Thread Dom Grigonis via Python-list
Fair point. However, I gave it a shot for the following reason: I couldn’t find a way to make such performant function. Using python builtin components still ends up several times slower than builtin `all`. Cython or numba or similar is not an option as they do not support `truth` values. Or if

RE: xor operator (DEPRECATED)

2023-11-13 Thread AVI GROSS via Python-list
tly decent substitute for the non-standard evaluation in R where you can arrange for lots of your data to not be interpreted till absolutely needed. -Original Message- From: Dom Grigonis Sent: Monday, November 13, 2023 10:12 PM To: [email protected] Cc: Grant Edwards ; Python S

Re: xor operator (DEPRECATED)

2023-11-13 Thread Thomas Passin via Python-list
On 11/13/2023 11:44 PM, AVI GROSS via Python-list wrote: Dom, I hear you. As you say, writing your own extension in something like C++ may not appeal to you even if it is faster. I was wondering if using a generator or something similar in R might make sense. I mean what happens if you

Re: xor operator (DEPRECATED)

2023-11-13 Thread Dom Grigonis via Python-list
Thank you, I have spent a fair bit of time on these and found optimal solutions (at least I think so), but they are still multiple times slower than python builtin function. I am currently out of ideas, maybe will dig something out in time. > On 14 Nov 2023, at 07:23, Thomas Passin via Pyt

Re: No current way to just compile flet code into truly native packages for smart phones, etc.?

2023-11-14 Thread Jacob Kruger via Python-list
.." On 2023/11/13 19:47, Barry wrote: On 13 Nov 2023, at 17:21, Jacob Kruger via Python-list wrote: Had a look at the following bit of introduction to using python and flet to build cross-platform flutter-based apps using same python code, and, while it seems to work alright if tell

Code improvement question

2023-11-14 Thread Mike Dewhirst via Python-list
(bit) > 6 else "")     return " ".join(pieces) Many thanks for any hints Cheers Mike -- https://mail.python.org/mailman/listinfo/python-list

Re: Code improvement question

2023-11-14 Thread Mike Dewhirst via Python-list
On 15/11/2023 10:25 am, MRAB via Python-list wrote: On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like to improve the code below, which works. It feels clunky to me. I need to clean up user-uploaded files the size of which I don't know in advance. After cleaning the

Newline (NuBe Question)

2023-11-14 Thread Grizzy Adams via Python-list
ere a way to get the newline in as I append to list? Thanks again -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline (NuBe Question)

2023-11-15 Thread Alan Gauld via Python-list
On 15/11/2023 07:25, Grizzy Adams via Python-list wrote: > for s in students: > grades.append(s.school) > grades.append(s.name) > grades.append(s.finalGrade()) > if s.finalGrade()>82: >

Re: Newline (NuBe Question)

2023-11-15 Thread Cameron Simpson via Python-list
? I ask because it looks to me that you're: - appending all the individual grade fields (school, name, ...) to one long grades list containing all the data from all the students - you're printing that single enormous list in one go at the end What I'm imagine you want is one line

Re: xor operator

2023-11-15 Thread Dom Grigonis via Python-list
significantly slower. Regards, DG > On 15 Nov 2023, at 02:34, Peter J. Holzer via Python-list > wrote: > > On 2023-11-14 00:11:30 +0200, Dom Grigonis via Python-list wrote: >> Benchmarks: >> test1 = [False] * 100 + [True] * 2 >> test2 = [True] * 100 + [False] * 2 >

Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023 at 9:50, Alan Gauld via Python-list wrote: Re: Newline (NuBe Question) (at least in part) >On 15/11/2023 07:25, Grizzy Adams via Python-list wrote: >> for s in students: >> grades.append(s.school) >>

Re: Newline (NuBe Question)

2023-11-15 Thread Thomas Passin via Python-list
On 11/15/2023 2:25 AM, Grizzy Adams via Python-list wrote: Hi & thanks for patience with what could be simple to you Have this (from an online "classes" tutorial) --- Start Code Snippit --- students = [] grades = [] for s in geographyClass: students.append(geographyStu

Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023 at 9:45, Thomas Passin via Python-list wrote: Re: Newline (NuBe Question) (at least in part) >On 11/15/2023 2:25 AM, Grizzy Adams via Python-list wrote: >> Hi & thanks for patience with what could be simple to you >You may see responses that sugg

Re: Newline (NuBe Question)

2023-11-15 Thread Pierre Fortin via Python-list
On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote: I don't give solutions; just a nudge... you appear not to fully grok "list"; your list is ONE list with no delineation between students. You want a "list of lists"... >['Example High'

Re: xor operator

2023-11-15 Thread Dom Grigonis via Python-list
, but it seems fairly probable to need `set() > n` and `set() < n`. Regards, DG > On 15 Nov 2023, at 19:16, Peter J. Holzer via Python-list > wrote: > > On 2023-11-15 12:26:32 +0200, Dom Grigonis wrote: >> >> Thank you, >> >> >> test2 = [True]

__set_name__ equivalent for instance

2023-11-15 Thread Dom Grigonis via Python-list
of attribute to receive `instance` argument on instance creation. Regards, DG -- https://mail.python.org/mailman/listinfo/python-list

Re: xor operator

2023-11-15 Thread Dom Grigonis via Python-list
here one would need `set() == n` is hard to think > of, but it seems fairly probable to need `set() > n` and `set() < n`. > > Regards, > DG > >> On 15 Nov 2023, at 19:16, Peter J. Holzer via Python-list >> mailto:[email protected]>> wrote: >> >>

Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023 at 12:19, Pierre Fortin wrote: Re: Newline (NuBe Question) (at least in part) >On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote: > >I don't give solutions; just a nudge... you appear not to fully grok >"list"; yo

Re: Newline (NuBe Question)

2023-11-15 Thread Thomas Passin via Python-list
On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote: Wednesday, November 15, 2023 at 12:19, Pierre Fortin wrote: Re: Newline (NuBe Question) (at least in part) On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote: I don't give solutions; just a nudge... you appea

Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023 at 15:54, Thomas Passin via Python-list wrote: Re: Newline (NuBe Question) (at least in part) >On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote: >> Wednesday, November 15, 2023 at 12:19, Pierre Fortin wrote: >> Re: Newline (NuBe Question) (a

Amy known issues with tkinter /ttk on latest MacOS?

2023-11-16 Thread Alan Gauld via Python-list
e button. Also, I've just noticed that if I move the mouse slightly while clicking that seems to work. There are no error/warning messages in the Console. I'm just wondered if this is a known issue, or just my setup? Any suggestions welcomed. Python version - 3.10.4 OS version - Sonoma 14.1

Re: Newline (NuBe Question)

2023-11-16 Thread Thomas Passin via Python-list
On 11/16/2023 1:19 AM, Grizzy Adams via Python-list wrote: Wednesday, November 15, 2023 at 15:54, Thomas Passin via Python-list wrote: Re: Newline (NuBe Question) (at least in part) On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote: Wednesday, November 15, 2023 at 12:19, Pierre

Re: Newline (NuBe Question)

2023-11-16 Thread Grizzy Adams via Python-list
Thursday, November 16, 2023 at 7:47, Thomas Passin via Python-list wrote: Re: Newline (NuBe Question) (at least in part) >I wrote that you don't need the "students" list, which is correct. But >there could be a use for a list. It would let you change the order in >

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dom Grigonis via Python-list
e instance as parameter. > Note that descriptors are stored in the class: they must not store > instance specific information in their attributes. > Therefore, a method informing an descriptor about instance creation > would not help: it cannot do anything with it. -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
rmation in their attributes. Therefore, a method informing an descriptor about instance creation would not help: it cannot do anything with it. -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
ou would need a metaclass or `__inist_subclass__` is you want your "custom method binding" globally. For many methods (but usually not the `__...__` methods), you can take over the binding in `__new__` or `__init__` and populate the instance with prebound methods. -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dom Grigonis via Python-list
at can be used on arbitrary methods. Needing to inherit and add metaclasses whenever I want to decorate is not an option. I think I will continue with descriptor approach and am slowly finding route to get where I need to, but still exploring options. Regards, DG -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
e) are handled specially; functions are bound. Other objects are returned as is. `__getattribute__` can be used to take over control over the attribute access. -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dom Grigonis via Python-list
> language reference. > > Functions and descriptors accessed via an instance but found in a class (i.e. > not directly in the instance) are handled specially; > functions are bound. Other objects are returned as is. > > `__getattribute__` can be used to take over control over the attribute > access. -- https://mail.python.org/mailman/listinfo/python-list

Re: Code improvement question

2023-11-16 Thread Mike Dewhirst via Python-list
On 15/11/2023 3:08 pm, MRAB via Python-list wrote: On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote: On 15/11/2023 10:25 am, MRAB via Python-list wrote: On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like to improve the code below, which works. It feels clunky t

Re: Code improvement question

2023-11-16 Thread Rimu Atkinson via Python-list
bility. You might find https://regex101.com/ to be useful for testing your regex. You can enter in sample data and see if it matches. If I understood what your regex was trying to do I might be able to suggest some python to do the same thing. Is it just removing numbers from text? The for loop, &

Re: Code improvement question

2023-11-16 Thread Mike Dewhirst via Python-list
On 16/11/2023 9:34 am, Rimu Atkinson via Python-list wrote: Why don't you use re.findall? re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt) I think I can see what you did there but it won't make sense to me - or whoever looks at the code - in future. That a

Re: Code improvement question

2023-11-17 Thread Thomas Passin via Python-list
On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote: On 2023-11-16 11:34:16 +1300, Rimu Atkinson via Python-list wrote: Why don't you use re.findall? re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt) I think I can see what you did there but it won't make sens

Re: Code improvement question

2023-11-17 Thread Thomas Passin via Python-list
On 11/17/2023 9:46 AM, Peter J. Holzer via Python-list wrote: On 2023-11-17 07:48:41 -0500, Thomas Passin via Python-list wrote: On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote: Oh, and Python (just like Perl) allows you to embed whitespace and comments into Regexps, which helps

RE: Code improvement question

2023-11-17 Thread AVI GROSS via Python-list
in a module for either speed or to simplify things so that the RE part is simpler and easier to follow. And, as noted, Python allows ways to include comments in RE or ways to specify extensions such as PERL-style and so on. Adding enough comments above or within the code can help remind people

Re: Amy known issues with tkinter /ttk on latest MacOS?

2023-11-19 Thread Alan Gauld via Python-list
On 17/11/2023 03:38, Terry Reedy wrote: > There have been other reports on the cpython issue tracker than Sonoma > broke bits of tk behavior. > https://github.com/python/cpython/issues?q=is%3Aissue+label%3AOS-mac+is%3Aclosed > > shows a couple Thanks Terry, I had a browse a

Re: Code improvement question

2023-11-21 Thread Rimu Atkinson via Python-list
ward to me. I'll be impressed if you can write that in Python in a way which is easier to read. Now that I know what {} does, you're right, that IS straightforward! Maybe 2023 will be the year I finally get off my arse and learn regex. Thanks :) -- https://mail.python.org/mailman/listinfo/python-list

Python 3.13.0 alpha 2 now available.

2023-11-22 Thread Thomas Wouters via Python-list
Well, well, well, it’s time for Python 3.13.0 alpha 2! https://www.python.org/downloads/release/python-3130a2/ *This is an early developer preview of Python 3.13* <https://discuss.python.org/t/python-3-13-0-alpha-2/39379#major-new-features-of-the-313-series-compared-to-312-1>Major new featu

RE: Newline (NuBe Question)

2023-11-24 Thread AVI GROSS via Python-list
ch as some form of matrix or data.frame. And, yes, you can sort something like the above by name or GPA or number of credits taken but the point was responding to why bother making a list just to print it. The answer is that many and even most programs do a bit more than that and a good choice of da

Printing dict value for possibly undefined key

2023-11-25 Thread Loris Bennett via Python-list
;) Is there any more compact way of achieving the same thing? Cheers, Loris -- This signature is currently under constuction. -- https://mail.python.org/mailman/listinfo/python-list

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
#x27;foo']} {d['bar']}") Is there any more compact way of achieving the same thing? Cheers, Loris Yes. e.g. d.get('foo', "NULL") Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Rimu Atkinson via Python-list
I really can't think of a case where the missing comma would make any sense at all. That is pretty tricky, yes. The comma means it's a tuple. Without the comma, it's just a string with parenthesis around it, which is a string. PyDev console: starting. Python 3.9.1

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
="NULL"    print(f"{id} {d['foo']} {d['bar']}") Is there any more compact way of achieving the same thing? Cheers, Loris Yes. e.g. d.get('foo', "NULL") Duncan Or make d a defaultdict. from collections import defaultdict dic = defaultdict(lambda:'NULL') dic['foo'] = 'astring' dic['foo'] 'astring' dic['bar'] 'NULL' Duncan -- https://mail.python.org/mailman/listinfo/python-list

Silly/crazy problem with sqlite

2023-11-25 Thread Chris Green via Python-list
imo$ It's treating the "2023-11" plus % at each end as separate variables to the binding, this is crazy! I've done similar elsewhere and it works OK, what on earth am I doing wrong here? It has to be something very silly but I can't see it at the moment. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Chris Green via Python-list
say this seems very non-pythonesque to me, the 'obvious' default simply doesn't work right, and I really can't think of a case where the missing comma would make any sense at all. Maybe I've had too much to eat and drink tonight! :-) -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Sibylle Koczian via Python-list
Am 24.11.2023 um 22:49 schrieb Rimu Atkinson via Python-list: I really can't think of a case where the missing comma would make any sense at all. That is pretty tricky, yes. The comma means it's a tuple. Without the comma, it's just a string with parenthesis around

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Mats Wichmann via Python-list
On 11/24/23 14:10, Chris Green via Python-list wrote: Chris Green wrote: This is driving me crazy, I'm running this code:- OK, I've found what's wrong:- cr.execute(sql, ('%' + "2023-11" + '%')) should be:- cr.execute(sql, ('

Re: Printing dict value for possibly undefined key

2023-11-25 Thread DL Neil via Python-list
On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") How

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Thomas Passin via Python-list
On 11/24/2023 4:49 PM, Rimu Atkinson via Python-list wrote: I really can't think of a case where the missing comma would make any sense at all. That is pretty tricky, yes. The comma means it's a tuple. Without the comma, it's just a string with parenthesis around it, wh

Re: Silly/crazy problem with sqlite

2023-11-26 Thread Chris Green via Python-list
15 Expression lists > ... > |an expression list containing at least one comma yields a tuple. > ... > The Python Language Reference, Release 3.13.0a0; > Guido van Rossum and the Python development team; > October 10, 2023. > I wasn't meaning that it wasn't correct Pyth

Context without manager

2023-11-26 Thread Piergiorgio Sartor via Python-list
Hi all, I apologize in advance for the "foggy" question, but I've myself unclear ideas. Anyway... Python has "context manager". For example, the "open()" class can be simply used as follow: with open(...) as fp: fp.do_something() On the other hand, it

Re: RE: Newline (NuBe Question)

2023-11-26 Thread Chris Angelico via Python-list
On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list wrote: > > On 24/11/2023 21.45, [email protected] wrote: > > Grizz[l]y, > > > > I think the point is not about a sorted list or sorting in general It is > > about reasons why maintaining a data

Re: Newline (NuBe Question)

2023-11-26 Thread Roel Schroeven via Python-list
Michael F. Stemper via Python-list schreef op 25/11/2023 om 15:32: On 24/11/2023 21.45,[email protected] wrote: > Grizz[l]y, > > I think the point is not about a sorted list or sorting in general It is > about reasons why maintaining a data structure such as a list in a prog

Re: Context without manager

2023-11-26 Thread Dieter Maurer via Python-list
) perform some operations in this context (--> body of `with` statement) tear down the context (--> method `__exit__`). If you do not have this case (e.g. usually if you open the file in a class's `__init__`), you do not use a context manager. -- https://mail.python.org/mailman/listinfo/python-list

RE: RE: Newline (NuBe Question)

2023-11-26 Thread AVI GROSS via Python-list
That is an entirely different discussion, Michael. I do not know what ideas Guido had ages ago and where he might stand now and I actually seriously disagree with the snippet you quoted below. Python was started long ago as a way to improve in some ways on what was there before. Some of the

RE: RE: Newline (NuBe Question)

2023-11-26 Thread AVI GROSS via Python-list
al Message----- From: Python-list On Behalf Of Chris Angelico via Python-list Sent: Sunday, November 26, 2023 6:49 AM To: [email protected] Subject: Re: RE: Newline (NuBe Question) On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list wrote: > > On 24/11/2023 21.45, avi.e.gr...

Re: Newline (NuBe Question)

2023-11-26 Thread DL Neil via Python-list
On 11/27/2023 12:48 AM, Chris Angelico via Python-list wrote: On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list wrote: On 24/11/2023 21.45, [email protected] wrote: Grizz[l]y, I think the point is not about a sorted list or sorting in general It is about reasons why

Re: RE: Newline (NuBe Question)

2023-11-26 Thread Chris Angelico via Python-list
s variable name would make complete sense. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline (NuBe Question)

2023-11-26 Thread DL Neil via Python-list
On 11/27/2023 1:08 AM, Roel Schroeven via Python-list wrote: I prefer namedtuples or dataclasses over tuples. They allow you to refer to their fields by name instead of index: student.gpa is much clearer than student[2], and makes it less likely to accidentally refer to the wrong field. +1

Re: Newline (NuBe Question)

2023-11-26 Thread DL Neil via Python-list
On 11/27/2023 10:04 AM, Peter J. Holzer via Python-list wrote: On 2023-11-25 08:32:24 -0600, Michael F. Stemper via Python-list wrote: On 24/11/2023 21.45, [email protected] wrote: Of course, for serious work, some might suggest avoiding constructs like a list of lists and switch to using

RE: Newline (NuBe Question)

2023-11-26 Thread AVI GROSS via Python-list
came from the Latin word for news. Be that as it may, and I have no interest in this topic, in the future I may use the ever popular names of Primus, Secundus and Tertius and get blamed for using Latin. -Original Message- From: Python-list On Behalf Of DL Neil via Python-list Sent: Sunda

Re: Newline (NuBe Question)

2023-11-26 Thread Chris Angelico via Python-list
On Mon, 27 Nov 2023 at 13:52, AVI GROSS via Python-list wrote: > Be that as it > may, and I have no interest in this topic, in the future I may use the ever > popular names of Primus, Secundus and Tertius and get blamed for using > Latin. > Imperious Prima flashes forth her edi

RE: Newline (NuBe Question)

2023-11-26 Thread AVI GROSS via Python-list
components of an object but verify the validity of the contents or do logging or any number of other things. Using a list or tuple does nothing else. So if you need nothing else, they are often suitable and sometimes even preferable. -Original Message----- From: Python-list On Behalf Of D

Re: Context without manager

2023-11-26 Thread Grant Edwards via Python-list
On 2023-11-26, Dieter Maurer via Python-list wrote: > If you do not have this case (e.g. usually if you open the file > in a class's `__init__`), you do not use a context manager. He knows that. The OP wrote that he wants to use that can _only_ be used by a context manager, but he

Re: Context without manager

2023-11-26 Thread Grant Edwards via Python-list
On 2023-11-27, Grant Edwards via Python-list wrote: > On 2023-11-26, Dieter Maurer via Python-list wrote: > >> If you do not have this case (e.g. usually if you open the file >> in a class's `__init__`), you do not use a context manager. > > He knows that. The OP wro

Re: Context without manager

2023-11-26 Thread Greg Ewing via Python-list
On 27/11/23 9:03 am, Stefan Ram wrote: Above, "have" is followed by another verb in "have been", so it should be eligible for a contraction there! Yes, "been" is the past participle of 'to be", so "I've been" is fine. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Context without manager

2023-11-26 Thread Greg Ewing via Python-list
er: def __init__(self): self.cm = device_open() self.device = self.cm.__enter__() # Other methods here for doing things with # self.device def close(self): self.cm.__exit__(None, None, None) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline (NuBe Question)

2023-11-26 Thread 'DL Neil&#x27; via Python-list
are an easy place-holder/intro for NoSQL DBs - in fact, Python dicts and MongoDB go hand-in-glove. The next issue raised is sparseness. In a table, the assumption is that all fields, or at least most of them, will be filled with values. However, a sparse matrix would make such very 'expensi

argparse argument post-processing

2023-11-27 Thread Dom Grigonis via Python-list
ferent modules and do not call `parse_args` themselves. Any ideas appreciated, Regards, DG -- https://mail.python.org/mailman/listinfo/python-list

Re: argparse argument post-processing

2023-11-27 Thread Chris Angelico via Python-list
On Mon, 27 Nov 2023 at 22:31, Dom Grigonis via Python-list wrote: > > Hi all, > > I have a situation, maybe someone can give some insight. > > Say I want to have input which is comma separated array (e.g. > paths='path1,path2,path3') and convert it to the desired o

RE: Newline (NuBe Question)

2023-11-27 Thread AVI GROSS via Python-list
l. But the overall paradigm compared to Python has major differences and I see strengths and weaknesses and tradeoffs. Your dictionary example is one of them as numpy/pandas often make good use of them as part of dealing with similar data.frame type structures that are often simpler or easier to

Re: Context without manager

2023-11-27 Thread Piergiorgio Sartor via Python-list
to have a class where the device is opened in the __init__() and used in some methods. Any ideas? bye, -- piergiorgio -- https://mail.python.org/mailman/listinfo/python-list

how to connect linux aws ec2 instance to windows local machine at my home using paramiko

2023-11-27 Thread Kashish Naqvi via Python-list
ssh.connect(local_machine_ip, username=username, key_filename=private_key_path,password='abc') print("Connected 2") # Stop the first script: check_messages.py stop_check_messages_command = 'pkill -f python C:/Project/pipeline-deployment/check_

Re: Context without manager

2023-11-27 Thread Richard Damon via Python-list
). Note, YOUR program must now make sure that the __exit__ function is called, and handle any exceptions that got thrown, and that ob and var are put somewhere you can access them at that later time. > On Nov 27, 2023, at 12:24 PM, Piergiorgio Sartor via Python-list > wrote: > > O

Context without manager

2023-11-27 Thread Richard Damon via Python-list
). Note, YOUR program must now make sure that the __exit__ function is called, and handle any exceptions that got thrown, and that ob and var are put somewhere you can access them at that later time. > On Nov 27, 2023, at 12:24 PM, Piergiorgio Sartor via Python-list > wrote: > > O

RE: Context without manager

2023-11-27 Thread David Raymond via Python-list
il.python.org/mailman/listinfo/python-list

Re: argparse argument post-processing

2023-11-27 Thread Mats Wichmann via Python-list
On 11/27/23 04:29, Dom Grigonis via Python-list wrote: Hi all, I have a situation, maybe someone can give some insight. Say I want to have input which is comma separated array (e.g. paths='path1,path2,path3') and convert it to the desired output - list: import argpa

Re: argparse argument post-processing

2023-11-27 Thread Dom Grigonis via Python-list
ats Wichmann via Python-list > wrote: > > On 11/27/23 04:29, Dom Grigonis via Python-list wrote: >> Hi all, >> I have a situation, maybe someone can give some insight. >> Say I want to have input which is comma separated array (e.g. >> paths='path1,path2,pat

Re: argparse argument post-processing

2023-11-27 Thread Mats Wichmann via Python-list
the base Action class's initializer with the rest of the args super().__init__(option_strings=option_strings, *args, **kwargs) Hopefully someone else has done this kind of thing because now I'm just guessing! -- https://mail.python.org/mailman/listinfo/python-list

Re: argparse argument post-processing

2023-11-27 Thread Dom Grigonis via Python-list
gs, **kwargs) > > Hopefully someone else has done this kind of thing because now I'm just > guessing! > > -- https://mail.python.org/mailman/listinfo/python-list

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
ultdict. > > from collections import defaultdict > > dic = defaultdict(lambda:'NULL') > dic['foo'] = 'astring' > dic['foo'] > 'astring' > dic['bar'] > 'NULL' > > Duncan > I have gone with the 'd.get' solution, as I am just need to print the dict to the terminal. The dict is actually from a list of dicts which is generated by querying a database, so I don't think the defaultdict approach would be so appropriate, but it's good to know about it. Thanks, Loris -- This signature is currently under constuction. -- https://mail.python.org/mailman/listinfo/python-list

<    29   30   31   32   33   34   35   36   37   38   >