"Bob Ippolito" <[EMAIL PROTECTED]> writes:
> Well "is" tests for object identity. It's strange that the
> configuration file cares either way though, traditionally anything
> that coerces to False should be fine (e.g. empty list, empty string,
> None, 0, 0.0).
That's the point. If I use:
>>> a = 0
>>> if a: print "Hi!"
...
>>> if not a: print "oops!"
...
oops!
>>>
Then this shouldn't matter. But if I use:
>>> if a is False: print "Hi!"
...
>>> if a is True: print "oops!"
...
>>>
Then it won't work. They shouldn't do that ("is True"/"is False") but I've
seen code like that around and this is why I made my comment.
>From PEP-8:
- Don't compare boolean values to True or False using ==
Yes: if greeting:
No: if greeting == True:
Worse: if greeting is True:
Looking at the source code in SQL Alchemy you'll see that they do the identity
check (line between "#" below). Here's the result of a "grep" for echo:
engine/default.py: kwargs.setdefault('echo', False)
engine/base.py: if self.__engine.echo:
engine/base.py: if self.__engine.echo:
engine/base.py: if self.__engine.echo:
engine/base.py: def _execute_raw(self, statement, parameters=None,
cursor=None, echo=None, context=None, **kwargs):
################################################################################
engine/base.py: if echo is True or self.__engine.echo is not False:
################################################################################
engine/base.py: def __init__(self, connection_provider, dialect, echo=False,
logger=None, **kwargs):
engine/base.py: self.echo = echo
engine/base.py: self.echo = engine.echo=="debug"
engine/base.py: if self.echo: self.engine.log(repr(row))
engine/__init__.py: echo=False : if True, the Engine will log all statements
as well as a repr() of their
engine/__init__.py: "echo" data member can be modified at any time to turn
logging on and off. If set to the string
engine/__init__.py: logger=None : a file-like object where logging output
can be sent, if echo is set to True.
engine/strategies.py: for key in (('echo_pool', 'echo'), ('pool_size',
'pool_size'), ('max_overflow', 'max_overflow'), ('poolclass', 'poolclass'),
('pool_timeout','timeout'), ('pool', 'pool')):
engine/strategies.py: for key in (('echo_pool', 'echo'), ('pool_size',
'pool_size'), ('max_overflow', 'max_overflow'), ('poolclass', 'poolclass'),
('pool_timeout','timeout'), ('pool', 'pool')):
orm/unitofwork.py:# with the "echo_uow=True" keyword argument.
orm/unitofwork.py: def flush(self, session, objects=None, echo=False):
orm/unitofwork.py: flush_context.execute(echo=echo)
orm/unitofwork.py: def execute(self, echo=False):
orm/unitofwork.py: if LOG or echo:
orm/unitofwork.py: if LOG or echo:
orm/session.py: def __init__(self, bind_to=None, hash_key=None,
import_session=None, echo_uow=False):
orm/session.py: self.echo_uow = echo_uow
orm/session.py: self.uow.flush(self, objects, echo=self.echo_uow)
pool.py: echo=False : if set to True, connections being pulled and retrieved
from/to the pool will
pool.py: def __init__(self, echo = False, use_threadlocal = True,
logger=None):
pool.py: self.echo = echo
pool.py: if self.pool.echo:
pool.py: if self.pool.echo:
pool.py: if self.pool.echo:
sql.py: def execute_compiled(self, compiled, parameters, echo=None,
**kwargs):
Be seeing you,
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---