Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107528 > unrolled thread
| Started by | Christopher Reimer <christopher_reimer@icloud.com> |
|---|---|
| First post | 2016-04-23 19:03 -0700 |
| Last post | 2016-04-24 08:56 +0300 |
| Articles | 3 — 3 participants |
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? Christopher Reimer <christopher_reimer@icloud.com> - 2016-04-23 19:03 -0700
Re: How much sanity checking is required for function inputs? Steven D'Aprano <steve@pearwood.info> - 2016-04-24 15:38 +1000
Re: How much sanity checking is required for function inputs? Marko Rauhamaa <marko@pacujo.net> - 2016-04-24 08:56 +0300
| From | Christopher Reimer <christopher_reimer@icloud.com> |
|---|---|
| Date | 2016-04-23 19:03 -0700 |
| Subject | Re: How much sanity checking is required for function inputs? |
| Message-ID | <mailman.21.1461463390.32212.python-list@python.org> |
On 4/23/2016 2:33 PM, Matt Wheeler wrote: > This is still backwards to me. It prevents your classes from being > suitable for restoring a stored game state, not just custom starting > positions (which I think is what Ethan means by custom setups). I haven't thought that far about saving the game state. I'm under the impression that pickle (or something else) would save and load the instantiated object of each piece. If that's not the case, I'll change the code then. The sanity check does have an exemption for pawn promotion, where a pawn reaching the other side of the board can be promoted to another piece (typically a queen). I played Sargon II chess on the Commodore 64 for five years as a teenager. The worst game I ever won was when the computer had nine queens on the board. I thought the computer was cheating outrageously but a chess rule book confirmed that promotion was a legit move. https://en.wikipedia.org/wiki/Promotion_(chess) If I need to add an exemption to custom plays, I'll add it then. Right now I'm cleaning up the existing code from all the bad Java habits. Thank you, Chris R.
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2016-04-24 15:38 +1000 |
| Message-ID | <571c5bd3$0$1602$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #107528 |
On Sun, 24 Apr 2016 12:03 pm, Christopher Reimer wrote: > On 4/23/2016 2:33 PM, Matt Wheeler wrote: >> This is still backwards to me. It prevents your classes from being >> suitable for restoring a stored game state, not just custom starting >> positions (which I think is what Ethan means by custom setups). > > I haven't thought that far about saving the game state. I'm under the > impression that pickle (or something else) would save and load the > instantiated object of each piece. If that's not the case, I'll change > the code then. Pickle will do what you are thinking of, but pickle is not secure and involves executing arbitrary code. If you cannot trust the source of the pickle, then you should not use it. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2016-04-24 08:56 +0300 |
| Message-ID | <8737qby2gn.fsf@elektro.pacujo.net> |
| In reply to | #107536 |
Steven D'Aprano <steve@pearwood.info>: > On Sun, 24 Apr 2016 12:03 pm, Christopher Reimer wrote: > >> On 4/23/2016 2:33 PM, Matt Wheeler wrote: >>> This is still backwards to me. It prevents your classes from being >>> suitable for restoring a stored game state, not just custom starting >>> positions (which I think is what Ethan means by custom setups). >> >> I haven't thought that far about saving the game state. I'm under the >> impression that pickle (or something else) would save and load the >> instantiated object of each piece. If that's not the case, I'll change >> the code then. > > Pickle will do what you are thinking of, but pickle is not secure and > involves executing arbitrary code. If you cannot trust the source of > the pickle, then you should not use it. You shouldn't use your runtime objects as a storage format. Instead, design the storage objects separately and translate between runtime and storage objects as needed. JSON objects or straight Python dicts are good candidates for overall storage format. JSON would allow for easy interchange between different programming languages if need be. Marko
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web