Thanks for the script, it works fine. The only annoying thing was that it syncs everything, including .git/ folders and the like.
This is my solution to exclude a folder from syncing:
- move the .git folder out of the Dropbox sync folder
- create an empty .git folder in the old location
- uncheck this empty folder in the selective sync list in the Dropbox preferences. It will be deleted locally (that's why we moved it in step 1)
- move back the folder to it's previous location. Dropbox will now ignore it.
Something is wrong with the scroll position of the actions menu. I spotted it first in landscape mode and with the keyboard visible, but it also happens in portrait mode when the menu contains more items than fit on the screen. The items at the bottom are there but can't be reached.
This will indent or outdent all selected lines:
#Indent/Outdent selected lines
indent_char = '\t'
text = editor.get_text()
selection = editor.get_line_selection()
selected_text = text[selection:selection]
indent = console.alert('indent or outdent?', '', '<<', '>>') == 2
replacement = ''
for line in selected_text.splitlines():
replacement += indent_char + line + '\n'
replacement += line[line.find(indent_char) + len(indent_char):] + '\n'
editor.replace_text(selection, selection, replacement)
editor.set_selection(selection, selection + len(replacement) - 1)
Most of it is stolen from the (un)comment script. Change the indent_char variable to whatever your preference is, e.g. this could be 2 or 4 spaces. Outdent will only work if all lines use the same indent_char.
This piece of code hangs after running it:
from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write('<body><h2>hello</h2></body>')
if name == 'main':
server = HTTPServer(('', 80), RequestHandler)
webbrowser.open('http://localhost', stop_when_done = True)
Pythonista keeps displaying the stop button (instead of play) even after tapping "done". I can't run this script again (or any other script) until completely quitting and restarting Pythonista. What could be the problem and what can I do?
Changing the port helps:
server = HTTPServer(('', 8001), RequestHandler)
webbrowser.open('http://localhost:8001', stop_when_done = True)
This works as I expected: "Done" closes the browser and the server exits. No restart needed.
Weird: When I omit the stop_when_done parameter, it works with port 80 but hangs with port 8001?! In all cases browser and server start and run fine, only sometimes the server won't quit, "stop" button not working. So it probably has nothing to do with privileged ports, right?
I'm lost here, can't explain that. Any ideas? I'm an absolute beginner in Python, so am I maybe missing something obvious? E.g. is this behaviour perfectly normal and to be expected from Python?
Hi, maybe I'm just missing the obvious: How can I get files - like libraries, existing code or text files for analyzing - into Pythonista?
Is there a way to easily share or sync a piece of code between Pythonista and my desktop computer, so that I can continue coding on either machine?