python tricks

2020-09-04 06:27

exclude a directory from os.walk()

note that dir[:] forces internal overwrite rather than copy

for root, dir, files in os.walk():
    dir[:] = [d for d in dir if not d == 'exclude']
    for f in files:
        print(f)

load node.js in python venv

$ python3 -m venv venv
$ source /venv/bin/activate
$ curl http://nodejs.org/dist/node-latest.tar.gz | tar xzf
$ cd node-v*
$ ./configure --prefix=$VIRTUAL_ENV
$ make install