예제 #1
0
def period2pos(index, date):
    """Returns the position (index) of a timestamp vector.

    Args:
        index (list): timestamp vector.
        date (string): date to search.

    Returns:
        position (int): position of date in index.

    """
    x = [i for i, elem in enumerate(index) if elem == date]
    if x == []:
        raise ValueError('Date does not exists: ' + date.__repr__())
    return x[0]
예제 #2
0
 def __repr__(self):
     return 'bdateutil.' + basedate.__repr__(self)
예제 #3
0
 def __repr__(self):
     return 'bdateutil.' + basedate.__repr__(self)
예제 #4
0
from datetime import date
tues = date(2011, 9, 12)
print(repr(tues))
print(str(tues))

print(tues.__repr__())
print(date.__repr__(tues))
print(tues.__str__())
print(date.__str__(tues))

print(len('Go Bears!'))
print('Go Bears!'.__len__())
print(bool(''))
print(bool([]))
print(bool('Go Bears!'))
print('Go Bears!'[3])
print('Go Bears!'.__getitem__(3))


def make_adder(n):
    def adder(k):
        return n + k
    return adder

add_three = make_adder(3)
print(add_three(4))

class Adder:
    def __init__(self, n):
        self.n = n