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

2023-04-29 Thread Phu Sam
Unsubscribe On Sat, Apr 29, 2023 at 7:05 PM Chris Angelico wrote: > On Sun, 30 Apr 2023 at 11:58, Chris Green wrote: > > > > Chris Angelico wrote: > > > 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

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

2023-04-29 Thread Chris Angelico
On Sun, 30 Apr 2023 at 12:02, jak wrote: > > Chris Angelico ha scritto: > > Using mkdirs when you only want to make one is inviting problems of > > being subtly wrong, where it creates too many levels of directory. > > Personally, I would just do: > > > Maybe I only say this because it has

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

2023-04-29 Thread jak
Stefan Ram ha scritto: jak writes: Maybe I only say this because it has happened to me too many times but before ignoring the error in the 'except' branch, I would make sure that if the name exists it is a folder and not a file. If the name exists and it is a file's name, this will be

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

2023-04-29 Thread Chris Angelico
On Sun, 30 Apr 2023 at 11:58, Chris Green wrote: > > Chris Angelico wrote: > > 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

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

2023-04-29 Thread jak
Chris Angelico ha scritto: Using mkdirs when you only want to make one is inviting problems of being subtly wrong, where it creates too many levels of directory. Personally, I would just do: Maybe I only say this because it has happened to me too many times but before ignoring the error in

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

2023-04-29 Thread Chris Green
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 just continue. > > > > So, I

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

2023-04-29 Thread Chris Green
Chris Angelico wrote: > 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 > >

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

2023-04-29 Thread Greg Ewing via Python-list
On 30/04/23 2:43 am, jak wrote: Maybe I expressed myself badly but I didn't mean to propose alternatives to the EAFP way but just to evaluate the possibility that it is not a folder. If it's not a folder, you'll find out when the next thing you try to do to it fails. You could check for it

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

2023-04-29 Thread avi.e.gross
I get a tad suspicious when someone keeps telling us every offered solution does not feel right. Perhaps they are not using the right programming language as clearly they are not willing to work with it as it is not as it should be. After all the back and forth, there are several choices