<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def take(self, n=None, constructor=list):
 """ Returns a container with the n first elements from the Stream, or less if there aren't enough. Use this without args if you need only one element outside a list. Parameters n : Number of elements to be taken. Defaults to None. Rounded when it's a float, and this can be ``inf`` for taking all. constructor : Container constructor function that can receie a generator as input. Defaults to ``list``. Returns ------- The first ``n`` elements of the Stream sequence, created by the given constructor unless ``n == None``, which means returns the next element from the sequence outside any container. If ``n`` is None, this can raise StopIteration due to lack of data in the Stream. When ``n`` is a number, there's no such exception. Examples -------- [5, 5, 5] 1.2 [1.2] (1.2,) [1, 2] Traceback (most recent call last):
 StopIteration Taking rounded float quantities and "up to infinity" elements (don't try using ``inf`` with endless Stream instances):
 [4, 3, 2] [4, 3, 2, 3] [4, 3, 2, 3, 2] See Also -------- Stream.peek : Returns the n first elements from the Stream, without removing them. Note ---- You should avoid using take() as if this would be an iterator. Streams are iterables that can be easily part of a "for" loop, and their iterators (the ones automatically used in for loops) are slightly faster. Use iter() builtin if you need that, instead, or perhaps the blocks method. """

    if n is None:
      return next(self._data)
    if isinf(n) and n > 0:
      return constructor(self._data)
    if isinstance(n, float):
      n = rint(n) if n > 0 else 0 # So this works with -inf and nan
    return constructor(next(self._data) for _ in xrange(n))