Archive

Coding Bits

Pipenv is so snazzy.

Here’s a list of problems it solves: https://realpython.com/pipenv-guide/

My favorite (minor) feature is that I now no longer have to .gitignore all the virtualenv directories for Python projects.

Thoughtbot has a great guide on getting started: https://robots.thoughtbot.com/how-to-manage-your-python-projects-with-pipenv

Recently, there was a “TypeError: ‘module’ object is not callable” bug (with a workaround) but looks like it’s been fixed: https://github.com/pypa/pipenv/issues/2871

This post is a gift to my future self for when I no longer writer Python daily and need a refresher.

Chris Yeh has a wonderful post on the correct syntax to write import statements in Python.

The essence is, if you have a directory structure like:

awesome_project/
    run.py
    foo/
        __init__.py
        bar.py
        baz.py

In run.py:

from foo import bar

bar.Bar()

In baz.py:

from .bar import Bar

Bar()

We went to a delightful Python conference this past weekend in the small town of Petaluma.

North Bay Python

The entire conference took place inside a cute little theater.

There were tons of great talks, from the keynotes by Brandon Rhodes and Carina C Zona to our friend George.

I loved the atmosphere of the conference. It was very charming.

As always, here are some great conference quotes:

“Monkey patching is software bankruptcy.” ~Brandon Rhodes

“You want to ride the line between funny and what the hell did [the bot] just say.” ~Benno Rice

 

So I’m here at GHC again.

I heard an amazing keynote from Dr. Fei-Fei Li. She mentioned the Hubel and Wiesel Cat Experiment.

I’d never heard of this experiment before, but was pretty amazed.

Maybe it’s because I took a ML class recently but hearing the neurons fire from the straight line was incredible. It’s totally what the lower level neurons perceive in an artificial multi-layered neural network for image processing!

So exciting!

Go has some interesting quirks.

Recently I learned you can iterate over nil slices.

Here’s an example:

var foo []string // nil slice
var bar = []string{} // empty slice

fmt.Println(foo == nil) // true
fmt.Println(bar == nil) // false

for _, v := range foo { // no errors
	fmt.Println("%v", v)
}

for _, v := range bar { // no errors
	fmt.Println("%v", v)
}

Normally, I avoid returning nils in functions, to reduce the need for a nil check before iterating, but looks like Go has it built in.

Neat!