Changeset 815 for trunk/pgdb.py


Ignore:
Timestamp:
Feb 3, 2016, 4:11:13 PM (4 years ago)
Author:
cito
Message:

PEP8 recommends not assigning lambda expressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pgdb.py

    r814 r815  
    7373from math import isnan, isinf
    7474from collections import namedtuple
     75from functools import partial
    7576from re import compile as regex
    7677from json import loads as jsondecode, dumps as jsonencode
     
    117118    from inspect import getargspec
    118119
    119     get_args = lambda func: getargspec(func).args
     120    def get_args(func):
     121        return getargspec(func).args
    120122else:
    121     get_args = lambda func: list(signature(func).parameters)
     123
     124    def get_args(func):
     125        return list(signature(func).parameters)
    122126
    123127try:
     
    432436        if not self.connection or not self._needs_connection(cast):
    433437            return cast
    434         connection = self.connection
    435         return lambda value: cast(value, connection=connection)
     438        return partial(cast, connection=self.connection)
    436439
    437440    def get(self, typ, default=None):
     
    480483                    self.pop('_%s' % t, None)
    481484
    482     def create_array_cast(self, cast):
     485    def create_array_cast(self, basecast):
    483486        """Create an array typecast for the given base cast."""
    484         return lambda v: cast_array(v, cast)
     487        def cast(v):
     488            return cast_array(v, basecast)
     489        return cast
    485490
    486491    def create_record_cast(self, name, fields, casts):
    487492        """Create a named record typecast for the given fields and casts."""
    488493        record = namedtuple(name, fields)
    489         return lambda v: record(*cast_record(v, casts))
     494        def cast(v):
     495            return record(*cast_record(v, casts))
     496        return cast
    490497
    491498
Note: See TracChangeset for help on using the changeset viewer.