[Tutor] UnicodeEncodeError

2009-07-19 Thread gpo
I'm doing a simple excercise in reading a file, and printing each line. However, I'm getting this error. The file is a windows txt file, ecoded in ANSI(ascii). I don't understand why Pythin is displaying a Unicode error. Here is my script: f=open('I:\\PythonScripts\\statement.txt') for line

[Tutor] Issues with regex escaping on \{

2009-07-29 Thread gpo
My regex is being run in both Python v2.6 and v3.1 For this example, I'll give one line. This lines will be read out of log files. I'm trying to get the GUID for the User ID to query a database with it, so I'd like a sub match. Here is the code - import re line = '>Checking Priv

Re: [Tutor] Issues with regex escaping on \{

2009-07-30 Thread gpo
Thanks! The ? got rid of the greediness! vince spicer wrote: > > On Wed, Jul 29, 2009 at 11:35 AM, gpo wrote: > > > your grouping (.+) appears to be greedy, you can make it non-greedy with a > question mark > > EX: > > pUserID=re.compile('

[Tutor] New Issues with REGEX Greediness:

2009-08-02 Thread gpo
Thanks for the replies in the last thread. I'm still trying to figure out how Python is handling RegEx. I'm converting my thoughts from Perl (the mother of regex) to Python, and expect the same results. Why are they different? Perl: $line='>Checking Privilege for UserId: {874BE70A-194B-DE11-BE