Hi John,
On 2010-08-11 20:24, John Nagle wrote:
Perl has a function which will take a remote directory page, in
the form that most web sites return for a file directory, and
parse it into a useful form:
http://www.xav.com/perl/site/lib/File/Listing.html
This is especially useful
Perl has a function which will take a remote directory page, in
the form that most web sites return for a file directory, and
parse it into a useful form:
http://www.xav.com/perl/site/lib/File/Listing.html
This is especially useful for FTP sites.
Is there a Python equivalent of this?
On Wednesday 11 August 2010, it occurred to John Nagle to exclaim:
This is especially useful for FTP sites.
It sounds like you're trying to use HTTP to something a lot more easily done
with FTP, without any reason not to use FTP.
http://docs.python.org/library/ftplib.html#ftplib.FTP.dir
--
Does python have an equivalent to Perl's inplace-edit variable $^I?
For example, the following perl code below changes mike to dave in a file
that is passed as an argument.
#!/usr/bin/env perl
#chgit script
$^I = '';
while() {
s/mike/dave/g;
print;
}
The script would be used as below:
chgit
#!/usr/bin/env perl
#chgit script
$^I = '';
while() {
s/mike/dave/g;
print;
}
#!/usr/bin/python
import sys
lines = open(sys.argv[1]).readlines()
open(sys.argv[1], 'w').writelines([line.replace('mike', 'dave') for
line in lines])
--
http://mail.python.org/mailman/listinfo/python-list
En Thu, 08 May 2008 09:11:56 -0300, Michael Mabin [EMAIL PROTECTED] escribió:
Does python have an equivalent to Perl's inplace-edit variable $^I?
For example, the following perl code below changes mike to dave in a file
that is passed as an argument.
#!/usr/bin/env perl
#chgit script
$^I =
On Thu, May 8, 2008 at 2:11 PM, Michael Mabin [EMAIL PROTECTED] wrote:
Does python have an equivalent to Perl's inplace-edit variable $^I?
I misread your question.
No, Python eschews magic characters and symbols. They make code ugly
and harder to read and maintain.
The first 3 lines of the
I miswrote my question. But I still completely understand. What I really
wanted to know was whether there was something equivalent to how perl can
perform inplace edits of a file with something like the magic $^I variable.
I see from Gabriel that you can use the fileinput module to achieve
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that interests me is '$/ = .\n' which,
rather than splitting a file into lines, splits on a period-newline
boundary.
On Aug 19, 1:13 pm, John K Masters [EMAIL PROTECTED]
wrote:
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that interests me is '$/ = .\n' which,
rather than
John K Masters [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that interests me is '$/ = .\n' which,
John K Masters [EMAIL PROTECTED] wrote:
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that interests me is '$/ = .\n' which,
rather than splitting a file
On 10:30 Mon 20 Aug , Nick Craig-Wood wrote:
Something like this maybe?
import re
input_data = I am currently working my way through Jeffrey Friedl's book
Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that
On Aug 19, 11:13 am, John K Masters [EMAIL PROTECTED]
wrote:
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.
One particular expression that interests me is '$/ = .\n' which,
rather than
On 19:19 Mon 20 Aug , [EMAIL PROTECTED] wrote:
import StringIO
text = \
To mimic Perl's input record separator in
Python, you can use a generator.
And a substring test.
Perhaps something like the following
is what you wanted.
mockfile = StringIO.StringIO(text)
def
On Aug 20, 1:02 pm, John K Masters [EMAIL PROTECTED]
wrote:
On 19:19 Mon 20 Aug , [EMAIL PROTECTED] wrote:
import StringIO
text = \
To mimic Perl's input record separator in
Python, you can use a generator.
And a substring test.
Perhaps something like the following
is what
16 matches
Mail list logo