Re: try..except or type() or isinstance()?

2020-08-16 Thread Alexa Oña
n-list@python.org Asunto: Re: try..except or type() or isinstance()? On Sun, 16 Aug 2020 09:40:12 +0200 Manfred Lotz wrote: > On Sat, 15 Aug 2020 12:20:48 -0400 > Dennis Lee Bieber wrote: > > > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > > declaimed the following: &

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On Sun, 16 Aug 2020 09:40:12 +0200 Manfred Lotz wrote: > On Sat, 15 Aug 2020 12:20:48 -0400 > Dennis Lee Bieber wrote: > > > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > > declaimed the following: > > > > >On Sat, 15 Aug 2020 11:47:03 +0200 > > >Sibylle Koczian wrote: > > > > >

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On 15 Aug 2020 14:49:48 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: > Manfred Lotz writes: > >Here a minimal example > > main.py > > source=""" > sehr gut > 1 > """[ 1: -1 ].split( "\n" ) > > class grades: > names =[ "sehr gut" ] > @staticmethod > def is_numeric( text ): >

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On Sat, 15 Aug 2020 12:20:48 -0400 Dennis Lee Bieber wrote: > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > declaimed the following: > > >On Sat, 15 Aug 2020 11:47:03 +0200 > >Sibylle Koczian wrote: > > > > >> if the value comes from a file, isn't it a > >> string in any case? A string

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
On Sat, 15 Aug 2020 11:47:03 +0200 Sibylle Koczian wrote: > Am 15.08.2020 um 10:14 schrieb Manfred Lotz: > > Hi Chris, > > Thanks a lot for you advice. > > > > On Sat, 15 Aug 2020 16:15:29 +1000 > > Chris Angelico wrote: > > > >> On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz > >> wrote: > >>

Re: try..except or type() or isinstance()?

2020-08-15 Thread Sibylle Koczian
Am 15.08.2020 um 10:14 schrieb Manfred Lotz: Hi Chris, Thanks a lot for you advice. On Sat, 15 Aug 2020 16:15:29 +1000 Chris Angelico wrote: On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: I have an object which I could initialize providind an int or a str. ... For my use case I do

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
On Sat, 15 Aug 2020 08:33:58 +0200 Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > > > On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz > > wrote: > >> > >> I have an object which I could initialize providind an int or a > >> str. > >> > >> I am not sure which of the following is b

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
Hi Chris, Thanks a lot for you advice. On Sat, 15 Aug 2020 16:15:29 +1000 Chris Angelico wrote: > On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz > wrote: > > > > I have an object which I could initialize providind an int or a str. > > > > I am not sure which of the following is best to use > > -

Re: try..except or type() or isinstance()?

2020-08-14 Thread Peter Otten
Chris Angelico wrote: > On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: >> >> I have an object which I could initialize providind an int or a str. >> >> I am not sure which of the following is best to use >> - try/except >> - if type(int)... >> - if isinstance(v, int) >> >> Here a minimal

Re: try..except or type() or isinstance()?

2020-08-14 Thread Chris Angelico
On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: > > I have an object which I could initialize providind an int or a str. > > I am not sure which of the following is best to use > - try/except > - if type(int)... > - if isinstance(v, int) > > Here a minimal example > > def get_id(fromname):

try..except or type() or isinstance()?

2020-08-14 Thread Manfred Lotz
I have an object which I could initialize providind an int or a str. I am not sure which of the following is best to use - try/except - if type(int)... - if isinstance(v, int) Here a minimal example def get_id(fromname): # do something with `fromname` return 0 def get_name(fromid):