How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
Hi,

I want to know what type is a variable.
For example, I get the contents of an xml but some content is a list or
a string, and I need to know what type it is.

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
great, thanks

And how I can compare this "" output ?
I want to decide what to do if the var is an string and what to do if
not..

Tried with:
if type(artistList) == "":

and
if type(artistList) == "list":

but nothing..

On Nov 29, 12:41 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2006-11-29, Leandro Ardissone <[EMAIL PROTECTED]> wrote:
>
>
>
> > I want to know what type is a variable. For example, I get the
> > contents of an xml but some content is a list or a string, and
> > I need to know what type it is.
> >>> x = 'asdf'
> >>> type(x)
> 
> >>> i = 0
> >>> type(i)
> --
> Grant Edwards   grante Yow!  I Know A Joke!!
>   at
>visi.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
Thanks,

I don't store Python objects in xml, but I get an object from a library
that parses xml and converts it to objects.


On Nov 29, 12:43 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2006-11-29, Grant Edwards <[EMAIL PROTECTED]> wrote:
>
> > On 2006-11-29, Leandro Ardissone <[EMAIL PROTECTED]> wrote:
>
> >> I want to know what type is a variable. For example, I get the
> >> contents of an xml but some content is a list or a string, and
> >> I need to know what type it is.
>
> >>>> x = 'asdf'
> >>>> type(x)
> >
> >>>> i = 0
> >>>> type(i)
> >That makes me wonder how he manages to store Python objects in
> xml.
> 
> --
> Neil Cerutti

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
great,

that is just what I need!

Thank you all!

--
Leandro Ardissone

On Nov 29, 1:29 pm, Roberto Bonvallet <[EMAIL PROTECTED]>
wrote:
> Leandro Ardissone wrote:
> > And how I can compare this "" output ?
> > I want to decide what to do if the var is an string and what to do if
> > not..
>
> > Tried with:
> > if type(artistList) == "":
>
> > and
> > if type(artistList) == "list":
>
> > but nothing..type() doesn't return a string, it returns a type object.
> You should try this:
>
> if isinstance(artistList, list):
> ...
> 
> Cheers,
> --
> Roberto Bonvallet

-- 
http://mail.python.org/mailman/listinfo/python-list