Tim Finley wrote:
> I get the following when running a script.
>  
> TypeError: argument 1 must be string or read-only character buffer, 
> not _sre.SRE_Pattern

First, please post the entire error report when asking for help.  In 
this case I can tell you what the problem is, but in others the context 
of the error may not be so apparent.

>  
> Here is the script I am trying to run.   I am trying to verify that my 
> search is returning what I am trying to search for, but due to the 
> error I can verify it.
>  
> import re
>  
> log = open('audit.log') # Opens audit log
> log2 = open('timaudit.log','w')
> for line in log:
>     line =re.compile(r"""

I think you want to use a different variable name than "line".  You're 
using it for the current line, then setting it to the compiled regular 
expression.

>         \w      #match any alphanumeric character
>         \Audit report for user+
>         \User reported as inactive+
>         """, re.VERBOSE)
>     line.search('Audit report for user () User reported as inactive')
>     log2.write(line)

Hence the error.  Write expects a line of text, but it doesn't point to 
the line of text you read any more.

Hope that helps,
e.

>  
> log.close()
> log2.close()
>  
> Thank you,
>  
> Tim Finley
> Novell IT Services Engineer
> Novell Technical Services
> Novell
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to