Re: [IronPython] Dictionary Ordering
It's an implementation detail which may change in future versions. There's a OrderedDict in the Python cookbook though that should work w/ IP. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438823 Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord Sent: Wednesday, May 17, 2006 6:36 AM To: Discussion of IronPython Subject: [IronPython] Dictionary Ordering Hello all, IronPython seems to default to have a dictionary 'ordering' based on key insertion order. This is nice, but differs from the CPython implementation. However the spec (as I'm sure you're aware) says : (from http://docs.python.org/lib/typesmapping.html ) Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's history of insertions and deletions. So IronPython behaviour is well within the spec. My question is, can we rely on the ordered behaviour of IronPython ? (Or is it an implementation detail that may change in future versions ?) Michael Foord http://www.resolversystems.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] from xml import xpath
Title: from xml import xpath This doesnt work for my in CPython 2.4 either, so I think the docs are wrong: from xml import xpath Traceback (most recent call last): File stdin, line 1, in ? ImportError: cannot import name xpath import sys sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]' Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Lee Sent: Tuesday, May 16, 2006 3:17 PM To: users@lists.ironpython.com Subject: [IronPython] from xml import xpath I'm porting an application that uses PyXML. The following from the PyXml documentation http://pyxml.sourceforge.net/topics/howto/section-XPath.html doesn't work: from xml import xpath Traceback (most recent call last): File , line 0, in input##113 ImportError: cannot import xpath from xml Any suggestions? I messed around with adding site-packages to IRONPYTHONPATH but other BadThings happened. Here's the installation: Microsoft Windows XP [Version 5.1.2600] IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 python 2.4.2 pyxml 0.8.4 pywin32 205 py2exe 0.6.3 IRONPYTHONPATH = c:\python24\lib ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] from xml import xpath
Dino, you seemed to have missed the part about pyxml..It works in cpython with pyxml installed. However, pyxml is playing tricks with paths etc, and there might even be pyd:s involved..C:\Python24python.exe Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32Type help, copyright, credits or license for more information. import xml xml.__file__'C:\\Python24\\lib\\site-packages\\_xmlplus\\__init__.pyc' from xml import xpathOn 5/17/06, Dino Viehland [EMAIL PROTECTED] wrote: This doesn't work for my in CPython 2.4 either, so I think the docs are wrong: from xml import xpath Traceback (most recent call last): File stdin, line 1, in ? ImportError: cannot import name xpath import sys sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]' Do you want to help develop Dynamic languages on CLR? ( http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Greg Lee Sent: Tuesday, May 16, 2006 3:17 PM To: users@lists.ironpython.com Subject: [IronPython] from xml import xpath I'm porting an application that uses PyXML. The following from the PyXml documentation http://pyxml.sourceforge.net/topics/howto/section-XPath.html doesn't work: from xml import xpath Traceback (most recent call last): File , line 0, in input##113 ImportError: cannot import xpath from xml Any suggestions? I messed around with adding site-packages to IRONPYTHONPATH but other BadThings happened. Here's the installation: Microsoft Windows XP [Version 5.1.2600] IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 python 2.4.2 pyxml 0.8.4 pywin32 205 py2exe 0.6.3 IRONPYTHONPATH = c:\python24\lib ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] from xml import xpath
Youre right, I did miss that Looking at this page: http://pyxml.sourceforge.net/topics/howto/section-install.html It would seem that you may be right about the Pyds (it at least requires a C compiler, making that likely and almost guaranteeing it wont work w/ IronPython). Unfortunately we dont support PYDs currently (and arent likely to soon) so most likely this wont currently work. If you absolutely need XPath support in the mean time Id suggest using .NETs XMLPath (and if you need to work on both you could make a thin wrapper over either PyXml for CPython and .NETs XPath support). For example: import clr clr.AddReference(System.Xml) import System.Xml.XPath as XPath xpathDoc = XPath.XPathDocument(file://foo.txt) Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Simon Dahlbacka Sent: Wednesday, May 17, 2006 11:41 AM To: Discussion of IronPython Subject: Re: [IronPython] from xml import xpath Dino, you seemed to have missed the part about pyxml.. It works in cpython with pyxml installed. However, pyxml is playing tricks with paths etc, and there might even be pyd:s involved.. C:\Python24python.exe Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import xml xml.__file__ 'C:\\Python24\\lib\\site-packages\\_xmlplus\\__init__.pyc' from xml import xpath On 5/17/06, Dino Viehland [EMAIL PROTECTED] wrote: This doesn't work for my in CPython 2.4 either, so I think the docs are wrong: from xml import xpath Traceback (most recent call last): File stdin, line 1, in ? ImportError: cannot import name xpath import sys sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]' Do you want to help develop Dynamic languages on CLR? ( http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Greg Lee Sent: Tuesday, May 16, 2006 3:17 PM To: users@lists.ironpython.com Subject: [IronPython] from xml import xpath I'm porting an application that uses PyXML. The following from the PyXml documentation http://pyxml.sourceforge.net/topics/howto/section-XPath.html doesn't work: from xml import xpath Traceback (most recent call last): File , line 0, in input##113 ImportError: cannot import xpath from xml Any suggestions? I messed around with adding site-packages to IRONPYTHONPATH but other BadThings happened. Here's the installation: Microsoft Windows XP [Version 5.1.2600] IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 python 2.4.2 pyxml 0.8.4 pywin32 205 py2exe 0.6.3 IRONPYTHONPATH = c:\python24\lib ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Line numbers in snippets...
I was trying to suggest to the IP developers that access to file, line and perhaps column should be readily available from any exception. Your response suggests that I might not have said so clearly. When there's a Name Error, it's often possible to work on solving the problem without line number info -- you can look at the script for where the bad name is used. (In the particular case of Name Error, the code that's wrong isn't necessarily on the line that was running when the exception occurs -- if you define a method named SpelledRite and other code calls method SpelledRight, the error will be on the line that does the call, regardless of which name you intended to use.) At 04:24 PM 5/16/2006, Alex Henderson wrote The name error exception does give you the name causing the grief, but the line number isn't available, not without doing a little extra work (as Dino outlined) by wrapping up the evaluation of the snippet within a python try... except block and pulling some of the info in from sys.exc_info() and exposing it to the application hosting the PythonEngine. The name isn't really enough for us, we need access to the line number and a python stack trace so clients can better analyse what went wrong (we aren't evaluating one line exceptions, these are like 100 line snippets)... and there are some other errors where the information provided in the exception makes it very difficult to resolve the issue without access to the additional info. Chez, - Alex -Original Message- From: [EMAIL PROTECTED] [mailto:users- [EMAIL PROTECTED] On Behalf Of J. Merrill Sent: Wednesday, 17 May 2006 3:50 a.m. To: Discussion of IronPython Subject: Re: [IronPython] Line numbers in snippets... Shouldn't all Python errors (not just Synax) provide the filename line number? Column number would often be less important, particularly for run-time (vs compile-time -- e.g. not Syntax) errors. As a practical matter, how can it be that a PythonNameError exception doesn't provide a way to get at the name that couldn't be resolved? What more important bit of info could there be? (But I haven't looked to make sure that the name is NOT available in the latest IP.) At 04:55 PM 5/15/2006, Dino Viehland wrote Ahh, ok... Can you wrap the user code you run w/ more python code? If you could then you could do: [snip] J. Merrill / Analytical Software Corp ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Dictionary Ordering
Dino Viehland wrote: It's an implementation detail which may change in future versions. There's a OrderedDict in the Python cookbook though that should work w/ IP. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438823 Hey - there's an even better one at : http://www.voidspace.org.uk/python/odict.html :-) I was wondering whether the ordering in IronPython was a design decision or a con-incidence. We've just upgraded (downgraded ?) our unit tests from a home-brew system to PyUnit. Our own system ran tests in the order they were defined, which was just a co-incidence as it turns out - not a design decision on our part. That change alone has uncovered a few issues for us, which in the long run is a good thing I guess. Michael Foord http://www.voidspace.org.uk/python/index.shtml Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord Sent: Wednesday, May 17, 2006 6:36 AM To: Discussion of IronPython Subject: [IronPython] Dictionary Ordering Hello all, IronPython seems to default to have a dictionary 'ordering' based on key insertion order. This is nice, but differs from the CPython implementation. However the spec (as I'm sure you're aware) says : (from http://docs.python.org/lib/typesmapping.html ) Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's history of insertions and deletions. So IronPython behaviour is well within the spec. My question is, can we rely on the ordered behaviour of IronPython ? (Or is it an implementation detail that may change in future versions ?) Michael Foord http://www.resolversystems.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com