[Tutor] python equivalent of perl readlink()?

2006-10-15 Thread Bill Campbell
Is there a python equivalent of the perl readlink() function (e.g. one that returns the relative path in cases where a command such as ``ln -s ls /usr/local/bin/gls'' created the link? Reading the documentation on the various os.path functions, the only thing I see returns the fully resolved path

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Luke Paireepinart
On 10/14/06, Chris Hengge [EMAIL PROTECTED] wrote: Guess nobody has had a chance to point me in the write direction on this problem yet?Thats ok, I've gotten a ton of other code written, and I'll come back to this tricky part later.This particular project I've been working on to automate some of

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Chris Hengge
I must have not been clear.. I have a zip file with folders inside.. When I extract it.. I dont want the folder structure, just the files.. using split doesn't seem to help in this situation.. unless I'm not putting the results in the right spot.. Thanks again though. On 10/15/06, Luke

[Tutor] [OT] Python and Excel/OOCalc

2006-10-15 Thread Basil Shubin
Hi, friends! Is there exist python extension or library for writing or exporting data into the Excel and/or OO Calc file? Excuse me for crossposting. Thanks in advance! ___ Tutor maillist - Tutor@python.org

[Tutor] How to open file in Excel/Calc spreadsheet?

2006-10-15 Thread Basil Shubin
Hi ,friends! How I can open Excel or OOCalc spreadsheet file 'remotely' from python programm? I mean how to execute Excel or Calc with appropriate spreadsheet file? Thanks in advance! ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Kent Johnson
Chris Hengge wrote: I must have not been clear.. I have a zip file with folders inside.. When I extract it.. I dont want the folder structure, just the files.. using split doesn't seem to help in this situation.. unless I'm not putting the results in the right spot.. Can you show us what

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Kent Johnson
Chris Hengge wrote: I was using afile.split(/), but I'm not sure how to impliment it... Did you see my hint below? Is there something you don't understand about it? Kent if / in afile: (for some reason I can't add 'or \ in afile' on this line) outfile = open(afile, 'w') #

Re: [Tutor] How to open file in Excel/Calc spreadsheet?

2006-10-15 Thread Kent Johnson
Basil Shubin wrote: Hi ,friends! How I can open Excel or OOCalc spreadsheet file 'remotely' from python programm? I mean how to execute Excel or Calc with appropriate spreadsheet file? You can use win32com to drive Excel using its COM interface. The sample chapter from the O'Reilly book

[Tutor] Exception and sys.exit() in a cgi script

2006-10-15 Thread Paulino
This is a peace of a CGI script i have. 1 import cgi 2 form=cgi.FieldStorage() 3 try : 4 ano=form[ano].value 5 conta=form[conta].value 6 except KeyError : 7 print 'htmlbrbrbodypPlease enter values in the fields/p/body/html ' 8 sys.exit(0) When the excption occurs, no message is

Re: [Tutor] How to open file in Excel/Calc spreadsheet?

2006-10-15 Thread Paulino
Very simple: os.startfile([file]) ex: import os os.startfile("d:\\documentos\\eleicoes2005-dn.xls") It works with any file tipe in windows, the file is opened with it's associated application. Basil Shubin wrote: Hi ,friends! How I can open Excel or OOCalc spreadsheet file

Re: [Tutor] Exception and sys.exit() in a cgi script

2006-10-15 Thread Alan Gauld
Hi Paulino, This is a peace of a CGI script i have. 1 import cgi 2 form=cgi.FieldStorage() 3 try : 4 ano=form[ano].value 5 conta=form[conta].value 6 except KeyError : 7 print 'htmlbrbrbodypPlease enter values in the fields/p/body/html ' 8 sys.exit(0) When the

Re: [Tutor] Exception and sys.exit() in a cgi script

2006-10-15 Thread Paulino
Thank you, Yes I have other scripts working fine. The OS is WXP and the server is the python's CGIHTTPserver (for an intranet use only) - Hi Paulino, This is a peace of a CGI script i have. 1 import cgi 2 form=cgi.FieldStorage() 3 try : 4 ano=form["ano"].value 5

Re: [Tutor] How to open file in Excel/Calc spreadsheet?

2006-10-15 Thread wesley chun
How I can open Excel or OOCalc spreadsheet file 'remotely' from python programm? I mean how to execute Excel or Calc with appropriate spreadsheet file? there was a similar question on the main newsgroup a few days ago, slightly related to this post, but the answers will be helpful here.

Re: [Tutor] CGIHTTPServer - redirect output to a log file

2006-10-15 Thread Glenn T Norton
Paulino wrote: How can I redirect the output of an CGIHTTPServer from the console to a logfile? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor You can start it from a shell script #!/bin/sh ./MyWebServer.py

Re: [Tutor] CGIHTTPServer - redirect output to a log file

2006-10-15 Thread Paulino
well, I'm running this CGIserver on windows... Glenn T Norton escreveu: Paulino wrote: How can I redirect the output of an CGIHTTPServer from the console to a logfile? ___ Tutor maillist - Tutor@python.org

Re: [Tutor] CGIHTTPServer - redirect output to a log file

2006-10-15 Thread Alan Gauld
You can start it from a shell script #!/bin/sh ./MyWebServer.py 2/path/to/output.log Paulino [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] well, I'm running this CGIserver on windows... You can still use redirection although its not as powerful as unix. Just try C:\PATH

[Tutor] executing with double click on linux

2006-10-15 Thread Alfonso
Thank you for your answer, Jonathon. I have found that the problem ocurs only with programs that make use of glade files for the interface. With pure pygtk programs without using glade files, making a launcher with a simple double click works perfectly. But if the program builds his interface

[Tutor] an alternative to shutil.move()?

2006-10-15 Thread Alfonso
Is there an alternative in python to use shutil.move()? It copies the files and then removes the source file insted of just moving directly the file (don't know much about file systems, but I suppose that when you move using the shell, if both source and destination are in the same partition,

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Chris Hengge
After getting some sleep and looking at my code, I think I was just to tired to work through that problem =PHere is my fully working and tested code..Thanks to you all for your assistance!if / in afile: aZipFile = afile.rsplit('/', 1)[-1] # Split file based on criteria. outfile = open(aZipFile,

[Tutor] Equivalent to perl -e

2006-10-15 Thread Chris Lasher
My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python equivalent to perl -e 'some oneliner'? Embarassingly, I had no answer, but I figure, someone on the list will know. His use of Python is at

Re: [Tutor] Equivalent to perl -e

2006-10-15 Thread Kent Johnson
Chris Lasher wrote: My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python equivalent to perl -e 'some oneliner'? python -c More details here: http://linuxcommand.org/man_pages/python1.html

Re: [Tutor] Equivalent to perl -e

2006-10-15 Thread Glenn T Norton
Chris Lasher wrote: My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python equivalent to perl -e 'some oneliner'? Embarassingly, I had no answer, but I figure, someone on the list will know. His use

Re: [Tutor] python equivalent of perl readlink()?

2006-10-15 Thread Michael P. Reilly
On 10/15/06, Bill Campbell [EMAIL PROTECTED] wrote: Is there a python equivalent of the perl readlink() function(e.g. one that returns the relative path in cases where a commandsuch as ``ln -s ls /usr/local/bin/gls'' created the link?Reading the documentation on the various os.path functions,

Re: [Tutor] Equivalent to perl -e

2006-10-15 Thread Chris Lasher
Haha! I'll relay that message! Thanks Kent and Glenn! Chris On 10/15/06, Glenn T Norton [EMAIL PROTECTED] wrote: Chris Lasher wrote: My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Bill Burns
Chris Hengge wrote: After getting some sleep and looking at my code, I think I was just to tired to work through that problem =P Here is my fully working and tested code.. Thanks to you all for your assistance! if / in afile: aZipFile = afile.rsplit('/', 1)[-1] # Split file based on

Re: [Tutor] Equivalent to perl -e

2006-10-15 Thread Tim Peters
[Chris Lasher] My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python equivalent to perl -e 'some oneliner'? The initally attractive but unsatisfying answer is: python -c 'some oneliner' The

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-15 Thread Chris Hengge
The code in my last email that I stated worked, is doing exactly what I want (perhaps there is a better method, but this is working)The slash detection is for the subdirectories located inside of a zip file. The name list for a file located inside a zipped folder shows up as folder/file.ext in

[Tutor] Help with sessions

2006-10-15 Thread anil maran
I tried creating sessions for each appand then did htis codedef session_mw(app): sessionStore = DiskSessionStore(storeDir="%s/sessions/" % os.getcwd(), timeout=5) sessionStore= sessionStore.createSession() return SessionMiddleware(sessionStore, app)def initsession(session): session['id'] = 0

Re: [Tutor] Equivalent to perl -e

2006-10-15 Thread Chris Lasher
Points well taken. In fact, the example he demonstrated to me as a one-liner was a regular expression as a line filter in Emacs--essentially just a grep. There's no Pythonic equivalent to this. Right tool for the right job, as you said. He was half-joking about not learning Python if it lacked the

Re: [Tutor] python equivalent of perl readlink()?

2006-10-15 Thread Bill Campbell
On Sun, Oct 15, 2006, Michael P. Reilly wrote: On 10/15/06, Bill Campbell [EMAIL PROTECTED] wrote: Is there a python equivalent of the perl readlink() function (e.g. one that returns the relative path in cases where a command such as ``ln -s ls /usr/local/bin/gls'' created the