On 4/21/2016 10:25 PM, Stephen Hansen wrote:

Why not, 'color in ("black", "white")'?

Checkers seems popular around here. What if I want to change "white" to "red," as red and black is a common color scheme for checkers. Do I change a single constant variable or replace all the occurrences in the files?

Some of these constants are shortcuts. Instead of writing slice(0, 16) or slice(48, 64), and getting the two confused, I write const['board_bottom'] or const['board_top'], respectively, when I want to pull the correct set of positions from coordinates list.

That said, if you're wanting to share constants across different parts
of your code, use a module.

I did that at first, made it into a dictionary class and added ConfigParser to the mix. I had a lot of fun putting that one together. However, as I refactor my code further as I learn new things, it will probably get changed or removed. Being a research project, I'm willing to dive into every rabbit hole that I come across to learn Python properly.

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to