Graphics

2008-07-10 Thread vanam
hi all
i am new to python programming a beginner. I Came to know from the
groups that "How to think like a computer scientist" is preferable for
begineers. i just looking through that i came to one section where a
sample program for generation of graphics is present.i tried to copy
the same script to the interpreter and it is showing an error i want
to know whether is there anything that has to be installed in addition
to python 2.5
below is the program
from gasp import *
begin_graphics()
Circle((200, 200), 60)
Line((100, 400), (580, 200))
Box((400, 350), 120, 100)
end_graphics()
--
http://mail.python.org/mailman/listinfo/python-list


[File Input Module]Replacing string in a file

2010-01-28 Thread vanam
Hi all,

For replacing string in the file, i have used the module File
input for replacing the string in the file.

For understanding and execution purpose, i have just included Python
as a string in the file and want it to be replaced to PYTHON.

Below are my queries and code: (Correct me if my understanding is
wrong???)

1))

import fileinput
x = fileinput.input('data.txt',inplace=0)
for line in x:
line = line.replace('Python','PYTHON)
print line,
x.close()

The above piece of code will not create any backup file but  it will
replace PYTHON (Print on the console) but not physically write to the
file.

2)))

import fileinput
x = fileinput.input('data.txt',inplace=1)
for line in x:
   line = line.replace('Python','PYTHON')
   print line,
x.close()

The above piece of code will create backup file but hidden (in the
form of bak file) and it will physically write to the file -- I have
verified the contents of data.txt after the file operation and it had
written successfully.But why it is not printing line i.e. string in
the file on the console.

3)))

import fileinput
x = fileinput.input('data.txt',inplace=1)
for line in x:
   line = line.replace('Python','PYTHON')
x.close()

The above piece of code after execution is wiping out the full
contents. But addition of print line, is exactly replacing the string,
what exactly addition of print is making difference???

4)))

import fileinput
x = fileinput.input('data.txt',inplace=1,backup='content.txt')
for line in x:
   line = line.replace('Python','PYTHON')
   print line,
x.close()

The above piece is creating a backup file by name data.txtcontent.txt
(I am not sure whether created file name is correct or not?) and to
the back up file it had added previous content i.e., Python and it had
replaced the contents in data.txt to PYTHON
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: process mp3 file

2010-03-05 Thread vanam
On Mar 3, 3:43 pm, asit  wrote:
> > Define "processing".
>
> getting the title, song name, etc of the file and updating in a
> database

Other possibility can be passing out the extension of the file and
directory where
the files are present, using os.walk we can extract the file name by
filtering the .mp3 extension.
-- 
http://mail.python.org/mailman/listinfo/python-list