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...

May 18, 2013

and sparks flew.

Sometimes the more pythonic notation can obfuscate the intent, does anyone agree?
def CountPointOnEdges(point, edges):
''' returns the number of edges that a point lies on. '''
v1, v2, v3, v4 = edges
count = 0
if(isPointOnEdge(point, v1, v2)): count+=1
if(isPointOnEdge(point, v3, v4)): count+=1
return count
def CountPointOnEdges(point, edges):
''' returns the number of edges that a point lies on. '''
edges = zip(*[iter(edges)]*2)
return sum([1 for edge in edges if isPointOnEdge(point, *edge)])
view raw bonafide.py hosted with ❤ by GitHub