If there is 1/4 chance of winning a day and you play every day for a year (365 days), what is the chance of winning at least once? I suck at math, can anyone help me?
Whenever you need to calculate a "at least once" probability, you actually need to do the opposite: Calculate the probability that you don't win a single time. Then subtract that from 1.
@Aran-Fey Yeah except you also changed file1 = open('recentlyUpdated.yaml') to with open('recentlyUpdated.yaml') as file1. Newbies won't understand the equivalence. Probably the question should show both ways.
We don't need data = yaml.load(file1) in the example, and we don't need file1.close() in the example. Everything after the open()`` falure is irrelevant. We are not teaching them how to write a file-read method, just how to troubleshoot the open()` failure.
@roganjosh No. You cannot "improve" the code in a simple one-line example, in a way where neither newbies nor search-engines will understand (or even locate) the equivalence. The right way is show both alternatives: f = open(...) and with open(...) as f:
I still fail to understand how the with statement makes the question incomprehensible for newbies. They see an open call, they see a "file not found" error, and they don't need to understand anything else
@AndrasDeak Remember that much newbie traffic comes from Google. Also being visible boosts SO's SEO ranking. @roganjosh if you didn't know SO existed in the first place, you wouldn't have learned Python from it. You would have learned from whatever (2.x) tutorials or examples you could find.
No we're not done yet. I also had to clean up the canonical answer for clarity. stackoverflow.com/posts/12201952/revisions . Another common cause is Windows users forgetting r'' rawstring with C:\path
And I believe another cause is (Unix or Windows) permissions, esp. when Python was installed as user not administrator. But maybe don't need to mention that. Both Windows 10 and recent MacOS have gotten too clever by half with various directories that the OS magically hides from user. MacOS with ~/Library or whatever
Example #51834 of why SO voting shouldn't be taken seriously: over the last few weeks I've come up with some answers I'm pretty proud of, some of which faded into obscurity. OTOH, I point out that a guy needs parentheses, and you can just watch the upvotes flow in. :-/
@roganjosh I can't understand what you're saying. We cannot expect all users will have started out with SO. By the time they eventually arrive at SO they may have tons of misconceptions. Just because you did, or I did...
Here's something else problematic: the square brackets in Python open() gives IOError: [Errno 2] No such file or directory make it invisible to the duplicate-question-search-engine, so it suggests bad alternatives. Sigh...
@AndrasDeak close a question > "Why should this question be closed?" > select Duplicate > pops up a search window for Closing > Duplicate with top-8 suggestions. It's bad that brackets will make our dupe target invisible
Hello! I am creating a form input via Django. I followed the instructions in the django docs but the issue is that the form is not rendering on the site.
@Aran-Fey I reordered the answer so "Check the files exists in your cwd" comes before "Change your cwd". It's hard to do a one-size-fits-all answer; if the user is on Windows, it's always the stuff about rawstrings or escaping backslashes (even though Windows accepts forward-slashes since 1995...); of course that's irrelevant to Linux users
@AndrasDeak because few have heard of the actual books "Do Androids Dream of Electric Sheep?" and "We Can Remember It for You Wholesale". Frankly the former is a dreary read and David Peoples and Hampton Fancher (Blade Runner scriptwriters) really did a good job on the script.
Like how Frank Herbert is not as famous as he deserves to be, because he came before CGI could do justice to his oeuvre. Else, Dune might be bigger than Game of Thrones.
@connectyourcharger please read our room rules and not post problems here that you've recently asked on the main site
@smci I never got the hang of Dune movies, but I'm not sure it's just because of their quality. I read the first three books as a teenager and I prefer my imagination to whatever others can cook up
I'm talking the Dune books, not the films, which never really got traction. The whole thing is often the film does not do justice to the book. Philip K Dick is one of the rare cases where the book needs to be reworked to make a decent movie.
While I'm at it, Alex Garland's 'Dredd' was superb, 30-years overdue bringing Judge Dredd to the big screen properly. But he doesn't want to do a sequel.
Andras in general yeah there's a tension between SFX and plot, but the SFX in the 1984 Dune film weren't great so we never really saw Herbert's vision... a sad loss...
Talking about, high time to release Avatar 2/3/4/5
@AndrasDeak In general books are the better source, but often not as well-known. But when it comes to the film adaptation, too little SFX is also bad as too much SFX.
Did you guys see Alex Garland's 'Dredd'? It was superb. But there's a much darker and more political slant on the 1980s IPC comic Judge Dredd. Think Robocop, without the happy bits.