Re: Bug in Python

2012-04-17 Thread Terry Reedy
On 4/18/2012 12:47 AM, Hans Mulder wrote: On 18/04/12 03:08:08, Kiuhnm wrote: print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() How much of that is needed to trigger the problem? All three prints? Any of them? I get the same

Re: Bug in Python

2012-04-17 Thread John O'Hagan
On Wed, 18 Apr 2012 03:08:08 +0200 Kiuhnm wrote: > I'm using Python 3.2.2, 64 bit on Windows 7. > > Consider this code: > ---> > print(1) > print(2) > print(3) > > with open('test') as f: > data = f.read() > with open('test') as f: > data = f.read() > <--- > If I debug this code with

Re: Bug in Python

2012-04-17 Thread Hans Mulder
On 18/04/12 03:08:08, Kiuhnm wrote: > print(1) > print(2) > print(3) > > with open('test') as f: > data = f.read() > with open('test') as f: > data = f.read() I get the same result with Pythin 3.3.0a0 on MacOS X 10.6: 93> ./python.exe -m pdb /tmp/script.py > /tmp/script.py(1)() -> print(

Re: Framework for a beginner

2012-04-17 Thread Bryan
Roy Smith wrote: > Bryan wrote: > > Django has emphasized backwards compatibility with the > > down-side that, last I heard, there was no plan to move to Python 3. > > Hardly.  Seehttps://www.djangoproject.com/weblog/2012/mar/13/py3k/ Ah, I'm behind the times again. Thanks, that's good news. -- -

Bug in Python

2012-04-17 Thread Kiuhnm
I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: ---> print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() <--- If I debug this code with python -m pdb script.py and I issue the command j 7 Python crashes. Kiuhnm

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:59 AM, Edward d'Auvergne wrote: > Hi, > > Thanks for the incredibly quick responses!  The os.isatty() call (and > sys.std*.isatty() calls as suggested by Chris Angelico at > http://mail.python.org/pipermail/python-list/2012-April/1291048.html) > work perfectly for this j

Re: Working with Cursors

2012-04-17 Thread nn
On Apr 17, 2:11 pm, timlash wrote: > Searched the web and this forum without satisfaction.  Using Python 2.7 and > pyODBC on Windows XP I can get the code below to run and generate two cursors > from two different databases without problems.  Ideally, I'd then like to > join these result cursor

Re: Working with Cursors

2012-04-17 Thread nn
On Apr 17, 2:11 pm, timlash wrote: > Searched the web and this forum without satisfaction.  Using Python 2.7 and > pyODBC on Windows XP I can get the code below to run and generate two cursors > from two different databases without problems.  Ideally, I'd then like to > join these result cursor

Re: how to count the total number of strings (in the list) used in Python?

2012-04-17 Thread nn
On Apr 16, 3:00 pm, Chinesekidz wrote: > Hello! > > I would like to know how to write the program to count the total > number of strings (in the list) used in Python.. > > for example: > > list:['1','2','3','4'] > > for l in range(4): >      num=input("list:"+list[l]+"(between 1 and 4):") >      i

Re: Working with Cursors

2012-04-17 Thread Ian Kelly
On Tue, Apr 17, 2012 at 12:11 PM, timlash wrote: > Searched the web and this forum without satisfaction.  Using Python 2.7 and > pyODBC on Windows XP I can get the code below to run and generate two cursors > from two different databases without problems.  Ideally, I'd then like to > join these

Re: Framework for a beginner

2012-04-17 Thread Gerd Niemetz
Am Mittwoch, 11. April 2012 22:11:37 UTC+2 schrieb biof...@gmail.com: > I am new to python and only have read the Byte of Python ebook, but want to > move to the web. I am tired of being a CMS tweaker and after I tried python, > ruby and php, the python language makes more sense (if that makes an

Working with Cursors

2012-04-17 Thread timlash
Searched the web and this forum without satisfaction. Using Python 2.7 and pyODBC on Windows XP I can get the code below to run and generate two cursors from two different databases without problems. Ideally, I'd then like to join these result cursors thusly: SELECT a.state, sum(b.Sales) FROM

Re: Framework for a beginner

2012-04-17 Thread Gerd Niemetz
Am Mittwoch, 11. April 2012 22:11:37 UTC+2 schrieb biof...@gmail.com: > I am new to python and only have read the Byte of Python ebook, but want to > move to the web. I am tired of being a CMS tweaker and after I tried python, > ruby and php, the python language makes more sense (if that makes an

A better way to read Image from a server and start download / load

2012-04-17 Thread vijay swaminathan
Hi Expert, I'm a newbie to python and still on the process of learning on the go ... I have a webserver which has list of images to load on a Device Under Test (DUT) ... *Requirement is:* if the image is already present on the server, proceed with loading the image onto the DUT. if the image i

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Edward d'Auvergne
Hi, Thanks for the incredibly quick responses! The os.isatty() call (and sys.std*.isatty() calls as suggested by Chris Angelico at http://mail.python.org/pipermail/python-list/2012-April/1291048.html) work perfectly for this job! I might have to do some testing later on Windows though to see wha

Re: File traversing

2012-04-17 Thread Nibin V M
thanks for a super fast reply Chris :) On Tue, Apr 17, 2012 at 8:06 PM, Chris Angelico wrote: > On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M wrote: > > # python test.py > > File "test.py", line 1 > > with open('/etc/trueuserowners') as res_own_file: > > ^ > > IndentationError: unexpe

Re: File traversing

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M wrote: > # python test.py >   File "test.py", line 1 >     with open('/etc/trueuserowners') as res_own_file: >     ^ > IndentationError: unexpected indent Make sure your first code line is flush left. Since indentation indicates block structure (and not

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:21 AM, Edward d'Auvergne wrote: > I was wondering if anyone knows of how to detect when IO redirection > of any form is happening within a Python program?  I would like to > emulate the behaviour of the GNU tools (for example the Unix commands > 'ls' or 'grep') whereby a

Re: File traversing

2012-04-17 Thread Nibin V M
# python test.py File "test.py", line 1 with open('/etc/trueuserowners') as res_own_file: ^ IndentationError: unexpected indent [~]# cat test.py with open('/etc/trueuserowners') as res_own_file: all_res = set(line.strip().replace(' ', '').split(':')[1] for line in res_own_file if ':

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread pat
Check os.isatty(fd). It will return True if fd is a terminal-like device. On Tue, Apr 17, 2012 at 5:21 PM, Edward d'Auvergne wrote: > Hi, > > I was wondering if anyone knows of how to detect when IO redirection > of any form is happening within a Python program? I would like to > emulate the beh

Re: PrintPreviewDialog problem

2012-04-17 Thread Chris Angelico
On Tue, Apr 17, 2012 at 4:09 PM, alhad wrote: > but, i am getting AttributeError for "paintRequested" Before executing that line, find out what 'preview' contains. My guess is that you have an error return such as None, which will of course not have a paintRequested attribute. If it's not obvious

How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Edward d'Auvergne
Hi, I was wondering if anyone knows of how to detect when IO redirection of any form is happening within a Python program? I would like to emulate the behaviour of the GNU tools (for example the Unix commands 'ls' or 'grep') whereby ascii escape sequences are printed if the output is solely to th

Simple TLS NPN negotiation not working on socket server

2012-04-17 Thread Alek Storm
Hi all, Support for the TLS NPN extension was apparently just added in Python 3.3 (see http://bugs.python.org/issue14204), but I can't get the following simple TCP server using it to work with a browser: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('',8000)) sock.listen(5)

Re: system call that is killed after n seconds if not finished

2012-04-17 Thread Adam Skutt
On Apr 16, 11:34 am, Alain Ketterlin wrote: > Jaroslav Dobrek writes: > > I would like to execute shell commands, but only if their execution > > time is not longer than n seconds. Like so: > > > monitor(os.system("do_something"), 5) > > > I.e. the command do_somthing should be executed by the op

Re: logging.config.fileConfig FileHandler configure to write to APP_DATA

2012-04-17 Thread Jean-Michel Pichavant
Jeffrey Britton wrote: I figured out what I was after. logfn = os.path.join(os.environ['APPDATA'], directory, filename) ensure_path(logfn) logging.config.fileConfig("logging.conf", defaults={'logfn': logfn}) In the config file use: [handler_fileHandler] class=FileHandler level=DEBUG formatter=s

Re: Framework for a beginner

2012-04-17 Thread Roy Smith
In article , Bryan wrote: > Django has emphasized backwards compatibility with the > down-side that, last I heard, there was no plan to move to Python 3. Hardly. See https://www.djangoproject.com/weblog/2012/mar/13/py3k/ I agree that Django is probably what the OP should be looking at, for

Re: File traversing

2012-04-17 Thread Nibin V M
wow...thanks Karl :) On Tue, Apr 17, 2012 at 2:20 AM, Karl Knechtel wrote: > > > On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico wrote: > >> >> (You may also want to consider using the 'with' statement to guarantee >> a timely closing of the file. Outside the scope of this mail though.) >> >> I

Re: pygame: output to file?

2012-04-17 Thread Temia Eszteri
Oh, forgot to mention some things. Also poorly phrased other things. Let me try that again. >* ImageMagick (http://www.imagemagick.org/) as Ian suggested - the >ctypes binding I found for this was too immature to use, and the other >option will require compiling, The 'other option' I meant here w

Re: Framework for a beginner

2012-04-17 Thread Arnaud Delobelle
On 17 April 2012 09:54, Bryan wrote: > Django has emphasized backwards compatibility with the > down-side that, last I heard, there was no plan to move to Python 3. Not quite: https://www.djangoproject.com/weblog/2012/mar/13/py3k/ -- Arnaud -- http://mail.python.org/mailman/listinfo/python-li

Re: Framework for a beginner

2012-04-17 Thread Bryan
biofob wrote: > I am new to python and only have read the Byte of Python ebook, but want to > move to the web. I am tired of being a CMS tweaker and after I tried python, > ruby and php, the python language makes more sense (if that makes any "sense" > for the real programmers). I heard a lot of

Re: escaping

2012-04-17 Thread Serhiy Storchaka
This was the original intention, i.e. 'format' preferred over '%' but even the core developers have backtracked on this issue. If I could remember the thread it was on I'd give you a reference, but I haven't the faintest idea as to which mailing list it was on. I'm certain that other subscribers w

Re: PrintPreviewDialog problem

2012-04-17 Thread Vincent Vande Vyvre
Le 17/04/12 08:09, alhad a écrit : > Hi Guys, > > I am using Python 2.5 & Qt4.4.1 on windows xp machine. I am trying to use > printpreviewdialog for my application. > > printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution) > preview = QtGui.QPrintPreviewDialog(printer,self) > preview.paintRequest

Re: pygame: output to file?

2012-04-17 Thread Temia Eszteri
Okay, superpollo. I'm looking at a few possible ways to do this (the Zen of Python hates me, even though I'm dutch-blooded!), and I'd like to ask a couple more questions before I dive into writing up a solution. First, are you simply trying to capture the framebuffer of a Pygame-made game in realt