Re: Easy Q

2010-01-12 Thread Gabriel Genellina
En Sat, 09 Jan 2010 13:11:28 -0300, Victor Subervi 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 I distinguish it? len

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.com>> wrote: >> >>Victor Subervi wrote: >> >>Hi; >>I have a string.join statement on a

Re: Easy Q

2010-01-11 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron 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 may be a list or a

Re: Easy Q

2010-01-09 Thread Victor Subervi
On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron wrote: > 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

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 s

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 t

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 th

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

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, is

Re: Easy Q: dealing with object type

2005-02-03 Thread Erik Johnson
> 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

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(

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". > >> > >>F

Re: Easy Q: dealing with object type

2005-02-02 Thread Steven Bethard
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 A(object): That works! :) I guess I am fortunate to be running 2.2 - looks kinda ugly prio

Re: Easy Q: dealing with object type

2005-02-02 Thread Erik Johnson
"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 A(object): That works! :) I guess I am fortunate to be running 2.2 - looks kinda ugly prior

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) >>> type(a) == A True >>> type(a) is A True >>> b=A() >>> type(a) == type(b) True >>> type(a) is type(b) True Check out t

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) >>> type(a) == A True >>> type(a) is A True >>> b=A() >>> type(a) == type(b) True >>> type(a) is type(b) True Check out t

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