Re: How to 'ignore' an error in Python?

2023-04-28 Thread Chris Angelico
On Sat, 29 Apr 2023 at 14:27, Kushal Kumaran wrote: > > On Fri, Apr 28 2023 at 04:55:41 PM, Chris Green wrote: > > I'm sure I'm missing something obvious here but I can't see an elegant > > way to do this. I want to create a directory, but if it exists it's > > not an error and the code should

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Kushal Kumaran
On Fri, Apr 28 2023 at 04:55:41 PM, Chris Green wrote: > I'm sure I'm missing something obvious here but I can't see an elegant > way to do this. I want to create a directory, but if it exists it's > not an error and the code should just continue. > > So, I have:- > > for dirname in

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Cameron Simpson
On 28Apr2023 10:39, Mats Wichmann wrote: For this specific case, you can use os.makedirs: os.makedirs(dirname, exist_ok=True) I'm not a great fan of makedirs because it will make all the missing components, not just the final one. So as an example, if you've got a NAS mounted backup area at

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Cameron Simpson
On 28Apr2023 16:55, Chris Green wrote: for dirname in listofdirs: try: os.mkdir(dirname) except FileExistsError: # so what can I do here that says 'carry on regardless' except: # handle any other error, which is really an error #

[Python-announce] foffinf 0.1 released

2023-04-28 Thread Facundo Batista
I'm happy to announce a newborn library! foffinf, a way to use stdlib's logging with the new Format Specification Mini-Language. In other words, you will be able to do: logger.info("The result is {:05d}", result) You can forget about old printf-style formatting now! To enable which modules

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Mats Wichmann
On 4/28/23 11:05, MRAB wrote: On 2023-04-28 16:55, Chris Green wrote: I'm sure I'm missing something obvious here but I can't see an elegant way to do this.  I want to create a directory, but if it exists it's not an error and the code should just continue. So, I have:- for dirname in

Re: How to 'ignore' an error in Python?

2023-04-28 Thread MRAB
On 2023-04-28 16:55, Chris Green wrote: I'm sure I'm missing something obvious here but I can't see an elegant way to do this. I want to create a directory, but if it exists it's not an error and the code should just continue. So, I have:- for dirname in listofdirs: try:

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Mats Wichmann
On 4/28/23 09:55, Chris Green wrote: I'm sure I'm missing something obvious here but I can't see an elegant way to do this. I want to create a directory, but if it exists it's not an error and the code should just continue. So, I have:- for dirname in listofdirs: try:

How to 'ignore' an error in Python?

2023-04-28 Thread Chris Green
I'm sure I'm missing something obvious here but I can't see an elegant way to do this. I want to create a directory, but if it exists it's not an error and the code should just continue. So, I have:- for dirname in listofdirs: try: os.mkdir(dirname) except

Multithreading? How?

2023-04-28 Thread pozz
I need to develop a Python application that is a sort of gateway between to networks: a "serial bus" network (think of a serial port or a USB connection) and a MQTT connection (in my case, it's AWS IoT service). On the bus, a proprietary protocol is implemented. From the bus, the app knows