Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

April 05, 2013

Convenient Python Comparisons

I should use these more often, they certainly happen a lot with geometric coding.
# convenient comparisons
for i in range(30):
if 20 <= i <= 25:
print(i)
"""
20
21
22
23
24
25
"""
convenient comparison inside list comprehension
# convenient comparison inside list comprehension
valid_list = [i for i in range(30) if (20 <= i <= 25)]
print(valid_list)
"""
[20, 21, 22, 23, 24, 25]
"""