help with this simple DB script

2006-05-16 Thread John Salerno
Ok, before I contact my server host, I figured I should make sure I'm not just making a Python mistake. I get an Internal Server Error with this script: !#/usr/bin/python import MySQLdb db = MySQLdb.connect(host='xxx', user='xxx', passwd='xxx',

python vs perl lines of code

2006-05-16 Thread Edward Elliott
This is just anecdotal, but I still find it interesting. Take it for what it's worth. I'm interested in hearing others' perspectives, just please don't turn this into a pissing contest. I'm in the process of converting some old perl programs to python. These programs use some network code and d

Re: python vs perl lines of code

2006-05-16 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > This is just anecdotal, but I still find it interesting. Take it for > what it's worth. I'm interested in hearing others' perspectives, just > please don't turn this into a pissing contest. Without seeing the actual code this is quite meaningless. -

Re: python vs perl lines of code

2006-05-16 Thread Edward Elliott
John Bokma wrote: > Edward Elliott <[EMAIL PROTECTED]> wrote: > >> This is just anecdotal, but I still find it interesting. Take it for >> what it's worth. I'm interested in hearing others' perspectives, just >> please don't turn this into a pissing contest. > > Without seeing the actual code

Re: help with this simple DB script

2006-05-16 Thread BartlebyScrivener
Are you able to connect to the DB using MySQL administrator? -- http://mail.python.org/mailman/listinfo/python-list

Re: help with this simple DB script

2006-05-16 Thread John Machin
Please learn to provide needed information when asking questions. 1. What does "run it directly with my URL" mean?? 2. Show the traceback that you got. -- http://mail.python.org/mailman/listinfo/python-list

Re: any plans to make pprint() a builtin?

2006-05-16 Thread Edward Elliott
Ant wrote: > Longer, messy, and what's the actual point? Wouldn't: > > import pprint as pp > pp.pprint(x) > > be better, standard *and* shorter? why not just: from pprint import pprint pprint (x) No need to modify the interpreter when you can pollute the global namespace yourself just as easi

Re: help with this simple DB script

2006-05-16 Thread trebucket
This is probably causing a problem: !#/usr/bin/python It should be "#!", not "!#". If that doesnt' work, add this line at the top of your script, to check that the script is begin executed: print "Content-Type: text/html\n\n" print "Hello, World!" If you still get an Internal Server Error put t

Re: do/while structure needed

2006-05-16 Thread Edward Elliott
Dennis Lee Bieber wrote: > Would you put the condition at the top of the loop -- and confuse > those people who believe the exit condition should appear at the point > the exit activates? Confusion is not the issue. You can put the condition smack dab in the middle of the loop, as long as the lo

help with a function

2006-05-16 Thread Lance Hoffmeyer
Hey all, I'm new to python. I keep getting an error when running this. I'm sure there is an easy fix but I can't figure it out. What am I doing wrong? How do I fix it? def even_odd_round(num): if(round(num,2) + .5 == int(round(num,2)) + 1): if(int(num,0) % 2):

Re: constucting a lookup table

2006-05-16 Thread mhodkin
Larry Bates wrote: > [EMAIL PROTECTED] wrote: > > I'm new to Python and want to contruct a "lookup table" which would be > > similar to a spreadsheet in that a value is read along the first > > column, then along the top row, and the intersection of the two gives a > > value that is hard-coded, i.

Re: A Unicode problem -HELP

2006-05-16 Thread manstey
Hi Martin, HEre is how I write: input_file = open(input_file_loc, 'r') output_file = open(output_file_loc, 'w') for line in input_file: output_file.write(str(word_info + parse + gloss)) # = three functions that return tuples (u'F', u'\u0254') are two of the many unicode tuple elements retu

Re: help with a function

2006-05-16 Thread Ben Finney
Lance Hoffmeyer <[EMAIL PROTECTED]> writes: > def even_odd_round(num): > if(round(num,2) + .5 == int(round(num,2)) + 1): >if(int(num,0) % 2):#an odd number > rounded_num = round(num,2) + .1 >else: #an even n

Re: help with a function

2006-05-16 Thread Paul McGuire
"Lance Hoffmeyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey all, > > I'm new to python. I keep getting an error when running this. > I'm sure there is an easy fix but I can't figure it out. > What am I doing wrong? How do I fix it? > > def even_odd_round(num): > if(round

Re: A Unicode problem -HELP

2006-05-16 Thread Ben Finney
"manstey" <[EMAIL PROTECTED]> writes: > input_file = open(input_file_loc, 'r') > output_file = open(output_file_loc, 'w') > for line in input_file: > output_file.write(str(word_info + parse + gloss)) # = three functions > that return tuples If you mean that 'word_info', 'parse' and 'gloss'

Re: common practice for creating utility functions?

2006-05-16 Thread Edward Elliott
BartlebyScrivener wrote: > QOTW > > "Programming is not just creating strings of instructions for a > computer to execute. It's also 'literary' in that you are trying to > communicate a program structure to other humans reading the code." Paul > Rubin I take it you've never heard of Donald Knut

Re: help with this simple DB script

2006-05-16 Thread John Salerno
[EMAIL PROTECTED] wrote: > This is probably causing a problem: > !#/usr/bin/python > > It should be "#!", not "!#". Ugh! So stupid! Thanks for correcting that, but it wasn't the only problem. > If that doesnt' work, add this line at the top of your script, to check > that the script is begin exe

Re: common practice for creating utility functions?

2006-05-16 Thread Edward Elliott
Bruno Desthuilliers wrote: > Then it would be better to just alias it: > > # def convert_quote(quote): > # return make_code(quote) > convert_quote = make_code The former makes sense if you're planning to do more with the calling function later. > About the "fine to do" part, remember that

Re: help with a function

2006-05-16 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Lance Hoffmeyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hey all, > > > > I'm new to python. I keep getting an error when running this. > > I'm sure there is an easy fix but I can't figure it ou

Re: using target words from arrays in regex, pythons version of perls 'map'

2006-05-16 Thread Edward Elliott
John Machin wrote: > Would you believe "steps 3 & 4"? How about "two pops and a pass?" Quick! Lower the cone of silence! -- Edward Elliott UC Berkeley School of Law (Boalt Hall) complangpython at eddeye dot net -- http://mail.python.org/mailman/listinfo/python-list

Re: [silly] Does the python mascot have a name ?

2006-05-16 Thread Edward Elliott
Carl J. Van Arsdall wrote: > Well, we could call the perl camel Joe but I don't know if the perlcores > (read: hardcore PERL users) would be down for that ;) Hmmm. Perl is like smoking, it feels great and gives you cancer. Yes, there's definitely potential here. ;) -- Edward Elliott UC Berkel

Re: Is the only way to connect Python and Lua through a C interface?

2006-05-16 Thread Pierre Rouleau
Casey Hawthorne wrote: > Is the only way to connect Python and Lua through a C interface? Take a look at Lunatic Python (http://labix.org/lunatic-python) -- Pierre Rouleau -- http://mail.python.org/mailman/listinfo/python-list

Re: Help System For Python Applications

2006-05-16 Thread BartlebyScrivener
At the commandline, run: pydoc -g In the interpreter: help("modulename") or help () for interactive. Are you on Windows? Using ActivePython? Or the Python.org download? rd -- http://mail.python.org/mailman/listinfo/python-list

Re: help with this simple DB script

2006-05-16 Thread John Salerno
BartlebyScrivener wrote: > Are you able to connect to the DB using MySQL administrator? > Yes, through my hosting control panel. That's how I created the DB, but I want to try to do everything else with mysqldb. -- http://mail.python.org/mailman/listinfo/python-list

Re: help with this simple DB script

2006-05-16 Thread John Salerno
John Salerno wrote: > Ok, before I contact my server host, I figured I should make sure I'm > not just making a Python mistake. I get an Internal Server Error with > this script: Ok, got some help from Dennis Bieber and he solved it. I was using number(), which is a SQL but not a MySQL command.

A better way of making subsclassing of built-in types stick for attributes?

2006-05-16 Thread [EMAIL PROTECTED]
Is there a better way to make the subclassing of built-in types stick? The goal is to have the the fields of a class behave like strings with extra methods attached. That is, I want the fact that the fields are not strings to be invisible to the client programmers. But I always want the extras to

Re: A Unicode problem -HELP

2006-05-16 Thread manstey
I'm a newbie at python, so I don't really understand how your answer solves my unicode problem. I have done more reading on unicode and then tried my code in IDLE rather than WING IDE, and discovered that it works fine in IDLE, so I think WING has a problem with unicode. For example, in WING this

Re: pythoncom and IDispatch

2006-05-16 Thread Roger Upole
"fraca7" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello. I got a little problem while using pythoncom to automate IE; for some > reason, changing the 'selectedIndex' on an > instance of IHTMLSelectElement doesn't fire the 'onchange' event (I guess > this is a bug in mshtml)

Re: common practice for creating utility functions?

2006-05-16 Thread BartlebyScrivener
Hey, thanks. I got the writing thing down: http://dooling.com Now I'm trying to pick up the programming part. Thanks for links. rick -- http://mail.python.org/mailman/listinfo/python-list

Re: build now requires Python exist before the build starts

2006-05-16 Thread [EMAIL PROTECTED]
Toon Knapen wrote: > I'm trying to build the svn-trunk version of python on a Solaris box. > However I do not have a python installed yet and apparantly the build of > python requires a python to be accessible (as also annotated in the > Makefile generated during the ./configure). How can I solve t

assignment in a for loop

2006-05-16 Thread MackS
Hello everyone Consider the following >>> l = [1,2] >>> for i in l: ... i = i + 1 ... >>> l [1, 2] I understand (I think!) that this is due to the fact that in Python what looks like "assignment" really is binding a name to an object. The result is that inside the loop I am creating an objec

Re: A Unicode problem -HELP

2006-05-16 Thread Ben Finney
"manstey" <[EMAIL PROTECTED]> writes: > I'm a newbie at python, so I don't really understand how your answer > solves my unicode problem. Since your replies fail to give any context of the existing discussion, I could only go by the content of what you'd written in that message. I didn't see a pr

Re: Creating an Active Desktop Window

2006-05-16 Thread Roger Upole
rodmc wrote: > Hi, > > Does anyone know how I can create an Active Desktop window from within > a Python script? It would also be good to know how to refresh that > window and nothing else. > > At present I have an application which writes to a file which is read > by the Active Desktop (embeded I

Re: assignment in a for loop

2006-05-16 Thread MackS
Sorry, my previous post probably was not very good at explaining _why_ I want to do this. Suppose I want to do modify all arguments which are passed to a function. Do I need to use a list comprehension such as def f(arg1,arg2,arg3): arg1,arg2,arg3 = [i+1 for i in (arg1,arg2,arg3)] ...

Re: A better way of making subsclassing of built-in types stick for attributes?

2006-05-16 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Is there a better way to make the subclassing of built-in types > stick? They stick. Your new classes are available until you get rid of them. > The goal is to have the the fields of a class behave like strings > with extra methods attached. That

Re: python vs perl lines of code

2006-05-16 Thread Charles DeRykus
Edward Elliott wrote: > John Bokma wrote: > >> Edward Elliott <[EMAIL PROTECTED]> wrote: >> >>> This is just anecdotal, but I still find it interesting. Take it for >>> what it's worth. I'm interested in hearing others' perspectives, just >>> please don't turn this into a pissing contest. >> Wit

Re: Time to bundle PythonWin

2006-05-16 Thread Martin v. Löwis
Dave Benjamin wrote: > Sure. I wasn't proposing that this be done behind Mark's back. I wasn't > even proposing a fork; rather, just two installers bundled into one. The > user, upon running the .msi file, would simply be asked if they'd like > PythonWin also. PythonWin could be automatically combi

Re: python vs perl lines of code

2006-05-16 Thread Ala Qumsieh
Edward Elliott wrote: > John Bokma wrote: >> >>Without seeing the actual code this is quite meaningless. > > > Evaluating my experiences yes, relating your own no. Well, quality of code is directly related to its author. Without knowing the author personally, or at least seeing the code, your a

Re: assignment in a for loop

2006-05-16 Thread Ben Finney
"MackS" <[EMAIL PROTECTED]> writes: > >>> l = [1,2] > >>> for i in l: > ... i = i + 1 > ... > >>> l > [1, 2] > > I understand (I think!) that this is due to the fact that in Python > what looks like "assignment" really is binding a name to an > object. The result is that inside the loop I am

Re: A Unicode problem -HELP

2006-05-16 Thread Martin v. Löwis
manstey wrote: > input_file = open(input_file_loc, 'r') > output_file = open(output_file_loc, 'w') > for line in input_file: > output_file.write(str(word_info + parse + gloss)) # = three > functions that return tuples > > (u'F', u'\u0254') are two of the many unicode tuple elements returned

Re: assignment in a for loop

2006-05-16 Thread Ben Finney
"MackS" <[EMAIL PROTECTED]> writes: [MackS, please don't top-post.] > Suppose I want to do modify all arguments which are passed to a > function. Do I need to use a list comprehension such as > > def f(arg1,arg2,arg3): > > arg1,arg2,arg3 = [i+1 for i in (arg1,arg2,arg3)] > ... > > Th

Re: python vs perl lines of code

2006-05-16 Thread Edward Elliott
Charles DeRykus wrote: > This subject thread may be of great interest but I think an language > advocacy mailing list would be a better forum. Fair enough, but advocacy isn't at all what I'm after. Anecdotes are fine, after all what is data but a collection of anecdotes? :) Seriously, anecdot

Re: assignment in a for loop

2006-05-16 Thread MackS
Thank you for your reply. > > 1) Is what I wrote above (minimally) correct? > > Correct for what? You can tell if it's *syntactically* correct by > simply running it. > > As for any other "correct", define that. Does it do what you want it > to do? I was referring to my attempted explanation, no

Re: A Unicode problem -HELP

2006-05-16 Thread manstey
OK, I apologise for not being clearer. 1. Here is my input data file, line 2: gn1:1,1.2 R")$I73YT R")[EMAIL PROTECTED] 2. Here is my output data file, line 2: u'gn', u'1', u'1', u'1', u'2', u'-', u'R")$I73YT', u'R")$IYT', u'R")$IYT', u'@', u'ncfsa', u'nc', '', '', '', u'f', u's', u'a', '', '', ''

Re: python vs perl lines of code

2006-05-16 Thread Edward Elliott
Ala Qumsieh wrote: > Btw, do you include space chars that go toward indentating Python code > in your count? If not, you should since they are required. Not so for > Perl. All chars are counted on lines which are counted. The perl and python versions use the same amount and type of indentation,

Re: assignment in a for loop

2006-05-16 Thread Ben Finney
"MackS" <[EMAIL PROTECTED]> writes: > Thank you for your reply. A pleasure to help. > > What's preventing the use of list comprehensions? > > > > new_list = [x+1 for x in old_list] > > Suppose I want to do anything as trivial as modify the values of the > list members _and_ print their new

Re: A Unicode problem -HELP

2006-05-16 Thread Martin v. Löwis
manstey wrote: > a=str(word_info + parse + gloss).encode('utf-8') > a=a[1:len(a)-1] > > Is this clearer? Indeed. The problem is your usage of str() to "render" the output. As word_info+parse+gloss is a list (or is it a tuple?), str() will already produc

Re: A Unicode problem -HELP

2006-05-16 Thread Tim Roberts
"manstey" <[EMAIL PROTECTED]> wrote: > >I have done more reading on unicode and then tried my code in IDLE >rather than WING IDE, and discovered that it works fine in IDLE, so I >think WING has a problem with unicode. Rather, its output defaults to ASCII. >So, assuming I now work in IDLE, all I w

Re: A Unicode problem -HELP

2006-05-16 Thread Ben Finney
"manstey" <[EMAIL PROTECTED]> writes: > 1. Here is my input data file, line 2: > gn1:1,1.2 R")$I73YT R")[EMAIL PROTECTED] Your program is reading this using the 'utf-8' encoding. When it does so, all the characters you show above will be read in happily as you see them (so long as you view them w

cross-compile PIL

2006-05-16 Thread NicolasP
Hello, I need to compile PIL (python imaging library) package for an ARM based linux system. Does anyone can tell me how to do this ? Thanks Nicolas -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3