Working with databases (ODBC and ORMs) in Python 3.2

2011-11-10 Thread tkp...@hotmail.com
We are in the process of trying to decide between Python 2.7 and 3.2 with a view to making a 5-10 year commitment to the right platform, and would appreciate some guidance on how best to connect to SQL databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, does anyone have experience

Re: Python 3.2 bug? Reading the last line of a file

2011-05-27 Thread tkp...@hotmail.com
This is exactly what I want to do - I can then pick up various elements of the list and turn them into floats, ints, etc. I have not ever used decode, and will look it up in the docs to better understand it. I can't thank everyone enough for the generous serving of help and guidance - I certainly w

Re: Python 3.2 bug? Reading the last line of a file

2011-05-25 Thread tkp...@hotmail.com
Thanks for the guidance - it was indeed an issue with reading in binary vs. text., and I do now succeed in reading the last line, except that I now seem unable to split it, as I demonstrate below. Here's what I get when I read the last line in text mode using 2.7.1 and in binary mode using 3.2 resp

Python 3.2 bug? Reading the last line of a file

2011-05-25 Thread tkp...@hotmail.com
The following function that returns the last line of a file works perfectly well under Python 2.71. but fails reliably under Python 3.2. Is this a bug, or am I doing something wrong? Any help would be greatly appreciated. import os def lastLine(filename): ''' Returns the last line of

Re: how to read the last line of a huge file???

2011-03-10 Thread tkp...@hotmail.com
There is a problem, and it's a Python 3.2 problem. All the solutions presented here work perfectly well in Python 2.7.1, and they all fail at exactly the same point in Python 3.2 - it's the line that tries to seek from the end. e.g. f.seek(offset, os.SEEK_END) I'll register this as a Python bug. T

Re: how to read the last line of a huge file???

2011-03-05 Thread tkp...@hotmail.com
Thanks for the pointer. Yes, it is a text file, but the mystery runs deeper: I later found that it works perfectly as written when I run it from IDLE or the Python shell, but it fails reliably when I run it from PyScripter 2.4.1 (an open source Python IDE)! So I suspect there's a PyScripter issue l

Re: how to read the last line of a huge file???

2011-03-04 Thread tkp...@hotmail.com
I've implementing this method of reading a file from the end, i.e def seeker(filename): offset = -10 with open(filename) as f: while True: f.seek(offset, os.SEEK_END) lines = f.readlines() if len(lines) >= 2: return lines[-1]

Uploading files to an an FTP site through a proxy server which requires authentication

2011-02-09 Thread tkp...@hotmail.com
I would like to upload files to a ftp site, but can't seem to get through our proxy server, which requires authentication. How can one do this in Python (I use 2.7, but am more than happy to use 3.2 rc2) Thanks in advance Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread tkp...@hotmail.com
Worked like a charm! Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread tkp...@hotmail.com
I’m experiencing a problem with the csv module in Python 3.1.2, and would greatly appreciate any help anyone can offer me. When writing csv files in Python 2.6, I open the output file as 'wb' to prevent a blank line being inserted after every line. Works like a charm. But I get an error if I do the

Re: Startup problems with Python 3.1.2 and PythonPath under XP

2010-04-12 Thread tkp...@hotmail.com
I fixed the problem by creating a file call MyPath.pth that has only one line H:/Python and placing it in the C:\Python31\Lib\site-packages directory. So as a practical matter, my problem is solved. That said, I'm still puzzled by why Python 3.1 acts up when I set the environment variable PYTHONPA

Startup problems with Python 3.1.2 and PythonPath under XP

2010-04-12 Thread tkp...@hotmail.com
I run Python under Windows XP SP3, and for the longest time, I have installed it on my C: drive under C:\PythonXX (XX = 20, 21., 26), and maintained all my Python files on our network in a directory called H:\Python that I point to by creating an environment variable called PYTHONPATH. I recent

Re: python needs a tutorial for install and setup on a Mac

2009-06-22 Thread tkp...@hotmail.com
I think a setup guide for the Mac would prove very useful. Earlier this year, I tried installing Python 2.6 on my iMac, and ran into all sorts of problems, largely as a result of the fact that I knew very little about Unix. I finally downloaded and installed the Enthought Python distribution for th

Re: Q: "Best" book for teaching

2009-04-08 Thread tkp...@hotmail.com
I taught myself Python from Python Programming for the Absolute Beginner by Michael Dawson (which has been mentioned above) and with lots of help from the friendly members of this group, but there's now a free e-book titled Snake Wrangling for Kids by Jason Briggs. You can view it at http://www.bri