We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrote this code today: https://github.com/simonw/datasette-public/blob/1401bfae50e71c1dfd2bfb6954f2e86d5a7ab21b/datasette_public/__init__.py#L41
results = await db.execute( "select 1 from _public_tables where table_name = ?", [table_name] ) if len(results): return True
Would be nice if I could use if results there instead.
if results
The text was updated successfully, but these errors were encountered:
Code can go here:
datasette/datasette/database.py
Lines 511 to 515 in b6ba117
Sorry, something went wrong.
Turns out this already works - __bool__ falls back on __len__: https://docs.python.org/3/reference/datamodel.html#object.__bool__
__bool__
__len__
When this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero.
__len__()
I'll add a test to demonstrate this.
Test for bool(results), closes #1832
b545b6a
bbf33a7
Release 0.63a1
602c088
Refs #1646, #1819, #1825, #1829, #1831, #1832, #1834, #1844, #1848
No branches or pull requests
Wrote this code today: https://github.com/simonw/datasette-public/blob/1401bfae50e71c1dfd2bfb6954f2e86d5a7ab21b/datasette_public/__init__.py#L41
Would be nice if I could use
if results
there instead.The text was updated successfully, but these errors were encountered: