Quick questions about globals and database connections

Python python at example.invalid
Thu Apr 6 10:54:21 EDT 2017


Le 06/04/2017 à 16:46, DFS a écrit :
> On 4/5/2017 10:52 PM, Dan Sommers wrote:
>> On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:
>>
>>> I have a simple hard-coded check in place before even trying to connect:
>>>
>>> if dbtype not in ('sqlite postgres'):
>>>    print "db type must be sqlite or postgres"
>>>    exit()
>>
>> That's not doing what you think it is.
>>
>> Hint:  What is ('sqlite postgres')?
>
> ?
>
> dbtype is a string, and the check works perfectly.  No typos make it
> past the guard.

except that it would be True for dbtype = 'lite post' or dbtype = 'stgr'





More information about the Python-list mailing list