On Sat, Dec 20, 2008 at 3:40 PM, R. Ellsworth Pollard
wrote:
> Where might I find instructions for compiling Python on Leopard?
If your goal is just to install Python, there is now a Mac installer available.
http://www.python.org/download/releases/2.6.1/
If you really want to build, download the
The following works :
file1 = open (file0, "r")
re.findall ( 'some_text', file1.readline() )
But this doesn't :
re.findall ( 'some_text', file1.readlines() )
How do I use grep for a whole text file, not just a single string ?
--
View this message in context:
http://www.nabble.com/Equival
i believe that the following should work
file1 = open(fileO, 'r')
re.findall ('some_text', file1.read())
readlines returns a list with lists inside, where every list is a line of
the text. The read function returns the entire file as one string, so it
should work to what you are wanting to do.
b
i forgot, this might help you
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
On Sun, Dec 21, 2008 at 11:57 AM, Tiago Katcipis wrote:
> i believe that the following should work
>
> file1 = open(fileO, 'r')
> re.findall ('some_text', file1.read())
>
> readlines returns
Sorry its true, i made a mistake. Readlines is a list with all the lines
inside. I never used readlines (i usually use read), i just read about it on
the tutorial long time ago.
>>> f.readlines()
['This is the first line of the file.\n', 'Second line of the file\n'
Thanks for the help.
On Sun,
- Forwarded message from Tiago Katcipis -
i forgot, this might help you
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
I can't help wondering how to do this in python:
perl -wnl -e '/string/ and print;' filename(s)
Not that I want to forget the pre
file1.read() works.
What do I do if I want line numbers ?
I found this code :
http://snippets.dzone.com/posts/show/1638
src = open('2.htm').read()
pattern = '([^<]+)' # or anything else
for m in re.finditer(pattern, src):
start = m.start()
lineno = src.count('\n', 0, start) +
Hi everyone.
Just learning :) I have one program to parse a podcast feed and put it
into a file.
#!/usr/bin/python
"""Get feed date and link details"""
import feedparser
import sys
def getFeed():
url = raw_input("Please enter the feed: ")
data = feedparser.parse(url)
for entry in d
"Matt Herzog" wrote
I can't help wondering how to do this in python:
perl -wnl -e '/string/ and print;' filename(s)
The first thing to say is that python is not Perl so there will
be things Perl does more easily than Python and vice versa.
(For example Pythons intersactive mode is miles be
This seems to work;
download = L.readline()
print download
download = download[0:-1]
What is that last character that is added;
.mp3%0A
--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu
___
Tutor maillist - Tutor@python.org
http
On Sun, Dec 21, 2008 at 7:29 PM, David wrote:
> This seems to work;
>
> download = L.readline()
> print download
> download = download[0:-1]
>
> What is that last character that is added;
> .mp3%0A
It is a newline character (line feed). readline() includes the line
endings in the returned lines.
Hi David,
David wrote:
> Hi everyone.
> Just learning :) I have one program to parse a podcast feed and put it
> into a file.
Welcome!
>
> def getFeed():
> url = raw_input("Please enter the feed: ")
> data = feedparser.parse(url)
> for entry in data.entries:
> sys.stdout =
Martin Walsh wrote:
Welcome!
thanks
You should probably try to avoid reassigning sys.stdout. This is usually
a bad idea, and can cause odd behavior that is difficult to
troubleshoot, especially for a beginner. A reasonable approach is to
assign the open file object to a name of your own ch
"David" wrote
sys.stdout = open("podcast_links.txt", "a")
print '%s' % (entry.link)
sys.stdout.close()
getFeed()
This "podcast_file.write('%s: %s' % (entry.updated, entry.link))"
writes it in one very long string
Use podcastfile.writeline() to write it line by line
David wrote:
> Martin Walsh wrote:
>
>> Welcome!
>
> thanks
welcome (uh oh, infinite loop warning)
> This "podcast_file.write('%s: %s' % (entry.updated, entry.link))"
> writes it in one very long string
Copy and paste gets me every time. Try this, and note the presence of
the newline ('\n'):
15 matches
Mail list logo