how should I organize my project? (beginner) anthony explains

Поділитися
Вставка
  • Опубліковано 13 жов 2024
  • today I give my advice for how to organize your project: aka don't worry about it and start hacking!
    playlist: • anthony explains
    ==========
    twitch: / anthonywritescode
    dicsord: / discord
    twitter: / codewithanthony
    github: github.com/aso...
    stream github: github.com/ant...
    I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!

КОМЕНТАРІ • 33

  • @fexofenadinaGenerica
    @fexofenadinaGenerica Рік тому +14

    This is a nice advice. Although I would not bare to have a file with more than 500 lines. But yeah, splitting things when the need arrives is the best way to go

    • @nexovec
      @nexovec Рік тому +2

      Largely depends on your stack. I like using as few things as possible and use languages that have compilers, and that enables me to write single file pograms of couple thousand lines. But this is python land, so no :D

    • @nicwhites
      @nicwhites 11 місяців тому

      @@nexovec I’d argue your logic should be reversed. Being compiled, you should have better structured projects as once built it will be a single binary (unless you’re build .so ) vs python which being that it’s a runtime language, you’d have to distribute more files in order to run.
      In the end though, the most important thing is actually building something so if it works for ya and you’re building things, then keep it up

    • @nexovec
      @nexovec 11 місяців тому

      @@nicwhites The fitting continuation of this conversation is that I've mostly transitioned to go. Bottom line for me is a more structured language leads to more structured code. If your standard for code quality is high enough, python starts to need some help from external tools to get the same thing at best.

  • @_Amilio_
    @_Amilio_ Рік тому +11

    "stick with that until it is painful" 👍😂

  • @ericng8807
    @ericng8807 Рік тому +24

    so you're telling me you don't enjoy dedicating 1 file for every class!?!

    • @Bryft
      @Bryft Рік тому +5

      _smiles in java_

  • @santiagoperez6769
    @santiagoperez6769 2 місяці тому

    Love the channel! I swear I go through this everytime and endup starting projects way too late lol. Question, how would you go about setting up a project that uses different python versions? For example, I have a project that requires python2.7 and python3.9. Its a drone project and its essentially 2 scripts, one for each python version. The scripts will be executed sequentially, so first the 3.9 script and then the 2.7 script. However, I am not sure if its better to use virtual environments or docker... any insight will be greatly appreciated. Thanks!

    • @anthonywritescode
      @anthonywritescode  2 місяці тому +1

      I would port the 2.7 code to python 3, it's 4 years end of lifed after all.

    • @santiagoperez6769
      @santiagoperez6769 2 місяці тому

      @@anthonywritescode, thanks for the reply! And yeah, I would love to do that, but that would be a big task since the code communicates with the drone's firmware and I believe there are some physics and PID loop aspects, so I might have to get familiar with the ArduPilot code (the drone autopilot firmware) as well... it's a task that I've never taken on before. lol, But I guess thats more of a reason to dive in, right? lol, The 2.7 code I'm referring to is actually an open-source API, its the dronekit repo, which uses the MAVLink communication protocol to control the drone's autopilot. It requires Python 2.7 and its really unfortunate, but I might go ahead and try to port it myself so that I have it for future use and to contribute to the open-source project. Have you ever taken on such a task? If so, any good resources I can read or look up to get me started? Im going to reach out to the authors of the API as well, but to start, I was thinking that drawing out a giant flowchart or something to visualize the mechanics would be good. Something to wrap my head around the big picture

  • @Ca1vema
    @Ca1vema Рік тому +3

    At work we have main application file which contains 31k SLOC and no open source language server can handle this, have to use py charm if one want to use some fancy lsp features. Split your file guys :(

    • @d3stinYwOw
      @d3stinYwOw Рік тому

      PyCharm doesn't choke on it? Maybe try different IDE :P

    • @Ca1vema
      @Ca1vema Рік тому

      @@d3stinYwOw which one, for example?

    • @d3stinYwOw
      @d3stinYwOw Рік тому

      @@Ca1vema As IDE? If it can be non open source one, wing python ide might also work for this, if PyCharm chokes on this file.

    • @Ca1vema
      @Ca1vema Рік тому +2

      @@d3stinYwOw I said pycharm is the only IDE which is able to handle this with fancy language server features… so we have to use it, even if we don’t like it.
      Will try Wing, thanks

    • @d3stinYwOw
      @d3stinYwOw Рік тому +1

      @@Ca1vema Sorry, I misunderstood. If you want to use LSP instead of full IDE, I can recommend Kate with pyls/pylsp. How can I replicate your case on my side in order to check if LSP have troubles on files this big?

  • @theendlessriver13
    @theendlessriver13 Рік тому +1

    would you go the same way with tests? For tools like pyupgrade tests are always end to end tests and fully independent on the implementation. Although you usually don't want to test implementation, sometimes you test smaller parts individually, but while also having larger end to end tests, which may be slow. Would you split those out or mark them and use something like "-k not slow"?

    • @anthonywritescode
      @anthonywritescode  Рік тому +4

      pyupgrade's tests were all in one file too -- and the integration-y tests aren't slower than the unit tests -- pyupgrade's 1000 tests run in like ~500ms. I usually make the testsuite match the project structure

  • @samuelcurrans2506
    @samuelcurrans2506 Рік тому +2

    Yo Anthony do you know where you got that shirt it looks fire.

  • @jamesfitzpatrick9607
    @jamesfitzpatrick9607 Рік тому

    I like the idea of rhe sungle file but want to add my reasoning for not doing it. Normally when coming back to a project I can't remember what is going on and the new work gets added to a new file while i explore what i am doing. Then this gets refactored as I work more on the feature.
    I am not saying this a good way, only that it is my way.

  • @walkdead94
    @walkdead94 11 місяців тому

    Or.. bundle whatever you have in a .zip with the __main__.py and it becomes a single file again! :)

    • @anthonywritescode
      @anthonywritescode  11 місяців тому

      that's more of a question of _distributing_ it -- not about organization. also misses the point of this video which is "don't worry about it and start building or you'll never finish"
      also have a video on zipapps here: ua-cam.com/video/HfL2s2JySos/v-deo.html and how you can make them even more powerful as exes on windows: ua-cam.com/video/nzaH5n-Xk64/v-deo.html

  • @ancoopa
    @ancoopa Рік тому

    Great thoughts. Thank you for sharing. ^^

  • @lukerbs
    @lukerbs 6 місяців тому

    this is definitely a hot take!

  • @ItzAnameOk
    @ItzAnameOk Рік тому

    Hello hello!

  • @b_0rk
    @b_0rk Рік тому +3

    How DARE YOU tell me not to use $PYTHONPATH ... my setup works perfectly for me!!!!

    • @Bryft
      @Bryft Рік тому

      Well, if it suits your needs ;-]
      But damn, recently I was playing with Robot Framework and Apache Airflow, and both of them also do some weird shit with PYTHONPATH, so it doesn't seem to be only a rookie mistake. Unfortunately :-/

    • @anthonywritescode
      @anthonywritescode  Рік тому +1

      heh griffinbork is being heavily sarcastic :)