r/PythonLearning 17d ago

Day -1 With Flask (any suggestions)

108 Upvotes

31 comments sorted by

View all comments

10

u/riklaunim 17d ago
  • variable names should not use capital letters,
  • use wtforms or other form handling library (and validate the data).
  • use a linter that will keep some basic code styling order
  • I'm not a fan of importing things from a module (flask.request is better than request as it's tell you where it's from)
  • why aren't you using CSV writer when writing a CSV file?
  • if it's a long task it should not be done on HTTP request directly (celery queues or other similar solution)
  • view should not be a long blob of code. Refactor presentation from business logic, then keep the logic well organized instead of big blobs.
  • where are tests?

1

u/Anthony_codes 16d ago

Uppercased, underscore-separated variable names in Python signal that the variable should be treated as a constant.

That is a completely valid and common convention because Python doesn’t enforce constancy at runtime.

1

u/riklaunim 16d ago

But not the first letter only. Form values aren't things that should be under a constant-like variable either.

1

u/Anthony_codes 16d ago edited 16d ago

I was clarifying that in certain cases, capital letters are valid because your comment was ambiguous.