Chris Lasher escribió:
How about os.rename
http://docs.python.org/lib/os-file-dir.html
On 10/15/06, Alfonso [EMAIL PROTECTED] wrote:
Is there an alternative in python to use shutil.move()?
That's exactly what I was looking for. Thank you very much. Don't know
how I didn't find it before. I
His lab maintains a significant amount of Perl code
this sounds like a full-time job on its own. everyone brings up a
good point... use the right tool for the job. if it's one-liners,
that's what perl -e is made for. for everything else that you
mentioned above, Python is the the one,
Bill Campbell [EMAIL PROTECTED] wrote in messageThe
function is in the os module ([2]
http://docs.python.org/lib/os-file-dir.html).
Silly me. I was looking in the os.path module :-).
Yes, its confusing/. One thing that should be rationalised IMHO
is the various os modules.There are
Chris Hengge wrote:
I like this little snip of code from your suggestion, and I may
incorporate it...
for ext in ['.cap', '.hex', '.fru', '.cfg']:
if aFile.lower().endswith(ext):
return True
Just for sake of sharing.. here is my entire method..
Hopefully for the
On Mon, 16 Oct 2006 01:16:19 +0200
Alfonso [EMAIL PROTECTED] wrote:
Is there an alternative in python to use shutil.move()?
It copies the files and then removes the source file insted of just
moving directly the file (don't know much about file systems, but I
suppose that when you move
| Alfonso [EMAIL PROTECTED] wrote:
|
| Is there an alternative in python to use shutil.move()?
|
| It copies the files and then removes the source file insted of just
| moving directly the file (don't know much about file systems, but I
| suppose that when you move using the shell, if
I know about using sendkeys to simulate typing on
the keyboard, but how can I simulate holding down a key for several
seconds?
thanks
Jack
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
What commands can I use tohave the program
know a certain key has been pressed while another program is in
focus?
thanks,
Jack
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Jack wrote:
What commands can I use to have the program know a certain key has
been pressed while another program is in focus?
I think Pygame and TKInter have a capture-all-keys function, but this
might also prevent the keypresses from actually going to the target
application.
thanks,
On Mon, Oct 16, 2006, Alan Gauld wrote:
Bill Campbell [EMAIL PROTECTED] wrote in messageThe
function is in the os module ([2]
http://docs.python.org/lib/os-file-dir.html).
Silly me. I was looking in the os.path module :-).
Yes, its confusing/. One thing that should be rationalised
Alan Gauld wrote:
Bill Campbell [EMAIL PROTECTED] wrote in messageThe
function is in the os module ([2]
http://docs.python.org/lib/os-file-dir.html).
Silly me. I was looking in the os.path module :-).
Yes, its confusing/. One thing that should be rationalised IMHO
is the various os
* Chris Lasher [EMAIL PROTECTED] [2006-10-15 22:07]:
Haha! I'll relay that message! Thanks Kent and Glenn!
Here is one I actually use in real life. I needed something to figure
out what the previous year, month, etc for rolling up old log files.
The best thing I could think of for date
Excellent suggestions! I'll see how many of them I can impliment.Part of my project 'criteria' is that someone that doesn't know python (or possibly programming) should be able to follow my work to add a new system to the list. Right now I've got it setup so it only takes 3 steps. The reason for
David Rock [EMAIL PROTECTED] wrote in message
This is embedded inside a shell script.
python -c '
import time
import datetime
dtup_now = time.localtime()
y,m,d = dtup_now[:3]
d_today = datetime.datetime(y,m,d)
d_delta = datetime.timedelta(d_today.day)
last_month = d_today - d_delta
Jack [EMAIL PROTECTED] wrote in message
I know about using sendkeys to simulate typing on the keyboard,
but how can I simulate holding down a key for several seconds?
I think you need to use ctypes or pythonwin to send a
key_down/key_up sequence using the Windows
Post/SendMessage API function.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paulino
Sent: Sunday, October 15, 2006 10:10 AM
To: tutor@python.org
Subject: [Tutor] Exception and sys.exit() in a cgi script
This is a peace of a CGI script i have.
1 import cgi
2
Jack [EMAIL PROTECTED] wrote in message
What commands can I use to have the program know a certain key has
been pressed while another program is in focus?
In windows the Key_Down message will tell you if you know the
other (focused) window handle.
Alan G.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of wesley chun
Sent: Monday, October 16, 2006 12:51 AM
To: Chris Lasher
Cc: Python Tutor
Subject: Re: [Tutor] Equivalent to perl -e
His lab maintains a significant amount of Perl code
this
Yes, its confusing/. One thing that should be rationalised IMHO
is the various os modules.There are os, os.path, shutil, and now
subprocess too.
The portions of these modules that have to do with files and file
paths
are collected in the path module which many people find very handy:
[...]
I certainly wouldn't like to see python breaking backwards
compatibility, which is probably my primary gripe about open
source software (although Bell Labs was equally guilty when they
did things like change the ``grep -y'' option to ``grep -i'').
Bill
From what I understand,
[Jack]
What commands can I use to have the program know a certain key has
been pressed while another program is in focus?
[Luke]
I think Pygame and TKInter have a capture-all-keys function, but this
might also prevent the keypresses from actually going to the target
application.
If you
Hello,
I am trying to capture telnet output to a file. For example I want to
telnet into a router and run the command “show arp” and be able to
capture all the arp information that normally would show up on the
screen to a file on my system.I am using python and pexpect to
backup my router
On Mon, Oct 16, 2006, [EMAIL PROTECTED] wrote:
Hello,
I am trying to capture telnet output to a file. For example I want to
telnet into a router and run the command ?show arp? and be able to
capture all the arp information that normally would show up on the
screen to a file on my system.I am
From what I understand, Python 3000 is going to break backwards
compatibility. However, I think I read that someone is writing a utility
that will translate your pre-Python 3000 code to Python 3000 code.
this will mainly be side effects or for features that are deprecated
(sufficient notice is
* Alan Gauld [EMAIL PROTECTED] [2006-10-16 17:32]:
Why?
Why not just put it in a Python script?
I'm missing something I think.
I don't think you are missing anything. It was something that just sort
of happened one day. I was trying to do something fairly simple in a
shell script and
[EMAIL PROTECTED] wrote:
Hello,
I am trying to capture telnet output to a file. For example I want to
telnet into a router and run the command “show arp” and be able to
capture all the arp information that normally would show up on the
screen to a file on my system.I am using python
I was not aware of script. Thanks!
- Original Message -
From: Bill Campbell [EMAIL PROTECTED]
Date: Monday, October 16, 2006 1:55 pm
Subject: Re: [Tutor] Capture telnet output to a file?
To: tutor@python.org
On Mon, Oct 16, 2006, [EMAIL PROTECTED] wrote:
Hello,
I am trying to
That looks like it will do what I want.
Thank You!
- Original Message -
From: Kent Johnson [EMAIL PROTECTED]
Date: Monday, October 16, 2006 2:06 pm
Subject: Re: [Tutor] Capture telnet output to a file?
To: [EMAIL PROTECTED]
Cc: tutor@python.org
[EMAIL PROTECTED] wrote:
Hello,
I
On 16/10/06, Jack [EMAIL PROTECTED] wrote:
What commands can I use tohave the program
know a certain key has been pressed while another program is in
focus?Hello,On windows I use the pyHook module (simple to use and works fine) :http://www.cs.unc.edu/~parente/tech/tr08.shtml
On Linux its
wesley chun wrote:
From what I understand, Python 3000 is going to break backwards
compatibility. However, I think I read that someone is writing a utility
that will translate your pre-Python 3000 code to Python 3000 code.
this will mainly be side effects or for features that are deprecated
On Mon, Oct 16, 2006, [EMAIL PROTECTED] wrote:
I was not aware of script. Thanks!
Don't feel bad.
I've been using *NIX systems since 1982, and still find new
commands from time to time (and we won't talk of the continual
``stupid vi tricks'' I find :-).
Bill
--
INTERNET: [EMAIL PROTECTED]
Using one of the things you suggested... if / in afile: aZipFile = afile.rsplit('/', 1)[-1] # Split file based on criteria. outfile = open(aZipFile, 'w') # Open output buffer
for writing. outfile.write(zfile.read(afile)) # Write the file. outfile.close() # Close the output file buffer. elif \\ in
On 10/16/06, Kent Johnson [EMAIL PROTECTED] wrote:
wesley chun wrote:
From what I understand, Python 3000 is going to break backwards
compatibility. However, I think I read that someone is writing a utility
that will translate your pre-Python 3000 code to Python 3000 code.
this will
Chris Hengge wrote:
Here is my solution, completed with (I think) all your suggestions...
#
def extractZip(filePathName):
This method recieves the zip file name for decompression, placing the
contents of
I chose the way I used the names because to me...outFile = open(aFile.lower(), 'w') # Open output buffer for writing.= open a file with lowercase name for writing.it is implied that aFile is from the zip, since it is created in the loop to read the zip..
outFile.write(zFile.read(insideZip)) #
Here is a snippet of code that may work for you:
#---
import telnetlib
HOST = myServer
Username = bob
Password = fido
LoginList = ['=login:', '%s=password:' % (Username), '%s=$' %
(Password)] ## Like an Expect script
Terminator = $
print CONNECTING:
Telnet =
hi :
I have a simple question to ask tutors:
list A :
a = [10,15,18,20,25,30,40]
I want to print
10 15 (first two elements)
16 18 (16 is last number +1)
19 20
21 25
26 30
31 40
fx = a[0]
fy = a[1]
b = a[2:]
ai = iter(b)
last = ai.next()
for j in ai:
... print fy+1,last
... last
I want to print
10 15 (first two elements)
16 18 (16 is last number +1)
:
fx = a[0]
fy = a[1]
b = a[2:]
ai = iter(b)
last = ai.next()
for j in ai:
... print fy+1,last
... last = j
...
16 18
16 20
16 25
16 30
look very carefully at variables 'fy' vs. 'last', what
On 10/16/06, kumar s [EMAIL PROTECTED] wrote:
hi :I have a simple question to ask tutors:list A :a = [10,15,18,20,25,30,40]I want to print10 15 (first two elements)16 18 (16 is last number +1)19 2021 2526 3031 40
fx = a[0] fy = a[1] b = a[2:] ai = iter(b) last = ai.next() for j in ai:... print
kumar s [EMAIL PROTECTED] wrote
a = [10,15,18,20,25,30,40]
I want to print
10 15 (first two elements)
16 18 (16 is last number +1)
19 20
The simplest solution would seem to be a while loop:
print a[0], a[1] # special case
index = 1
while index len(a):
print a[index-1]+1, a[index]
Chris Hengge wrote:
I chose the way I used the names because to me...
outFile = open(aFile.lower(), 'w') # Open output buffer for writing.
= open a file with lowercase name for writing.
it is implied that aFile is from the zip, since it is created in the
loop to read the zip..
wesley chun [EMAIL PROTECTED] wrote in message
look very carefully at variables 'fy' vs. 'last', what you do with
them, and when, and you should be able to figure out your homework
assignment problem.
Hmmm, homework assignment was probably what I was missing
Alan G.
I want to make a GUI in which user can write text in a text box and then
click a button to save it to a text file. I'm using wxPython's TextCtrl
widget.
Then later I would want the user to be able to open it back into that
window.
Any help appreciated, thank you.
My solution : (i have tested it)
list1 = [10,15,18,20,25,30,40]
for i in range(len(list1)-1): print list1[i],list1[i+1]list1[i+1] += 1
Note:
#print the consecutive elements;for thefirst pass of the loop the elements are unchanged, for the remaining we add one.
On 10/16/06, kumar s [EMAIL
On 17/10/06, Pine Marten [EMAIL PROTECTED] wrote:
I want to make a GUI in which user can write text in a text box and then
click a button to save it to a text file. I'm using wxPython's TextCtrl
widget.
Then later I would want the user to be able to open it back into that
window.
Any help
Asrarahmed Kadri wrote:
My solution : (i have tested it)
list1 = [10,15,18,20,25,30,40]
for i in range(len(list1)-1):
print list1[i],list1[i+1]
list1[i+1] += 1
Note that this changes the original list, which may or may not be
acceptable. Normally you would expect a printing
I agree.
Regards,
Asrar
On 10/17/06, Kent Johnson [EMAIL PROTECTED] wrote:
Asrarahmed Kadri wrote: My solution : (i have tested it) list1 = [10,15,18,20,25,30,40]
for i in range(len(list1)-1): print list1[i],list1[i+1] list1[i+1] += 1Note that this changes the original list, which may or may not
On 17/10/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote:
My solution : (i have tested it)
As long as we're all taking turns, what about a functional approach:
a = [10, 15, 18, 20, 25, 30, 40]
def pairs(lst):
... return list.__add__([(lst[0], lst[1])], zip(map((1).__add__,
lst[1:]), lst[2:]))
I want to make a GUI in which user can write text in a text box and then
click a button to save it to a text file. I'm using wxPython's TextCtrl
widget.
Then later I would want the user to be able to open it back into that
window.
Any help appreciated, thank you.
Have you learnt how
I didn't come up with those variable names willy nilly... I chose them because they reflect their functionality.. Which to me, is much more important then anything else... if I go back and look at code months later.. I have an easier time remember names based on functionality, and less of an easy
Chris Hengge wrote:
I didn't come up with those variable names willy nilly...
I know :)
I just wanted to make it clear that your statement 'that's what comments
are for' wasn't really a good way to look at it.
If you have to write a comment because your usage of variables, or
something else
[quote]and I didn't read your code[/quote]How's that supposed to help? =D
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Thank you John for the code but I still can't get it to work and to simply
save the contents of the text box to a file. Here is the code I have which
just makes a panel with a text control and two buttons, Save and Save
As... My hope is this can easily incorporate the changes you suggest,
On 17/10/06, Pine Marten [EMAIL PROTECTED] wrote:
Thank you John for the code but I still can't get it to work and to simply
save the contents of the text box to a file. Here is the code I have which
just makes a panel with a text control and two buttons, Save and Save
As... My hope is this
Chris Hengge wrote:
I chose the way I used the names because to me...
outFile = open(aFile.lower(), 'w') # Open output buffer for writing.
= open a file with lowercase name for writing.
it is implied that aFile is from the zip, since it is created in the
loop to read the zip..
Oops, I replied off-list. Forwarding copy to list.
---BeginMessage---
Pine Marten wrote:
Thank you John for the code but I still can't get it to work and to simply
save the contents of the text box to a file. Here is the code I have which
just makes a panel with a text control and two
Have you even read my code to see if you find it cryptic? I'm starting to beleive people just read the one comment on possibly using better naming conventions and assumed I had picked completely irrelivent names.
On 10/16/06, Jonathon Sisson [EMAIL PROTECTED] wrote:
Chris Hengge wrote: I chose
Chris Hengge wrote:
Have you even read my code to see if you find it cryptic? I'm starting
to beleive people just read the one comment on possibly using better
naming conventions and assumed I had picked completely irrelivent names.
Well, Chris, what can I say? We're busy people and we
Did you create this code, or did someone give it to you? It looks
like it's been made with BoaConstructor. If you're using Boa for
development, you'd probably be better off using it to add your save
functionality, rather than writing the code by hand.
Unfortunately, I can't help you with
On Mon, 16 Oct 2006, Chris Hengge wrote:
Have you even read my code to see if you find it cryptic? I'm starting
to beleive people just read the one comment on possibly using better
naming conventions and assumed I had picked completely irrelivent names.
Hi Chris,
Sometimes one of us (or
On 10/17/06, David Rock [EMAIL PROTECTED] wrote:
* Alan Gauld [EMAIL PROTECTED] [2006-10-16 17:32]: Why? Why not just put it in a Python script? I'm missing something I think.
I don't think you are missing anything.It was something that just sortof happened one day.I was trying to do something
61 matches
Mail list logo