If you don’t know what Nock is, you had better start here. It’ll take you a while. Don’t worry. We’ll still be here when you get back.
Welcome back! Now that you know what Nock is… have you written a Nock parser, and you still don’t understand Nock? This module is for you. Not only is this a fully [1] functional [2] Nock environment, it’s a Nock environment that will explain what the heck is going on.
The module is written in a literate style (cribbing generously from urbit.org). We encourage a close reading. While you’re reading, we also recommend playing along at home:
In [1]: from nock import *
In [2]: debug()
In [3]: tar((42, (4, 0, 1)))
DEBUG:nock:*[42 [4 0 1]]
DEBUG:nock: <- 25 :: *[a 4 b] +*[a b]
DEBUG:nock: *[42 [0 1]]
DEBUG:nock: <- 21 :: *[a 0 b] /[b a]
DEBUG:nock: /[1 42]
DEBUG:nock: 42
DEBUG:nock: 42
DEBUG:nock: +42
DEBUG:nock: 43
DEBUG:nock: 43
Out[3]: 43
Or better yet:
In [4]: tar((42, (6, (1, 0), (4, 0, 1), (1, 233))))
DEBUG:nock:*[42 [6 [1 0] [4 0 1] [1 233]]]
DEBUG:nock: <- 28 :: *[a 6 b c d] *[a 2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]
DEBUG:nock: *[42 2 [0 1] 2 [1 [4 [0 1]] [1 233]] [1 0] 2 [1 2 3] [1 0] 4 4 [1 0]]
DEBUG:nock: <- 23 :: *[a 2 b c] *[*[a b] *[a c]]
DEBUG:nock: *[42 [0 1]]
DEBUG:nock: <- 21 :: *[a 0 b] /[b a]
DEBUG:nock: /[1 42]
DEBUG:nock: 42
DEBUG:nock: 42
DEBUG:nock: *[42 [2 [[1 [[4 [0 1]] [1 233]]] [[1 0] [2 [[1 [2 3]] [[1 0] [4 [4 [1 0]]]]]]]]]]
DEBUG:nock: <- 23 :: *[a 2 b c] *[*[a b] *[a c]]
DEBUG:nock: *[42 [1 [[4 [0 1]] [1 233]]]]
DEBUG:nock: <- 22 :: *[a 1 b] b
DEBUG:nock: [[4 [0 1]] [1 233]]
DEBUG:nock: *[42 [[1 0] [2 [[1 [2 3]] [[1 0] [4 [4 [1 0]]]]]]]]
DEBUG:nock: <- 19 :: *[a [b c] d] [*[a b c] *[a d]]
DEBUG:nock: *[42 [1 0]]
DEBUG:nock: <- 22 :: *[a 1 b] b
DEBUG:nock: 0
DEBUG:nock: *[42 [2 [[1 [2 3]] [[1 0] [4 [4 [1 0]]]]]]]
DEBUG:nock: <- 23 :: *[a 2 b c] *[*[a b] *[a c]]
DEBUG:nock: *[42 [1 [2 3]]]
DEBUG:nock: <- 22 :: *[a 1 b] b
DEBUG:nock: [2 3]
DEBUG:nock: *[42 [[1 0] [4 [4 [1 0]]]]]
DEBUG:nock: <- 19 :: *[a [b c] d] [*[a b c] *[a d]]
DEBUG:nock: *[42 [1 0]]
DEBUG:nock: <- 22 :: *[a 1 b] b
DEBUG:nock: 0
DEBUG:nock: *[42 [4 [4 [1 0]]]]
DEBUG:nock: <- 25 :: *[a 4 b] +*[a b]
DEBUG:nock: *[42 [4 [1 0]]]
DEBUG:nock: <- 25 :: *[a 4 b] +*[a b]
DEBUG:nock: *[42 [1 0]]
DEBUG:nock: <- 22 :: *[a 1 b] b
DEBUG:nock: 0
DEBUG:nock: +0
DEBUG:nock: 1
DEBUG:nock: 1
DEBUG:nock: +1
DEBUG:nock: 2
DEBUG:nock: 2
DEBUG:nock: [0 2]
DEBUG:nock: *[[2 3] [0 2]]
DEBUG:nock: <- 21 :: *[a 0 b] /[b a]
DEBUG:nock: /[2 [2 3]]
DEBUG:nock: 2
DEBUG:nock: 2
DEBUG:nock: 2
DEBUG:nock: [0 2]
DEBUG:nock: *[[[4 [0 1]] [1 233]] [0 2]]
DEBUG:nock: <- 21 :: *[a 0 b] /[b a]
DEBUG:nock: /[2 [[4 [0 1]] [1 233]]]
DEBUG:nock: [4 [0 1]]
DEBUG:nock: [4 [0 1]]
DEBUG:nock: [4 [0 1]]
DEBUG:nock: *[42 [4 [0 1]]]
DEBUG:nock: <- 25 :: *[a 4 b] +*[a b]
DEBUG:nock: *[42 [0 1]]
DEBUG:nock: <- 21 :: *[a 0 b] /[b a]
DEBUG:nock: /[1 42]
DEBUG:nock: 42
DEBUG:nock: 42
DEBUG:nock: +42
DEBUG:nock: 43
DEBUG:nock: 43
DEBUG:nock: 43
DEBUG:nock: 43
Out[4]: 43
Horrifying, innit? Welcome to life in the offworld colonies. The air gets installed next week.
Unfortunately, there’s no parser yet, so you have to translate that lovely Nock syntax into verbose Python function calls and tuples, but we use true names for all the operators, so we only help you sink deeper into the water. Is that really water? Either way, soon enough, you won’t even realize you’re breathing it.
Tests
Did we mention we have tests? Bushels and bushels of glorious doctests. Well, for everything except lines 31 and 32. We have no idea what those are about, but we’re sure they’re just fine.
To run the tests, install nose and run it with:
nosetests --with-doctest
Contributing
Is something bothering you? Join the club. Join the club and open an issue, that is. Do you have a way to make this better? Do you happen to have a Nock parser burning a hole in your back pocket? DO YOU UNDERSTAND WHAT LINES 31 AND 32 MEAN, AND CAN YOU WRITE TESTS TO PROVE IT?! Open a pull request.
Credits
Thanks to James Tauber, for his original pynock. This would have taken a lot longer without that. And of course, thanks to C. Guy Yarvin, for his methodical madness.
Metadata
Release files for nock 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nock-0.2.1.tar.gz | 14.8 kB | Without provenance | Details |
Release files / nock-0.2.1.tar.gz
| Download URL | nock-0.2.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6feb47055f821519c50e5bb2d1d6d87c7f78837baa759fc1383bc07d2f372d02
|
|
BLAKE2b-256 checksum How to use checksums |
8efe16dd567968fa81d81290ed4667263baae7cac6277044ba933f0f84e6af52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for nock 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.