On 4/21/2016 7:20 PM, Stephen Hansen wrote:
Whyyy are you using getattr? Something wrong with PieceFactory.factory(color, piece, position)? (Or, better yet, yield piece_factory(color, piece, position) where piece_factory is just a function)

Because the example I found used it, I implemented it, and it worked in my code. Based on feedback that I gotten from this list, I'll go back and clean it up.

I... that... what... I'd forget that link and pretend you never went
there. Its not helpful.

I found it on the Internet, so it must be true -- and Pythonic at that!

What's the contents of this big dictionary that has everything in it for some reason?

Keep in mind that I'm coming from a Java background (not by choice) with a smattering of C programming. I initially had ALL THESE CONSTANTS in different parts of my code and couldn't easily use them across different modules. I didn't like all these constants, created a singleton class that uses ConfigParser, dumped everything into a .ini file, and accessed from in each module. As I learn to write Pythonic code, the constants may go away. Switching from my original code to the factory method eliminated a half-dozen constants.

Thank you,

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

Reply via email to