Re: Easy Q

2010-01-12 Thread Gabriel Genellina
En Sat, 09 Jan 2010 13:11:28 -0300, Victor Subervi victorsube...@gmail.com escribió: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can

Re: Easy Q

2010-01-11 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron gher...@islandtraining.com mailto:gher...@islandtraining.com wrote: Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable

Re: Easy Q

2010-01-11 Thread Victor Subervi
On Mon, Jan 11, 2010 at 10:00 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron gher...@islandtraining.commailto: gher...@islandtraining.com wrote: Victor Subervi wrote: Hi; I have a string.join

Easy Q

2010-01-09 Thread Victor Subervi
Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can I distinguish it? len(var) will obviously give me the length of the string if it's a string

Re: Easy Q

2010-01-09 Thread MRAB
Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can I distinguish it? len(var) will obviously give me the length of

Re: Easy Q

2010-01-09 Thread Gary Herron
Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can I distinguish it? len(var) will obviously give me the length of

Re: Easy Q

2010-01-09 Thread Dave Angel
Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can I distinguish it? len(var) will obviously give me the length of the

Re: Easy Q

2010-01-09 Thread Victor Subervi
On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron gher...@islandtraining.comwrote: Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which

Re: Easy Q: dealing with object type

2005-02-03 Thread Just
In article [EMAIL PROTECTED], Steven Bethard [EMAIL PROTECTED] wrote: Erik Johnson wrote: Erick [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ah, you're running into the old-style classes vs. new style classes. Try subclassing from object. For example: class

Re: Easy Q: dealing with object type

2005-02-03 Thread Steven Bethard
Just wrote: In article [EMAIL PROTECTED], Steven Bethard [EMAIL PROTECTED] wrote: py class A: ... pass ... py class B: ... pass ... py a = A() py a.__class__ == A True py a.__class__ == B False Uh, isinstance(a, A) works for both new-style and old-style classes. Heck, isinstance() even

Re: Easy Q: dealing with object type

2005-02-03 Thread Steve Holden
Erik Johnson wrote: Steven Bethard [EMAIL PROTECTED] wrote: py class A: ... pass ... py class B: ... pass ... py a = A() py a.__class__ == A True py a.__class__ == B False Just [EMAIL PROTECTED] wrote Uh, isinstance(a, A) works for both new-style and old-style classes. Heck, isinstance()

Re: Easy Q: dealing with object type

2005-02-03 Thread Fredrik Lundh
Erik Johnson wrote: As an aside, I notice a lot of other people's interpreters actually print 'True' or 'False' where my system prints 0 or 1. Is that a configuration that can easily set somewhere? $ python2.1 -c print 1 == 1 1 $ python2.2 -c print 1 == 1 1 $ python2.3 -c print 1 == 1

Easy Q: dealing with object type

2005-02-02 Thread Erik Johnson
I quickly browsed through section 9 of the Tutorial, tried some simple Google searches: I'm not readily seeing how to test class type. Given some object (might be an instance of a user-created class, might be None, might be list, might be some other standard type object instance), how do you

Re: Easy Q: dealing with object type

2005-02-02 Thread Daniel Bickett
On Erik Johnson wrote: # The following works, but I don't want to keep a set of instances to compare against obj2 = A() type(obj) == type(obj2) 1 How about: class A: pass class B: pass objA = A() type( objA ) == type( A() ) True then again objB = B() type( objA

Re: Easy Q: dealing with object type

2005-02-02 Thread Erick
Ah, you're running into the old-style classes vs. new style classes. Try subclassing from object. For example: class A(object): ... pass ... a=A() type(a) class '__main__.A' type(a) == A True type(a) is A True b=A() type(a) == type(b) True type(a) is type(b) True Check out the