Re: [Tutor] find and replace relative to an nearby search string in a file

2009-07-13 Thread A.T.Hofkamp
Pete O'Connell wrote: Write { file /Volumes/raid0/Z353_002_comp_v27.%04d.cin file_type cin name Write1 xpos 13762 ypos -364 } The simplest approach imho is to parse the input with a proper parser, eg PLY or pyparsing. If you want to do the parsing manually, I'd start by classifying

Re: [Tutor] Why is there no uninstall option for setup.py?

2009-07-13 Thread A.T.Hofkamp
Hai, Welcome to the complexities of package management :) wcyee wrote: Hi, When I am able to find and install a windows package distributed as an exe file, I can just go to Add Remove Programs in the Control Panel and uninstall it. That's what I call an OS package manager. My Linux one

[Tutor] Pythonify this code!

2009-07-13 Thread Muhammad Ali
Hi, This is my first attempt at python. I tried my hand at steganography for fun. The code includes separate, combine, encode, decode functions. The separate function takes a number and it's base and returns a list containing each digit of the number in a list, vice versa for combine. The encode

Re: [Tutor] find and replace relative to an nearby search string in afile

2009-07-13 Thread Alan Gauld
Pete O'Connell pedrooconn...@gmail.com wrote I am always looking for the line name Write1 as my starting point. In the first example below, I want to replace the path, which is 2 lines above it. I have made a basic script to do that and it works fine. The problem I am having is when the

Re: [Tutor] Pythonify this code!

2009-07-13 Thread Alan Gauld
Muhammad Ali ali@gmail.com wrote I tried my hand at steganography Never heard of it before! #The code starts here: def separate(num, base): li = [] while num / base 0: li.insert(0, num % base) num = num / base li.insert(0,num) return li def combine(tup,

Re: [Tutor] Pythonify this code!

2009-07-13 Thread Luke Paireepinart
I tried my hand at steganography Never heard of it before![snip] I didn't notice anything that would be v3 specific. Also I can't comment on the algorithm since I don't really know what its doing! Alan, Steganography's really neat! You should look into it. Basically what his code

[Tutor] for statement with addition ...

2009-07-13 Thread Markus Hubig
Hi @all, within diveintopython I often found a for-statement like this: f for f in bla: print f So what actually is the first f for ... is it just to declare f before starting the for loop? I can't find any information on python.org and it's hard to google this kinda stuff. - Markus --

Re: [Tutor] Pythonify this code!

2009-07-13 Thread Dave Angel
Muhammad Ali wrote: Hi, This is my first attempt at python. I tried my hand at steganography for fun. The code includes separate, combine, encode, decode functions. The separate function takes a number and it's base and returns a list containing each digit of the number in a list, vice versa

Re: [Tutor] for statement with addition ...

2009-07-13 Thread Rommel Asibal
Markus, That looks like a typo. remove it and it should work. On Mon, Jul 13, 2009 at 4:50 AM, Markus Hubig mhu...@gmail.com wrote: Hi @all, within diveintopython I often found a for-statement like this: f for f in bla: print f So what actually is the first f for ... is it just to

[Tutor] Xampp Python

2009-07-13 Thread Rommel Asibal
Hello All, I am trying to go through the Python Power! book and i am at the part where i need to setup a web server. I am thinking of using XAMPP and have checked its site and wanted to try using mod_python. I am using Python 3.1 but from initial looks it seems mod_python doesnt support it,

Re: [Tutor] thesaurus

2009-07-13 Thread Dave Angel
Pete Froslie wrote: The url function btw: def url(): fin = open(journey_test.txt, r) response = re.split(r[/|/,\n, , ,:\\\.?,)(\-\\[\]'\r'], fin.read()) thesaurus = API_URL + response[word_number] + '/' #API_URL is established at the start of the code return thesaurus yes.

Re: [Tutor] for statement with addition ...

2009-07-13 Thread Dave Angel
Markus Hubig wrote: Hi @all, within diveintopython I often found a for-statement like this: f for f in bla: print f So what actually is the first f for ... is it just to declare f before starting the for loop? I can't find any information on python.org and it's hard to google this kinda

Re: [Tutor] for statement with addition ...

2009-07-13 Thread Markus Hubig
On Mon, Jul 13, 2009 at 2:08 PM, Dave Angel da...@ieee.org wrote: Markus Hubig wrote: Hi @all, within diveintopython I often found a for-statement like this: f for f in bla: print f So what actually is the first f for ... is it just to declare f before starting the for loop? I can't

[Tutor] Saving class instances

2009-07-13 Thread Thomas Scrace
part -- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20090713/ad0174f6/attachment-0001.htm -- Message: 2 Date: Mon, 13 Jul 2009 07:37:45 -0400 From: Kent Johnson ken...@tds.net To: Markus Hubig mhu...@gmail.com

Re: [Tutor] Saving class instances

2009-07-13 Thread Daniel Woodhouse
I think you are better off using a database in this situation, sqlite3 is a good choice since no extra setup is required. See http://docs.python.org/library/sqlite3.html And to answer your question, the python pickle module can save class instances, see http://docs.python.org/library/pickle.html

Re: [Tutor] Pythonify this code!

2009-07-13 Thread ALAN GAULD
Steganography's really neat! You should look into it. I did a quick lookup on Wikipedia. Basically what his code does is takes an image, and it twiddles the least significant bits Interestingly when I was at university the head of signal processing was into crypto stuff and was looking

Re: [Tutor] Saving class instances

2009-07-13 Thread Thomas Scrace
I think I will give both approaches a go, since this is just a learning exercise anyway. Thanks very much for your help. Oh, and sorry for accidentally quoting the whole digest last time. Won't happen again! Tom On 13 Jul 2009, at 17:53, tutor-requ...@python.org wrote: I think you are

Re: [Tutor] Saving class instances

2009-07-13 Thread Alan Gauld
Thomas Scrace t.scr...@gmail.com wrote class with attributes like name, artist, year etc. However, I am at a loss as to how to save these instances so that they can be retrieved the next time I run the program. I assume I need to write them to a file somehow, That's one way and you

[Tutor] browser encoding standards?

2009-07-13 Thread Serdar Tumgoren
Hi everyone, I just ran into a glitch that got me wondering about the proper encoding to use when outputting data for non-technical folks. I took pains to ensure that I converted a number of XML feeds to UTF-8 prior to storage in a database. And then, when pulling the feed data from a database

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Stefan Behnel
Serdar Tumgoren wrote: I just ran into a glitch that got me wondering about the proper encoding to use when outputting data for non-technical folks. I took pains to ensure that I converted a number of XML feeds to UTF-8 prior to storage in a database. And then, when pulling the feed data

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Serdar Tumgoren
I guess you forgot to output a meta tag that defines the content-type of the page. Aha! Yes indeed. I was just writing out data quick and dirty for testing purposes and forgot to write out the headers. I added Content Header info and all works fine. Thanks!

[Tutor] gtk.Notebook error

2009-07-13 Thread Amit Sethi
Hi , I am having problem with adding pages to gtk.Notebook : What I want is to be able to pass a random container widget to a new tab: thus my code is : class SmNotebook(gtk.Notebook): def __init__(self): gtk.Notebook.__init__(self) #set the tab

Re: [Tutor] gtk.Notebook error

2009-07-13 Thread Alan Gauld
Amit Sethi amit.pureene...@gmail.com wrote I am having problem with adding pages to gtk.Notebook : I know nothing about Gtk so I could mbe missing something here but Now while creating I do : def new_tab(widget,widget_render): notebook.new_tab(widget_render) notebook =

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Alan Gauld
Serdar Tumgoren zstumgo...@gmail.com wrote The problem I stumbled into is that when I used UTF-8, several characters showed up as gobbledygook in my Firefox browser. Specifically, the characters \u201c and \u201d (quote marks) were not carrying over. Some googling revealed that I should change

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Alan Gauld
Serdar Tumgoren zstumgo...@gmail.com wrote I guess you forgot to output a meta tag that defines the content-type of the page. Aha! Yes indeed. I was just writing out data quick and dirty for testing purposes and forgot to write out the headers. I added Content Header info and all works

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Serdar Tumgoren
meta http-equiv=content-type content=text/html;charset=UTF-8/ That's precisely the solution that worked for me, though I should say that I only tested this in Firefox 3 on Ubuntu 9.04. The below blog post circa 2006 suggests that IE at least uses some behind-the-scenes magic to decide on an

Re: [Tutor] find and replace relative to an nearby search string

2009-07-13 Thread pedro
Hi and thanks everyone for the enlightenment. I guess pyparsing is the way to go then. I just installed it and am trying it out. It looks good for all the stuff I need to do in Nuke frequently. I am going to do a bit of testing with Paul's solution. Cheers Pete