On 2007-08-20, Shawn Milochik <[EMAIL PROTECTED]> wrote:
> Everybody hates regexes. Except me. Discrimination!
I love them when I'm editing files with Vim, hate 'em when I'm
analyzing files with Python code. So I'm a descriminate
descriminator.
--
Neil Cerutti
The First World War, cause by the
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote:
>
> Shawn, Tim ,Jay
>
> many thanks,
>
> It looks like there are many ways this problem can be approached
>
> either by using regex or a tokens
>
> Tim I'm not familiar with your solution, but will learn about that method
> also
Hi Brian,
> bu
Shawn Milochik wrote:
> Although you're technically correct, I think there's a knee-jerk
> anti-regex reaction, citing the meaningless overhead. If you're
> running many thousands of records or something then it becomes a small
> issue compared to a replace statement or something. But in most cases
db.connstr=jdbc:oracle:thin:@127.0.0.1:1521:XE
From: [EMAIL PROTECTED] on behalf of Shawn Milochik
Sent: Mon 8/20/2007 4:35 PM
To: python-list@python.org
Subject: Re: reading a line in file
Although you're technically correct, I think there's a
Although you're technically correct, I think there's a knee-jerk
anti-regex reaction, citing the meaningless overhead. If you're
running many thousands of records or something then it becomes a small
issue compared to a replace statement or something. But in most cases
it makes no difference at all
Shawn Milochik wrote:
> Everybody hates regexes. Except me. Discrimination!
Actually, I love them, they are an amazingly powerful tool. I just happen to
also believe the old axiom "when all you have is a hammer, everything looks
like your thumb". Also the related "some people think when they see
Everybody hates regexes. Except me. Discrimination!
--
http://mail.python.org/mailman/listinfo/python-list
Brian McCann wrote:
> Shawn, Tim ,Jay
>
> many thanks,
>
> It looks like there are many ways this problem can be approached
>
> either by using regex or a tokens
>
> Tim I'm not familiar with your solution, but will learn about that
> method also
> Jay, what do you mean by regex comes with a
Brian
From: [EMAIL PROTECTED] on behalf of Shawn Milochik
Sent: Mon 8/20/2007 3:07 PM
To: python-list@python.org
Subject: Re: reading a line in file
Hopefully this will help (using your input file)
#!/usr/bin/env python
import re
buildinfo = "input.txt"
input =
Shawn Milochik wrote:
> Hopefully this will help (using your input file)
>
> #!/usr/bin/env python
> import re
> buildinfo = "input.txt"
> input = open(buildinfo, 'r')
>
> regex = re.compile(r"^\s*build.number=(\d+)\s*$")
>
> for line in input:
> if re.search(regex, line):
> print li
On 20/08/07, Shawn Milochik <[EMAIL PROTECTED]> wrote:
> Hopefully this will help (using your input file)
>
> #!/usr/bin/env python
> import re
> buildinfo = "input.txt"
> input = open(buildinfo, 'r')
>
> regex = re.compile(r"^\s*build.number=(\d+)\s*$")
>
> for line in input:
>if re.search(reg
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote:
>
>
>
>
> From: [EMAIL PROTECTED] on behalf of Tim Williams
> Sent: Mon 8/20/2007 2:59 PM
> To: Brian McCann
> Cc: python-list@python.org
> Subject: Re: reading a line in file
&g
Hopefully this will help (using your input file)
#!/usr/bin/env python
import re
buildinfo = "input.txt"
input = open(buildinfo, 'r')
regex = re.compile(r"^\s*build.number=(\d+)\s*$")
for line in input:
if re.search(regex, line):
print line
buildNum = re.sub(r"^\s*build.numbe
To: Brian McCann
Cc: python-list@python.org
Subject: Re: reading a line in file
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I can read in the whole file build.number which has the following lines
> how do I just capture the value of build.number and as
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I can read in the whole file build.number which has the following lines
> how do I just capture the value of build.number and assign it to a variable
> Thanks,
> Brian
>
> contents of file build.number:
> #Build Number for ANT. Do not
e when script is run
$ buildinfo.py
#Build Number for ANT. Do not edit!
#Mon Aug 20 04:04:51 EDT 2007
build.number=1
From: [EMAIL PROTECTED] on behalf of Shawn Milochik
Sent: Mon 8/20/2007 1:29 PM
To: python-list@python.org
Subject: Re: reading a line in file
Writ
Write some code, even if it doesn't quite work, and post it. We'll
help you fix it.
You can open a file with: input = open("file.txt", "r")
You can read a line with: someText = input.readline()
You can loop through an open file like this:
for line in input:
#do something with line
That s
17 matches
Mail list logo