[Tutor] string replacement

2007-05-21 Thread Chandrashekar
Hi,

I am trying to do something like this in python. Can you please help?

handle= open('test.txt','a')

handle.write('''

Testsomething$i

something$i-test

'''
)

when i write into the file, i would like to have the output like this.

Testsomething1
something1-test
Testsomething2
something2-test
Testsomething3
something3-test
...

I can perform the same using a loop. But how do i append i (1,2,..n) while 
i am writing into the file.(I mean inside the handle.write)

Thanks,
Chandru

   
-
Pinpoint customers who are looking for what you sell. ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] SSH using python

2007-06-04 Thread Chandrashekar
Hi ,

Can anyone tell me how to do ssh to a machine using python and execute programs 
on the remote machine? Thanks in advance. 

Regards,
Chandru


   
-
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] clarification on os.path.walk

2007-06-11 Thread Chandrashekar
Hi,

I have a program like this.

import os,os.path
import re

def print_files(arg,dir,files):
'''print 'arg', arg
print 'dir', dir
print 'files',files'''
for file in files:
path = os.path.join(dir,file)
path = os.path.normcase(path)
if re.search(r".*\.txt",path):
print path
 

os.path.walk('.',print_files,1)

My doubt is that what does the argument stand for in this program?
os.path.walk('.',print_files,0)
os.path.walk('.',print_files,1)
os.path.walk('.',print_files,2)

all seems to be rendering the same output. Can anyone clarify when this 
argument is used.

Thanks,
Chandru



 
-
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Re : Project Work

2006-02-01 Thread Chandrashekar Jayaraman
I m doing a project using Python and Bluetooth . I tried running the
sample programs given with the pybluez-0.5 distro with python 2.4 . The
socket program s just dont seem to run . However the inquiry.py program
run s perfectly. 
ne solutions ?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor