• 1 Post
  • 62 Comments
Joined 2 years ago
cake
Cake day: June 16th, 2023

help-circle
  • The older is 9, found it challenging in the beginning, but caught on. Younger is 5, definitely not into Pandemic.

    Speaking of snakes and ladders, we had a very fun project of making our own. Basically I stole the positions of snakes and ladders from another board, but we drew and painted all of it on thick cardboard. Small enough and really fun project. You can customize to your fancy.





  • monomontoPythonunittest recipes for temporary files and directories
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    18 days ago

    This. We kinda stumbled on this pattern, and use it to great effect. Simplified code:

    @pytest.fixture
    def tmpfiles():
        with NamedTemporaryFile(suffix=".html") as f:
            yield f
    
    # or for paths, which are more suitable for certain tests
    # touch them so they exist
    @pytest.fixture
    def othertmppaths() -> list[Path]:
        f1 = Path("...")
        f1.touch()
        f2 = Path("...")
        f2.touch()
    
        yield [f1, f2]
        # you could delete them here if needed
        f1.unlink()
    
    def test_foo(othertmppaths list[Path]):
        result = upload_resource(othertmppaths[0]) 
        assert result.status == 200
    

    The context manager one will properly clean up all files.

    E: Pretty website btw



  • This might be contrary to some, but i recommend diagramming! Can be anything from paper doodles to d2 to full blown uml diagrams. They help you stay focused, and aware of the program’s data dependencies.

    Regarding code practices - read code. If you use a library for something, dive into its code. This can be beneficial in many ways - you observe the style they used, you understand better how the library works (documentation rarely contains enough detail), and you see how libraries are structured, which is often lacking in newbies.

    Learn your language’s idioms. They can reduce complexity, and are usually more readable to people with experience in the given language.

    Finally, don’t sweat it too much. The more you write, the better you’ll become, so just do it. New problems lead to new insights.





  • monomontoProgrammingWhy Pseudocode?
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    6 months ago

    I started doing exactly this. Write a bunch of functions, that may end up in different systems, on different machines, even. This allows you to define the interfaces, figure out data dependencies, and so on.

    The code may be runnable, just printing out some statements. Then I copy blocks of it to the place where it will belong.

    It’s more of a thinking tool, than “actual code”.