Re: A problem with str VS int.

2023-12-09 Thread Thomas Passin via Python-list
On 12/9/2023 9:42 PM, Steve GS via Python-list wrote: If I enter a one-digit input or a three-digit number, the code works but if I enter a two digit number, the if statement fails and the else condition prevails. tsReading = input(" Enter the " + Brand + " tes

RE: A problem with str VS int.

2023-12-09 Thread AVI GROSS via Python-list
user can enter any text, they might enter ".01" or "hello" or al kinds of nonsense. If you converted to numbers and tested whether it failed, ... -Original Message- From: Python-list On Behalf Of Steve GS via Python-list Sent: Saturday, December 9, 2023 9:42 PM To:

A problem with str VS int.

2023-12-09 Thread Steve GS via Python-list
t;Enter valid sensor test strip Reading.") I converted the variable to int along with the if statement comparison and it works as expected. See if it fails for you... Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: How/where to store calibration values - written by program A, read by program B

2023-12-09 Thread Peter J. Holzer via Python-list
On 2023-12-06 07:23:51 -0500, Thomas Passin via Python-list wrote: > On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: > > Personally I would not use .ini style these days as the format does not > > include type of the data. > > Neither does JSON. Well, it disti

Python 3.12.1 is now available

2023-12-07 Thread Thomas Wouters via Python-list
Python 3.12.1 is now available. https://www.python.org/downloads/release/python-3121/ This is the first maintenance release of Python 3.12 Python 3.12 is the newest major release of the Python programming language, and it contains many new features and optimizations. 3.12.1 is the latest

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Thomas Passin via Python-list
On 12/6/2023 1:12 PM, MRAB via Python-list wrote: On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement is *slightly* more complex than just key value

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread MRAB via Python-list
On 2023-12-06 20:11, dn via Python-list wrote: On 7/12/23 07:12, MRAB via Python-list wrote: On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread dn via Python-list
On 7/12/23 07:12, MRAB via Python-list wrote: On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement is *slightly* more complex than just key value pairs

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread MRAB via Python-list
On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement is *slightly* more complex than just key value pairs, it has one level of hierarchy, e.g

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Thomas Passin via Python-list
On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement is *slightly* more complex than just key value pairs, it has one level of hierarchy, e.g.:- KEY1: a: v1 c: v3 d: v4 KEY2

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Dan Purgert via Python-list
n application-specific configuration directory). Or an .ini file with two sections (although I don't think you can re-use key-names in a single ini file) -- |_|O|_| |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860 -- https://mail.python.org/mailman/listinfo/python-list

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Barry Scott via Python-list
> On 6 Dec 2023, at 09:32, Chris Green via Python-list > wrote: > > My requirement is *slightly* more complex than just key value pairs, > it has one level of hierarchy, e.g.:- > >KEY1: > a: v1 > c: v3 > d: v4 >KEY2: >

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Dan Sommers via Python-list
On 2023-12-06 at 09:32:02 +, Chris Green via Python-list wrote: > Thomas Passin wrote: [...] > > Just go with an .ini file. Simple, well-supported by the standard > > library. And it gives you key/value pairs. > > > My requirement is *slightly* more complex t

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Chris Green via Python-list
Thank you everyone for all the suggestions, I now have several possibilities to follow up. :-) -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Chris Green via Python-list
Thomas Passin wrote: > On 12/5/2023 11:50 AM, MRAB via Python-list wrote: > > On 2023-12-05 14:37, Chris Green via Python-list wrote: > >> Is there a neat, pythonic way to store values which are 'sometimes' > >> changed? > >> > >> My particular cas

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Chris Green via Python-list
roliferation of markup formats > of this type. So while I don't know exactly what TOML is, I figure it > must be bad. > > I sometimes use ast.literal_eval though it is Python specific. > That's interesting, I'll add it to my armoury anyway. :-) > Of course there is also sqlite

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Thomas Passin via Python-list
On 12/5/2023 11:50 AM, MRAB via Python-list wrote: On 2023-12-05 14:37, Chris Green via Python-list wrote: Is there a neat, pythonic way to store values which are 'sometimes' changed? My particular case at the moment is calibration values for ADC inputs which are set by running a calibration

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread DL Neil via Python-list
Apologies: neglected suggested web.refs: https://datagy.io/python-environment-variables/ https://pypi.org/project/json_environ/ -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread DL Neil via Python-list
On 12/6/23 03:37, Chris Green via Python-list wrote: Is there a neat, pythonic way to store values which are 'sometimes' changed? My particular case at the moment is calibration values for ADC inputs which are set by running a calibration program and used by lots of programs which display

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Barry Scott via Python-list
> On 5 Dec 2023, at 14:37, Chris Green via Python-list > wrote: > > Are there any Python modules aimed specifically at this sort of > requirement? I tend to use JSON for this type of thing. Suggest that you use the options to pretty print the json that is saved so that a

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Mats Wichmann via Python-list
On 12/5/23 07:37, Chris Green via Python-list wrote: Is there a neat, pythonic way to store values which are 'sometimes' changed? My particular case at the moment is calibration values for ADC inputs which are set by running a calibration program and used by lots of programs which display

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread MRAB via Python-list
On 2023-12-05 14:37, Chris Green via Python-list wrote: Is there a neat, pythonic way to store values which are 'sometimes' changed? My particular case at the moment is calibration values for ADC inputs which are set by running a calibration program and used by lots of programs which display

How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Chris Green via Python-list
readability point of view it would be good to have a Python module with the values in it but using a Python program to write/update a Python module sounds a bit odd somehow. I could simply write the values to a file (or a database) and I suspect that this may be the best answer but it does make

Re: on writing a number as 2^s * q, where q is odd

2023-12-05 Thread jak via Python-list
n & 0o070707070707070707070) >> 3)) return (n % 63) + (0, 1, 1, 2)[lt] n=0x bit_count_64(n) 64 n=0x3ffe bit_count_64(n) 61 bit_count_64(1 << 63) 1 ...in C it would have been simpler :^) -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-12-05 Thread Alan Bawden via Python-list
ia.org/wiki/Hacker%27s_Delight>. - Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: Request: inspect: signature & getfullargspec & getcallargs

2023-12-04 Thread Barry Scott via Python-list
> On 4 Dec 2023, at 02:29, Dom Grigonis via Python-list > wrote: > > Hello, > > I have a request. > > Would it be possible to include `follow_wrapper_chains` and `skip_bound_arg` > arguments to higher level functions of `inspect` module? > > Would ex

Re: on writing a number as 2^s * q, where q is odd

2023-12-04 Thread jak via Python-list
Oscar Benjamin ha scritto: On Sun, 3 Dec 2023 at 10:25, Julieta Shem via Python-list wrote: Alan Bawden writes: def powers_of_2_in(n): bc = (n ^ (n - 1)).bit_count() - 1 return bc, n >> bc That's pretty fancy and likely the fastest. It might be the fastest but it depen

Request: inspect: signature & getfullargspec & getcallargs

2023-12-03 Thread Dom Grigonis via Python-list
`, but without `bound_arg` * `getfullargspec` to `follow_wrapper_chains` * `signature` to include `bound_arg`. Regards, DG -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-12-03 Thread Oscar Benjamin via Python-list
On Sun, 3 Dec 2023 at 10:25, Julieta Shem via Python-list wrote: > > Alan Bawden writes: > > > > def powers_of_2_in(n): > > bc = (n ^ (n - 1)).bit_count() - 1 > > return bc, n >> bc > > That's pretty fancy and likely the fastest. It might be the

Re: on writing a number as 2^s * q, where q is odd

2023-12-03 Thread jak via Python-list
--end--->8--- for n = 0 your function get stack overflow That's right. Let's say ``assert n > 0'' before we say ``if''. ...or just: ... if n == 0 or remainder(n, 2) != 0: ... -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-12-03 Thread Julieta Shem via Python-list
>> --8<---cut here---end--->8--- > > for n = 0 your function get stack overflow That's right. Let's say ``assert n > 0'' before we say ``if''. -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-12-03 Thread jak via Python-list
---end--->8--- for n = 0 your function get stack overflow -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-12-03 Thread Julieta Shem via Python-list
// 2) return 1 + s, r --8<---cut here---end--->8--- -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
c = (n ^ (n - 1)).bit_count() - 1 return bc, n >> bc -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread jak via Python-list
Dom Grigonis ha scritto: def powers_of_2_in(n): s = 0 while n % 2 == 0: s += 1 n = n // 2 return s, n Good solution, unfortunately if the input data is zero, the function never ends. On 30 Nov 2023, at 02:44, Julieta Shem via Python-list wrote: How would

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread jak via Python-list
? def powers_of_2_inB(n): bc = (n ^ (n - 1)).bit_count() - 1 return bc, int(n / (1 << bc)) -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
Julieta Shem writes: How would you write this procedure? def powers_of_2_in(n): ... def powers_of_2_in(n): return (n ^ (n - 1)).bit_count() - 1 -- https://mail.python.org/mailman/listinfo/python-list

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Dan Sommers via Python-list
On 2023-11-29 at 21:44:01 -0300, Julieta Shem via Python-list wrote: > How would you write this procedure? > > --8<---cut here---start->8--- > def powers_of_2_in(n): > s = 0 > while "I still find factors of 2 in n...": &g

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Dom Grigonis via Python-list
def powers_of_2_in(n): s = 0 while n % 2 == 0: s += 1 n = n // 2 return s, n > On 30 Nov 2023, at 02:44, Julieta Shem via Python-list > wrote: > > How would you write this procedure? > > --8<---cut here---start---

on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Julieta Shem via Python-list
return s, n --8<---cut here---end--->8--- -- https://mail.python.org/mailman/listinfo/python-list

Accessing configuration across multiple modules

2023-11-28 Thread Loris Bennett via Python-list
accessible at the point where the object wrapping the LDAP server is initialized? I found this a suggestion here which involves creating a separate module for the configuration and then importing it https://codereview.stackexchange.com/questions/269550/python-share-global-variables-across

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
DL Neil writes: > 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 >>

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
'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

Re: argparse argument post-processing

2023-11-27 Thread Dom Grigonis via Python-list
ully 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 Mats Wichmann via Python-list
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
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,path3')

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 argparse parser

RE: Context without manager

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

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 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

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
p, 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_messages.py' ssh.exec_command(stop_check_m

Re: Context without manager

2023-11-27 Thread Piergiorgio Sartor via Python-list
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

RE: Newline (NuBe Question)

2023-11-27 Thread AVI GROSS via Python-list
ery useful. 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 easi

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 output - li

argparse argument post-processing

2023-11-27 Thread Dom Grigonis via Python-list
ideas appreciated, Regards, DG -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline (NuBe Question)

2023-11-26 Thread 'DL Neil' via Python-list
lder/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 'expensive' in terms of storage-space

Re: Context without manager

2023-11-26 Thread Greg Ewing via Python-list
f __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: 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 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 wr

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: 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: 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

RE: Newline (NuBe Question)

2023-11-26 Thread AVI GROSS via Python-list
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: Sunday, Novembe

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, avi.e.gr...@gmail.com 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 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: RE: Newline (NuBe Question)

2023-11-26 Thread Chris Angelico via Python-list
iable 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 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, avi.e.gr...@gmail.com wrote: Grizz[l]y, I think the point is not about a sorted list or sorting in general It is about reasons why

Re: Newline (NuBe Question)

2023-11-26 Thread Peter J. Holzer via Python-list
On 2023-11-25 08:32:24 -0600, Michael F. Stemper via Python-list wrote: > On 24/11/2023 21.45, avi.e.gr...@gmail.com wrote: > > Of course, for serious work, some might suggest avoiding constructs like a > > list of lists and switch to using modules and data structures [...] >

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: python-list@python.org 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: 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

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: 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,avi.e.gr...@gmail.com 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 p

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, avi.e.gr...@gmail.com 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

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 is a

Re: Silly/crazy problem with sqlite

2023-11-26 Thread Chris Green via Python-list
> ... > |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 Python, more that doing the obviou

Re: RE: Newline (NuBe Question)

2023-11-26 Thread Michael F. Stemper via Python-list
ing Python_ -- Michael F. Stemper This sentence no verb. -- https://mail.python.org/mailman/listinfo/python-list

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, which is a string

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']}") However, the dict does

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, ('%' + x + '%',) ) I have to say this

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 it, which

Re: Silly/crazy problem with sqlite

2023-11-25 Thread Chris Green via Python-list
' 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

Silly/crazy problem with sqlite

2023-11-25 Thread Chris Green via Python-list
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: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
y 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

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.15 (main, Oct 28

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
ing? Cheers, Loris Yes. e.g. d.get('foo', "NULL") Duncan -- https://mail.python.org/mailman/listinfo/python-list

Printing dict value for possibly undefined key

2023-11-25 Thread Loris Bennett via Python-list
s currently under constuction. -- https://mail.python.org/mailman/listinfo/python-list

RE: Newline (NuBe Question)

2023-11-24 Thread AVI GROSS via Python-list
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 data structure facilitates ... -Original Message-

FOSDEM 2024: Call for Proposals - Python Devrooom

2023-11-23 Thread Marc-Andre Lemburg via Python-list
We are happy to announce that we will be running a Python devroom again at FOSDEM 2024. This year's edition will be exclusively in-person, and take place on the 3rd and 4th of February, with the Python devroom being available on Sunday 4th. If you have not heard about FOSDEM before

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 fe

NZPUG Mtg: Making Python faster, and "Dependency Inversion"

2023-11-22 Thread dn via Python-list
Virtual meeting: Wednesday 6 December, 1815 for 1830 NZDT/UTC+13 Book at https://www.meetup.com/nzpug-auckland/events/295433876/ 1 Making Python faster - using type hints Tushar will lead us through: A brief history of type hints Using type checkers to verify your type hints

Re: Code improvement question

2023-11-21 Thread Rimu Atkinson via Python-list
. 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

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-17 Thread AVI GROSS via Python-list
-in or 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: Code improvement question

2023-11-17 Thread jak via Python-list
://mail.python.org/mailman/listinfo/python-list

Re: Code improvement question

2023-11-17 Thread MRAB via Python-list
On 2023-11-17 09:38, jak via Python-list wrote: Mike Dewhirst ha scritto: 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

Re: Code improvement question

2023-11-17 Thread jak via Python-list
Mike Dewhirst ha scritto: 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

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 Peter J. Holzer via Python-list
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 readability a lot if you have to > &g

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 sense to me - or whoever

Re: Code improvement question

2023-11-17 Thread Peter J. Holzer via Python-list
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 sense to me - or &g

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