MostAwesomeDude/construct — pull request #23 by tomerfiliba (2012-04-01 15:14:47+00:00)
Title: Adding this expressions

I backported the `this` expression that I introduced to construct3 (which I don't have time to finish). So I decided it would be a good idea to backport it. It's 100% backwards compatible, so there's no harm whatsoever, and it's much more readable and concise than those ugly lambdas.

In short:
* instead of `Field(..., lambda ctx.length)` use `Field(..., this.length)`
* Instead of `Field(..., lambda ctx: ctx["_"]["length"] * 4)` use `Field(..., this._.length * 4)`
* Instead of `If(lambda ctx: ctx["foo"] > 17, ...)`, use `If(this.foo > 17, ...)`

I included a unit test (`tests/test_this.py`).

By the way, I would suggest moving the tests directory out of the package, e.g.

construct_repo/
construct/
core.py
...
docs/
tests/ <==