Hello David,
R. David Murray wrote:
Esmail ebo...@hotmail.com wrote:
Here's a more Pythonic way to do that:
with open('somefile') as f:
for line in f:
if 'somestring' in line:
#do something
In other words, you don't have to read the lines into a list
Esmail wrote:
Hello David,
R. David Murray wrote:
Esmail ebo...@hotmail.com wrote:
Here's a more Pythonic way to do that:
with open('somefile') as f:
for line in f:
if 'somestring' in line:
#do something
In other words, you don't have to
Peter Otten wrote:
In this case I believe I needed the contents in a list because the line
I was looking for was above one that I could easily identify. Ie, once
I had the index, I could go back/up one index to find the line I needed
to process.
Here's one way to avoid the list:
last_line =
MRAB wrote:
Two quick questions:
As a replacement for grep I would use the re module and its methods?
What about awk which I regularly use to extract fields based on position
but not column number, what should I be using in Python to do the same?
Just use string slicing.
Would that be
Hi Gabriel,
Gabriel Genellina wrote:
En Sun, 22 Mar 2009 11:05:22 -0300, MRAB goo...@mrabarnett.plus.com
escribió:
Esmail wrote:
Nick Craig-Wood wrote:
Esmail ebo...@hotmail.com wrote:
..
As a replacement for grep I would use the re module and its methods?
Perhaps; but strings have
Hello again Nick,
thanks for the additional script example. I was able to put
something together where I read the whole file into a list
as a series of lines (via readlines()) and then loop through
the lines seeing if the target string was in the line .. seems
to have worked reasonably well.
I
On 3/21/2009 9:26 AM Esmail apparently wrote:
I also write out some gnuplot scripts
that later get executed to generate .jpg images.
See Gnuplot.py
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list
Alan G Isaac wrote:
On 3/21/2009 9:26 AM Esmail apparently wrote:
I also write out some gnuplot scripts
that later get executed to generate .jpg images.
See Gnuplot.py
Thanks Alan, I will!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Esmail ebo...@hotmail.com wrote:
Hello again Nick,
thanks for the additional script example. I was able to put
something together where I read the whole file into a list
as a series of lines (via readlines()) and then loop through
the lines seeing if the target string was in the line ..
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
Yes!
Right now I have a bigg'ish bash/tcsh script that contain some grep/awk
command plus various files are processed and created, renamed and
moved to specific directories. I also write out
Nick Craig-Wood wrote:
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
Yes!
..
Almost any script that contains a loop I convert into python.
In any case, the scripts are starting to look pretty hairy and I was
wondering if it would
Esmail wrote:
Nick Craig-Wood wrote:
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
Yes!
..
Almost any script that contains a loop I convert into python.
In any case, the scripts are starting to look pretty hairy and I was
wondering
En Sun, 22 Mar 2009 11:05:22 -0300, MRAB goo...@mrabarnett.plus.com
escribió:
Esmail wrote:
Nick Craig-Wood wrote:
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
Two quick questions:
As a replacement for grep I would use the re module
Esmail ebo...@hotmail.com wrote:
thanks for including the script, that really helps. Nice way of
finding files.
Python has lots of useful stuff like that!
Two quick questions:
As a replacement for grep I would use the re module and its
methods?
The re module works on strings not
Hello all,
I am wondering if anyone is using python to write script files?
Right now I have a bigg'ish bash/tcsh script that contain some grep/awk
command plus various files are processed and created, renamed and
moved to specific directories. I also write out some gnuplot scripts
that later
In article mailman.2374.1237641982.11746.python-l...@python.org,
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
These days, I always convert any even slightly complicated script to
Python.
I've looked around the web w/o much luck for some
Aahz wrote:
In article mailman.2374.1237641982.11746.python-l...@python.org,
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
These days, I always convert any even slightly complicated script to
Python.
well .. that sounds encouraging ...
On Sat, Mar 21, 2009 at 9:26 AM, Esmail ebo...@hotmail.com wrote:
In any case, the scripts are starting to look pretty hairy and I was
wondering if it would make sense to re-write them in Python. I am not
sure how suitable it would be for this.
Are these scripts run on computers that are
Hi Joe,
Joe Riopel wrote:
Are these scripts run on computers that are guaranteed to have Python
installed? If not, can you install Python on them?
I use Python when I can, but sometimes shell scripts just makes sense. T
Yes. Currently I am running the bash/tcsh scripts under Ubuntu. The
On Sat, 21 Mar 2009 09:26:02 -0400
Esmail ebo...@hotmail.com wrote:
Hello all,
I am wondering if anyone is using python to write script files?
All the time.
Right now I have a bigg'ish bash/tcsh script that contain some grep/awk
command plus various files are processed and created, renamed
In article mailman.2384.1237643720.11746.python-l...@python.org,
Esmail ebo...@hotmail.com wrote:
Aahz wrote:
In article mailman.2374.1237641982.11746.python-l...@python.org,
Esmail ebo...@hotmail.com wrote:
I've looked around the web w/o much luck for some examples but come
short. Any
On Sat, 21 Mar 2009 09:26:02 -0400, Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
If it can be done in a few simple lines of shell script,
fine: make it a shell script. But if it's more complex than
that, Python is clearer. Just my two cents.
Aahz wrote:
If you post a sample script you're trying to convert, you may get some
responses that show how different people would write it in Python.
That's a nice suggestion .. I may end up doing this after I do some
readings, just wanted to make sure this is not too outlandish of an
idea
Peter Pearson wrote:
On Sat, 21 Mar 2009 09:26:02 -0400, Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
If it can be done in a few simple lines of shell script,
fine: make it a shell script. But if it's more complex than
that, Python is
In article gq2rjc$j...@ger.gmane.org, Esmail ebo...@hotmail.com
wrote:
Aahz wrote:
In article mailman.2374.1237641982.11746.python-l...@python.org,
Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
These days, I always convert any even
Esmail wrote:
Peter Pearson wrote:
On Sat, 21 Mar 2009 09:26:02 -0400, Esmail ebo...@hotmail.com wrote:
I am wondering if anyone is using python to write script files?
If it can be done in a few simple lines of shell script,
fine: make it a shell script. But if it's more complex than
that,
Ned Deily wrote:
Perhaps the recipe for Pyline might give you some ideas on how to write
python scripts that play well with other scripts.
http://code.activestate.com/recipes/437932/
ah .. very nice .. thanks!
--
http://mail.python.org/mailman/listinfo/python-list
andrew cooke wrote:
Esmail wrote:
just a quick data point here -
..
so you might be better spending the time improving your bash skills than
doing what will be largely drudge work in a language you already know.
I'll have to think about it .. at this point I know both languages about
28 matches
Mail list logo