[Ironpython-users] type for unicode and str
Dino Viehland
dinov at microsoft.com
Wed Feb 1 18:54:48 CET 2012
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/20120201/d30bac78/attachment.html>
More information about the Ironpython-users
mailing list