Python type checking?

gregj at ancor.com gregj at ancor.com
Tue Dec 7 11:48:21 EST 1999


In article <82j9u8$da7$1 at nnrp1.deja.com>,
  Arinte <jamarijr at hotmail.com> wrote:
> class PossArg:
>    def __init__(self,argname, argvalue):
>       self.argname = argname
>       self.argvalue = argvalue
>
>    def getValue(self):
>       return self.argvalue
>    def getName(self):
>       return self.argname
>
>    def setValue(self, value):
>       self.argvalue = value
>
> On the set setValue(), they set it to an integer value I want to make
> it a long else if it is a string leave it as a string.  How can this
be
> done?  I figure I can do a if (type(argvalue)=="int"), but how would I
> handle a cast in python.

if (type(argvalue) == 'int'):
  argvalue = long(argvalue)


> TIA
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list