Re: Python or PHP?

2005-04-23 Thread Leif B. Kristensen
Lad skrev: Is anyone capable of providing Python advantages over PHP if there are any? Much more compact and yet much more readable code, making it easier to maintain and extend your programs. -- Leif Biberg Kristensen http://solumslekt.org/ --

Re: How to run Python in Windows w/o popping a DOS box?

2005-04-19 Thread Leif B. Kristensen
Paul Rubin skrev: Question: is there any simple way to arrange to launch the app from the desktop, without also launching a DOS box? Just use the .pyw extension instead of .py, and the DOS box automagically disappears -- or so I have been told ... -- Leif Biberg Kristensen

Re: sscanf needed

2005-04-17 Thread Leif B. Kristensen
Uwe Mayer skrev: Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Look up time.strptime, it does exactly what you want. -- Leif Biberg Kristensen http://solumslekt.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with national characters

2005-04-09 Thread Leif B. Kristensen
Martin v. Löwis skrev: You need to do locale.setlocale(locale.LC_ALL, ) to get locale-specific upper-casing. That makes a lot of sense. Thank you. 'før'.upper() 'F\xf8R' 'FØR' 'F\xd8R' import locale locale.setlocale(locale.LC_ALL, ) 'no_NO' 'før'.upper() 'F\xd8R' 'FØR' 'F\xd8R' I must

Problem with national characters

2005-03-31 Thread Leif B. Kristensen
I'm developing a routine that will parse user input. For simplicity, I'm converting the entire input string to upper case. One of the words that will have special meaning for the parser is the word før, (before in English). However, this word is not recognized. A test in the interactive shell

Re: Problem with national characters

2005-03-31 Thread Leif B. Kristensen
[EMAIL PROTECTED] wrote: put import sys sys.setdefaultencoding('UTF-8') into sitecustomize.py in the top level of your PYTHONPATH . Uh ... it doesn't seem like I've got PYTHONPATH defined on my system in the first place: [EMAIL PROTECTED] leif $ env |grep -i python

Re: Problem with national characters

2005-03-31 Thread Leif B. Kristensen
[EMAIL PROTECTED] wrote: put import sys sys.setdefaultencoding('UTF-8') into sitecustomize.py in the top level of your PYTHONPATH . I found out of it, sort of. Now I've got a PYTHONPATH that points to my home directory, and followed your instructions. The first time I got an error

Re: Problem with national characters

2005-03-31 Thread Leif B. Kristensen
Leif B. Kristensen skrev: Is there something else I have to do? Please forgive me for talking with myself here :-) I should have looked up Unicode in Learning Python before I asked. This seems to work: u'før'.upper() u'F\xd8R' u'FØR' u'F\xd8R' 'FØR' 'F\xd8R' So far, so good. Note

escape single and double quotes

2005-03-24 Thread Leif B. Kristensen
I'm working with a Python program to insert / update textual data into a PostgreSQL database. The text has single and double quotes in it, and I wonder: What is the easiest way to escape quotes in Python, similar to the Perlism $str =~ s/(['])/\\$1/g;? I tried the re.escape() method, but it

Re: escape single and double quotes

2005-03-24 Thread Leif B. Kristensen
Damjan skrev: You don't need to escape text when using the Python DB-API. DB-API will do everything for you. For example: SQL = 'INSERT into TEMP data = %s' c.execute(SQL, text containing ' and ` and all other stuff we might read from the network) You see, the SQL string contains

Re: escape single and double quotes

2005-03-24 Thread Leif B. Kristensen
First, thanks to all who have replied. I learned a lot more than I had expected :-) This is a small part of a major project; converting my genealogy database from a commercial FoxPro application to my homegrown Python / PostgreSQL app. I'm still in a phase where I'm experimenting with different

Re: Python for a 10-14 years old?

2005-03-24 Thread Leif B. Kristensen
R.Meijer wrote: Jot jot at nad.com writes: If she's really gifted i hope she dumps that obsolete monolithic kernel as soon as she realizes that such beautiful language as python shouldn't be used on top of ugly, badly designed software. Did somebody say off-topic? I'd say it's a Troll

Re: fastest postgresql module

2005-03-17 Thread Leif B. Kristensen
Timothy Smith skrev: has anyone got some hard numbers on which pg access module is the fastest, i currently use pypgsql, but i can't help but feel it's a little slow. 3 seconds to connect, send one query, get th return data. i'm on a adsl 1.5mbit/256kbit link, the server is on a 10/10mbit,

Re: fastest postgresql module

2005-03-17 Thread Leif B. Kristensen
Timothy Smith skrev: my only issue with psycopg, is last time i looked they had no win32 port? Uh, in that case, maybe you should consider changing platform? 8^) -- Leif Biberg Kristensen just another global village idiot -- http://mail.python.org/mailman/listinfo/python-list

Re: About Databases...

2005-03-16 Thread Leif B. Kristensen
Peter A. Schott wrote: PostGreSQL - good feature set, open source. Not sure on speed, but it should run natively on Unix, Linux, and Win32 (not sure about BSD or others). A lot of the core developers of PostgreSQL are apparently running *BSD. On the PostgreSQL-General mailing list, I've

Re: Need help running external program

2005-02-27 Thread Leif B. Kristensen
I'm using wget from Python to get extactly one line from a reports page. I made this function that works for me: def wgetline(exp): # see Python Cookbook p. 228 print Getting result from server ... command = 'wget -q -O - \ http://www.foobar.com/report.pl\?UserID=xxx\UserPW=xxx \

Re: running a shell command from a python program

2005-02-23 Thread Leif B. Kristensen
Sandman wrote: How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and do stuff with the contents of that list. There's a Python Cookbook example that should fit nicely with what you're trying to

Re: python tutorial/projects

2005-02-22 Thread Leif B. Kristensen
Danny skrev: Does anyone know of a good python tutorial? I was also looking for some non-trivial projects to do in python. There's a lot of projects on Sourceforge that are written in Python, where you're free to study the code and maybe participate, if you've got what it takes. Basically

Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Leif B. Kristensen
john san skrev: pure DOS, old pc, used for teaching . want show some windows under DOS (under Python). curses is a text-based interface that will let you build windowed applications like you could with the crt unit in Turbo Pascal of those golden days. I've no idea if anyone's compiled it for

Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Leif B. Kristensen
john san skrev: Actually the windows running very good under the xbox-NTOS via xboxmediacenter. its just limited functions(not easy to programming the windows prog.), if we can find WxPython-like can be ported (I can import * from it to my xboxPython) )it will be a great great . You