• Olaf

    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 read more
  • Olaf

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

    posted in Pythonista read more
  • Olaf

    @edenb thanks!

    posted in Pythonista read more
  • Olaf

    Happy to see you @omz and the update!

    posted in Pythonista read more
  • Olaf

    @JITASIDA
    No, you can't
    That would require adding a method to a built-in type and that's not possible (without going to the C source for Python):

    >>> str.clean=lambda self:'clean'+self
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    TypeError: can't set attributes of built-in/extension type 'str'
    

    posted in Pythonista read more
  • Olaf

    The error results from your lines not being well-aligned
    Unindenting the x=... and y=... lines should fix it

    posted in Pythonista read more
  • Olaf

    thanks. works after pip docutils

    posted in Pythonista read more
  • Olaf

    Okay, I'll try my luck at some parts of scene

    Well, no luck :-(
    pygenstub will not install (pip install) at my iPad with File Not Found Error.
    pip successfully downloads the .whl from pythonhosted.org, but on installing the wheel stops at an error
    Version 1.2 (current version is 1.4) installs

    posted in Pythonista read more
  • Olaf

    Very welcome initiative!

    I may contribute a module or two that I'm comfortable with.
    In the style guide, you state "no Union[] return annotations"; does that also imply "no Optional[] return annotations"? The Pythonista modules have some.

    posted in Pythonista read more
  • Olaf

    nice :-)

    posted in Pythonista read more
  • Olaf

    Congrats @omz!

    posted in Pythonista read more
  • Olaf

    Thanks! Downloading now

    posted in Pythonista read more
  • Olaf

    Great, thanks!

    posted in Pythonista read more
  • Olaf

    @omz, can you please let us know whether you plan on publishing a new version to TestFlight (or extend the validity of the current version) on time? Otherwise I'll need to fallback to the regular version from the AppStore

    posted in Pythonista read more
  • Olaf

    @omz wow, 3 * 365 * 50 > 50,000 Pythonistas, that's quite a global tribe!

    posted in Pythonista read more
  • Olaf

    @dgelessus thanks, mystery solved
    This applies both inside and outside triple quotes

    In long-press run doctest, the cwd differs differs from

    import doctest
    doctest.testmod()
    

    posted in Pythonista read more
  • Olaf

    Great! Also the PEP8.

    Although run with args clears the console now, doctest still doesn't, although that's merely inconsistent, not an issue, now doctest flags its outcomes in the source file.

    Also, doctest fails mysteriously on

    with open('test.txt', 'w') as f:
        pass
    

    with

    PermissionError: [Errno 1] Operation not permitted: 'test.txt'
    

    posted in Pythonista read more
  • Olaf

    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 read more
  • Olaf

    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 read more
  • Olaf

    Great news!

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!