[Tutor] python equivalent of perl readlink()?

2006-10-14 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

[Tutor] executing with double click on linux

2006-10-14 Thread Jonathon Sisson
I'm afraid I don't have enough experience with Gnome to answer your questions, Alfonso. I will share what I know, though. If you could, run this: $ gnomevfs-info .pyc | grep MIME and see what it says? (If it gives you nothing back, then you need to register a MIME type for .pyc files. http

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
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 my job at work has been an excellent learning experie

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
Correction... The first comment I just realised I needed "\\" to make it work.. so that issue is gone.. On 10/14/06, Chris Hengge < [EMAIL PROTECTED]> wrote:I was using afile.split("/"), but I'm not sure how to impliment it... if "/" in afile: (for some reason I can't add 'or "\" in afile' on this

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
I was using afile.split("/"), but I'm not sure how to impliment it... if "/" in afile: (for some reason I can't add 'or "\" in afile' on this line)    outfile = open(afile, 'w') # Open output buffer for writing. (to open the file, I can't split here)     outfile.write(zfile.

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Kent Johnson
Chris Hengge wrote: > Ok, last problem with this whole shebang... > > When I write the file from the zip, if it is in a subfolder, it will > error.. > The code below will detect if the file in contained inside a directory > in the zip, but I just want it to write it like it wasn't. > Another wor

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
Ok, last problem with this whole shebang...When I write the file from the zip, if it is in a subfolder, it will error.. The code below will detect if the file in contained inside a directory in the zip, but I just want it to write it like it wasn't. Another wordsZipfile.zip looks like thisfile.extf

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
Got that working now, thanks. I've been using activepythons release, and they dont have 2.5 prepared yet. Guess I should just upgrade without them?On 10/14/06, Kent Johnson <[EMAIL PROTECTED]> wrote:Chris Hengge wrote: > Oops I get an error using that code..>> if filename.endswith('.cap','

Re: [Tutor] Building a simple text editor

2006-10-14 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Is it possible to make the utility like in vi, where the user keeps > on > entering the data and when he hits ':wq', the work is saved and the > application exists. YES BUT THE ACTUAL CODE TO READ KEYSTROKES AS THEY ARE TYPED WILL BE VERY DIFFERENT

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Kent Johnson
Chris Hengge wrote: > Oops I get an error using that code.. > > if filename.endswith('.cap','.fru','.hex') or > filename.endswith('.sdr', '.cfg'): > TypeError: slice indices must be integers or None With Python 2.5 you can do this with a tuple argument. You need an extra set of parenthe

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
Oops I get an error using that code..     if filename.endswith('.cap','.fru','.hex') or filename.endswith('.sdr', '.cfg'):TypeError: slice indices must be integers or None On 10/14/06, Bill Burns <[EMAIL PROTECTED]> wrote: Chris Hengge wrote:> First question..>> This is the code that I have:> f

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Kent Johnson
Bill Burns wrote: > Maybe take a look at 'endswith': > > Example: > for filename in zfile.namelist(): > if filename.endswith('.exe') or filename.endswith('.txt'): > # do something with filename In Python 2.5 endswith() can take a tuple of strings to try: if filename.endswith(('.e

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Chris Hengge
Excellent suggestion! Thanks!I have a question... is endswith() case sensitive?On 10/14/06, Bill Burns < [EMAIL PROTECTED]> wrote:Chris Hengge wrote:> First question.. >> This is the code that I have:> for filename in zfile.namelist():> outfile = open(filename, 'w')> outfile.write(z

Re: [Tutor] Reading escaped characters from a file

2006-10-14 Thread Kent Johnson
David Heiser wrote: > > I have code that uses variables to hold escaped characters like "\n" or > "\03". As long as the assignment is done within the code, like > self.crChar = "\n", there is no problem. But When I try to read the > same character string from a text file and assign it, the str

Re: [Tutor] A puzzle for you

2006-10-14 Thread Bob Gailer
John Fouhy wrote: > >From the python_dev LiveJournal community --- > > Predict the outcome of the following code: > > ## > from random import * > seed() > [choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0] > ## > Hmm - interesting. Given that the argument of random.choice is sup

Re: [Tutor] Building a simple text editor

2006-10-14 Thread wesley chun
> I am trying to build a simple text editor which has a couple of options of > editing, displaying and saving the file. > Now what I want to do is to allow teh user to keep entering the text unless > he pressed ':q'. reading of and writing of a text file is one of the examples i added to "Core Py

Re: [Tutor] Reading escaped characters from a file

2006-10-14 Thread wesley chun
> I have code that uses variables to hold escaped characters like "\n" or > "\03". As long as the assignment is done within the code, like self.crChar = > "\n", there is no problem. But When I try to read the same character string > from a text file and assign it, the string is seen as just a strin

Re: [Tutor] Reading escaped characters from a file

2006-10-14 Thread Luke Paireepinart
David Heiser wrote: > > I have code that uses variables to hold escaped characters like "\n" > or "\03". As long as the assignment is done within the code, like > self.crChar = "\n", there is no problem. But When I try to read the > same character string from a text file and assign it, the str

[Tutor] Reading escaped characters from a file

2006-10-14 Thread David Heiser
Title: Message   I have code that uses variables to hold escaped characters like "\n" or "\03". As long as the assignment is done within the code, like self.crChar = "\n", there is no problem. But When I try to read the same character string from a text file and assign it, the string is seen

Re: [Tutor] Building a simple text editor

2006-10-14 Thread Asrarahmed Kadri
  Is it possible to make the utility like in vi, where the user keeps on entering the data and when he hits ':wq', the work is saved and the application exists.   I guess the use of standard input file would be applicable???   Thanks. Regrds, Asrar  On 10/14/06, Alan Gauld <[EMAIL PROTECTED]> wrote

Re: [Tutor] Building a simple text editor

2006-10-14 Thread Alan Gauld
> I am trying to build a simple text editor which has a couple of > options of > editing, displaying and saving the file. Are you using a GUI or console? The solution is potentially quite different depending on the choice. > Now what I want to do is to allow teh user to keep entering the text >

[Tutor] Building a simple text editor

2006-10-14 Thread Asrarahmed Kadri
  Folks,   I am trying to build a simple text editor which has a couple of options of editing, displaying and saving the file. Now what I want to do is to allow teh user to keep entering the text unless he pressed ':q'.   How can I add this functionality??   Thanks. REgards, Asrar -- To HIM you sha

Re: [Tutor] Python Magazine

2006-10-14 Thread Amadeo Bellotti
i saw it but it didnt quite meet what i wanted :\On 10/14/06, Glenn T Norton <[EMAIL PROTECTED]> wrote: Amadeo Bellotti wrote:> I no im probally not the best pereson to go about this but maybe > people in this community are. I was wondering if there was or maybe> someone can start a Python maganize

Re: [Tutor] Python Magazine

2006-10-14 Thread Glenn T Norton
Amadeo Bellotti wrote: > I no im probally not the best pereson to go about this but maybe > people in this community are. I was wondering if there was or maybe > someone can start a Python maganize kinda like 3dCreative or 2d > Artist. that is an PDF magazine with tutorials interviews, python

[Tutor] Python Magazine

2006-10-14 Thread Amadeo Bellotti
I no im probally not the best pereson to go about this but maybe people in this community are. I was wondering if there was or maybe someone can start a Python maganize kinda like 3dCreative or 2d Artist. that is an PDF magazine with tutorials interviews, python news, and maybe a programming challe

Re: [Tutor] A puzzle for you

2006-10-14 Thread Glenn T Norton
John Fouhy wrote: >>From the python_dev LiveJournal community --- > >Predict the outcome of the following code: > >## >from random import * >seed() >[choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0] >## > > > random.choice( [ SyntaxError: invalid syntax, 42 the answer is young

Re: [Tutor] tkinter tutorials

2006-10-14 Thread Alan Gauld
"Alan Gauld" <[EMAIL PROTECTED]> wrote > Tkinter has not changed hardly at all. Yuk, a double negative, sorry. That should of course say: Tkinter has hardly changed at all. Hopefully that was obvious from my subsequent comments! Alan G. ___ Tutor

Re: [Tutor] Zipfile and File manipulation questions.

2006-10-14 Thread Bill Burns
Chris Hengge wrote: > First question.. > > This is the code that I have: > for filename in zfile.namelist(): > outfile = open(filename, 'w') > outfile.write(zfile.read(filename)) > outfile.close() > > Is there a way to say : > for filename in zfile.namelist() contains '.tx

Re: [Tutor] tkinter tutorials

2006-10-14 Thread Alan Gauld
> Danny, "Python and Tkinter Programming" is still in its first > edition, which came out in 2000. Python has changed a lot since > then. > Hasn't Tkinter? Is the book still usable by a Tkinter beginner? Tkinter has not changed hardly at all. The only shame about the book is that it strongly feat

Re: [Tutor] How to read content in a tar file with tarfile module

2006-10-14 Thread Magnus Wirström
Thank you for all the answers. Sorry for not replying but i have been very busy this week I will try all the suggested ways. //Magnus Magnus Wirström skrev: > Hi everyone > > I have written a app that makes a tar file and all works well... Now i > want to expand that app so it can read read the