Strange error with getattr() function
Hi There! I'm trying to use Zope and the product OpenFlow. I got the following error while I was using the built-in function getattr() to retrieve an OpenFlow object: attribute name must be string Actually, I surely pass a string as attribute name to getattr() The code: #following instruction returns me the string "WorkFlowTest" openflow_id=container.aq_parent.id if (hasattr(container,openflow_id): #the interpreter enter in this block, so #it's sure that container has an attribute called WorkFlowTest openflow=getattr(container,openflow_id) At this point, I got the error: attribute name must be string The *strange* is that I get the same error even if I pass the attribute name to the getattr() function as pure string: getattr(container,"WorkFlowTest") (sic!) I'm a lot confused! Thanks in advance. -- H0le -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange error with getattr() function
Hole ha scritto: > Hi There! > > I'm trying to use Zope and the product OpenFlow. > > I got the following error while I was using the built-in function > getattr() to retrieve an OpenFlow object: > > attribute name must be string > > > Actually, I surely pass a string as attribute name to getattr() > > The code: > > #following instruction returns me the string "WorkFlowTest" > openflow_id=container.aq_parent.id > > if (hasattr(container,openflow_id): > #the interpreter enter in this block, so > #it's sure that container has an attribute called WorkFlowTest > openflow=getattr(container,openflow_id) > > At this point, I got the error: attribute name must be string > I'm wondering if the exception is raised in a hidden function and not in the explicit call to getattr(). How can I view the traceback in a script running in zope?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange error with getattr() function
Gabriel Genellina ha scritto: > At Monday 18/12/2006 13:25, Hole wrote: > > > > At this point, I got the error: attribute name must be string > > > >I'm wondering if the exception is raised in a hidden function and not > >in the explicit call to getattr(). How can I view the traceback in a > >script running in zope?? > > (Which Zope version?) > If you don't catch the exception, an error page will be displayed, > pointing to the error_log object. > > Hi Gabriel, thanks a lot for your replies. I've resolved the problem catching the exception and printing the traceback in a file. The problem was, indeed, in a getattr() call performed in another function, to which I passed an int rather than a string. Bye! -- DN -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, XML and XPath
> > I need to use XML parsing with xpath: a simple xml reader. > > You can try lxml, have a look herehttp://codespeak.net/lxml/xpathxslt.html Thanks a lot to everyone! -- http://mail.python.org/mailman/listinfo/python-list
Python, XML and XPath
Hi all, I hope this is not an "overasked" question but I find myself quite confused about python xml management (I have to use python for a project and I come from java world, you know...where frameworks, libraries and tools to use are standard de iure or standard de facto). I need to use XML parsing with xpath: a simple xml reader. I've found that the standard distribution of python doesn't include xpath support modules so I've decided to add libxml2. I've installed cygwin c compiler but I still have errors like the following: C:\Python25\Lib\libxml2-python-2.6.9>python setup.py build install C:\Python25\lib\distutils\dist.py:247: UserWarning: 'licence' distribution option is deprecated; use 'license' warnings.warn(msg) running build running build_py running build_ext building 'libxml2mod' extension writing build\temp.win32-2.5\Release\libxml2mod.def C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build \temp.win32-2.5\Release\libxml2-py.o build\temp.win32-2.5\Release \libxml.o build\temp.win32-2.5\Release\types.o build \temp.win32-2.5\Release\libxml2mod .def -L/usr\lib -LC:\Python25\libs -LC:\Python25\PCBuild -llibxslt - llibexslt -llibxml2 -lpython25 -lmsvcr71 -o build \lib.win32-2.5\libxmlmods\libxml2mod.pyd build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x1629): undefined reference to `_imp__xmlFree' build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x2802): undefined reference to `_imp__xmlFree' build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x44b2): undefined reference to `_imp__xmlFree' build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x50e4): undefined reference to `_imp__xmlFree' build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x5519): undefined reference to `_imp__xmlFree' build\temp.win32-2.5\Release\libxml2-py.o:libxml2-py.c:(.text+0x7339): more undefined references to `_imp__xmlFree' follow Does anyone know how to solve this issue or has suggestions for another (easy-to-install) xml-xpath library? Thanks for your support! -- http://mail.python.org/mailman/listinfo/python-list
"run" Package Query
When I write program (.py) with IDLE , I am able to use run package . - - - - start - - - - if __name__ == '__main__': import sys,os import run run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) - - - - end - - - - - above code works simply with the IDLE. But problem arises , when I use Eric or pyScriptter , On other editor it gives the error "Exceptions.ImportError : No Module named run" Do i need to set any variable ? or path ? run is a system package or third party ? Thanx In Advance -- http://mail.python.org/mailman/listinfo/python-list
How to create Standalone PYC File
I have .py file which uses some third party modules like egg files, like simplejson and python-twitter , - start of file - import ConfigParser import getopt import os import sys import twitter when i compile this py file using compile module , i get .pyc file . Now my question is , if i run .pyc file on another computer containing only python installed , will it run ? or do i need to install 3rd party lib again on that computer ? Anyone know how to make program lib independent , something called embedded into one file only ? thank you in anticipation . Rohan. -- http://mail.python.org/mailman/listinfo/python-list