Re: How to lock files (the easiest/best way)?

2006-07-16 Thread Jim Segrave
the lockfile. Convert the os.open file # descriptor into a Python file object and record our PID in it f = os.fdopen(fd, w) f.write(%d\n % os.getpid()) f.close() -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to lock files (the easiest/best way)?

2006-07-16 Thread Jim Segrave
In article [EMAIL PROTECTED], Jim Segrave [EMAIL PROTECTED] wrote: except OSError, e: if e.errno != errno.EEXIST: this should read: if e.errno != errno.ENOENT: (it was left with EEXIST from testing this code by forcing an error, as the code for this failure

Re: stderr, stdout, and errno 24

2006-07-13 Thread Jim Segrave
. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Augument assignment versus regular assignment

2006-07-10 Thread Jim Segrave
calls with the same argument. The += version finds the object to be operated upon once, the expanded version does it twice. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: re question

2006-07-10 Thread Jim Segrave
, but not Python's, support (?-flag) and this allows turning the flag off and on for parts of the regex. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: how can I avoid abusing lists?

2006-07-08 Thread Jim Segrave
counters as in the quoted posting. For Python 2.4 and later, you can replace the keyz = counts.keys()/keyz.sourt() for k in keyz: with for k in sorted(counters.heys()): print k, counters[k] -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting 64bit vs. 32bit Linux

2006-07-08 Thread Jim Segrave
which can detect this situation -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: socket buffer flush question

2006-07-05 Thread Jim Segrave
application simply stops transmitting new commands after a timeout? Do you eventually get all the responses in? -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I do it using python?? about xterm and telnet

2006-07-02 Thread Jim Segrave
was to have a post-install CD or floppy which fetched standard server configuration data. This included an ssh public key for our ssh-key distribution, so after running the post-install disc, we could push out staff ssh-keys and logins were available. -- Jim Segrave ([EMAIL PROTECTED

Re: Regular Expression - old regex module vs. re module

2006-07-01 Thread Jim Segrave
ColumnReportTemplate: This class allows one to specify column oriented output formats. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression - old regex module vs. re module

2006-06-30 Thread Jim Segrave
right string Result: right string %6s short right string %1s Testing: escaped chars \ \.## \\ \\ Result: escaped chars \#%3d \#%6.2f \\%-3s \\%-3s -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: string replace

2006-06-30 Thread Jim Segrave
included into.translate(trans_table) prints: I dOn't knOw, bUt cAn bE thIs fEAtUrE InclUdEd IntO That more than addresses your requirements, as it can do multiple character substitutions multiple times in one call. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman

Re: Regular Expression - old regex module vs. re module

2006-06-30 Thread Jim Segrave
. Pyparsing's project wiki is at http://pyparsing.wikispaces.com. If fails for floats specified as ###. or .###, it outputs an integer format and the decimal point separately. It also ignores \# which should prevent the '#' from being included in a format. -- Jim Segrave ([EMAIL PROTECTED

Re: Regular Expression - old regex module vs. re module

2006-06-30 Thread Jim Segrave
In article [EMAIL PROTECTED], Paul McGuire [EMAIL PROTECTED] wrote: Jim Segrave [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In article [EMAIL PROTECTED], Paul McGuire [EMAIL PROTECTED] wrote: Not an re solution, but pyparsing makes for an easy-to-follow program. TransformString

Re: Regular Expression - old regex module vs. re module

2006-06-30 Thread Jim Segrave
In article [EMAIL PROTECTED], Paul McGuire [EMAIL PROTECTED] wrote: Jim Segrave [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I can see that the OP omitted the concept of @||| centering, since the Python string interpolation forms only support right or left justified fields

Re: locating strings approximately

2006-06-29 Thread Jim Segrave
of a large number of string comparision algorithms. They should not be too difficult to port to Python. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Dictionaries

2006-06-05 Thread Jim Segrave
great care to avoid pathological cases. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Dictionaries

2006-06-05 Thread Jim Segrave
In article [EMAIL PROTECTED], Tim Peters [EMAIL PROTECTED] wrote: [Jim Segrave] Actually, presorted lists are not a bad case for heapsort - it's quite immune to any existing order or lack thereof, Write a heapsort and time it. It's not a difference in O() behavior, but more memory movement

Re: wxpython wxgrid question

2006-06-03 Thread Jim Segrave
), bg = #%02x%02x%02x % ((row * 4 + col) * 16, (row * 4 + col) * 16, (row * 4 + col) * 16), fg = #ff ).grid(row = row, column = col, sticky = NSEW) root.mainloop() -- Jim Segrave

Re: grouping a flat list of number by range

2006-06-02 Thread Jim Segrave
' or an exception in his solution, it's a simple if statement at the start of the function. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Jim Segrave
the more common test, to see if the elements of a sequence are identical at the time of comparision need a new operator or hand coding, since most of the time programmers aren't interested in future equality or not of the structures. -- Jim Segrave ([EMAIL PROTECTED]) -- http

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Jim Segrave
there - that's what == does. If you really think there's a need for a comparision which includes dealing with aliasing, then it seems to me a python module with a set of functions for comparisions would make more sense. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman

Re: grouping a flat list of number by range

2006-06-01 Thread Jim Segrave
interval.py [3, 6, 7, 8, 12, 13, 15] = [[3, 4], [6, 9], [12, 14], [15, 16]] [3] = [[3, 4]] [] = [] -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: grouping a flat list of number by range

2006-06-01 Thread Jim Segrave
==0: tmp = val valinc = val + 1 elif val != valinc: yield [tmp, valinc] tmp = val valinc = val+1 yield [tmp, valinc] it now works, but returns [0, 0] when passed an empty list, when it should return nothing at all -- Jim

Re: grouping a flat list of number by range

2006-06-01 Thread Jim Segrave
= val+1 yield [tmp, valinc] Still fails when passed an empty list, the initial assignment to tmp is an IndexError -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: grouping a flat list of number by range

2006-06-01 Thread Jim Segrave
= val ...elif val != valinc: ...yield [tmp, valinc]; tmp = val ...valinc = val+1 ...yield [tmp, valinc] ... list(interv2(inlist)) [[3, 4], [6, 9], [12, 14], [15, 16]] Fails on an empty list, as tmp is not defined when it hits the yield -- Jim

Re: iterator? way of generating all possible combinations?

2006-05-31 Thread Jim Segrave
__iter__(self): self.file.seek(0) while True: line = self.file.readline() if line == '': raise StopIteration nextpos = self.file.tell() yield line self.file.seek(nextpos) -- Jim Segrave ([EMAIL PROTECTED]) -- http

Re: hi,everyone. a problem with shelve Module

2006-05-26 Thread Jim Segrave
In article [EMAIL PROTECTED], softwindow [EMAIL PROTECTED] wrote: [some context restored] Sometimes you add records but the size of the database does not change... :-) really in which case? whenever the database is big enough to add them without it's having to grow :) -- Jim Segrave

Re: regex in python

2006-05-25 Thread Jim Segrave
mean the input is London|country/uk/region/europe/geocoord/32.3244,42.1221244 and you want to convert it to: London|country/uk/region/europe/geocoord/32.32,42.12 then the above regex will work -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python

Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread Jim Segrave
in transit/ -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: buffers readlines and general popen2 confusion...

2006-05-20 Thread Jim Segrave
program normally closes stdin/stdout/stderr and disconnects from its controlling terminal, so where is its output going? -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a tear off menu in TKinter. Help Needed

2006-04-07 Thread Jim Segrave
/Python/Recipe/442500 (see the notes, the demonstration program doesn't work correctly on Windows, because I forgot the directory separator is a '\'. But the code itself works to create cascading auto-pop-up menus, or any other widget you want to pop-up as part of a menu. -- Jim Segrave

Re: Server.sendmail with no to_addrs parameter.

2006-03-22 Thread Jim Segrave
the To: CC: and or Bcc: headers are empty. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Server.sendmail with no to_addrs parameter.

2006-03-22 Thread Jim Segrave
1 bcc 0 1 ... So the answere is, that it's not required to have any destinations listed in the headers of the message. It appears that it's not kosher to have an empty To: header, though I think that few MUAs will balk at this -- Jim Segrave ([EMAIL

Re: time series calculation in list comprehension?

2006-03-12 Thread Jim Segrave
12: 2 38.75 13: 7 33.50 14: 8 27.50 15: 30 11.75 16: 1 11.50 17: 8 11.75 18: 40 19.75 19: 8 14.25 For all but the first 3 rows, the third column is the average of the values in the 2nd column for this and the preceding 3 rows. -- Jim Segrave ([EMAIL PROTECTED

Re: put multiple condition in if statement

2006-03-12 Thread Jim Segrave
for strings containing one space or empty strings. Tab characters and multi-spaces would not match. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb question... using table name as arg

2006-02-03 Thread Jim Segrave
%s set col1 = %%s, col2 = %%s, col3=%%s % (sometable), \ ['the', 'cat', 'in the hat']) Note the need to double the %'s for the parameters to be bound. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs C for a mail server

2006-01-29 Thread Jim Segrave
. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs C for a mail server

2006-01-29 Thread Jim Segrave
sales were insufficient to persuade O'Reilly to do an update. As we use Exim heavily, we have both the 3 and 4 books in our NOC, as well as sending almost all new staff to Phil Hazel's excellent courses in Cambridge. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org

Re: Python vs C for a mail server

2006-01-28 Thread Jim Segrave
use eail and do so incorrectly is astounding and depressing. There's a reason that the source for sendmail is about 120K lines, exim is nearly 270K lines. Doing it right is _hard_. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting problems in a forked process

2005-12-29 Thread Jim Segrave
of the various os.wait functions in the parent to retrieve it. or create a pipe before forking and you can pass data back and forth between the parent and child or look at one of the shared memory libraries -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman

Re: how do i use tkinter.createfilehandler with a regular c program?

2005-11-14 Thread Jim Segrave
newText = filehandle.readline() textBox.insert(END, newText) tkinter.createfilehandler(fh, tkinter.READABLE, readfh) root.mainloop() -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: mod_python

2005-11-06 Thread Jim Segrave
, z_price) ) I hate to ask, but what happens when I enter a, b, c);DROP DATABASE; as the entry for z_name? (Or some similar attempt to close the SQL statement and start a new one). I think you want to google for SQL injection and think about sanitising user input a bit. -- Jim Segrave

Re: strange sockets

2005-11-04 Thread Jim Segrave
until the data has been put on the wire and acknowledged before there's space for the writes. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter- checkbutton

2005-11-04 Thread Jim Segrave
This is impossible, but it happened b = Checkbutton(root, text = 'Press Me', command = check, variable = v) b.grid(row = 0, column = 0) root.mainloop() -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter- New Window

2005-11-04 Thread Jim Segrave
) root.mainloop() -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: fcntl.flock() not working when called from a function

2005-11-04 Thread Jim Segrave
for a SIGINT, the second copy prints nothing. Killing the first copy prints OK on the second one -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list

Re: If Statement Error (Tic Tac Toe)

2005-11-02 Thread Jim Segrave
for r in range(0, 9, 3): print [%s] * 3 % tuple (board[r : r + 3]) print else: print Tie -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list