Re: Datetime module

2005-01-09 Thread Binu K S
The time module will do. >>> import time >>> time.ctime() 'Mon Jan 10 11:17:54 2005' Use strftime if you need to format the time differently. >>> time.strftime("%Y-%m-%d %H:%m:%S",time.localtime()) '2005-01-10 11:01:45' On 9 Jan 2005 21:46:12 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >

Re: file.readlines() - gives me error (bad file descriptor)

2005-01-06 Thread Binu K S
http://mail.python.org/pipermail/python-bugs-list/2001-October/007650.html Rest assured you're not on drugs :) On Thu, 6 Jan 2005 14:45:24 +0530, Gurpreet Sachdeva <[EMAIL PROTECTED]> wrote: > On Thu, 6 Jan 2005 14:27:40 +0530, Binu K S <[EMAIL PROTECTED]> wrote: > > I&

Re: file.readlines() - gives me error (bad file descriptor)

2005-01-06 Thread Binu K S
On Thu, 6 Jan 2005 13:17:11 +0530, Gurpreet Sachdeva <[EMAIL PROTECTED]> wrote: > On Thu, 6 Jan 2005 12:55:22 +0530, Binu K S <[EMAIL PROTECTED]> wrote: > >>>The file's current position moves as you write into it. > I concure and have figured out the solution BUT

Re: file.readlines() - gives me error (bad file descriptor)

2005-01-05 Thread Binu K S
There's nothing crazy going on here. The file's current position moves as you write into it. Both read and write operation use the same offset. The tell() method gives you the current position at any time. When you append to a file the position moves to the end of the file so that the next write ha

Re: date/time

2005-01-05 Thread Binu K S
>>> import time >>> time.strftime('%Y%m%d',time.localtime()) '20050105' On Wed, 05 Jan 2005 15:08:37 +0100, Nader Emami <[EMAIL PROTECTED]> wrote: > L.S., > > Could somebody help me how I can get the next format of date > from the time module? > > example: I have to have this time 20050105. It i

Re: Problem in threading

2004-12-29 Thread Binu K S
You haven't split the task between the threads here. loops should be set to [2500,2500] for a correct comparison. On a single processor system, a tight loop like the one you are testing will at best show the same time as the non-threaded case. Most likely the threaded version will take more time o

Re: Global variables and modules

2004-12-23 Thread Binu K S
Add these lines to test1.py and see what you get: import test2 print 'test2.glbl postinc ', test2.glbl This will work as you expect. Next try chaning glbl in test2 to a list (a mutable type). test2.py: glbl = [25] def inc_glbl(): global glbl glbl[0] = glbl[0] + 1 def get_glb

Re: String backslash characters

2004-12-23 Thread Binu K S
'\378' becomes a two character string. The first character is '\37' and the second character is '8'. >>> str = '\378' >>> str[0] '\x1f' >>> str[1] '8' >>> On 23 Dec 2004 20:53:13 -0800, PD <[EMAIL PROTECTED]> wrote: > Hello, > > I am new to python, but i am quite curious about the following. >

Re: word to digit module

2004-12-21 Thread Binu K S
Oops! That just does the opposite of what you want. I guess you can tinker it a bit to do the reverse conversion unless someone suggests a better module. On Wed, 22 Dec 2004 10:41:46 +0530, Binu K S <[EMAIL PROTECTED]> wrote: > You'll find a script here: > http://www.python

Re: word to digit module

2004-12-21 Thread Binu K S
You'll find a script here: http://www.python.org/pycon/dc2004/papers/42/ex1-C/ Found it in the miscellany section at http://www.vex.net/parnassus/ (num2eng) On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva <[EMAIL PROTECTED]> wrote: > Is there any module available that converts word like 'one

Re: Avaliable free modules

2004-12-16 Thread Binu K S
Vaults of Parnassus: http://www.vex.net/parnassus/ On Thu, 16 Dec 2004 18:56:09 +0800, sam <[EMAIL PROTECTED]> wrote: > Hi group, > > Is there any site like cpan.org for python? > > Thanks > Sam > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listi

Re: temp file name

2004-12-16 Thread Binu K S
Use the tempfile module instead. It is more secure. Check the documentation for tempfile.NamedTemporaryFile. If you are only looking to get a unique name and want to do the file management yourself, you may have to close the file opened by this function and reopen it. On Fri, 17 Dec 2004 17:21:53

Re: How do I convert characters into integers?

2004-12-15 Thread Binu K S
On Wed, 15 Dec 2004 23:59:13 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote: > > message = [chr( (ord( x ) + 3 )%256) for x in message] > Minor correction: message = ''.join([chr( (ord( x ) + 3 )%256) for x in message]) -- http://mail.python.org/mailman/listinfo/python-list

Re: ftp

2004-12-15 Thread Binu K S
Try retrbinary instead of retrlines in the original script (the one without write('\n')). retrlines fetches the file in ASCII mode and that must be altering the line terminations. On 15 Dec 2004 15:49:31 -0800, hawkmoon269 <[EMAIL PROTECTED]> wrote: > I would like to write a small ftp script that

Re: spawn* or exec* and fork, what should I use and how ?

2004-12-15 Thread Binu K S
exec calls will replace the script process with the new process. >From the execv documentation: "These functions all execute a new program, replacing the current process; they do not return. On Unix, the new executable is loaded into the current process, and will have the same process ID as the ca

Re: Regular Expression

2004-12-14 Thread Binu K S
You can do this without regular expressions if you like >>> uptime='12:12:05 up 21 days, 16:31, 10 users, load average: 0.01, 0.02, 0.04' >>> load = uptime[uptime.find('load average:'):] >>> load 'load average: 0.01, 0.02, 0.04' >>> load = load.split(':') >>> load ['load average', ' 0.01, 0.02,

Re: Path problem

2004-12-12 Thread Binu K S
THONPATH." -Binu On Mon, 13 Dec 2004 18:03:30 +1100, Lars Yencken <[EMAIL PROTECTED]> wrote: > Hi Binu, > > On 13/12/2004, at 4:11 PM, Binu K S wrote: > > This should get you the module's path: > > > > import sys > > sys.modules['rpy']._

Re: Path problem

2004-12-12 Thread Binu K S
This should get you the module's path: import sys sys.modules['rpy'].__file__ On Mon, 13 Dec 2004 15:48:29 +1100, Lars Yencken <[EMAIL PROTECTED]> wrote: > Hello, > > I'm working on a project where my python modules are using persistent > files in the same directory. As an example, we're using r

Re: for loop

2004-12-12 Thread Binu K S
If you are used to the C kind of for loops, avoid mistakes like this one: >>> for i in range(1,6): ... print i ... i+=2 ... 1 2 3 4 5 Obvious if you know you are iterating over a sequence. -- http://mail.python.org/mailman/listinfo/python-list