RE: [Zope] type in python methods

2001-01-11 Thread Juan Carlos Coruña



-Mensaje original-
De: Luciano Ramalho [mailto:[EMAIL PROTECTED]]
Enviado el: jueves, 11 de enero de 2001 15:21
Para: Juan Carlos Coruña
CC: [EMAIL PROTECTED]
Asunto: Re: [Zope] type in python methods


> The instruction "if type(var1) == type(var2): " doesn't work.

It does work:

-
Python 1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> x = 'spam'
>>> y = 'eggs'
>>> z = 99
>>> type(x) == type(y)
1
>>> type(x) == type(z)
0
>>>
-



How isn't it working for you? What is the context? What kinds of
variables are you trying to compare?

Are you aware that type() only knows about primitive types (for example,
all class instances are of type 'instance')?

Regards,

Luciano Ramalho

Juan Carlos Coruña wrote:
>
> How can I compare the type of 2 variables in a python method?
>
> The instruction "if type(var1) == type(var2): " doesn't work.
>
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

You are testing "type" in the python interpreter, but try to test the same
in the product "PythonMethod Ver. 0.1.7".


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




RE: [Zope] type in python methods

2001-01-11 Thread Juan Carlos Coruña

Yes, it works. Thanks.



-Mensaje original-
De: Evan Simpson [mailto:[EMAIL PROTECTED]]
Enviado el: jueves, 11 de enero de 2001 15:49
Para: Juan Carlos Coruña; [EMAIL PROTECTED]
Asunto: Re: [Zope] type in python methods


From: Juan Carlos Coruña <[EMAIL PROTECTED]>
> How can I compare the type of 2 variables in a python method?
>
> The instruction "if type(var1) == type(var2): " doesn't work.

_.same_type(var1, var2) should do it. (Without the "_." in Scripts).

Cheers,

Evan @ digicool & 4-am


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] type in python methods

2001-01-11 Thread Evan Simpson

From: Juan Carlos Coruña <[EMAIL PROTECTED]>
> How can I compare the type of 2 variables in a python method?
>
> The instruction "if type(var1) == type(var2): " doesn't work.

_.same_type(var1, var2) should do it. (Without the "_." in Scripts).

Cheers,

Evan @ digicool & 4-am



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] type in python methods

2001-01-11 Thread Luciano Ramalho

> The instruction "if type(var1) == type(var2): " doesn't work.

It does work:

-
Python 1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> x = 'spam'
>>> y = 'eggs'
>>> z = 99
>>> type(x) == type(y)
1
>>> type(x) == type(z)
0
>>>
-

How isn't it working for you? What is the context? What kinds of
variables are you trying to compare?

Are you aware that type() only knows about primitive types (for example,
all class instances are of type 'instance')?

Regards,

Luciano Ramalho

Juan Carlos Coruña wrote:
> 
> How can I compare the type of 2 variables in a python method?
> 
> The instruction "if type(var1) == type(var2): " doesn't work.
> 
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )