• bennr01

    @ccc said:

    What parts of StaSH are not compatible with Python 3??

    git, gh as well as some less commonly used commands. Still, pip should work with python3.

    @eddo888 are you sure you are using the latest version? Some time ago there was an update which requires an forced update (selfupdate -f). It was the same update which introduced py3 compatibility.

    posted in Pythonista read more
  • bennr01

    @timtim said:

    @bennr01 r u sure?
    "I will do a maintenance update around the same time as the next Pythonista update (early 2019).”

    The tweet is dated 18. Nov. 2019 and was written after @omz long silence. It is likely that for some personal reasons he had to take some time off and the originally planned update was delayed.

    posted in Pythonista read more
  • bennr01

    @timtim said:

    Where r u, omz? 2 years.

    He recently became active on twitter again and posted some stuff about pythonista:

    PSA: The built-in Shortcuts integration for Pythonista will be removed early next year. I‘m working on integrating the new iOS 13 APIs, and I hope to have it ready by the end of the year. Migration might be automatic, but I‘m not sure about that yet.

    This does imply that there will be a pythonista update this year.

    posted in Pythonista read more
  • bennr01

    @Hasthohaha Are you sure the scripts were lost? Depending on the version you upgrade from, the Documents root directory was moved into a different directory. I have never lost a script due to an update, so it is either a very rare occurence or they are still somewhere.

    posted in Pythonista read more
  • bennr01

    BTW, PyPy (the python JIT which is in many usecases faster than CPython) will continue to support py2 indefinetly and probably forever. So as long as you do not have to use c-dependent modules and are OK with using outdated modules, it is a good way to continue using py2 after its EOL.

    posted in Pythonista read more
  • bennr01

    @mikael You are right. This was only meant as a suggestion for reducing the number of times you have to write my_property (for a complete getter/setter/deleter setup it would be 3 instead of 5 times). Your decorator @prop is indeed neat, but it may still be useful to remember the my_property = property(...) syntax in case you (or anyone else who reads this) may find themself in a situation where you can not use it (due to code style guidelines or other reasons). I had not seen that you actually used this syntax in your example above and thought it may be a nice tip for you.

    would I not still need to maintain 3 names – property, getter and setter?

    I am not sure, but you may be able to use lambda in this case, which could still be usefull for some cases like read-only properties. Also, in some cases the getter and setter may only be calling some other aliases (like getting/setting text labels).

    posted in Pythonista read more
  • bennr01

    I am not sure, but IIRC, you could also use my_property = property(getter, setter) instead of the @property syntax.

    posted in Pythonista read more
  • bennr01

    Hi guys, is anyone interested in beta testing a few new features for StaSh?
    I have spend the last few weeks to port StaSh to PC, but the changes were rather extensive so i may have broken a few things.
    If you are interested in helping, here is a list of stuff which needs to be tested:

    What needs to be tested:

    • [iOS] Check that everything previously working still works (installation, updates, commands, ...)
    • [PC] Check that the port does not contain any bugs.
    • [iOS/PC] Check that StaSh still runs on both py2 and py3. I only had the chances to test the changes on py2.

    What is not working on PC:

    • The telnet and ssh commands will not work on PC. They need ui.measure_string which i am not sure how to implement using tkinter.
    • easy_config uses its own UI, which was not ported.

    How to install:

    • PC: Clone/download the crossplatform branch of bennr01/stash from github and run python setup.py install. Start with the launch_stash.py command.
    • iOS: If you do not already have StaSh installed, install the normal release first, then force quit pythonista. Afterwards, run selfupdate bennr01:crossplatform and force quit pythonista again.

    How to report bugs:
    If you find any bugs, please report them either in this thread or in my StaSh fork. Please do not report them directly to the main repo to reduce the number of issues created there.
    Of course, pull requests are welcome :)

    posted in Pythonista read more
  • bennr01

    A few month ago someone asked a similiar question on reddit.
    Assuming you can run python on both sides, you can use this example. For more details, please see the discussion in the reddit discussion linked above. This example does not use SSH, but the socket & webbrowser modules instead.

    posted in Pythonista read more
  • bennr01

    @danaportenier replace def __ini__(...) with def __init__(...) (notice the t)

    Edit: You can also replace your if-construct with something like this:

    inp = input("What was the month (1-12) ").strip()
    self.month_input = {
       "01": 1,
       "1": 1,
       "Jan": 1,
        "02": 2,
        "2": 2,
        "Feb": 2,
        }.get(inp, None)

    This does the following:

    1. ask the user for input, saving it in the local variable inp
    2. create a dictionary (key-value mapping) containing the inputs and their numeric values, then checks if inp is in the dictionary. If it is, the value for the input is assigned to self.month_input, otherwise the value None is used.

    I would also recomment to restructure the code as follows:

    class UserInputDate(object):   # inherit from object, use PEP8-style naming conventions
        MONTH_TO_YEAR = {...}  # your month names to values, as dicussed above
        def __init__(self, month, year):
            self.month = self.MONTH_TO_YEAR.get(month, None)   # do not call I/O functions from `__init__`. You may later need the same class without input.
            self.year = year
        def from_input(cls):
            # use a classmethod to directly create the class from input
            month = input("Please enther month (1-12)")
            year = input("Please enther year")
            return cls(month, year)
        def combine(self):
             # as your old code, but using self.month and self.year
    if __name__ == "__main__":
        # place top-level code inside such an if-statement, so it does not get executed on import
        primary_bariatric_date = UserInputDate()

    The above code is not tested, but it should prove you with some tips regarding class layout.
    Most of these changes seem useless at first, but are more useful later on.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!