I am developing with Flask, and am trying to create a page to create pages (as a sort of custom CMS). So the page will need to create its own @app.route decorator for a function that renders the page template when called in the app.py file. What I have come up with is to create three functions: remove_last_two_lines and create_rendering_func and add_back_last_lines (named for what they do). The remove_last_two_lines function and the add_back_last_lines function do exactly what I want. What I'm having trouble with is the create_rendering_func. It simply doesn't do anything, and doesn't raise an error. So I think the code is valid (and I am passing valid arguments), I just don't understand why it isn't working. The lines being overwritten are empty (that's why there is multiple newlines after the last line of the function). Thanks in advance!  def add_new_url(route, func_name, title, filename):     lines = open(__file__, 'r').readlines()     lines[-6] = '@app.route(\'%s\')' % route     lines[-5] = '\ndef %s' % func_name     lines[-4] = '\n\trender_template(\'filename\', the_title=%s)\n\n\n\n\n' % title    (This method sucks. Any tips on better methods appreciated)
I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it.  What is the best way to do this, within the following code?  f = open(file) for line in f:     if line.contains('foo'):         newline = line.replace('foo', 'bar')         # how to write this newline back to the file
I'm starting on mono blue mill deck and I saw . I'm not sure about its ability.     {tap}: put a charge counter on Grindclock      {tap}: target player puts the top X cards of his or her library into his or her graveyard, where X is the number of charge counters on Grindclock.   If I just cast  and use its first ability, will the second ability take effect, or do I just put a charge counter on it? If there's already one charge counter on it and I use the first ability again, it will have two charge counters on it? Then the second ability will take effect with two cards being sent to graveyard?  If I use spells or ability to untap it after being used can I use its ability again on the same turn? How to get attention to a post on a child meta site If I want to draw people's attention to a post on a child meta site, how can I do that? I want to get people  over at Area 51 to see what they think of the idea, because it requires opinions from the community. However, posts on the discussion zone of Area 51 rarely get activity, so it seems like I'm out of luck, unless something is changed. And from the sounds of , it seems like this is a problem on all child metas.  That post is similar, but while it talks about increasing activity in general, I am talking about how to raise participation to an individual post; the equivalent of a bounty  I can't use bounties because reputation is the same.   Could there be another way of drawing attention to individual posts? I'm looking for a formula to calculate the sum of $(a+b+c+d+...)^n$ but with coefficients equal to 1. For example in $(a+b+c)^2$. I want the sum of $a^2 + b^2 + c^2 + ab + bc + ca$. And for $(a+b+c+d)^3$, I want the sum of $a^3 + b^3 + c^3 + a^2b + a^2c + b^2a + b^2c + c^2a + c^2b + abc$. Similarly, I want the sum of expansion of $(a+b+c+d+e+....)^n$ with coefficient equal to 1. I tried to find the pattern by expanding the $(a+b+c)^2$. And I found that its formula is $a^2 + b^2 + c^2$ + $\frac{((a+b+c)^2 - a^2-b^2-c^2)}{2}$. This works for the power of 2. But fails on other powers. Any help will be really appreciated. If I have a 18-55mm lens, is there a point in buying a 35mm prime lens? I have the Nikon kit lens that came with a D5100 — the kit lens is  . I was thinking of getting a fast lens and I am looking to buy the .  Should I consider 35mm or instead buy a 55-200mm for better range? A Basic Question about Gravity, Inertia or Momentum or something along those lines Why is it that if I'm sitting on a seat on a bus or train and its moving quite fast, I am able to throw something in the air and easily catch it? Why is it that I haven't moved 'past' the thing during the time its travelling up and down? Novel about alien conquerers who conduct games to select servants I read this maybe 10-15 years ago.   Aliens have conquered earth. Possibly quite some time before the time then novel is set in. They have built their own cities. They conduct periodic athletic competitions for humans similar to the current olympics. The winners are take into the city to act as servants to the masters. The protagonist is part of a human resistance movement who is competing in the games. The plan is to infiltrate the city, gather intel and escape. He wins, get in, finally has to kill his master and escape down a waste disposal system which ends up outside the city.   Anybody knows which one I am talking about? How to say that you have plans to go to the movies tonight? How to say that you have plans to go to the movies tonight (but you are not sure yet, maybe you will have a pizza)? I mean there are options:     I am going to the cinema tonight.   Way too much certainty in this. For me it means that you have already bought tickets, the least.     I am going to go to the cinema tonight.   Sounds a bit awkward.     I will go to the cinema tonight.   Sounds too formal to me. How to change password complexity requirements in Ubuntu 14.04LTS My gaming computer is currently downloading Napoleon: Total War and Supreme Commander 2 which I purchased on Steam, and which will take some time to complete. While this download is going on, I would like to play some of my other multiplayer games on my laptop, but I would rather not interrupt the download to do so.   Is it possible to have both computers logged in at once? I know if I was playing a single player game, I could set Steam into offline mode, then resume the download on the other computer, but this won't work for multi player games. Convert ls -l output format to chmod format Say I have the following output from ls -l:  drwxr-xr-x 2 root root 4096 Apr  7 17:21 foo   How can I automatically convert this to the format used by chmod?  For example:  $ echo drwxr-xr-x | chmod-format 755   I'm using OS X 10.8.3. Kindle for PC via Wine I really want to get the Kindle PC program running on my computer so I can download, read, and manage my e-books. I realize that Calibre can be used to manage e-books and I do have that downloaded. However, Amazon won't let me download ebooks unless my PC is registered in their Kindle program and I'd like to just keep things streamlined.  I've viewed many tutorials and advice for setting it up. I have Wine, I have Kindle for PC, I set it to Win98, all of that. However, when I try to open KindlePC from the Wine menu or from the desktop icon, nothing happens. No error messages, nothing. I don't know what might be wrong. How can I make it work? This is more of a panic question after reading reviews on Istanbul Atatürk Airport. They said it's messy and hard to navigate, therefore I'm asking questions here in name of my girlfriend who will need to transit through this airport.  My girlfriend (Canadian national) traveling from Toronto (YYZ) to Istanbul (IST) for a couple hours (~4 hrs, so transiting) in order to come to Pristina (PRN). I would like a quick guideline on how to pass through this airport seamlessly without facing any trouble or delay.  Her tickets are both with Turkish Airlines. She purchased it via a third party (Flighthub.ca). It's only one booking and it includes both flights in it.   Once my girlfriend departs, she's obviously required to follow the signs and go to the transit area. Once she's there, will she be required to present a ticket? Where does she get that ticket? Does she get it in YYZ or does she need to visit a counter in IST and get it? After she's got the proper ticket, what does she need to do exactly? Wait in line to have her passport checked? Will they also control her carryon?  After this step, does she simply go to the PRN flight gate and that's it?   We're simply worried about Istanbul Atatürk Airport because of the recent things that happened in Turkey (coup attempt and ISIS attack) and she doesn't wanna somehow end up locked up there. I've read that the airport is a mess lately and a lot of people will be there waiting in line. So, another question: Are 4 hours enough?  I would appreciate a step by step guideline on how she needs to navigate and what she needs to do in that airport to have a smooth experience without facing any delays. Also some misc information on Istanbul Atatürk Airport would be appreciated. Play WAV file backward Suppose $G$ is a group generated by elements $x$ and $y$ where $xy^2 = y^3x$ and $yx^3 = x^2y$ What can you prove about $G$? Suppose $G$ is a group generated by elements $x$ and $y$ where $xy^2 = y^3x$ and $yx^3 = x^2y$ What can you prove about $G$?  I've just been playing around with the relations but I can't seem to get anywhere. It seems as if I'm going in circles. I don't know what to look for in terms of how the equations should look in order to give me an insight into the structure of the group.  So given a group presentation, are there any general strategies of what to look for in the relations (as in how to rearrange them) in order to obtain insight about the group? When I visit the reputation tab of my profile, I see a lot of stuff. I can make out some of it, but not all.   What do all the event types mean? Why do some events show an odd reputation gain or not show any reputation change at all? Why are some events sometimes highlighted in yellow? My reputation suddenly dropped, but I don't see anything. What happened? Why do some events disappear from my reputation history? What is LookDev/Material Preview mode for in 2.8? I accidentally killed the orphanage lady before I started the quest. She just pissed me off, sadly it will not acknowledge that I have finished the quest and I haven't been contacted. Is there another way to join the Dark Brotherhood? Insert eps graphics with graphicx (file not found) What are complex numbers, actually? Where to declare environment variables? What are correct places for:   Global environment variables meant to affect all users? User-specific environment variables?