Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107526 > unrolled thread
| Started by | Michael Selik <michael.selik@gmail.com> |
|---|---|
| First post | 2016-04-24 01:38 +0000 |
| Last post | 2016-04-24 01:38 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How much sanity checking is required for function inputs? Michael Selik <michael.selik@gmail.com> - 2016-04-24 01:38 +0000
| From | Michael Selik <michael.selik@gmail.com> |
|---|---|
| Date | 2016-04-24 01:38 +0000 |
| Subject | Re: How much sanity checking is required for function inputs? |
| Message-ID | <mailman.19.1461461927.32212.python-list@python.org> |
On Sat, Apr 23, 2016 at 9:31 PM Christopher Reimer <
christopher_reimer@icloud.com> wrote:
> 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?
>
Why so many files? Python can easily support thousands of lines in a file.
If it's just one file any text editor can do a quick find-replace.
That said, it's easy to make some global ``red = 'red'``.
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.
>
Why hide these things in a dict ``const`` instead of just making them
top-level variables in the module themselves? ``board_top = slice(48,
64)``
> That said, if you're wanting to share constants across different parts
> > of your code, use a module.
>
Or just use one file to keep things easier. But, yes, I agree a module of
constants is appropriate for bigger projects.
Back to top | Article view | comp.lang.python
csiph-web