The user types the name of file. If he writes the wrong name of the file and python has an error like "FileNotFoundError: [Errno 2] No such file or directory: '5'". How can I write to user that he has typed the wrong name of the file? This code doesn't want to work:   try:      filename = input ("Your file name") except OSError as e:     print('We have an error: ', str(e))
How do I check whether a file exists or not, without using the  statement?
I have enabled storing Desktop &amp; Document Folders in iCloud. I keep my Xcode projects on Desktop. Every hour or so, iCloud will store files, inside of Pods folder present alongside the Xcode Project in iCloud. This is very tedious as I then have to click on each one of them one-by-one to re-download.  How can I prevent iCloud from downloading my files in this manner, for this specific Xcode project?  I have tried disabling iCloud for Desktop, but this results in me losing all my Desktop folders/files, so I could rather not go this route. Borel-Cantelli-related exercise: Show that $\sum_{n=1}^{\infty} p_n < 1 \implies \prod_{n=1}^{\infty} (1-p_n) \geq 1- S$. This is supposed to be related to the  (my justification for the independence tag). In Williams' Probability with Martingales, 2BCL is proven and then the following is given as an exercise:  Prove $S \doteq \sum_{n=1}^\infty p_n &lt; \infty \implies \prod_{n=1}^\infty (1-p_n) &gt; 0$ assuming $0 \leq p_n &lt; 1$. Hint: Show that $S &lt; 1 \implies \prod_{n=1}^\infty (1-p_n) \geq 1 - S$.   Proving the hint: I tried to find $\{a_n\}$ s.t. $$\prod_{n=1}^\infty (1-p_n) \geq \prod_{n=1}^\infty e^{a_n} = e^{\sum_{n=1}^\infty a_n} \geq 1 - \sum_{n=1}^\infty a_n \geq 1 - S &gt; 0$$ That is, find $\{a_n\}$ s.t.: 1a. $1 - p_n \geq e^{a_n}$ 1b. $a_n \leq p_n$ I thought of $a_n = \ln(1-p_n)$ (a reason why $p_n &lt; 1$, I guess) Is that right? Edit: Actually, assuming my proof is right, is $S &lt; 1$ used in the proof? If so, where?  From Williams book: Why does water take a "wet" path? Allow me to explain what I mean... ((I am asking this question in the physics section in hopes of finding a "physics" argument))  I shall make it clear what I mean by demonstrating an experiment...  Hold your hand upright with your index finger pointing up towards the sky. Now drop about 2-3 drops of water right on top of your finger. Water drop should (theoretically) stay there. Now tilt your hand ever so slightly towards one side. The water drop rolls down your finger down your wrist leaving a trail towards the tilted side right?  Now's here comes my question. Now if you bring your finger and the hand to the initial upright state and place another water drop on the same finger. Now we see that the water drop takes the same trail! Why does it happen?  My argument: The water trail which was previously left off reduced the friction in that path by filling the gaps between the molecules. Hence the new drop tends to slide more on that path and hence ends up travelling in it.  ((This "effect" is also observed when tear drops keep rolling down in the same path. But that could just be because that path is the steepest.)) What is the distinction between "among" and "amongst"? How to get exact camera view? Why do I have to enter my password to log in? Using the Stack Exchange login, why do I have to enter my password again and again to log in? Wasn’t the whole purpose of OpenID to do away with this?  This doesn’t even only happen when visiting a new Stack Exchange site – it also happens for sites where I already have an account but which I don’t visit regularly. Here’s what I mean:    Of course I don’t remember my password (it’s a long random string). And so I have to go to my password manager and manually copy the password from openid.stackexchange.com’s account into the login form. – And incidentally, this is what my password manager looks like now:    (And, by the way, those are the only entries in my keychain so far, but by far not the only SE sites where I have an account.)  … I feel that this defeats the purpose of site-wide login and OpenID. In the olden times when MyOpenID was still working properly, I’d simply enter my OpenID on the login form, and the software would take care of the rest – namely, redirect to the OpenID service, (automatically) verify that I was authorised to use it, and redirect back to the original website, having logged me in. It was literally one button click for me. It’s substantially more work now, and I’d like to understand why this regression is necessary.  (Note: of course once a site’s password has landed in my password manager I (probably?) won’t have to enter it again. But still: wasn’t site-wide login and OpenID supposed to solve this already?) Korea: Visa required to go to the city while in transit in Seoul for a Philippine citizen? Hi I'm traveling to Uzbekistan and have 12 hours layover in Seoul via Korean Airlines. Do I need a visa to go out of the airport for sightseeing? I'm a Philippine passport holder. How do you handle uneven tiles while rendering a tile map? Here is what I want to do with my tile map that I am unsure of. As you can see the top walls are way larger then the bottom and side ones (this is also an issue with my corners which are odd shapes [more like an L then a square] as well as larger then the 40x40px that my current tiles are).    I have also attached the tile sheet I am using for the tiles to show you what the corners and tops look like compared to the rest of the tiles.  What I’m thinking is I might be able to just draw them using the same array I have if I use the tiles width and height instead of a set WxH? I dont know how well this will work, but were the blocks that will have different values will be blocks the player/NPCs can’t step on then it may not be an issue, again I’m not even sure if that is a viable solution.  My code in case you want to see how I'm currently handling it:  (pastebin) (edit:im not handling it, meant how I'm currently doing the map)  tl;dr - how can I take take my 2d looking tile map and change it to have different size tiles? or is there a better way to do what I am trying to do? Is there a name of a method that I should be looking for while googling? My users are sending me point data that were digitized using Google Earth. How can I convert their KML to a shapefile and vice versa? What should I do when the GETDEB repository is down? I'm having trouble understanding the simple "planetary" model of the atom that I'm being taught in my basic chemistry course.   In particular,    I can't see how a negatively charged electron can stay in "orbit" around a positively charged nucleus. Even if the electron actually orbits the nucleus, wouldn't that orbit eventually decay?  I can't reconcile the rapidly moving electrons required by the planetary model with the way atoms are described as forming bonds. If electrons are zooming around in orbits, how do they suddenly "stop" to form bonds.     I understand that certain aspects of quantum mechanics  to address these problems, and that there are  of atoms. My question here is whether the planetary model itself addresses these concerns in some way (that I'm missing) and whether I'm right to be uncomfortable with it. Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in? I've only found a recursive algorithm of the extended Euclidean algorithm. I'd like to know how to use it by hand. Any idea? A potentially dangerous Request.Form value was detected from the client Every time a user posts something containing &lt; or &gt; in a page in my web application, I get this exception thrown.  I don't want to go into the discussion about the smartness of throwing an exception or crashing an entire web application because somebody entered a character in a text box, but I am looking for an elegant way to handle this.  Trapping the exception and showing     An error has occurred please go back and re-type your entire form again, but this time please do not use &lt;   doesn't seem professional enough to me.  Disabling post validation (validateRequest="false") will definitely avoid this error, but it will leave the page vulnerable to a number of attacks.  Ideally: When a post back occurs containing HTML restricted characters, that posted value in the Form collection will be automatically HTML encoded. So the .Text property of my text-box will be something &amp; lt; html &amp; gt;  Is there a way I can do this from a handler? Unwanted faint lines connecting dashed double line How to draw neat polygons around scatterplot regions in ggplot2 How should I type author names in a bib file? Can someone please explain in a clear and concise way how am I supposed to enter the names of authors in a BibTeX file? I have entries with something like   @article{someid,    author = {Juan A. Navarro P\'erez, Ra\'ul de la Garza and Andr\'es Espinoza},    ...   but somehow the output seems kind of wrong! What is wrong with defining \bal as \begin{align}? Are +1/+1 counters different from +1/+1 effects? Is a +1/+1 counter I get from, say Unleash or Undying different than +1/+1 from something like  or ? Convince grep to output all lines, not just those with matches Say I have the following file:  $ cat test  test line 1 test line 2 line without the search word another line without it test line 3 with two test words test line 4   By default, grep returns each line that contains the search term:  $ grep test test  test line 1 test line 2 test line 3 with two test words test line 4   Passing the --color parameter to grep will make it highlight the portion of the line that matches the search expression, but it still only returns lines that contain the expression. Is there a way to get grep to output every line in the source file, but highlight the matches?  My current terrible hack to accomplish this (at least on files that don't have 10000+ consecutive lines with no matches) is:  $ grep -B 9999 -A 9999 test test     If grep can't accomplish this, is there another command-line tool that offers the same functionality? I've fiddled with , but it doesn't seem to have an option for it either.