Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52313

Re: Python Basic Doubt

Date 2013-08-10 20:00 +0200
From Xavi <jarabal@gmail.com>
Subject Re: Python Basic Doubt
References <CAL0E0u6wO_UBniWoSpePvhKhPDG_nf4p1rqYYrGwzoHTqp6ZHA@mail.gmail.com> <20130810114040.6ac78fe8@bigbox.christie.dr>
Newsgroups comp.lang.python
Message-ID <mailman.432.1376157806.1251.python-list@python.org> (permalink)

Show all headers | View raw


Hello,

El 10/08/2013 18:40, Tim Chase escribió:
> Generally, if you are using the "is" operator to compare against
> anything other than None, you're doing it wrong. There are exceptions
> to this, but it takes knowing the particulars.

Now I have one doubt, I use 'is' to compare basic types in python 3, for example .-

v = []
if type(v) is list:
     print('Is list...')

Because I think it is more clear and faster than .-
type(v) == [].__class__  ... or ... isinstance(v, list)

Is this correct?
Thanks.
-- 
Xavi

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Python Basic Doubt Xavi <jarabal@gmail.com> - 2013-08-10 20:00 +0200
  Re: Python Basic Doubt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-10 19:32 +0000
    Re: Python Basic Doubt Xavi <jarabal@gmail.com> - 2013-08-11 18:58 +0200
      Re: Python Basic Doubt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-12 01:08 +0000

csiph-web