• ccc

    @cvp. You should convince your wife to do https://en.m.wikipedia.org/wiki/Pair_programming with you.

    posted in Pythonista read more
  • ccc

    On the global thing... the reason that works is because it forces del to be called on older images that are no longer being used. Elsewhere in this forum you can find discussion that the garbage collector is not fast enough at deleting images when cycling thru lots of images. You can also fix this issue by calling del yourself but I like the elegance of the global solution.

    posted in Pythonista read more
  • ccc

    A naive first attempt...

    Also see https://forum.omz-software.com/topic/3261/instead-of-a-question-i-d-like-to-share-my-accomplishments

    from random import choice
    
    level = [[1,1,1,1,1,1,1,1],
             [1,1,1,2,0,0,1,1],
             [1,1,1,1,1,0,0,1],
             [1,1,1,0,0,1,0,1],
             [1,1,1,0,0,1,0,1],
             [1,1,1,0,1,1,0,1],
             [1,1,1,0,0,0,0,1],
             [1,1,1,1,1,1,1,1]]
    
    
    def new_level(maze_size=8):
        level = [[choice((0, 1)) for x in range(maze_size)] for y in range(maze_size)]
        level[choice(range(maze_size))][choice(range(maze_size))] = 2  # add the goal
        return level
    
    
    def print_level(level):
        print('\n'.join(str(row) for row in level) + '\n')
    
    
    print_level(level)
    print_level(new_level())
    

    posted in Pythonista read more
  • ccc

    @cvp Can you please edit your code above to add a carriage return before the trailing three backticks? Putting them alone on the next line will makes them disappear which will make you code easier to copy and paste. Thx

    posted in Pythonista read more
  • ccc

    https://github.com/cclauss/pythonista-module-versions

    import pep8 ; print(pep8.__version__)
    '1.7.0'

    posted in Pythonista read more
  • ccc

    I think Pythonista’s current checker is https://pypi.org/project/pyflakes/ not pycodestyle

    posted in Pythonista read more
  • ccc

    Just for fun... Things that you can do with a dict of foods instead of lists of foods...

    from typing import Dict, Tuple
    
    foodWeLike: Dict[str, Tuple[str]] = {
        "Pizza": ("Pizza Base", "Tomato Sauce", "Cheese", "Pepperoni"),
        "Beef Burgers": ("Beef Patties", "Burger Rolls", "Lettuce", "Tomatoes", "Relish"),
        "Pork Stir Fry": ("Pork loin", "Peppers", "Onion", "Hoi Sin Sauce", "Noodles"),
        "Chicken Fajitas": ("Chicken Breast", "Red Peppers", "Onion", "Fajita Kit"),
        "Orange Chicken": ("Chicken Breast", "Orange Sauce", "Panko crumbs"),
        "Lasagna": ("Cooked Lasagna Noodles", "Traditional Italian Cheese", "Parmesean Cheese",
                    "Mozzarella Cheese", "Eggs", "Ground Beef", "Ricotta Cheese")}
    
    print('Food we like is', ', '.join(sorted(foodWeLike)))
    
    for food, ingredients in foodWeLike.items():
        print(f"{food} contains {', '.join(sorted(ingredients))}")
    
    print('Food containing Chicken Brest:', ', '.join(food for food, ingredients in
                                                      foodWeLike.items()
                                                      if "Chicken Breast" in ingredients))
    
    print('Food containing any cheese:', ', '.join(food for food, ingredients in
                                                   foodWeLike.items()
                                                   if any('cheese' in ingredient.lower()
                                                          for ingredient in ingredients)))
    

    posted in Pythonista read more
  • ccc

    path = editor.get_path()
    file_name = os.path.basename(path)
    i = file_name.rfind('.')
    if i>= 0:
        file_name = file_name[:i] + '.pdf'
    
    # Can be rewritten as...
    
    file_name = os.path.basename(os.path.splitext(editor.get_path())[0]) + '.pdf'
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!