• Alex210

    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:

    1. move the .git folder out of the Dropbox sync folder
    2. create an empty .git folder in the old location
    3. 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)
    4. move back the folder to it's previous location. Dropbox will now ignore it.

    posted in Pythonista read more
  • Alex210

    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.

    posted in Pythonista read more
  • Alex210

    This will indent or outdent all selected lines:
    #Indent/Outdent selected lines

    import editor
    import console

    indent_char = '\t'
    text = editor.get_text()
    selection = editor.get_line_selection()
    selected_text = text[selection[0]:selection[1]]

    indent = console.alert('indent or outdent?', '', '<<', '>>') == 2

    replacement = ''
    for line in selected_text.splitlines():
    if indent:
    replacement += indent_char + line + '\n'
    replacement += line[line.find(indent_char) + len(indent_char):] + '\n'

    editor.replace_text(selection[0], selection[1], replacement)
    editor.set_selection(selection[0], selection[0] + 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.

    posted in Pythonista read more
  • Alex210

    This piece of code hangs after running it:
    import webbrowser
    from BaseHTTPServer import BaseHTTPRequestHandler
    from BaseHTTPServer import HTTPServer

    class RequestHandler(BaseHTTPRequestHandler):

        def do_GET(self):
                self.send_header('Content-type', 'text/html')

    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?

    posted in Pythonista read more
  • Alex210

    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?

    posted in Pythonista read more
  • Alex210

    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?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!