Re: [Tutor] Making pretty web pages from python code examples?

2010-04-14 Thread Modulok
  : 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

2010-04-14 Thread Dilip M
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

2010-04-14 Thread Dilip M
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

2010-04-14 Thread Bjorn Egil Ludvigsen
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 dilip...@gmail.com 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

2010-04-14 Thread Karjer Jdfjdf
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('?xml version=1.0 encoding=iso-8859-1?\n')
    
    for instance in query:    
    if doc != None:
    text = str('record id=' + str(instance.id)+ '\n' + \
   ' date' +  str(instance.datetime) + ' /date\n' + \
   ' order'  + instance.order +  ' /order\n' + \
   '/record\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

2010-04-14 Thread bob gailer

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('?xml version=1.0 encoding=iso-8859-1?\n')

for instance in query:
if doc != None:
text = str('record id=' + str(instance.id)+ '\n' + \
   ' date' +  str(instance.datetime) + ' 
/date\n' + \

   ' order'  + instance.order +  ' /order\n' + \
   '/record\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

2010-04-14 Thread Alan Gauld

Karjer Jdfjdf karper12...@yahoo.com 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('record id=' + str(instance.id)+ '\n' + \

' date' + str(instance.datetime) + ' /date\n' + \
' order' + instance.order + ' /order\n' + \
'/record\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

2010-04-14 Thread Eike Welk
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