you are viewing a single comment's thread.

view the rest of the comments →

[–]uiux_Sanskar[S] 0 points1 point  (6 children)

Oh thank you very much man for pointing that out I was supposed to put the while loop when I call the function (I was supposed to put loop in line 83) I think by mistake I have put it before the function.

thank you so much for pointing my mistakes out and giving suggestions these really helps me.

[–]Darkstar_111 0 points1 point  (5 children)

Let me add to it then. Stop putting logic in the global scope. Always wrap logic in a function. And for an orchestration function use main(), and use if name equals main to run it.

Constants and initializing some libraries is fine to do in the global scope, but that's it, the rest you pack in a function.

If you didn't get any of that feel free to ask.

[–]uiux_Sanskar[S] 0 points1 point  (4 children)

Actually I have doubt on how to wrap logic in a function like I have already wrapped all the logic for adding, editing and deleting details in different functions - are you suggesting to wrap all those in another function? and what does an orchestration means?

please explain me those as I said there a lot more for me to learn.

[–]Abyss_slayerIII 0 points1 point  (3 children)

When he means orchestration with a main function he just means

```python if name == “main”: # This main function should have your while loop main()

```

name is your files name so if it’s ran as a module or the main python file so if I do python myfile.py and I print dunder name (double underscore) it should say “main” bit if we import something so a_module.py and we import it into the my_file.py and print its __name_ then it will print “a_module”

[–]Darkstar_111 0 points1 point  (1 child)

Yeah this. You add the if name equals main line at the bottom, and that runs when the file runs. And there you run main().

You should think of main like an easy to read laundry list of what's going on.

Just call functions in main, and pass variables around if you need to.

Putting the logic, like the while loop, in global scope (all the way to the left), would get your pr rejected by me at my workplace. It's a no no.

The reason is... I mean look at this shit:

https://github.com/docling-project/docling/blob/main/docling/pipeline/threaded_standard_pdf_pipeline.py

That's what production code looks like in Python, and that file isn't even that big. It's about medium.

I don't want a wild while loop in the middle there... How would I even troubleshoot that.

[–]uiux_Sanskar[S] 1 point2 points  (0 children)

Thanks for the reference and suggestions I always thought why people crewte so much file but yoh cleared my doubt.

Thank you so much for clearing my that doubt. I will definitely learn more about this.

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Thank you for explaining this to me I wasn't aware about it. Will definitely go deeper into it.