--- Steve Howell <[EMAIL PROTECTED]> wrote:
>
> Can I suggest a minor optimization?
>
> Instead of this...
>
> def get_predicate(arg):
> return arg if callable(arg) else (
>arg.__eq__ if hasattr(arg,'__eq__')
> else
>lambda item: item == arg)
>
Neve
--- George Sakkis <[EMAIL PROTECTED]> wrote:
> > It seems
> > like it would be fairly straightforward to do a
> quick
> > prototype implementation of this. I'm off to work
> > soon, so I can't do it today, but maybe Sunday.
>
> I'm afraid I beat you to it :)
>
http://aspn.activestate.com/ASPN/
On Jun 1, 7:00 am, Steve Howell <[EMAIL PROTECTED]> wrote:
> --- Tijs <[EMAIL PROTECTED]> wrote:
>
> > Yes, or a single one that takes a wide range of
> > construction possibilities,
> > like strings, lambdas or regexes in various keyword
> > parameters.
>
> > BlockReader(f, start='>')
> > BlockRea
On 2007-06-01, Tijs <[EMAIL PROTECTED]> wrote:
> Steve Howell wrote:
>>>
>>> from blockread import BlockReader
>>>
>>> b = BlockReader(f, boundary='>')
>>> for block in b:
>>> # whatever
>>
>> Yep, I like this idea. You might have a few
>> variations:
>
> Yes, or a single one that takes
Steve Howell wrote:
> Do you have any free time on your hands?
Nope.
I think Python is a programmer's language, not a whack-something-together
script language for text processing (although it is used that way).
Any decent programmer has no need of this construct, since the time to
lookup how
--- Tijs <[EMAIL PROTECTED]> wrote:
>
> Yes, or a single one that takes a wide range of
> construction possibilities,
> like strings, lambdas or regexes in various keyword
> parameters.
>
> BlockReader(f, start='>')
> BlockReader(f, start=re.compile('>|<'), end='---')
> BlockReader(f, start=lambd
Steve Howell wrote:
>>
>> from blockread import BlockReader
>>
>> b = BlockReader(f, boundary='>')
>> for block in b:
>> # whatever
>>
>
> Yep, I like this idea. You might have a few
> variations:
>
Yes, or a single one that takes a wide range of construction possibilities,
like str
--- Tijs <[EMAIL PROTECTED]> wrote:
> Steve Howell wrote:
> > [...] but I wonder if the Python community
> > couldn't help a lot of newbies (or insufficiently
> > caffeinated non-newbies) by any of the following:
> >
> Well, I'm not a newbie, and I always make sure to be
> thoroughly caffeinated
Steve Howell wrote:
>
>
> I think itertools.groupby() is usually the key
> batteries-included component in elegant solutions to
> this problem, but I wonder if the Python community
> couldn't help a lot of newbies (or insufficiently
> caffeinated non-newbies) by any of the following:
>
Well, I
"Lee Sander" <[EMAIL PROTECTED]>wrote:
> I wanted to also say that this file is really huge, so I cannot
> just do a read() and then split on ">" to get a record
> thanks
> lee
>
> On May 31, 1:26 pm, Lee Sander <[EMAIL PROTECTED]> wrote:
> > Dear all,
> > I would like toreada really hugefileth
--- Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> There was just recently a thread with a
> `itertools.groupby()` solution.
Yes, indeed. I think it's a very common coding problem
(with plenty of mostly analogous variations) that has
these very common pitfalls:
1) People often forget t
In <[EMAIL PROTECTED]>, Lee Sander
wrote:
> Dear all,
> I would like to read a really huge file that looks like this:
>
>> name1
> line_11
> line_12
> line_13
> ...
>>name2 ...
> line_21
> line_22
> ...
> etc
>
> where line_ij is just a free form text on that line.
>
> how can i read file s
aspineux wrote:
>
> something like
>
> name=None
> lines=[]
> for line in open('yourfilename.txt'):
> if line.startwith('>'):
> if name!=None:
> print 'Here is the record', name
> print lines
> print
> name=line.stripr('\r')
> lines
Lee Sander wrote:
> I wanted to also say that this file is really huge, so I cannot
> just do a read() and then split on ">" to get a record
> thanks
> lee
Below is the easy solution. To get even better performance, or if '<' is not
always at the start of the line, you would have to implement the
something like
name=None
lines=[]
for line in open('yourfilename.txt'):
if line.startwith('>'):
if name!=None:
print 'Here is the record', name
print lines
print
name=line.stripr('\r')
lines=[]
else:
lines.append(line.str
I wanted to also say that this file is really huge, so I cannot
just do a read() and then split on ">" to get a record
thanks
lee
On May 31, 1:26 pm, Lee Sander <[EMAIL PROTECTED]> wrote:
> Dear all,
> I would like toreada really hugefilethat looks like this:
>
> > name1
>
> line_11
> line_12
16 matches
Mail list logo