[Tutor] CGI script to create an XML document from an HTML form

2005-03-22 Thread Gabriel Farrell
Hi, I'm just starting to get my feet wet with Python. I'm trying to write a CGI script to create an XML document using input from a web form. The created document would be a MODS record[1], so I already have a Schema for it. I think I could make it work if I just feed the input into a long strin

Re: [Tutor] Defining functions

2005-03-25 Thread Gabriel Farrell
So, as a newbie, I see this thread and I check out the PEP and I see that for future compatibility we should use sys.stdin.readline(). So I import sys to see how it works. Of course, sys.stdin.readline('type anything: ') doesn't work in quite the same way as raw_input('type anything: ') does. Th

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Gabriel Farrell
how about manyones = [ 1 for x in range(96) ] On Sat, Mar 26, 2005 at 03:02:34AM +0800, jrlen balane wrote: > basically, i'm going to create a list with 96 members but with only one value: > > list1[1,1,1,1...,1] > > is there a shorter way to write this one??? > ___

[Tutor] sys.path.append issues with cgi

2005-04-14 Thread Gabriel Farrell
Hello all, I'm trying to modify the sys.path in my cgi scripts to import modules that I've installed in my home directory. The top of the script reads as follows: #!/usr/local/bin/python import cgi, sys sys.path.append('/net/u/16/g/gsf/lib/python2.4/site-packages') from ElementTree import Elem

Re: [Tutor] sys.path.append issues with cgi

2005-04-14 Thread Gabriel Farrell
Sorry, addendum to that post. The line from ElementTree import Element, SubElement, tostring should read from elementtree.ElementTree import Element, SubElement, tostring but that still doesn't work. gabe ___ Tutor maillist - Tutor@python.org h

Re: [Tutor] sys.path.append issues with cgi

2005-04-18 Thread Gabriel Farrell
e libs are simply not accessible. This situation is particular to my web hosting service, so it may not apply to others who are running python cgi scripts and importing modules. gabe On Thu, Apr 14, 2005 at 06:43:26PM -0400, Gabriel Farrell wrote: > Hello all, > > I'm trying to m

[Tutor] making a cgi search safe(r)

2005-05-04 Thread Gabriel Farrell
Greetings, I'm setting up a search for an online catalog. It works right now by passing the cgi search query to the command-line swish-e via os.popen. I'll do it via a direct interface as soon as I figure out how to do that with swig or the swishe module. In the meantime, I'm trying to sanitize

Re: [Tutor] XML to Python

2005-05-06 Thread Gabriel Farrell
On Thu, 5 May 2005, Smith, Jeff wrote: > I'm able to use the built in XML parser to effect "normal" XML parsing > usage but frequently, I'm not doing anything to complicated and would > simply like to translate the XML file into a more "Pythonic" structure. > What's the best way to do this? Some

Re: [Tutor] output of dictionaries

2005-05-10 Thread Gabriel Farrell
take a look at pickle and shelve. info about both can be found at http://docs.python.org/lib/python.html On Tue, May 10, 2005 at 08:46:50AM -0700, Tom Cloyd wrote: > I'm creating a small database using a dictionary of dictionaries, and I > want to output it to a file. It seems that only strings

Re: [Tutor] Python versions and Debian?

2005-05-11 Thread Gabriel Farrell
Hi William, The short answer is go with the default until you run into something you can't do without 2.4. For the skinny on all the changes you'll want to check out http://python.org/doc/2.4/whatsnew/whatsnew24.html . That document lays it out about as well as can be done. If you find somethin

Re: [Tutor] Building an SQL query

2005-06-03 Thread Gabriel Farrell
On Thu, Jun 02, 2005 at 10:41:20PM +0100, Alan G wrote: > Why not convert the list to a tuple before applying str(): > > str(tuple(ids_to_process)) I'm just getting started with Python and PostgreSQL but I found that str(tuple(valueList)) wouldn't work for me because I had a few values with apost

Re: [Tutor] Building an SQL query (Gabriel Farrell)

2005-06-03 Thread Gabriel Farrell
On Fri, Jun 03, 2005 at 03:50:09PM -0400, Lloyd Kvam wrote: > The code to update the database should look something like: > the_cursor.execute( sql_cmd, data) > In PyGreSQL/pgdb it's cursor.execute(query[, params]) but it means more or less the same thing because pgdb's paramstyle (I knew from the

Re: [Tutor] Problem with pgbd & datetime

2005-07-27 Thread Gabriel Farrell
Are you using PyGreSQL? import pgdb works fine for me with PyGreSQL. I'm on Debian but I assume there's a package for it for SUSE. gsf On Wed, Jul 27, 2005 at 10:13:22AM -0400, Don Parris wrote: > O.k., I'm running SUSE Linux 9.2, Python 2.3.4, > > I have changed my DB back-end from MySQL t

Re: [Tutor] anything to do???

2005-07-27 Thread Gabriel Farrell
I assume you have checked out http://wiki.python.org/moin/VolunteerOpportunities . I've improved a lot by just reading this list and following along with the successes and failures (always temporary, I hope) of others. gsf On Wed, Jul 27, 2005 at 10:20:43PM +0500, Mustafa wrote: > i hav just fi

Re: [Tutor] Problem with pgbd & datetime

2005-07-28 Thread Gabriel Farrell
On Wed, Jul 27, 2005 at 07:13:49PM -0400, Don Parris wrote: > pg/pgdb are both part of the PyGreSQL distribution. You can choose > whichever you want to use, but pgdb supports the 2.0 API, whereas > (according to the readme) pg does not. I will try pg when I get back > to my box tonight, but woul

Re: [Tutor] Python Editors (particualrly Vim)

2005-09-21 Thread Gabriel Farrell
Uh oh, looks like you're begging for an editor war. That said, I'm in the vim camp. It can do everything you specified for all of the languages you mention (well, I'm not sure about collapsible code...web search...aha![1]). After using it for four years, I'm still learning new tricks (see, for

Re: [Tutor] Linking with C programs

2005-09-27 Thread Gabriel Farrell
You can read some of what Guido has to say about Python and C at http://python.org/doc/essays/omg-darpa-mcc-position.html and see SWIG documentation (a few pertain to Python) at http://www.swig.org/doc.html gsf On Tue, Sep 27, 2005 at 08:41:31AM -0600, Eric Walker wrote: > There is a program cal

Re: [Tutor] greetings...

2005-10-21 Thread Gabriel Farrell
Welcome to the list, Carl. Feel free to browse the list archive at http://mail.python.org/pipermail/tutor/ or http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/python-Tutor to get some idea of the kinds of questions asked and answers given. You'll find a lot of suggestions for beginners among

Re: [Tutor] file permissions

2005-12-07 Thread Gabriel Farrell
On Wed, Dec 07, 2005 at 11:52:20AM -0800, Danny Yoo wrote: > On Wed, 7 Dec 2005, Eric Walker wrote: > > > Looking for easiest way to get a files permissions in linux. > > Hi Eric, > > What have you looked at so far? I agree with Danny, the question lacks any evidence of prior investigation on t

Re: [Tutor] file permissions

2005-12-07 Thread Gabriel Farrell
On Wed, Dec 07, 2005 at 02:51:55PM -0700, Eric Walker wrote: > After 4+ hours > of playing around with this I made the futile post. Don't let the post be futile! Post what you've tried so far and you'll get help. gsf ___ Tutor maillist - Tutor@p

Re: [Tutor] ElementTree in Python 2.5!

2005-12-16 Thread Gabriel Farrell
This is great news. And the thread on comp.lang.python is awesome. The eff-bot and the martelli-bot and everyone's just talking about how great it would be to have it in the core, and, then, it just ... happens. Wow! gsf On Wed, Dec 14, 2005 at 03:20:38PM -0500, Kent Johnson wrote: > By some m

[Tutor] tempfile and passing files around

2006-07-11 Thread Gabriel Farrell
I have an issue with the tempfile module that I can't figure out. Snippet of relevant script looks like so: 1 bob = tempfile.NamedTemporaryFile() 2 bob.write('Hallo!') 3 bob.read() 4 sam = tempfile.NamedTemporaryFile() 5 bobHandle = file(bob.name) 6 bobHandle.read() As you can see, I

Re: [Tutor] tempfile and passing files around

2006-07-11 Thread Gabriel Farrell
On Tue, Jul 11, 2006 at 03:04:02PM -0400, Kent Johnson wrote: > Try bob.flush() instead of bob.read(), my guess is the read() is forcing > a flush(). That works! Thanks, Kent. If I understand flush (looking at [1]), I got no output because the data for the stream wasn't written to the file befo

[Tutor] piping to system commands

2006-07-13 Thread Gabriel Farrell
I'm trying to create a master dictionary in aspell, and I can do so with the following: inFile = tempfile.NamedTemporaryFile() inFile.write(wordList) inFile.flush() command = 'aspell --lang=en --dont-validate-words create master %s < %s' % \ ('./dict.cwl', inFile.name)

[Tutor] cartesian product recursive loop

2006-07-18 Thread Gabriel Farrell
In trying to combine a set of lists together, I landed upon http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302478 , which does the job beautifully. The problem is I really want to understand how it does it, and I can't quite get my brain wrapped around it. I'll try to explain, step by ste

Re: [Tutor] cartesian product recursive loop

2006-07-18 Thread Gabriel Farrell
On Tue, Jul 18, 2006 at 01:33:27PM -0400, Kent Johnson wrote: > Each call to rloop() has its own local variables and its own state. > Returning from one call doesn't pop all the way up the stack, it > resumes execution at the point of call with the local state restored > to what it was before the c

Re: [Tutor] lists and recursion

2006-07-22 Thread Gabriel Farrell
On Sat, Jul 22, 2006 at 06:20:12AM -0400, Kent Johnson wrote: > We just had a discussion of recursion, you might want to look at it - > though the code is a bit more complex than this example. > http://mail.python.org/pipermail/tutor/2006-July/048081.html Glad to see I'm not the only one to get t

Re: [Tutor] What after Learning Python 2nd

2006-10-09 Thread Gabriel Farrell
On Mon, Oct 09, 2006 at 10:51:26AM -0700, josip wrote: > Hi. > > Hi I have finished Learning Python 2nd ed. > What to do next? > Should I go with Programming Python book or Python Cookbook or? > Or maybe something else? > > Thanks people! > I went from Learning Python to the

Re: [Tutor] XML parsing in Python.. resources needed

2006-10-27 Thread Gabriel Farrell
On Fri, Oct 27, 2006 at 11:24:00AM +0100, Asrarahmed Kadri wrote: > Hi Folks, > > ANy comments about ELementTree module... > > I have heard that it is more 'Pythonic'... > > I need some basic examples to start learning the stuff.. If anyone has got > the information, please pass it along.. > E

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-09 Thread Gabriel Farrell
On Thu, Nov 09, 2006 at 06:23:50PM +, Asrarahmed Kadri wrote: > Hi Folks, > > > I am trying to parse XML documents using elementtree. > I have just started with it. Can somebody help me with how to select nodes > with a particular atribute set to some value. For example, I have the > followin

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-09 Thread Gabriel Farrell
On Fri, Nov 10, 2006 at 10:23:49AM +1300, John Fouhy wrote: > On 10/11/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote: > > I am trying to parse XML documents using elementtree. > > I have just started with it. Can somebody help me with how to select nodes > > with a particular atribute set to some

Re: [Tutor] Best IDE for Python

2007-01-29 Thread Gabriel Farrell
On Sat, Jan 27, 2007 at 02:58:38AM -0800, Dick Moores wrote: > > > At 07:12 PM 1/24/2007, Shadab Sayani wrote: > Hi, > I am using vim editor to code my project in python.Is there a good > IDEĀ  where in I type the name of the class object and then dot then > all the attributes of the object are di

[Tutor] A complete, functioning small web app: code for review

2007-02-09 Thread Gabriel Farrell
): User ${username | h} has been removed. % endfor % if form.getvalue('no_backups'): No backups to revert to. % endif % if form.getvalue('bak_days'): % if form.getvalue('bak_days') == 1: Reverted to