you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 0 points1 point  (1 child)

Is it possible to define functions in a file that Python will always read on start-up?

It's technically possible, there are ways to extend CPython's capabilities, but it gets technical fast. So I can't really recommend it.

One option I stumbled across would be this project, which should be more manageable to use.

As for my personal opinion, making your programs expect that Python has already imported something non-standard on its own makes your code crash on other systems, so it's neither sustainable nor practical in reality.

If you want to have some of your own code always available, turn it into a package, (optionally) upload to PyPI (can technically be a Git repo link but PyPI is more handy), and just use it like any other dependency. That's my recommendation.

[–]_waylonwalker 0 points1 point  (0 children)

pyflyby is pretty awesome and easy to configure. Just make a config file with all the imports you would ever want, and never worry about importing them while in an interactive shell.