one downside to this video, it didn't even cover the simplest (and best) use of tqdm - wrapping an iterator for item in tqdm(qs): tqdm can infer the length of most iterators, and if it can't it will stil show the amount of work already done
@Cod1ngTogether
8 күн бұрын
I get your point, and you're definitely right to some extent! It would have been simpler, with less code, and so on. qs = [1, 2, 3, 4, 5, 6, 7] for item in tqdm(qs, desc="progress bar", ascii="░X█", ncols=700): # Add processing/work here time.sleep(0.5) In this example, though, it's just harder to explain-for instance, when the .update() of the progress bar happens and how it works in general. That's why I decided to use the method I did. But hopefully, a lot of people will see your comment and learn from this approach too.
@aonodensetsu
6 күн бұрын
@@Cod1ngTogether with statements are good to know as well, and explicitly calling update is a clearer way, but you also don't manually increment indexes in python, instead using "for i in list:" which is the same concept, rather than i = 0 while True: if i >= len(qs): break item = qs[i] # do things i += 1 most concepts can be reduced, but python is a highly abstract language and abstract constructs for quality of life are highly important
@Cod1ngTogether
6 күн бұрын
@aonodensetsu i fully agree to your words. 👍🏻😄 and thank you for this discussion. Most of the time it just depends on your knowledge/ experience how efficient you can use python. Here is a older video from me: How to transpose a matrix with LIST COMPREHENSION #python #programming #coding kzitem.infonzE5cpFfSi8?feature=share Its possible in python, but i never would code like this in real projects because its hard to read if you use it barely 😄
@aonodensetsu
6 күн бұрын
@@Cod1ngTogether i do program like this in real projects, with some whitespace to clarify composed parts matrix_transpose = [ [ # return a list of lists, row[i] # with the inner lists containing column data for row in matrix ] for i # with the outer list containing rows in range(len(matrix)) ] list/set/dict/tuple/generator comprehensions are not difficult, but they are very information dense, so relaxing that information into multiple rows - which a for loop also does - makes it easier to parse, comments help as well
@Cod1ngTogether
6 күн бұрын
@aonodensetsu that seems to be a very good way to me 😄👍🏻
@Cod1ngTogether
8 күн бұрын
Thanks for watching! Does this help you? Did you like it? Would you like to see how to use this progress bar in a real-life function, such as unzipping a file and transferring the files? Let me know!
@tomvondeek
6 күн бұрын
i remember i school project back in something like 1996 or something, very first introduction in school to turbo pascal delphi. during that schoolyear we learned basic programming stuff and as a final had to program a hangman game, something like that. i wrote a progressbar loadingscreen. the progressbar itself was randomised to a total of 7.5 seconds, but how it got from start to end was random every time starting the code, i thought it was funny back then
Пікірлер: 9