Re: usage of python
Thanks to the all posters. This will be very useful! -- http://mail.python.org/mailman/listinfo/python-list
Re: usage of python
On May 13, 6:57 pm, afrobeard <[EMAIL PROTECTED]> wrote: > If I were you, I'd show them actual code and how easy it is to get > things done. Showing them how to implement a GTalk Bot[http:// > code.google.com/p/pygtalkrobot/] or how to build simple arcade games > with PyGame[http://www.pygame.org/news.html] would harbor much more > interest in my opinion because it'll show them their own power. There > may be some people who oppose this approach under the pretext that > students taking introductory programming courses should be taught C > because it incorporates the discipline that is much needed if they > want to become hard core CS researchers. Thanks for the pointers. I agree with your comments - the students are not necessarily going towards CS - there are many from telecom, business etc. That was one of the big reasons for using Python - the ability to get stuff done easily and quickly -- http://mail.python.org/mailman/listinfo/python-list
usage of python
Hi, I teach an introductory programming course in Python. As part of the introduction I'd like to highlight the usage of Python in industry. The idea is to show that there are big players using Python for a variety of tasks. Given that the students come from a variety of backgrounds and are not necessarily 'hackers', I'm trying to look for examples with a bit of wow-factor. Is there any list with people/groups/companies using Python for impressive things? Any pointers would be appreciated Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list
extracting Javadocs using Python
Hi, I work on a Java project and I was thinking out creating a hook in the subversion repo for the project that would check whether a class and it's associated methods were documented with Javadocs. Since I have written Subversion hooks for other purposes in Python, I'd like to try and do this task in Python as well. However, it seems that I'd need a full fledged Java/Javadoc parser written in Python. Does anybody know if something like this is available? Or would I need to implement a parser from scratch? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
mod_python, ElementTree and Aapche 2.0
Hi, this is a slightly vague question but I'm really puzzled as to when I write a mod_python (3.1.3) program that makes use of ElementTree and call it via a URL, the program simply stops when I do something like s = # some XML document in a string root = XML(s) There is no exception at all - the browser just shows a blank page But running the code outside of the web server makes it run fine. This is on a RHEL 4 machine, with Apache 2.0.52 and Python 2.3.4 Has anybody ever seen this type of behavior? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: ElementTree find with xmlns
On Oct 12, 11:19 pm, cakebread <[EMAIL PROTECTED]> wrote: > I'm having problems parsing a file: > > >>> tree = ElementTree.fromstring(""" >>> xmlns="http://www.w3.org/1999/xhtml"; > >>> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; > >>> xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; > >>> xmlns:dc="http://purl.org/dc/elements/1.1/"; > >>> xmlns:foaf="http://xmlns.com/foaf/0.1/"; > >>> xmlns:doap="http://usefulinc.com/ns/doap#";> > > Hello world > """) > > >>> print tree.find('body') > > None > > The above works fine with the first element being a simple , but > not when I have all the xmlns's. > > Thanks, > Rob You have to prefix the element name with its namespace. The following will work >>> tree.find('{http://www.w3.org/1999/xhtml}body') http://www.w3.org/1999/xhtml}body at 779d28> (Python 2.5, OS X 10.4.10) -- http://mail.python.org/mailman/listinfo/python-list
Re: 0 == False but [] != False?
Thanks a lot for all the responses -- http://mail.python.org/mailman/listinfo/python-list
0 == False but [] != False?
This is a slightly naive question, but I know that 0 can be used to represent False. So >>> 0 == False True But, I know I can use [] to represent False as in >>> if not []: print 'empty' ... empty But then doing the following gives a surprising (to me!) result >>> [] == False False Could anybody point out why this is the case? Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list
progress indicator in a mod_python script
Hi, I have a web application built using mod_python.Currently it behaves like a standard CGI - gets data from a form, performs a query on a backend database and presents a HTML page. However the query can sometimes take a bit of time and I'd like to show the user some form of indeterminate progress indicator (spinning dashes etc). My searching seems to indicate that this is based on some form of asynchronous calls (AJAX) and I'm not sure how I can achieve this effect in my mod_python app. Any pointers to achieve this would be very appreciated. Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Adding an XML fragment as a child node in a pre-existing Element tree
Hi, I'm using ElementTree for some RSS processing. The point where I face a problem is that within an I need to add another child node (in addition to etc) which is a well-formed XML document (Chemical Markup Language to be precise). So my code looks like: import cElementTree as ET c = open('x.cml').readlines() c = string.join(c) cml = ET.XML(c) Now I also have the following code: def addItem(self, title, link, description, cml = None): RSSitem = ET.SubElement ( self.RSSchannel, 'item' ) ET.SubElement( RSSitem, 'title' ).text = title ET.SubElement( RSSitem, 'description' ).text = description What I'm confused is how I can add the cml Element object that I generated, to the RSSitem as a child node. Do I need to manually traverse the tree of the CML document and add it one by one to the RSSitem as a child node? Or is there a smarter way to do this? Any pointers would be greatly appreciated Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list
removing the header from a gzip'd string
Hi, I have some code that takes a string and obtains a compressed version using zlib.compress Does anybody know how I can remove the header portion of the compressed bytes, such that I only have the compressed data remaining? (Obviously I do not intend to perform the decompression!) Thanks, -- http://mail.python.org/mailman/listinfo/python-list
ElementTree : parse string input
Hi, recently having discovered ElementTree I'm stumped by a very simple problem, which I can't find the answer to. I have some XML in a string object. Now the parse() method of ElementTree takes a filename or file-like object. So I tried creating a StringIO object from the original string and then giving that to parse(). But that does not seem to work. Any pointers to getting ElementTree to parse from a string would be appreciated (of course I could dump it to a temp file, but that doesn't seem elegent) Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list
Re: iterate over a series of nodes in an XML file
Stefan Behnel wrote: > [EMAIL PROTECTED] wrote: > > I have an XML file which contains entries of the form: > > > > > > 1 > > 2 > > > > 1 > > Thanks to everybody for the pointers. ElementTree is what I ended up using and my looks like this (based on the ElementTree tutorial code): def extractIds(filename): f = open(filename,'r') context = ET.iterparse(f, events=('start','end')) context = iter(context) even, root = context.next() for event, elem in context: if event == 'end' and elem.tag == 'Id': yield elem.text root.clear() As a result I can do: for id in extractIds(someFileName): do something -- http://mail.python.org/mailman/listinfo/python-list
iterate over a series of nodes in an XML file
Hi, I have an XML file which contains entries of the form: 1 2 1 Currently, I have written a SAX based handler that will read in all the entries and return a list of the contents of these entries. However this is not scalable and for my purposes it would be better if I could iterate over the list of nodes. Some thing like: for myid in getMyIDList(document): print myid I realize that I can do this with generators, but I can't see how I can incorporate generators into my handler class (which is a subclass of xml.sax.ContentHandler). Any pointers would be appreciated Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list
packaging a python project and associated graphics files
Hi, I've been trying to package a python project and I'm a little confused about how I distribute some PNG's that the program uses as icons. Using distutils I can set the data_files argument of setup() and get my data files located in, say, /usr/local/mydata. However when I write my code, it would seem that I have to hardcode the above path. But this would mean that while working on the code I would need to have it 'installed' on my system (or else actually make the above directory). This seems a little unwieldy. How do people handle this situation? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
accesing pages (or ranges of pages) via Reportlab
Hi, I've been using pdflatex to dump ranges of pages from a PDF file via Python. However, I was looking at the Reportlab toolkit and was wondering if this operation would be possible using this toolkit as well. Admittedly, I have'nt read the documentation in detail, but I was wondering if anybody could provide any pointers to extracting pages from a PDF via Python without using pdflatex Thanks, Rajarshi -- http://mail.python.org/mailman/listinfo/python-list