[Ironpython-users] type for unicode and str

Daniel Fernandez fernandez_dan2 at hotmail.com
Fri Feb 3 04:31:32 CET 2012


Dino and Jeff, Thanks alot, that helped alot. I was going crazy trying to step thru the code.  Danny
 From: dinov at microsoft.com
To: fernandez_dan2 at hotmail.com; ironpython-users at python.org
Subject: RE: [Ironpython-users] type for unicode and str
Date: Wed, 1 Feb 2012 17:54:48 +0000











Jeff answered the Unicode/str part, so I’ll answer the following code part.  Ultimately these come from the properties in Builtin.cs:
 
        public static PythonType unicode {
            get {
                return DynamicHelpers.GetPythonTypeFromType(typeof(string));
            }
        }
        public static PythonType str {
            get {
                return DynamicHelpers.GetPythonTypeFromType(typeof(string));
            }
        }
 
Ultimately we produce a PythonModule which has a PythonDictionary.  All of our dictionaries have a storage class which abstracts way how the dictionary is actually
 implemented.  For built-in modules we have a ModuleDictionaryStorage object.  The ModuleDictionaryStorage lazily reflects over the module type and caches the result.  For properties it’ll pull the value out the first time it’s accessed.




From: ironpython-users-bounces+dinov=microsoft.com at python.org [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org]
On Behalf Of Daniel Fernandez

Sent: Tuesday, January 31, 2012 8:55 PM

To: ironpython-users at python.org

Subject: [Ironpython-users] type for unicode and str


 

Hi All,

 

I was just playing with unicode strings and I notice a difference with CPython and IronPython. On CPython 2.7.2 I get the following

 

>>> type(u"A")

<type 'unicode'>

>>> type("A")

<type 'str'>

 

On Ironpython the latest 2.7.2 Alpha 1 I get the following

 

>>> type(u"A")

<type 'str'>

>>> type("A")

<type 'str'>

 

 

I decided to crack open the source and see where this type function is defined. I followed to the builtin.cs with the PythonModule but I got kind lost there. If anyone can provide some helpful hints that would be great.

 

Thanks

 

Danny


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120202/7d927451/attachment.html>


More information about the Ironpython-users mailing list