Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread William O'Higgins Witteman
On Tue, Aug 14, 2007 at 08:11:33PM +0100, Tom Fitzhenry wrote: >On Tue, Aug 14, 2007 at 11:06:05AM -0700, Dick Moores wrote: >> Replying only to the list takes a bit of trouble. The default >> behavior seems to be that the "Reply" button addresses the author >> only and not the list; "Reply to al

Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-04 Thread William O'Higgins Witteman
On Wed, Jul 04, 2007 at 02:47:45PM -0400, Kent Johnson wrote: >encode() really wants a unicode string not a byte string. If you call >encode() on a byte string, the string is first converted to unicode >using the default encoding (usually ascii), then converted with the >given encoding. Aha!

Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-04 Thread William O'Higgins Witteman
On Wed, Jul 04, 2007 at 11:28:53AM -0400, Kent Johnson wrote: >FWIW, I'm pretty sure you are confusing Unicode strings and UTF-8 >strings, they are not the same thing. A Unicode string uses 16 bits to >represent each character. It is a distinct data type from a 'regular' >string. Regular Python st

Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-04 Thread William O'Higgins Witteman
On Tue, Jul 03, 2007 at 06:04:16PM -0700, Terry Carroll wrote: > >> Has anyone found a silver bullet for ensuring that all the filenames >> encountered by os.walk are treated as UTF-8? Thanks. > >What happens if you specify the starting directory as a Unicode string, >rather than an ascii string,

[Tutor] UTF-8 filenames encountered in os.walk

2007-07-03 Thread William O'Higgins Witteman
I have several programs which traverse a Windows filesystem with French characters in the filenames. I have having trouble dealing with these filenames when outputting these paths to an XML file - I get UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 ... etc. That happens when I try to c

Re: [Tutor] pruning and ordering a list of lists

2007-03-23 Thread William O'Higgins Witteman
On Fri, Mar 23, 2007 at 05:31:51PM -0700, Bob Gailer wrote: >William O'Higgins Witteman wrote: >>I have a list of lists derived from a log file that I want to create a >>summary of, but I am not sure of an approach to do what I need. >> >>Here's a sample of the

[Tutor] pruning and ordering a list of lists

2007-03-22 Thread William O'Higgins Witteman
I have a list of lists derived from a log file that I want to create a summary of, but I am not sure of an approach to do what I need. Here's a sample of the data: [["user1","18/Mar/2007:07:52:38 -0400"],["user1","18/Mar/2007:07:52:40 -0400"],["user2","18/Mar/2007:07:52:42 -0400"],["user3","18/M

Re: [Tutor] Python for Sysadmins

2007-02-13 Thread William O'Higgins Witteman
On Tue, Feb 13, 2007 at 04:38:47PM +0100, Christopher Arndt wrote: >Steve Nelson schrieb: >> I'd like some suggestions for a course outline - bear in mind I'll >> only have a day for the course. The attendees are all sysadmins with >> a UNIX background, and are reasonably comfortable with shell, b

[Tutor] Getting HTTP response codes

2007-01-30 Thread William O'Higgins Witteman
I am looking to get the HTTP response from a URI - 200, 404, etc. I'm not sure which module I should look at. I've looked at urllib and urllib2, but they only seem to provide this information in Exceptions, and then only if there is an error. That's fine if I'm only looking for implicit 200's, b

Re: [Tutor] OT: Vim was: free IDE for Python?

2006-11-17 Thread William O'Higgins Witteman
On Fri, Nov 17, 2006 at 11:02:18AM +0530, [EMAIL PROTECTED] wrote: >What the settings of ppl using vim for python? A few Python-specific things that I have in my .vimrc are as follows: set autoindent set ts=2 set shiftwidth=2 set expandtab set shiftround set smarttab filetype plugin on syntax on

Re: [Tutor] free IDE for Python?

2006-11-16 Thread William O'Higgins Witteman
On Thu, Nov 16, 2006 at 08:36:25AM -0700, Mike Hansen wrote: >I found the getting started docs got me going with Eclipse and Pydev. > >http://www.fabioz.com/pydev/manual_101_root.html > >I still find myself using VIM more than Eclipse. I'll need to play with >Eclipse some more to make a decision i

Re: [Tutor] free IDE for Python?

2006-11-14 Thread William O'Higgins Witteman
On Tue, Nov 14, 2006 at 12:28:02PM -0500, Richard Querin wrote: > On 11/14/06, Tim Johnson <[EMAIL PROTECTED]> wrote: > > I've used vim in the past for python and recommend it for ease of > use and support. I also use emacs, which may be found harder to > > I have to chuckle when yo

Re: [Tutor] Encoding and XML troubles

2006-11-08 Thread William O'Higgins Witteman
Thanks for the help thusfar. To recap - when parsing XML, ElementTree is barfing on extended characters. 1. Yes, most XML is written by monkeys, or the programs written by such monkeys - tough beans, I cannot make my input XML any cleaner without pre-processing - I am not generating it. 2. The d

[Tutor] Encoding and XML troubles

2006-11-04 Thread William O'Higgins Witteman
I've been struggling with encodings in my XML input to Python programs. Here's the situation - my program has no declared encoding, so it defaults to ASCII. It's written in Unicode, but apparently that isn't confusing to the parser. Fine by me. I import some XML, probably encoded in the Windows

[Tutor] I need a time object from the future

2006-10-20 Thread William O'Higgins Witteman
I've been looking into this, and I am not understanding how to get this task done. I need to be able to look at a time object and know if it si between now and a set point 120 days in the future. I can get a value for now (currently I am using datetime.datetime.now()), but I haven't found a way t

[Tutor] embedding lists in configuration files

2006-10-12 Thread William O'Higgins Witteman
I am looking for a way to use a plain text configuration file in a Python program instead of hard-coded values. The configuration data currently is in the form of a couple of lists and some triple-quoted strings. I was looking at the ConfigParser module, but I cannot see how to use this format to

[Tutor] Trying to catch an exception...

2006-09-15 Thread William O'Higgins Witteman
I am running a program (via py2exe) that is reading some XML files with xml.minidom. I am getting an error wherein I pull a value from a tag which (I think) happens to be empty. Thus, it throws this error: AttributeError: 'NoneType' object has no attribute 'data' Here's the code that creates th

Re: [Tutor] Excluding branches while walking directory tree

2006-09-14 Thread William O'Higgins Witteman
On Wed, Sep 13, 2006 at 11:34:25AM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> I have to walk a directory tree and examine files within it. I have a >> set of directory names and filename patterns that I must skip while >> doing this walk. How do

[Tutor] Excluding branches while walking directory tree

2006-09-13 Thread William O'Higgins Witteman
Hello all, I am looking for an approach for the following problem: I have to walk a directory tree and examine files within it. I have a set of directory names and filename patterns that I must skip while doing this walk. How do I create a set of rules to skip files or directory branches? I'm

Re: [Tutor] Injecting Data into XML Files

2006-09-11 Thread William O'Higgins Witteman
On Mon, Sep 11, 2006 at 02:38:46PM -0400, Kent Johnson wrote: >>>On Mon, Sep 11, 2006 at 12:11:37PM -0400, William O'Higgins Witteman >>>wrote: >>>>What I want is to open each document and inject some data between >>>>specific sets of tags. I&

Re: [Tutor] Injecting Data into XML Files

2006-09-11 Thread William O'Higgins Witteman
On Mon, Sep 11, 2006 at 09:57:28AM -0700, Dave Kuhlman wrote: >On Mon, Sep 11, 2006 at 12:11:37PM -0400, William O'Higgins Witteman wrote: >> I have a large number of XML documents to add data to. They are >> currently skeletal documents, looking like this: >> >>

[Tutor] Injecting Data into XML Files

2006-09-11 Thread William O'Higgins Witteman
I am wrestling with the incredibly vast array of XML parsing and writing documentation, and I'm not seeing (or perhaps not understanding) what I'm looking for. Here's the situation: I have a large number of XML documents to add data to. They are currently skeletal documents, looking like this:

Re: [Tutor] Regex help

2006-08-28 Thread William O'Higgins Witteman
On Mon, Aug 28, 2006 at 11:36:18AM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> Thank you for this. The problem is apparently not my syntax, but >> something else. Here is a pared-down snippet of what I'm doing: >> >> In [1]: import r

Re: [Tutor] Regex help

2006-08-28 Thread William O'Higgins Witteman
On Sat, Aug 26, 2006 at 09:45:04AM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> I want a case-insensitive, verbose pattern. I have a long-ish list of >> match criteria (about a dozen distinct cases), which should be all "or", >> so I won

[Tutor] Regex help

2006-08-26 Thread William O'Higgins Witteman
Hello all, I've been looking for an example of the regex I need, and so far, I haven't found anything. Here's what I need: I want a case-insensitive, verbose pattern. I have a long-ish list of match criteria (about a dozen distinct cases), which should be all "or", so I won't need to be clever

Re: [Tutor] Matching dictionary entries by partial key

2005-10-07 Thread William O'Higgins Witteman
On Thu, Oct 06, 2005 at 10:28:23PM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> I'm trying to traverse a dictionary looking for partial matches of the >> key, and I'm not sure how. Here's a sample dictionary: >> >> dict =

[Tutor] Matching dictionary entries by partial key

2005-10-06 Thread William O'Higgins Witteman
I'm trying to traverse a dictionary looking for partial matches of the key, and I'm not sure how. Here's a sample dictionary: dict = {1234 : value1, 20051234 : value2, 20071234 : value3} Here's what I'm trying to do: for key in dict: if key == or key == 2005: do som