Wikipedia:Reference desk/Archives/Computing/2020 February 18

= February 18 =

What is the problem with this tic-tac-toe game code?
Here is the relevant code:

---

The main problem with this code that I can see is that it doesn't actually switch the turn from 'O' to 'X' once 'O' actually makes a move. Why exactly is this the case? 68.96.93.207 (talk) 03:06, 18 February 2020 (UTC)


 * I think the problem is here:

if turn is O it changes it to X, but the next statement turns X back to O. Bubba73 You talkin' to me? 03:24, 18 February 2020 (UTC)
 * I got it; basically, I wrote "if" the second time whereas I was actually supposed to write "elif" (short for "else if") the second time. Thank you! Futurist110 (talk) 22:25, 21 February 2020 (UTC)

It's slightly controversial but I favor using interactive debuggers to analyze this type of problem. Python comes with a semi-useful one called "pdb", and if you use an interactive development environment (IDE), it might have a debugger of its own. There are various ways you can simplify (refactor) that code as well and it's worth spending some time on that. 2601:648:8202:96B0:0:0:0:7AC0 (talk) 05:50, 18 February 2020 (UTC)
 * You're mixing code with your functions and functions should be placed before if __name__ == '__main__': line. Sleigh (talk) 08:39, 18 February 2020 (UTC)

I'm pretty sure that  is not going to do what you expect. It's not going to compare three things and evaluate to "true" if they're all the same. Rather, it's going to evaluate the equality of [0] and [1], and the compare "true" or "false" to [2]. (Or maybe the other way around, compare [1] to [2] first; I don't know how the precedence will go here.) Or is Perl unusual in this regard? Anyway, it's safer and easier and faster simply to say. --jpgordon&#x1d122;&#x1d106; &#x1D110;&#x1d107; 23:39, 18 February 2020 (UTC)


 * Regarding the chained comparison, Python has special handling for chained comparisons: "Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z". So


 * but


 * -- Finlay McWalter··–·Talk 10:51, 19 February 2020 (UTC)
 * Wow. Didn't know that one. Still, morally unsafe...I'll shut up now. --jpgordon&#x1d122;&#x1d106; &#x1D110;&#x1d107; 15:29, 19 February 2020 (UTC)
 * The behaviour you describe comes from C, and many post-C languages (including C++, Java, and it would seem Perl) inherited that thinking, I suspect without really considering there's much of an alternative. Haskell works (parses) similarly, but at least has the good grace to fail (because it refuses to silently coerce an integer to a boolean oops, a boolean to an integer). But mathematicians have been doing it the other way for centuries, so it's not obviously wrong. Python has traditionally been quite a bit more agressive about deciding to do things its way, rather than aping C syntax in a decidedly non-C language (and in general, learning Python from a C-ish background, one has to break onesself of a range of C-ish mindsets to write clear, ideomatic Python). So really, for the Python programmer, it's something of a shibboleth - if a < b <= c makes one's brain itchy, one is still thinking in C. -- Finlay McWalter··–·Talk 17:47, 19 February 2020 (UTC)

Skype's cloud storage
It seems that the inability to delete own Skype conversation persists since 2017, as I still get "some selected messages cannot be removed" on my laptop, Windows 10. I also have some privacy concerns since the calls are stored on a cloud server for 30 days. Is there anything to do about it? Brandmeistertalk  10:45, 18 February 2020 (UTC)
 * If you want to delete it locally, you can close Skype, find where it stores its data and open up the database. Every line of conversation is a row in one of the tables. Might also be in multiple tables, I don't remember. No idea how to delete it in the cloud. I suspect it's possible that it will come back if the other conversation member doesn't do the same thing in his Skype db. 89.172.57.225 (talk) 22:21, 18 February 2020 (UTC)

Snapchat filters
The Snapchat article describes the concept of a "filter" as something different than what I have heard it is. It seems the article should mention putting cat ears on people and that sort of thing. However, I'm not sure what to use as a source or how it would be described.— Vchimpanzee  •  talk  •  contributions  • 21:45, 18 February 2020‎ (UTC)
 * You can always keep it in scare quotes. That's what I usually do when dealing with "social" "media". 89.172.57.225 (talk) 22:22, 18 February 2020 (UTC)
 * I think that is covered by "Snaps can be personalized with various forms of visual effects", but you should start a discussion on the article's talk page if you have ideas for improvement. RudolfRed (talk) 22:23, 18 February 2020 (UTC)
 * I'm not convinced those words are enough to communicate the idea.— Vchimpanzee  •  talk  •  contributions  •  23:00, 18 February 2020 (UTC)
 * What's wrong with filter? In image processing (and for that matter in data processing in general), a filter can do pretty much anything to its data, including adding cat ears. --jpgordon&#x1d122;&#x1d106; &#x1D110;&#x1d107; 03:49, 19 February 2020 (UTC)
 * , that is an overly liberal definition of the word. By analogy from real-world items, such as a water filter or a camera lens filter, these are items which take a certain input and remove or add some elements to the output, for an overall subtle change, in most cases. A filter operates on the whole input by default. So, no, if I wanted to add cat ears to someone in a film camera, I would not attach a "cat ears filter" to the lens, I would draw them on in the darkroom. A "visual effect" is a very good description of such a process, and drawn from the film industry where visual effects can consist of scale models, background matte paintings, or CGI animations. (None of those are filters.) — Preceding unsigned comment added by Elizium23 (talk • contribs) 05:09, 19 February 2020 (UTC)
 * As an interesting aside, for Snapchat filters refers to things which apply a static effect to an image. E.g. text, colour effects etc [//support.snapchat.com/en-GB/a/geofilters]. Lenses refers to the AR style effects which operate on elements of the image [//support.snapchat.com/en-GB/a/face-world-lenses]. However, as can be seen from this e.g. [//www.techradar.com/nz/how-to/how-to-use-snapchat-filters-and-lenses], Snapchat lenses are still called filters, as are AR style effects for other companies [//www.theverge.com/2019/8/16/20808954/instagram-face-filters-facebook-videos-effects-how-to-spark-ar-studio] [//www.engadget.com/2019/08/13/instagram-spark-ar-filters-effects-public-beta/].  It's not overly liberal since it's the way the word is used in modern times. See for example Filter (software), Filter (video), Email filtering, or [//jamanetwork.com/journals/jamafacialplasticsurgery/article-abstract/2688763] [//www.sciencedirect.com/science/article/pii/S0747563219303711]. As always, it's a Etymological fallacy to assume just because a word means something in some older contexts, it must mean the same thing in other newer contexts. Languages evolves and adapts.  BTW Snapchat and other such images filters do operate on the whole input. They just selectively detect and modify certain components. Many such filters are able to detect multiple faces, and will apply the same effects to all human faces detected. Some can even detect cat and dog faces.  While it's true it's not really possible to do such things with traditional filters, the idea that their change is subtle or affects the whole image isn't true anyway. For example, the effects of filters on these images is clearly not 'subtle' . Meanwhile, if you imagine a darkened room with two lights, one with a very wide spectrum including in the infrared or UV and one with a narrow spectrum, if you apply a UV or IR selective filter when photographing those lights one light could very well look very similar with or without the filter (depending on the film and how you process it), one light may disappear. Then of course there is significant interest in developing selective filters for various liquid separation and processing e.g. [//pubs.rsc.org/en/content/articlehtml/2017/ra/c7ra05385a] [//now.tufts.edu/news-releases/study-new-filters-could-enable-manufacturers-perform-highly-selective-chemical]/[//pubs.acs.org/doi/abs/10.1021/acsnano.7b07596].  Note also I used both words earlier. The result can reasonably be called a visual effect, but it's a visual effect applied by a filter.  Nil Einne (talk) 11:16, 19 February 2020 (UTC)


 * Agreed. It needs the words "ears" and "noses" in there explicitly. Andy Dingley (talk) 12:21, 19 February 2020 (UTC)