omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Olaf
    3. Best

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 79
    • Best 23
    • Controversial 0
    • Groups 0

    Best posts made by Olaf

    • RE: Wish list for next release

      For an update 2.1, I would very much like the ability to assign (unused) keyboard shortcuts (e.g. command+Q on an external keyboard) to script shortcuts (under the wrench, as one of the options for edit shortcut, similar to icon).
      That way, you could make the editor fit your own taste :-)

      posted in Pythonista
      Olaf
      Olaf
    • RE: Python question about case insensitive replacement

      You can use \1 to refer to matched text grouped by () in the regex. So:

      import re
      my_text = 'Word word'
      src_str  = re.compile('(word)', re.IGNORECASE) 
      my_text = src_str.sub(r'\1xxx', my_text)
      print(my_text)
      posted in Pythonista
      Olaf
      Olaf
    • RE: Can’t load module “dict”

      dict is a built-in type, not a module that needs importing
      What are you trying to accomplish, @Sway?

      posted in Pythonista
      Olaf
      Olaf
    • RE: Save Script via Open In directly to Pythonista

      @jaredbidlow, Pythonista 2.0 provides appex, so you don't need Workflow and the clipboard anymore to Open in Pythonista. See e.g. https://forum.omz-software.com/topic/2494/appex-getfromurl-to-share-from-other-apps-to-pythonista for an alternative

      posted in Pythonista
      Olaf
      Olaf
    • RE: Is pandas supported on pythonista ?

      Today 18 Jan 2023, a beta of a new Pythonista was made available to testers. This contains a more recent numpy ☺ and pandas ☺☺☺.

      When the beta is promoted to the App Store, all users will benefit from this (and other evolutions like Python 3.10 instead of 3.6).

      posted in Pythonista
      Olaf
      Olaf
    • RE: What what what!! New version in TestFlight!!!

      Great news! Thanks @omz!

      And seems already submitted 7 Dec, hence 48 days remaining of 3-months TestFlight period. Whatever, it’s downloading and I look forward to more modern Python features

      posted in Pythonista
      Olaf
      Olaf
    • RE: Determining if JSON is a valid pyui file

      I'd say, list of dict with ('class', 'View') as one of its items and 'frame' as another key would be pretty telling. But it wouldn't provide 100% absolute dead-sure unmistakable certainty, I'm afraid, so don't use this if trying to control a nuclear reactor or pacemaker

      posted in Pythonista
      Olaf
      Olaf
    • Long-press run does not clear console

      Both in Pythonista2 and Pythonista3 (latest betas) a long press to run (i.e. with args in 2; either with args or doctest in 3) does not clear the console if clear output before running is set in settings. I don't know whether this is by design, but (especially with verbose option; great option BTW) the doctest output tends to get longish, so this behaviour may lead to confusing output

      posted in Pythonista
      Olaf
      Olaf
    • RE: Bug list for beta release 201001

      @dgelessus , I agree objc_util needs an __all__
      However, to exclude the imported modules, you don't necessarily need to enumerate; instead you can use inspect:

      {name for name in dir(objc_util)
            if not name.startswith("_") and
               not inspect.ismodule(getattr(objc_util, name))
      }
      
      posted in Pythonista
      Olaf
      Olaf
    • RE: [Share Code] Rechtschreibung (a little app for testing German spelling and the pitfalls thereof)

      Interesting!
      Off topic:
      As Nichtmuttersprachler who learned German in school way before the 1998 Rechtschreibereform, I was totally unaware of this German discussion. Do people actually propose writing "zwai"?

      posted in Pythonista
      Olaf
      Olaf
    • RE: Help with screen sizes

      iPad Air 2: (1024.00, 768.00)

      posted in Pythonista
      Olaf
      Olaf
    • RE: [SUGGESTION] "find" in the built-in docs

      By the way, this approach (below) also permits a second help tab open (in a browser), next to the regular one (help function), which may be helpful to toggle back and forth between two topics

      '''Open 2nd tab on help in browser (next to regular help function), proof of concept needs further work'''
      
      import os, webbrowser
      
      def dirname(path, n=1):
          return path if n<=0 else dirname(os.path.dirname(path), n-1)
      def openhelp():
          path = os.__file__
          txtpath = os.path.join(dirname(path, 4), 'Documentation', 'index.html')
          webbrowser.open('file://'+txtpath)
      
      openhelp()
      
      posted in Pythonista
      Olaf
      Olaf
    • RE: [SUGGESTION] "find" in the built-in docs

      +1 your request, @Webmaster4o

      Meanwhile, this also isn't what you look for, and far from ideal, but you could consider opening the source to the documentation in the editor and search then, like:

      '''Open documentation source text file in editor, proof of concept needs further work'''
      #TODO: doesn't work for builtins (so not e.g. sys)
      #TODO: only works for standard Python modules (pylib, so not e.g. scene or NUMPY)
      #TODO: doesn't work for submodules (e.g. os.path)
      #TODO: opens already-open text files in another tab
      #TODO: error handling
      
      import os, editor
      
      def dirname(path, n=1):
          return path if n<=0 else dirname(os.path.dirname(path), n-1)
      def opendoctxt(module):
          path = module.__file__
          basename = os.path.splitext(os.path.basename(path))[0] + '.txt'
          txtpath = os.path.join(dirname(path, 4), 'Documentation','_sources', 'library', basename)
          editor.open_file(txtpath, True)
      
      opendoctxt(os)
      
      posted in Pythonista
      Olaf
      Olaf
    • RE: How to import user defined modules?

      Hi @huub.
      import searches for the module in all directories mentioned in sys.path. Does that include the directory where you put your module? You need to import sys to inspect the sys.path value.

      posted in Pythonista
      Olaf
      Olaf
    • RE: Progress Tracker on App Badge

      Looks quite cool, @Webmaster4o!

      posted in Pythonista
      Olaf
      Olaf
    • RE: Wish list for next release

      @ShunS, backslash \ is available by swipe-up from slash / on the extended keyboard

      posted in Pythonista
      Olaf
      Olaf
    • RE: Pythonista 2 Release

      Version dates differ:

      import sys
      print(sys.version)
      

      yields 2.7.5 in each version of 1.5, 1.6 (beta), and 2.0, but with different dates (resp. 13 Jun 2014, 29 Nov 2015, and 19 Dec 2015)

      posted in Pythonista
      Olaf
      Olaf
    • RE: Pythonista 2 Release

      In the AppStore :-)

      posted in Pythonista
      Olaf
      Olaf
    • RE: Tip - Useful objects like Rect obj in scene module (others also)

      As @ccc points out, Point, Rect and Vector2 are identical. The same applies to Size, but the other common names, Button and Touch, are different.

      import inspect, scene, ui
      common = set(dict(inspect.getmembers(scene, inspect.isclass)))
      common &= set(dict(inspect.getmembers(ui, inspect.isclass)))
      common = sorted(list(common))
      for cls in common:
          print 'class', cls, 'in scene and ui are', 'identical' if getattr(scene, cls) is getattr(ui, cls) else 'different'
      

      results in

      class Button in scene and ui are different
      class Point in scene and ui are identical
      class Rect in scene and ui are identical
      class Size in scene and ui are identical
      class Touch in scene and ui are different
      class Vector2 in scene and ui are identical
      
      posted in Pythonista
      Olaf
      Olaf