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

Showing posts with label namedtuple. Show all posts
Showing posts with label namedtuple. Show all posts

June 29, 2013

named tuples replacement (bounding box tools)

To maintain sanity I suggest you don't read this script, it's just a memo to self.

April 13, 2013

filling namedtuple from content of a dict

not surprisingly this just works.

August 26, 2011

namedtuple


This is more a note to self, sometimes it makes sense to not use an iterable. While switching to a namedtuple won't make the task of programming routines easier, any prudent student of the language will instantly notice that employing a namedtuple can increase readability especially for parsing csv. I think it's really cool that the class creation is abstracted away, and can't wait to use it on the next project to call for it.

addendum by Campbell Barton:
" my main annoyance with named tuples is they're implemented in python so they're not as fast as builtin types like dicts."

Edit 2014: Amazingly.. there are easier ways

Almost 4 years on and I can safely say I've used neither method - ever. What I have used repeatedly is zero setup, zero hassle. A simple 'Null Lambda' Object, because it supports object attributes. lambda: None might look a little weird the first few times.