Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Eric Walstad
Hi Robert On Thu, Apr 10, 2008 at 1:34 PM, Robert Kirkpatrick <[EMAIL PROTECTED]> wrote: > Hi All, > > Just wondering if there are any basic conventions for including code > snippets that are for testing / debugging only? > > For example, you could set a boolean variable called DEBUG, then have

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Eric Walstad
Hey Alex, On Thu, Apr 10, 2008 at 1:43 PM, Alex Krycek <[EMAIL PROTECTED]> wrote: > Eric, > > I'm sorry, I never actually managed to get any stylesheets to work with my > cgi scripts. The scripts that did work are just simple HTML. I'm using > Apache 2.2.8 on a Mac OS X 10.4.11 system. If I underst

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Eric Walstad
Hi Alex, On Thu, Apr 10, 2008 at 1:22 PM, Alex Krycek <[EMAIL PROTECTED]> wrote: > Hi, > > I've looked all over the internet but have not found an answer to my > question. How do I apply an external stylesheet to the XHTML in a Python > script? I tried to include the standard " type='text/css' href

Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Eric Walstad
On Wed, Apr 9, 2008 at 9:43 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I'd never used Pylint until yesterday ... > Since when is 'az' a bad variable name? And 'AZ' is OK? ... > Comments? I understand that Pylint settings and output are *very* customizable. I seem to remember talk about a PEP['S

Re: [Tutor] Code optmisation

2008-04-07 Thread Eric Walstad
Hi Yogi On Fri, Apr 4, 2008 at 10:05 PM, yogi <[EMAIL PROTECTED]> wrote: > Hi , >Here is my first usable Python code. > The code works. Woohoo! congratulations. > Here is what I'm trying to do. > I have two huge text files. After some processing, One is 12M (file A) and > the other

Re: [Tutor] Diff for Python

2008-04-05 Thread Eric Walstad
> > Whoop, I should have specified I'm on Win XP. > > > Eric Walstad wrote: > Hi Wayne, > > On Fri, Apr 4, 2008 at 8:37 PM, Wayne Watson > <[EMAIL PROTECTED]> wrote: > > > Is there a Linux diff-like command for Python code? I'd like to see the &

Re: [Tutor] Python Newbie: Lost in Loop

2008-04-04 Thread Eric Walstad
Hi Yogi, welcome to Python! yogi wrote: ... > if (str(gen) == str(row[0])): > print 'Match for 16 found Is the conversion to string really necessary? Even if it is, do it once for gen, when you define it: gen = '16' so you don't have to convert on every iteration of the

Re: [Tutor] Saving an Image in a Given Format

2008-03-31 Thread Eric Walstad
Wayne Watson wrote: > current_image ... convert() and > save() must be methods in that class. The question is what class/module? > PIL? I don't know, but you could try the following from the python command line, which might give you some hints: dir(current_image) current_image.foobarfizzbang

Re: [Tutor] rsync python script

2008-03-21 Thread Eric Walstad
Kaushal Shriyan wrote: > Hi > > [EMAIL PROTECTED] > 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ > > If i put this two lines in crontab it will run correctly,My requirement > was to create a python script, this python script should indicate > succes

Re: [Tutor] CSV file processing...

2008-03-21 Thread Eric Walstad
Hey Spencer, Spencer Parker wrote: > This is why I should not be allowed to write emails at the end of the > day. At least ones that need deep explanation. Let's try this a second > time. Thanks, this looks better, but... > This is what I have now... *What isn't working* the way you want? T

Re: [Tutor] CSV file processing...

2008-03-20 Thread Eric Walstad
Hi Spencer Spencer Parker wrote: > I have a > piece of software that runs and each iteration is one like. I don't understand what this means. > It only > runs once right now; there is only one line + the headers. I use the > csv module to kill the headers and import the one line. Does 'kill

Re: [Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Eric Walstad
Hey Timmie, Tim Michelsen wrote: >> When I do this sort of thing I like >> to move my imports into my functions/methods. > Would this then be compliant with the style recommendations? Hm, I'm not sure. I guess that if you consider that somewhere near the top of the style guide it says something a

Re: [Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Eric Walstad
Hi Tim, Tim Michelsen wrote: > Hello fellow Pythonistas, > I have a question concerning import statements. ... > it takes a lot > of time for a TKinter-GUI to start up. And this start-up time is even > longer when matplotlib is imported > a optimized version would be: > import sys > > plot_

Re: [Tutor] c++::return

2008-03-18 Thread Eric Walstad
elis aeris wrote: > I seriously have done my homework on writing in python I wonder if I am misunderstanding your question. This is a simple question about how functions work in Python, right? Something that most every beginning tutorial covers? You wouldn't be asking here if you had done you

Re: [Tutor] c++::return

2008-03-18 Thread Eric Walstad
elis aeris wrote: > what do I do if i want the program/function to end? > > > in c++ of > > int main(){} > > I do a return 0; What have you tried in Python? How did it work and what didn't work the way you expected? What Python documentation or tutorials have you read? Maybe helpful: http:/

Re: [Tutor] python, wxpython and postgresql

2008-03-17 Thread Eric Walstad
Hey Bill, Bill Mais wrote: > I'm a newbie to python and would like to build a database app with > wxpython and postgresql. I would suggest you first write the basic app to work from the command line. It's easy to debug that way and enables you to focus on the critical features of your app witho

Re: [Tutor] SSH with Python

2008-02-27 Thread Eric Walstad
Hey Eric, Eric Brunson wrote: > Eric Walstad wrote: >> Eric Brunson wrote: >> >> import pexpect ... >> child.sendline("nottherealpassword") ... >> > > What's the path to ssh under windows vista? I hope I never have to find out :) &g

Re: [Tutor] SSH with Python

2008-02-27 Thread Eric Walstad
Eric Brunson wrote: > Tom wrote: >> I have a webfaction server (highly recommended btw) and I'm trying to >> use automate some tasks over ssh but I'm not having much luck with >> pyssh http://pyssh.sourceforge.net/ . >> >> Some of the docs mention methods that don't exist in the version I >> downlo

Re: [Tutor] ssh script

2008-01-24 Thread Eric Walstad
Hi Washake, Here's a sample I just whipped up from the example I found here: Note that I had to tweak the 'tunnel_command' line a bit as it was missing the conversion type. This sets

Re: [Tutor] ssh script

2008-01-23 Thread Eric Walstad
I've done similar with pexpect: http://pexpect.sourceforge.net/ washakie wrote: > Hello, I'm trying to write a script which will allow me to create a reverse > tunnel from a remote machine using SSH -R > > I know the reverse tunnel script works on it's own run from the shell, but I > don't want

Re: [Tutor] XML data reading [slightly off topic/silly]

2007-12-20 Thread Eric Walstad
Lockhart, Luke wrote: > ...now I'm a > Linux man and trying to realize my overly ambitious programming dreams > with Python Welcome to the real world, Neo. I'm not saying that you'll be able to work with XML via DOM or SAX in Python. I'm saying that when you are ready, you won't have to. :) (

Re: [Tutor] Noob question

2007-12-09 Thread Eric Walstad
Eric Brunson wrote: > quantrum75 wrote: >> Hi there, >> I am a newbie trying to actively learn python. >> My question is, >> Suppose I have a list >> a=["apple","orange","banana"] >> >> How do I convert this list into a string which is >> >> b="appleorangebanana" >> Sorry for my ignorance, > > No

Re: [Tutor] Turning multiple Popen calls into a function

2007-11-01 Thread Eric Walstad
Hi Jay... jay wrote: ... > I would be sending an arbitrary number of PIPES with each function call. > > I'm a little stumped as to how to handle the variables. If I have an > arbitrary number of PIPES, how do I declare my variables (p1, p2, p3, > etc...) ahead of time in the function?? > > Tha

Re: [Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Eric Walstad
Dick Moores wrote: > That looks like a very nice, concise tutorial that should help soup noobs like me to get up and running quickly. I like the added value of comments like: "Under the hood, attribute access is actually a search for the first

Re: [Tutor] how to read from a csv file?

2007-10-22 Thread Eric Walstad
Tim Golden wrote: > You really just want to rename __init__ to rawdata > and drop the redundant "return rawdata" function. But remember to include the line: return rawdata at the end of your function or else nothing will be printed when print csvdatareader.rawdata() is called. Also, I'd cons

Re: [Tutor] An idea for a script

2007-10-10 Thread Eric Walstad
Dick Moores wrote: > I think I could learn a lot about the use of Python with the web by > writing a script that would look at > and find all the links > to more that just the default shown by this one: > . I

Re: [Tutor] Updating MySQL Database

2007-10-07 Thread Eric Walstad
Hey Sam, wormwood_3 wrote: > Hello all, > > I have a script which takes data from a file or MySQL DB, looks up some > stuff, then can print results to console or file. I would also like it to be > able to update a MySQL database with the results. Does anyone have any ideas > on how to do this?

Re: [Tutor] Apache, CGI-BIN, Python

2007-09-11 Thread Eric Walstad
Ryan wrote: > Jan Erik Moström wrote: >> Ryan <[EMAIL PROTECTED]> 07-09-10 15:35 >> >>> Once I edit the config files for cgi scripts the browser says I don't >>> have permission to access the file. >> You must make sure that the script file has execute/read permissions >> for the process/user who

Re: [Tutor] Python / CGI

2007-09-06 Thread Eric Walstad
Michael Connors wrote: > Hi, > If you have your own server to run it on, I think it would make sense to > use one of the Python web frameworks that are out there. I used cherrypy > for my first web-based python project and I found it very easy to learn > and develop in quickly. > Regards, > Michael

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Walstad
Philippe Niquille wrote: > Using django I get a QuerySet of Score objects which are sorted by the > actual score, the actual score divided by the max. possible score (so > sorting by two db fields). > > I then need to loop through that queryset and sum up all the score > objects which belong to th

[Tutor] write a movie file thumbnail in Linux...

2007-07-01 Thread Eric Walstad
Hi all, Nautilus does it when I browse to a directory that contains images and movie files created with my digital camera. I see thumbnails of the image (jpeg) and the movie (mov) files. I use python to process (rename, make reduced resolution copies (PIL)) of my image files. I'd like to also h

Re: [Tutor] trouble with "if"

2007-05-23 Thread Eric Walstad
Hi Adam, adam urbas wrote: > when I input a radius, it says: > > can't multiply sequence by non-int of type 'float' ... > > radius=raw_input("Enter Radius:") > > diameter=(radius*2) After you collect the raw_input for the radius, the radius variable contains a string, not a number (that's what

Re: [Tutor] trouble with "if"

2007-05-23 Thread Eric Walstad
adam urbas wrote: > Hi all, > > I've been working with this new program that I wrote. ... > #"User's Choice:" > shape=raw_input("> ") > > #"Select Given:" > if shape == 1: ... [EMAIL PROTECTED]:~$ python Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubunt

Re: [Tutor] ImportError: No module named _apache

2007-05-15 Thread Eric Walstad
Hey ShivKumar, ShivKumar Anand wrote: > *I am getting this error message:* > > Traceback (most recent call last): > File "C:\Python24\exp\Web\SoapTest.py", line 1, in ? > from mod_python import apache > File "C:\Python24\lib\site-packages\mod_python\apache.py", line 28, in ? > import

Re: [Tutor] How to test for a remainder from division

2007-05-15 Thread Eric Walstad
Hey Matt, Matt Smith wrote: > I guessed that there would be a module out > there providing a function to do this but wanted to go through the > process as a learning exercise. Good form, old boy. > Here is the final code I have come up with, any comments? I think your code looks fine. I like to

Re: [Tutor] How to test for a remainder from division

2007-05-14 Thread Eric Walstad
ainder of the division. > > Can anyone suggest a better way of performing this test or alternately, > how can I get the line above to work. > > Thanks, > > Matt > > > ___ > Tutor maillist - Tutor@python.org > http://

Re: [Tutor] Python fast enough for ad server?

2007-05-12 Thread Eric Walstad
gh any negatives. >> >> Maybe once its a working project, we can then benchmark the code and see >> what gives. >> >> Thanks again, >> >> Lloyd >> >> On 5/9/07, Eric Walstad <[EMAIL PROTECTED]> wrote: >> > >> > Hey

Re: [Tutor] Web GUI for a network management tool

2007-05-10 Thread Eric Walstad
Hi Thanos, Alan Gauld wrote: > "Thanos Panousis" <[EMAIL PROTECTED]> wrote > >> The time has come to write some kind of gui for it, so that graphs, >> visualizations and configuration options are exposed to non >> developers. Do you think that a web app frame work like turbogears >> is >> approp

Re: [Tutor] Python fast enough for ad server?

2007-05-09 Thread Eric Walstad
Hey OkaMthenbo, OkaMthembo wrote: > Hi guys, > > I need to write an ad-serving application and i'm using Win XP as my dev > platform. Naturally, i want it to be as painless as possible and i was > thinking of writing it 100% in Python. However, i have not written any > big apps in the language an

Re: [Tutor] help me to do my exercise

2007-03-05 Thread Eric Walstad
In addition to what the others have said, you have a syntax error on line 7 of your leap.py file. The 'for' loop will want an iterable to loop over. The syntax error relates to the list you are trying to use, a slice of sys.argv. Remember, lists are denoted by square brackets '[' and ']'.

Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Eric Walstad
Hey Mark, Mark Bystry wrote: > sh.copy('C:\testing_it.txt', 'D:\') Also have a look at the os.path module. Because you want these scripts to work on both Linux and Windows, using os.path will let you avoid writing platform specific code to handle your slashes. For example: import os path_parts_l

Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Eric Walstad
Hey Mark, welcome aboard! There are a few different approaches you could take to convert your scripts. If most of your scripts are related to copying/moving files, I'd have a look at Python's shutil module. I think it'll work in both Windows and Linux but I don't have a Windows machine handy to

Re: [Tutor] Optimal solution in dealing with huge databases inpython

2007-01-25 Thread Eric Walstad
Alan Gauld wrote: > "Shadab Sayani" <[EMAIL PROTECTED]> wrote > >> Thank you very much for immediate response.I didnt get >> the point of loading the data using SQL.What does that >> mean? > > It means writing a SQL file that can then be run from > the database SQL prompt. I don't know what tha

Re: [Tutor] Optimal solution in dealing with huge databases in python

2007-01-25 Thread Eric Walstad
Alan Gauld wrote: > "Shadab Sayani" <[EMAIL PROTECTED]> wrote > >> The data I need to deal with is in 100s of GB. >> I am using postgresql backend and SQLALCHEMY ORM. > > All ORMs will introduce a significant performance hit. > If you really need high speed, and populating a 100G+ database > p

Re: [Tutor] (no subject) (fwd)

2007-01-19 Thread Eric Walstad
Hey Max, Danny Yoo wrote: > [Forwarding to tutor. Can someone answer Max? Slightly busy at the > moment. Quick note: get him to realize that the list he was playing > with originally had three elements. The example in his book has two > elements. Something has to change. *grin*] > > > --

Re: [Tutor] Share variables between py scripts

2006-10-06 Thread Eric Walstad
Bennett, Joe wrote: > Can anyone direct me to some documentation on how to take variables from > one py script, execute and pass them to another script? Then I need to > get data back from the executed script? I've been searching Google and I > see information, but I am in need of some examples.

Re: [Tutor] Random Variable at root

2006-10-03 Thread Eric Walstad
Hi Hugo, halamillo wrote: > I;m starting this > code so I can assign either a 0 or a 1 at a root node that I will later > evolve throughout a tree, but for some reason it is not printing the > rootState value. It's not clear to me which variable you are trying to assign a zero or one. Here's

Re: [Tutor] Python code to split and reassemble files

2006-10-02 Thread Eric Walstad
Andrew Robert wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Never mind.. :) > > > found it at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800 > > However, if someone has something better, I would be very interested. Hi Andrew, If you are on a *nix machine you cou

Re: [Tutor] database web app, what tool?

2006-10-02 Thread Eric Walstad
Hey Paulino, I'm a Django fan but from your description, a simple CGI app might do nicely. Heck, you've already got the code written, just wrap it in a CGI script that formats your list of records in HTML and serve the script from your (already setup?) apache or even from your workstation wit