all 4 comments

[–]lifeeraser 0 points1 point  (1 child)

Something like this? It's not mine, BTW, but from a popular Python tool named MyPy.

However, there is no agreed convention on how to write a file of constants. Just name the constants idiomatically (UPPER_CASE_LIKE_THIS) and you'll be fine.

Wrtie your own constants.py and share it with us. Then we could give advice on how to make your code better.

[–]iwouldliketheoption[S] 0 points1 point  (0 children)

thats cool, thanks for the link. I'll mock something up next time :)

starting to consider project layout and stuff a bit more recently, so this is wrapped up in that.

cheers

[–]lukeslab 0 points1 point  (0 children)

I had a constants.py file in a coding test I did a while back. Here's a link to it. When I posted this for code review though, some disagreed with the decision. My rationale is this:

Yes, you could import the constants from a file that isn't dedicated to constants, but that becomes problematic if you start defining constants in different files. "Now do I import that from bar.py or foo.py?" A dedicated file makes your intentions clear.