Re: Generating a unique identifier

2007-09-07 Thread Will Maier
On Fri, Sep 07, 2007 at 12:03:23PM -, Steven D'Aprano wrote: [...] > which is easy enough, but I thought I'd check if there was an existing > solution in the standard library that I missed. Also, for other > applications, I might want them to be rather less predictable. 2.5 includes the uuid

Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Will Maier
On Thu, Aug 23, 2007 at 11:22:55AM -0600, darren kirby wrote: > Python 2.4.4 (#1, Aug 23 2007, 10:51:29) > [GCC 4.1.2 (Gentoo 4.1.2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import time > 40:42:0 > >>> now = time.time() > Traceback (most recent call

Re: Simple python iteration question

2007-08-14 Thread Will Maier
On Tue, Aug 14, 2007 at 12:22:04PM -0400, Bryan wrote: > I just started with python, and have a for loop question > > In c++ (or a number of other languages) I can do this: > > for (int i=0, j=0; i < i_len, j< j_len; ++i, ++j) {} > > If I have this in python: > l = ['a', 'b', 'c'] > > I want to

Re: passing vars to py scipts in cron jobs

2007-08-07 Thread Will Maier
On Tue, Aug 07, 2007 at 05:45:46PM -0400, brad wrote: > What's the proper way to call a py script and pass in variables > while doing cron jobs? I can run the scripts fine from idle, > python, etc using raw_input() to prompt users. The scripts have > classes with methods that need arguments. This

Re: Sorting dict keys

2007-07-20 Thread Will Maier
On Fri, Jul 20, 2007 at 03:27:51PM -0700, [EMAIL PROTECTED] wrote: > Consider the following: > >>> a = {1:2, 3:4, 2:5} > > Say that i want to get the keys of a, sorted. First thing I tried: > > >>> b = a.keys().sort() > >>> print b > None list's sort() method sorts the list _in_place_: >>>

Re: How to check if an item exist in a nested list

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 02:43:13PM -0700, Arash Arfaee wrote: > One way is to check the length of each dimension. Does any body > know a simpler way? is there any way to check if "IndexError: list > index out of range" happened or going to happen and stop program > from terminating? If I understan

Re: Pure Python equivalent of unix "file" command?

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 03:29:35PM -0400, W3 wrote: > Just a quick one... Is there such a thing? Debian et al ship Python bindings[0] for file(1)[1]. file works by using a file (/etc/magic) with 'magic' numbers in it to figure out the type of a file. Googling 'python magic' will turn up a few inte

Re: Log Memory Usage

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 04:35:56AM -0500, Will Maier wrote: > On Thu, Jul 19, 2007 at 09:52:36AM +0100, Robert Rawlins - Think Blue wrote: > > I have a scheduled event which occurs every minute, i just need a > > code solution to give me the systems current memory consumptions

Re: Log Memory Usage

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 09:52:36AM +0100, Robert Rawlins - Think Blue wrote: > I have a scheduled event which occurs every minute, i just need a > code solution to give me the systems current memory consumptions > details, is there perhaps something in the os module? I don't know of anything in th

Re: Interpreting os.lstat()

2007-07-18 Thread Will Maier
On Wed, Jul 18, 2007 at 05:55:59PM -0700, Adrian Petrescu wrote: > I can see some correspondence between the "stat" call and os.lstat > (for example, I'm guessing os.lstat(path)[6] represents the filesize), > but I can't see the correspondence between some of the other fields. > What does os.lstat(

Re: Newbie: freebsd admin scripting

2007-07-18 Thread Will Maier
On Wed, Jul 18, 2007 at 04:31:35PM -0700, Evan Klitzke wrote: > > I found a built in mod for parseconfig but it deal with .ini > > file styles (windows) that include a [section] header as well as > > uses someiteam=somevalue format. I believe it requires the > > header though. > > I think you're r

Re: getting text inside the HTML tag

2007-07-14 Thread Will Maier
On Sat, Jul 14, 2007 at 05:47:22PM +, Nikola Skoric wrote: > I'm using sgmllib.SGMLParser to parse HTML. I have successfuly > parsed start tags by implementing start_something method. But, now > I have to fetch the string inside the start tag and end tag too. I > have been reading through SGMLP

Re: condor_compiled python interpreter

2007-07-11 Thread Will Maier
On Wed, Jul 11, 2007 at 10:28:52AM -0700, Thomas Nelson wrote: > Does anyone know where I could find help on condor_compiling a > python interpreter? My own attempts have failed, and I can't find > anything on google. This is probably more condor-related than Python-related, but are you building

Re: process stdin grab

2007-06-28 Thread Will Maier
On Thu, Jun 28, 2007 at 08:01:18PM +, Seltzer wrote: > I need to send commands to a process that i did not start. > (mplayer specifically) I have the PIP of the process, and thats > about all. I assume you mean 'PID'. This is somewhat offtopic, but mplayer supports receiving commands from a FI

Re: Reversing a string

2007-06-27 Thread Will Maier
On Wed, Jun 27, 2007 at 12:53:36PM -0400, Scott wrote: > So how on earth would be the best way to: Write a function that > takes a string as an argument and outputs the letters backward, > one per line. >>> def rev(forward): ... backward = list(forward) ... backward.reverse()

Re: finding an element in a string

2007-06-25 Thread Will Maier
On Mon, Jun 25, 2007 at 04:09:50PM -0400, Miguel Oliveira wrote: > I want to make an if statement in which I would like to find a > certain word in a sentence; here is what i have so far: > >x = raw_input("how are you?") > >if x == "fine": > print "Good." > > But that, obvio