[Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Tony Cappellini
I'm writing a python gui app that will call a python cmd line app. The gui will take users input, pass it to the cmd line app, then display the cmd app program output. The idea is to give users who aren't comfortable with the cmd line a way to run the program, without having to open a shell window

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Luke Paireepinart
Tony Cappellini wrote: > > I'm writing a python gui app that will call a python cmd line app. The > gui will take users input, pass it to the cmd line app, then display > the cmd app program output. The idea is to give users who aren't > comfortable with the cmd line a way to run the program, wi

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Tony Cappellini
got it -thanks On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Tony Cappellini wrote: > > I'm writing a python gui app that will call a python cmd line app. The > gui will take users input, pass it to the cmd line app, then display > the cmd app program output. The idea is to give user

Re: [Tutor] Diff between opening files in 'r' and 'r+' mode

2007-01-30 Thread Alan Gauld
Hi Vanam, I'm a wee bit confused by your email. > i want to know the difference between 'r' mode and 'r+' mode r+ allows you to both read and write to the file without having to close in between. But its up to you to control where the "cursor" is within the file so that you write in the correct

Re: [Tutor] Explanation of Pickle

2007-01-30 Thread Alan Gauld
"vanam" <[EMAIL PROTECTED]> wrote > can any one explain about pickle i read in the book but they have > not > provided any example for that so please explain with a simple > example Conceptually it is very simple. Pickle takes a python object and serialises it to a sequence of bytes which it st

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Alan Gauld
"Tony Cappellini" <[EMAIL PROTECTED]> wrote > The author of the cmd line app suggested I temporarily replace > sys.stdout'with a file descriptor class that can write directly to > the > gui'. I'm not sure that would be such a great idea since the command line tool knows nothing about the GUI -

Re: [Tutor] Explanation of Pickle

2007-01-30 Thread Kent Johnson
vanam wrote: > can any one explain about pickle i read in the book but they have not > provided any example for that so please explain with a simple example There are examples in the docs: http://docs.python.org/lib/pickle-example.html Kent ___ Tutor

Re: [Tutor] Variable Swap

2007-01-30 Thread Steve Nelson
On 1/29/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Because 2 ^ 3 == 1, right? Are you sure you understand what xor does? It > is a bitwise exclusive or: Yes... at a binary level, it returns true if either input is true, but not both: A B Q 0 0 0 0 1 1 1 0 1 1 1 0 Thus it has the effect of swa

Re: [Tutor] Variable Swap

2007-01-30 Thread Simon Brunning
On 1/30/07, Steve Nelson <[EMAIL PROTECTED]> wrote: > > x, y = y, x > > Doesn't this use temporary variables? Python doesn't really *have* variables, as such, so no. What it does is to create a tuple referring to the objects (or just possibly one object) referred to by the names 'y' and 'x', then

Re: [Tutor] Variable Swap

2007-01-30 Thread Kent Johnson
Steve Nelson wrote: >> x, y = y, x > > Doesn't this use temporary variables? Yes, behind the scenes maybe it does. It may create a temporary list, then unpack it - that is what the syntax actually means. Let's take a look: In [1]: import dis In [2]: def f(x, y): ...: x, y = y, x ..

[Tutor] OT: Would this be difficult to do?

2007-01-30 Thread Lance Haig
Hi, I have a need for a file system scanning tool that produces csv files of data that is older than a specified date. All the commercial ones I have found just don't quite do what I want. I have been a lurker on this list for some time and was wondering if this would be very difficult to do? A

Re: [Tutor] OT: Would this be difficult to do?

2007-01-30 Thread Kent Johnson
Lance Haig wrote: > Hi, > > I have a need for a file system scanning tool that produces csv files of > data that is older than a specified date. > > All the commercial ones I have found just don't quite do what I want. > > I have been a lurker on this list for some time and was wondering if > th

[Tutor] Getting HTTP response codes

2007-01-30 Thread William O'Higgins Witteman
I am looking to get the HTTP response from a URI - 200, 404, etc. I'm not sure which module I should look at. I've looked at urllib and urllib2, but they only seem to provide this information in Exceptions, and then only if there is an error. That's fine if I'm only looking for implicit 200's, b

Re: [Tutor] Explanation of Pickle

2007-01-30 Thread Eike Welk
Hello Vanam! On Tuesday 30 January 2007 08:11, vanam wrote: > can any one explain about pickle i read in the book but they have > not provided any example for that so please explain with a simple > example A class can pickle itself like this: class foo(object): #lots of code here def _l

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Danny Yoo
> The author of the cmd line app suggested I temporarily replace > sys.stdout'with a file descriptor class that can write directly to the > gui'. The author is now out of communications for a few weeks, so I > can't elaborate. It sounds like the subprocess module might be very useful here:

Re: [Tutor] Getting HTTP response codes

2007-01-30 Thread Kent Johnson
William O'Higgins Witteman wrote: > I am looking to get the HTTP response from a URI - 200, 404, etc. I'm > not sure which module I should look at. I've looked at urllib and > urllib2, but they only seem to provide this information in Exceptions, > and then only if there is an error. That's fine

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Tony Cappellini
That would be ideal- but I'm using 2.4 now, and the people using the app would also have to upgrade to 2.5. I don't like upgrading unless there's a pressing need. On 1/30/07, Danny Yoo <[EMAIL PROTECTED]> wrote: > The author of the cmd line app suggested I temporarily replace > sys.stdout'with

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Kent Johnson
Tony Cappellini wrote: > That would be ideal- but I'm using 2.4 now, and the people using the app > would also have to upgrade to 2.5. > I don't like upgrading unless there's a pressing need. subprocess was added in Python 2.4. Older Python versions have similar functionality in os.popen* and po

Re: [Tutor] [OT?] PyCon

2007-01-30 Thread Jeff Rush
Rob Andrews wrote: > I hope it's not unforgivably off-topic to ask if anyone's planning on > attending PyCon in Feb. > > My manager gave a thumbs-up for me to attend today. Alright! It's going to be a lot of fun. BTW, if you need a hotel room, the price goes up Feb 1st from the con rate of $79

[Tutor] Purging/deleting the logfile with the logging module

2007-01-30 Thread Tony Cappellini
I want to purge (empty) or delete the logfile created by the logging module, and reopen it for a new session. There is reference to a close function in the 2.3 docs, but I don't see how I can purge or delete the file, since I don't have access to the file descriptor. *close*( ) Tidy up any resour

Re: [Tutor] Purging/deleting the logfile with the logging module

2007-01-30 Thread Kent Johnson
Tony Cappellini wrote: > > > I want to purge (empty) or delete the logfile created by the logging > module, and reopen it for a new session. > > There is reference to a close function in the 2.3 docs, but I don't see > how I can purge or delete the file, since I don't have access to the > fil

Re: [Tutor] Purging/deleting the logfile with the logging module

2007-01-30 Thread Tony Cappellini
*close*( ) > > Tidy up any resources used by the handler. This version does nothing > and is intended to be implemented by subclasses. > > How can I purge/delete & reopen the logfile? >>FileHandler has a close() method that presumably does something useful. see above- It says i

Re: [Tutor] Purging/deleting the logfile with the logging module

2007-01-30 Thread Kent Johnson
Tony Cappellini wrote: > > *close*( ) > > > > > Tidy up any resources used by the handler. This version does > nothing > > and is intended to be implemented by subclasses. > > > > How can I purge/delete & reopen the logfile? > > >>FileHandler has a