r/Python • • Jun 06 '11

asq 1.0 : LINQ style queries over Python iterables. Feature equivalence with LINQ for objects, full test coverage and comprehensive documentation.

http://asq.googlecode.com
38 Upvotes

25 comments sorted by

View all comments

Show parent comments

2

u/norwegianwood Jun 06 '11

To answer your specific questions: Regarding take(),

>>> import asq.queryables
>>> help(asq.queryables.Queryable.take)
Help on method take in module asq.queryables:

take(self, count=1) unbound asq.queryables.Queryable method
    Returns a specified number of elements from the start of a sequence.

    If the source sequence contains fewer elements than requested only the
    available elements will be returned and no exception will be raised.

None of the query operators such as select() mutate the sequence, they all return a new iterable over the result elements, most of them lazily, like a generator. The method names and behaviour are the same as LINQ.

1

u/eryksun Jun 06 '11

Thanks again. I realize it's stuck with LINQ's nomenclature. By mutate I just meant that it's altering the returned values (such as making them uppercase), not mutating the underlying objects. It was counter-intuitive to me that a selection would do that. I expected the argument to be a predicate. Regarding 'take', I thought it could go either way -- taking from the beginning or the end. Neither of these was hard to figure out based on the results.

1

u/aaronla Jun 06 '11

... expected [the argument to select] to be a predicate

That would be where(). It took me a while to learn the naming conventions (I guess a bunch of the names come from SQL)