Do you know THIS about print() in Python??? 🤔

preview_player
Показать описание
Everyone knows the print function, but do you know it has 2 optional arguments that can be super useful sometimes?

Get my Free NumPy Handbook:

If you enjoyed this video, please subscribe to the channel:

~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

#Python #Shorts
Рекомендации по теме
Комментарии
Автор

Using \r would overwrite the previous line, helpful in animations

YuvrajRaghuvanshiS
Автор

yeah I am aware about these two...but after the "end" there are two more arguments in print function "file" and "flush" please make a short video on these two arguments as well

shreyansh
Автор

This is amazing!! Thank you!! I asked so many people about NOT printing every time on the new line and they all responded with 'No, its not possible'. Thanks for demoing that it is indeed possible!!

randommotion
Автор

Instead of multiple consecutive prints, what I do is put the values into a list, unpack the list inside a single `print`, and `sep` them with an \n. E.g. `print(*result_list, sep='\n')`

I could also skip the unpacking by just joining them beforehand, but this way I can also print non-string values easily

re.liable
Автор

Congrats on 100k Subscribers! I personally find your videos both high quality and value providing. Wish you the very best in growing your channel to new heights and helping out even more people on YouTube!

DogaOzgon
Автор

And there is also flush: bool which just flush or not the stream, actually stdout. And it is sometimes useful and can be a reason for not seeing a message in the terminal.

plutonion
Автор

We can also use split() fun for separation 😁

madleroshan
Автор

Try to print a string per character without a new line.
Hint: add "flush=True" to print

JustinDuijn
Автор

Kudos for so many small cool little things to learn

okoeroo
Автор

Oh boy, you are very helpful! Thank you!

happyhacker
Автор

What's more, u can really "print" your words using the flush. It's like using a for-loop to print each character out of a word, end = "", and set a time space. It's very cool to use it in questioning and text-based games.

longlong
Автор

As i watched many videos like this none of them had anything I didn’t know but yours did! Thanks!

buba
Автор

A while back I really struggled with the default new line at the end of a print function and it took me a while figuring out what the problem exactly was

jojosba
Автор

First cs50 class, definitely a worthy course

sergioalejandroosorioorozc
Автор

Ohh that's really cool. I once needed to print stuff on the same row with multiple prints. This way is much easier!

stefoben
Автор

And there is the file and Flush arguments. The file argument chooses where your text is printed (default is sys.stdout). And the Flush argument chooses whether or not to forcibly flush the stream (takes a boolean).

itoaster__
Автор

Hi, can you please make a video on python mock, patches, side_effects magicmock, mockito especially if need to unit test decorators, class based decorators, iterators/generators.
Will be really helpful in understanding...thank you

tempaccnt
Автор

x = 5
print(f"x is {x}") is also life changing.

bufdud
Автор

This is like the only thing I learned from my prof

jma
Автор

I have had experience in python for at least 1.5 years and never knew about those features which would have been extremely useful for a project I did recently

okbamtheman
join shbcf.ru