Re: [Tutor] Making pretty web pages from python code examples?
> : Basically, I'm trying to read python code examples from files on > : disk and generate pretty little web pages from them. > I think you may want sphinx [0] which is available in PyPI [1]. > > It understands reStrucTured text and adds a few Sphinx-specific > directives/features for pulling the docstrings from your python > modules. Much easier than building your own. Thanks! Looks like just what I'm after. -Modulok- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to deploy and upgrade python and its apps
Hi All, I would like to understand how to deploy specific version of python and its modules and apps in consistent manner. Use case: 1- How to install specific version of python in my own path. (consider NFS, /opt/sw/bin and /opt/sw/lib). This particular share is mounted on all dev machines. 2- How to develop application _using_ only the python and its libs installed in /opt/sw/bin and /opt/sw/lib. 3- Now once developed, my applications is dependent on python and its libs in /opt/sw/bin and /opt/sw/lib. Hence I want to keep it in sync on all machines (ofcourse it is mounted). Giving me chance to rollback it necessary. Here is what I am thinking of doing it. Please correct me and suggest the better way! 1- Install python in this location. ./configure --prefix=/opt/sw make make install 2- setenv PYTHONPATH=/opt/sw/lib/python 3. Add whole /opt/sw to some dvcs (hg) and keep updating to stable revisions. -- Dilip -- Dilip ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to deploy and upgrade python and its apps
Hi All, I would like to understand how to deploy specific version of python and its modules and apps in consistent manner. Use case: 1- How to install specific version of python in my own path. (consider NFS, /opt/sw/bin and /opt/sw/lib). This particular share is mounted on all dev machines. 2- How to develop application _using_ only the python and its libs installed in /opt/sw/bin and /opt/sw/lib. 3- Now once developed, my applications is dependent on python and its libs in /opt/sw/bin and /opt/sw/lib. Hence I want to keep it in sync on all machines (ofcourse it is mounted). Giving me chance to rollback it necessary. Here is what I am thinking of doing it. Please correct me and suggest the better way! 1- Install python in this location. ./configure --prefix=/opt/sw make make install 2- setenv PYTHONPATH=/opt/sw/lib/python 3. Add whole /opt/sw to some dvcs (hg) and keep updating to stable revisions. -- Dilip ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to deploy and upgrade python and its apps
Hi Dilip, There is some good information about this in the book "Expert Python Programming" by Tarek Ziade, and maybe you could look into http://pypi.python.org/virtualenv, easy_install and zc.buildout. Regards, Bjorn On Wed, Apr 14, 2010 at 10:27 AM, Dilip M wrote: > Hi All, > > I would like to understand how to deploy specific version of python and its > modules and apps in consistent manner. > > Use case: > > 1- How to install specific version of python in my own path. (consider > NFS, /opt/sw/bin and /opt/sw/lib). This particular share is mounted on all > dev machines. > > 2- How to develop application _using_ only the python and its libs > installed in > /opt/sw/bin and /opt/sw/lib. > > 3- Now once developed, my applications is dependent on python and its libs > in > /opt/sw/bin and /opt/sw/lib. Hence I want to keep it in sync on all > machines > (ofcourse it is mounted). Giving me chance to rollback it necessary. > > Here is what I am thinking of doing it. Please correct me and suggest > the better way! > > 1- > > Install python in this location. > > ./configure --prefix=/opt/sw > make > make install > > 2- > setenv PYTHONPATH=/opt/sw/lib/python > > 3. Add whole /opt/sw to some dvcs (hg) and keep updating to stable > revisions. > > > -- Dilip > > > > -- > Dilip > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Problems with creating XML-documents
I'm having problems with creating XML-documents, because I don't seem to write it to a document correctly. I have to write the document from a loop: doc.write('\n') for instance in query: if doc != None: text = str('\n' + \ ' ' + str(instance.datetime) + ' \n' + \ ' ' + instance.order + ' \n' + \ '\n') doc.write(text) When I try to parse it, it keeps giving errors. So I tried to use an external library jaxml, but I don't know how to implement this in the loop because the output is written at the end (doc._output) and I overwrite my values. The code below is from the jaxml website # an equivalent version using JAXML import jaxml doc = jaxml.XML_document() doc.sometag(someattr=1).anothertag(jaxml="Nice") doc.thirdone("Yo") doc._output("sample.xml") Can anybody point me in the rght direction or is there another library that I can use to create valid XML-documents? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problems with creating XML-documents
On 4/14/2010 4:16 PM, Karjer Jdfjdf wrote: I'm having problems with creating XML-documents, because I don't seem to write it to a document correctly. I have to write the document from a loop: doc.write('\n') for instance in query: if doc != None: text = str('\n' + \ ' ' + str(instance.datetime) + ' \n' + \ ' ' + instance.order + ' \n' + \ '\n') doc.write(text) When I try to parse it, it keeps giving errors. I am frustrated with the lack of clarity and completeness. Please respect our time as volunteers by giving complete explicit informaion. Show us the resultant file. Tell us what parsing tool you are using. Show us the exact errors. [snip] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problems with creating XML-documents
"Karjer Jdfjdf" wrote I'm having problems with creating XML-documents, because I don't seem to write it to a document correctly. Is that because you don't understand XML or because the output is not what you expect? How is the data being generated? Are you parsing an existing XML source or creating the XML from scratch? I'm not sure I understand your problem. text = str('\n' + \ ' ' + str(instance.datetime) + ' \n' + \ ' ' + instance.order + ' \n' + \ '\n') You can simplify this quite a lot. You almost certaionly don;t need the outer str() and you probably don;t need the \ characters either. Also it might be easier to use a triple quoted string and format characters to insert the dasta values. When I try to parse it, it keeps giving errors. Why do you need to parse it if you are creating it? Or is this after you read it back later? I don't understand the sequence of processing here. So I tried to use an external library jaxml, Did you try to use the standard library tools that come with Python, like elementTree or even sax? I think we need a few more pointers to the root cause here. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Introduction to modelling with Python
On Wednesday April 7 2010 11:38:07 AG wrote: > > Eike > > I just wanted to come back to you on the book recommendation you made > "Python scripting for computational science" - I tracked down a cheapish > copy of the 3rd edition from 2009 and flipping through it (it only > arrived yesterday), it seems like it is going to be very useful. > Certainly it draws a lot on numpy, goes into using Tcl for GUIs, and a > number of recipes for scripting, regular expressions and so on ... lots > to get my head around. "Python scripting for computational science" also contains a section about solving differential equations. It is in one of the chapters about additional libraries. The book contains many Fortran examples. As an alternative to Fortran you should also look at Cython. This is a very fast, compiled companion language for Python. It produces *.so (*.dll) files that can be directly loaded into Python as modules. http://www.cython.org/ > With respect to my original question then, > equipped with this book you recommended, a book on differential > equations, and one on an intro to environmental modelling, that should > give me enough to work on for the time being. An other possible book for an inter library loan might be "Mathematical Models in Biology" from Leah Edelstein-Keshet. It contains many differential equations from different fields of biology. Additionally it contains a very good introduction how to write your own partial differential equations. It is not an ideal book for someone who wants to do numerical computations (like you), because the differential equations are solved symbolically with pen and paper. On the other hand: Why do numerical experiments, when you can find all possible solutions at once "just" with pen and paper. I believe however the real reason is, that the book was written before computers became cheap (1988). > > So, just wanted to close the circle by letting you know that I took your > recommendation, and it looks like it will pay off in time. Great! Eike. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re Problems with creating XML-documents
>> I'm having problems with creating XML-documents, >> because I don't seem to write it to a document correctly. >Is that because you don't understand XML or because the >output is not what you expect? How is the data being generated? >Are you parsing an existing XML source or creating the XML >from scratch? I'm not sure I understand your problem. I know the theory of XML but have never used it really and I'm a bit unsecure about it. Basically I'm doing the following: 1. retrieve data from a database ( instance in q ) 2. pass the data to an external java-program that requires file-input 3. the java-program modifies the inputfile and creates an outputfile based on the inputfile 4. I read the outputfile and try to parse it. 1 to 3 are performed by a seperate program that creates the XML 4 is a program that tries to parse it (and then perform other modifications using python) When I try to parse the outputfile it creates different errors such as: * ExpatError: not well-formed (invalid token): Basically it ususally has something to do with not-well-formed XML. Unfortunately the Java-program also alters the content on essential points such as inserting spaces in tags (e.g. id="value" to id = " value " ), which makes it even harder. The Java is really a b&%$#!, but I have no alternatives because it is custommade (but very poorly imho). Sorry, I've nog been clear, but it's very difficult and frustrating for me to troubleshoot this properly because the Java-program is quite huge and takes a long time to load before doing it's actions and when running also requires a lot of time. The minimum is about 10 minutes per run. This means trying a few little things takes hours. Because of the long load and processing time of the Java-program I'm forced to store the output in a single file instead of processing it record by record. Also each time I have to change something I have to modify functions in different libraries that perform specific functions. This probably means that I've not done it the right way in the first place. >> text = str('\n' + \ ' ' + str(instance.datetime) + ' \n' + \ ' ' + instance.order + ' \n' + \ '\n') >You can simplify this quite a lot. You almost certaionly don;t need >the outer str() and you probably don;t need the \ characters either. I use a very simplified text-variable here. In reality I also include other fields which contain numeric values as well. I use the \ to keep each XML-tag on a seperate line to keep the overview. >Also it might be easier to use a triple quoted string and format >characters to insert the dasta values. >> When I try to parse it, it keeps giving errors. >Why do you need to parse it if you are creating it? >Or is this after you read it back later? I don't understand the >sequence of processing here. >> So I tried to use an external library jaxml, >Did you try to use the standard library tools that come with Python, >like elementTree or even sax? I've been trying to do this with minidom, but I'm not sure if this is the right solution because I'm pretty unaware of XML-writing/parsing At the moment I'm tempted to do a line-by-line parse and trigger on an identifier-string that identifies the end and start of a record. But that way I'll never learn XML. >I think we need a few more pointers to the root cause here. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor