Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
Alan Gauld wrote: > Why remove them? I think they might be confusing; unless perhaps you gave them special names. > How are you using the prompt? I tend to cut and paste individual lines. Incidentally the lack of readline is the reason why large amounts of output are such a big deal. I think we

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Alan Gauld
"Olivier Lefevre" <[EMAIL PROTECTED]> wrote >> Then assign the return value to a variable and never use it. > > That feels obfuscated; definitely not an elegant solution. > When I'm done with interactive development and save the > substance to a script I'd have to chase these bogus > assignments

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
> Sounds like you need a better interactive development tool. > You should try emacs. :-) With jython the options are limited: even readline is a luxury, but I'll look into it. -- O.L. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mai

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Eric Brunson
Olivier Lefevre wrote: >> Then assign the return value to a variable and never use it. >> > > That feels obfuscated; definitely not an elegant solution. > When I'm done with interactive development and save the > substance to a script I'd have to chase these bogus > assignments to junk variabl

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
> Then assign the return value to a variable and never use it. That feels obfuscated; definitely not an elegant solution. When I'm done with interactive development and save the substance to a script I'd have to chase these bogus assignments to junk variables and remove them; not a smooth workflow

Re: [Tutor] getting filen basename without extension

2008-01-11 Thread Tiger12506
I would always use the os functions to find the basename, but You could exploit the fact that Windows considers the extension to be whatever is after the last "." character. fn = fn[:fn.rfind(".")] >> > What I found is this: >> > import os >> > myfile_name_with_path = 'path/to/my/testfile.txt' >

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Kent Johnson
johnf wrote: > On Friday 11 January 2008 11:45:36 am you wrote: > Let's start over! Thank you. > import psycopg2 > > conn = psycopg2.connect("host='192.168.1.201' dbname='aName' user ='UserName' > password ='**'") > tempCursor= conn.cursor() > custnum = 'ABC123' > mysql ="Select ccustno fro

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Alan Gauld
"Olivier Lefevre" <[EMAIL PROTECTED]> wrote >> But if you refer to a loop when would you ever be evaluating >> expressions inside a loop without assigning them? > > Some method calls return a value that you may not be interested > in but which will still be printed, e.g., Set.add in Java (if >

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Eric Brunson
Olivier Lefevre wrote: >> Are you talking about the >>> prompt? >> > > Yes. > > >> But if you refer to a loop when would you ever be evaluating >> expressions inside a loop without assigning them? >> > > Some method calls return a value that you may not be interested > in but which w

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Kent Johnson
johnf wrote: > On Friday 11 January 2008 11:19:43 am you wrote: >> Can you post a small, complete program containing both the working and >> non-working variants and show the complete output of the program? Jeez, you might want to try to get this to work with something simple! This is still not

Re: [Tutor] preventing SQL injection

2008-01-11 Thread johnf
On Friday 11 January 2008 11:19:43 am you wrote: > johnf wrote: > > I spoke to soon. Where can I find the DB-API for postgres? Because the > > only way I can get this to work is using ('%s') and it does not work with > > (%s). > > What module are you using to connect to postgres? That module shou

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
> Are you talking about the >>> prompt? Yes. > But if you refer to a loop when would you ever be evaluating > expressions inside a loop without assigning them? Some method calls return a value that you may not be interested in but which will still be printed, e.g., Set.add in Java (if you are

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Kent Johnson
johnf wrote: > I spoke to soon. Where can I find the DB-API for postgres? Because the only > way I can get this to work is using ('%s') and it does not work with (%s). What module are you using to connect to postgres? That module should implement DB-API as documented here: http://www.python.or

Re: [Tutor] preventing SQL injection

2008-01-11 Thread johnf
On Friday 11 January 2008 10:20:13 am Alan Gauld wrote: > "johnf" <[EMAIL PROTECTED]> wrote > > > and should be doing > > tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as > > seq", ( 'public.arcust', 'pkid' ) ) > > > > which prevented SQL injection. > > The syntax of the execute st

Re: [Tutor] preventing SQL injection

2008-01-11 Thread johnf
On Friday 11 January 2008 09:14:25 am Simone wrote: > johnf ha scritto: > > But the above does not work when I use variables instead of strings as in > > > > tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as > > seq", ( tableName, fieldName ) ) > > > > So how am I suppose to prevent

Re: [Tutor] preventing SQL injection

2008-01-11 Thread johnf
On Friday 11 January 2008 10:20:13 am Alan Gauld wrote: > "johnf" <[EMAIL PROTECTED]> wrote > > > and should be doing > > tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as > > seq", ( 'public.arcust', 'pkid' ) ) > > > > which prevented SQL injection. > > The syntax of the execute st

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Alan Gauld
"johnf" <[EMAIL PROTECTED]> wrote > and should be doing > tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as > seq", ( 'public.arcust', 'pkid' ) ) > > which prevented SQL injection. The syntax of the execute statement varies by database Which DB are you using. For example SQLit

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Alan Gauld
"Olivier Lefevre" <[EMAIL PROTECTED]> wrote > This is stupid but my python is rusty I can neither > remember nor find out anew how to enter an expression > that returns a value w/o being seeing the result printed. I don;t understand the question. Are you talking about the >>> prompt? That is the

Re: [Tutor] Iterating backwards

2008-01-11 Thread James Newton
Kent Johnson wrote: >I guess counters is iterable but not a sequence. Try this: > for vCounter in reversed(list(counters)): Hi Kent, Thanks for your help. This solves my problem: vPos = pygame.mouse.get_pos() for vCounter in reversed(list(counters)): if vCounter.rect.collidep

Re: [Tutor] Iterating backwards

2008-01-11 Thread Kent Johnson
James Newton wrote: > I have created a series of pygame sprites. Visually, these sprites > represent counters and may overlap. I want to determine which sprite > the user clicked on. > > This seems to me to be a fairly standard feature of a game interface, so > I imagine that there is already a

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Simone
johnf ha scritto: > But the above does not work when I use variables instead of strings as in > > tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as > seq", ( tableName, fieldName ) ) > > So how am I suppose to prevent SQL injections? Try tu use '?' instead of %s, like this

[Tutor] Iterating backwards

2008-01-11 Thread James Newton
Hi Pygamers, I have created a series of pygame sprites. Visually, these sprites represent counters and may overlap. I want to determine which sprite the user clicked on. This seems to me to be a fairly standard feature of a game interface, so I imagine that there is already a standard technique

Re: [Tutor] preventing SQL injection

2008-01-11 Thread Kent Johnson
johnf wrote: > Hi, > I was recently told I was doing something wrong with my python sql statements. > I was doing > tempCursor.execute("Select pg_get_serial_sequence('%s','%s') as seq > " % ('public.arcust','pkid')) > > and should be doing > tempCursor.execute ( "Select pg_get_serial_sequence (

[Tutor] preventing SQL injection

2008-01-11 Thread johnf
Hi, I was recently told I was doing something wrong with my python sql statements. I was doing tempCursor.execute("Select pg_get_serial_sequence('%s','%s') as seq   " % ('public.arcust','pkid')) and should be doing tempCursor.execute ( "Select pg_get_serial_sequence ( %s, %s ) as   seq", ( 'publi

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
> If you follow the discussion thread look through the link I provided, > I believe this is addressed a bit later. Yes and no. They do discuss possible hooks a bit further in http://mail.python.org/pipermail/edu-sig/2007-August/008161.html but merely to suggest toggling between echo and no-echo. I

Re: [Tutor] shutils.copytree

2008-01-11 Thread Alan Gauld
"Tony Cappellini" <[EMAIL PROTECTED]> wrote >> The source also says, "Consider this example code rather than the >> ultimate tool" so maybe you should just copy it and make a version >> that >> does what you want. See shutil.py in your Python lib directory. > > Yes, I did read that and was shock

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Andre Roberge
On Jan 11, 2008 9:48 AM, Olivier Lefevre <[EMAIL PROTECTED]> wrote: > Thanks for both suggestions. The displayhook trick would > be OK if there was a way to retrieve what _would_ have > been printed last if the display had not been changed: > something like a modified '_'. As it stands, it's a bit

Re: [Tutor] shutils.copytree

2008-01-11 Thread Tim Golden
Tony Cappellini wrote: >> The source for copytree says, "The destination directory must not >> already exist." I suppose that is why you have a problem but I don't >> know the specific cause. Did you get a traceback? >> >> The source also says, "Consider this example code rather than the >> ultimat

Re: [Tutor] shutils.copytree

2008-01-11 Thread Kent Johnson
Tony Cappellini wrote: >> The source also says, "Consider this example code rather than the >> ultimate tool" so maybe you should just copy it and make a version that >> does what you want. See shutil.py in your Python lib directory. > > Yes, I did read that and was shocked. Is everything in pytho

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
Thanks for both suggestions. The displayhook trick would be OK if there was a way to retrieve what _would_ have been printed last if the display had not been changed: something like a modified '_'. As it stands, it's a bit radical. -- O.L. ___ Tutor mai

Re: [Tutor] shutils.copytree

2008-01-11 Thread Tony Cappellini
> The source for copytree says, "The destination directory must not > already exist." I suppose that is why you have a problem but I don't > know the specific cause. Did you get a traceback? > > The source also says, "Consider this example code rather than the > ultimate tool" so maybe you should j

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Kent Johnson
Olivier Lefevre wrote: > This is stupid but my python is rusty I can neither > remember nor find out anew how to enter an expression > that returns a value w/o being seeing the result printed. If you assign the expression to a variable, the value will not be printed. Kent

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Andre Roberge
You may want to check here: http://mail.python.org/pipermail/edu-sig/2007-August/008154.html André On Jan 11, 2008 7:26 AM, Olivier Lefevre <[EMAIL PROTECTED]> wrote: > This is stupid but my python is rusty I can neither > remember nor find out anew how to enter an expression > that returns a val

[Tutor] Suppressing output in interactive mode

2008-01-11 Thread Olivier Lefevre
This is stupid but my python is rusty I can neither remember nor find out anew how to enter an expression that returns a value w/o being seeing the result printed. I would have expected something expr; as opposed to exp to do the trick but no dice and I haven't had any luck with Google or t

Re: [Tutor] how to remove window borders

2008-01-11 Thread Alan Gauld
"brindly sujith" <[EMAIL PROTECTED]> wrote > i am developing a GUI application using TKINTER > > in my applicaton i dont want the window title bar(including MAX,MIN > and > CLOSE) I can't see a way to do this and it doesn't really surprise me because it varies so much between GUI systems. On

Re: [Tutor] run in "deamon" mode?

2008-01-11 Thread Alan Gauld
"Allen Fowler" <[EMAIL PROTECTED]> wrote > I must say that I'm a bit surprised that the Python Std > library does not have a module for this. To be honest I've never used a language that does have a special library for turning programs/processes into daemons. The tools are in the modules and

Re: [Tutor] shutils.copytree

2008-01-11 Thread Tim Golden
Kent Johnson wrote: > Tony Cappellini wrote: >> I'm using shutils for the first time, and I've un into a problem. >> The docs for copytree are pretty sparse and don't mention any problem >> situations >> >> Under WinXP, I'm trying to copy a directory tree to a USB device using >> copytree, but cop

[Tutor] how to remove window borders

2008-01-11 Thread brindly sujith
hi i am developing a GUI application using TKINTER in my applicaton i dont want the window title bar(including MAX,MIN and CLOSE) how to do this plz send me the code for this ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/list