I feel like the most useful case where you'd use strip() was left out of this video. When used with no parameters, it strips spaces from the beginning and the end of a string. It's used all the time as the first step in sanitizing data from user input. I loved this video regardless though! I did not know about some of these, namely the weird fill ones
Also the difference between strip and removeprefix: the first one takes a list of characters that may be removed multiple times, while the second one just removes the parameter as a single string.
.format() should only be considered for legacy code. F-strings are far superior and should be chosen in every case they can be used… much like List Comprehensions should be chosen wherever possible.
One of the greatest videos about python strings I have watched on TH-cam. It is comprehensive! One thing I want to add is the difference between lstrip and removeprefix. The first one removes all the characters specified in its arguments starting from the left of the string until it faces a character that is not in the list of characters specified in its argument. So, print(‘Luigi gui guard’.lstrip(‘Luig ‘)) will print “ard” The second one removes the substring passed to it. So, print(‘Luigi gui guard’.removeprefix(‘Luigi ‘)) will print “gui guard” The same thing apply for rstrip and removesuffix I enjoy watching your videos. Keep the great work!
I typed out every string method as I followed this video! omg we did it! Thank you for such a valuable video!! viewer: str = "{subject} is: {action}." print(viewer.format(subject="Midnight Anna", action="subscribing!"))
The lstrip() was presented here very shortly and used only in one scenario. It is important to add that if the text was "someemos text", it would return " text". If you want to remove only the "some" from "someemos text", you can use removeprefix(). Be careful with this. Last thing someone mentioned it in comments was: "What if you didn't give it any parameters?" -> It would delete spaces only on the left side, if there had been some spaces ofc
I enjoy these types of videos. I've used Python for years now but find myself using methods I'm more familiar with, and making them work instead of using the correct method and saving time. Keep up the great work!
one thing that makes sense for learning is to logically group operations together, like print(text.center(20,'*')) print(text.ljust(20,'*')) print(text.rjust(20,'*')) 3 alignments that take the exact same parameters. also, isspace() counts ALL whitespace as spaces - so tabs and linefeeds count as well, more useful than testing only for the space character.
yea, it's a bit misleading, since afaik python doesn't specifically have single characters and all these functions work with strings .replace() .startswith .endswith() etc
Wazzaaap, even though the index was my best one for some personal reasons , I found both center and expandtabs very useful in my current project, thanks to you as always, and happy new year!
I think it's worth mentioning that neither isdecimal() nor isnumeric() nor isdigit() return True for a line '-1', regardles the line is perfectly fine for int().
Disregard, despite the internet not having anything, ChatGPT gave some good use cases for normalizing strings before tokenizing and feeding it into NLP models and such.
\v \u \b ... in one function call, returns False if found any of them. can not test just on "\\" or chr(92) in text which could be normal. no need for if "\t" in text or " " in text or " " in text .... :
@@Indently Ahh I didn't see the count before. After watching the video though, I thought would it be better to do if not method.startswith("__") instead of if not "__" in method as it would allow functions to have a __ inside of them, as well as not checking the whole string for the characters
@@Indently Here ya go. Thanks for the video. def print_methods(obj): methods = [m for m in dir(obj) if '_' not in m] for i, method in enumerate(methods): print(i + 1, method, sep=": ")
Hi there, Great topic for strings, but if I want run the code in start of video it is not working code is as follow: def get_string_methods(): i: int = 0 for method in dir(str): if not in method: i += 1 print(i) print(i ,method, sep=': ') Is there any thing missing in the code?
Can you be more specific? Because you can directly type -> 🔥 for example and it will be in your code.
2 ปีที่แล้ว
@@Indently Specific? So, I dont know how to do it. You use at 13:49 some emoji as some character of string. But how I can type it? Its need for that some addon with browsing allowed emoji or what? You write "you can directly type" but how to directly type emoji of fire on keyboard?
Now I understand what you mean. On Mac I can do it by using a shortcut which gives me a small emoji table. You would have to search on Google whether there's an option for quick emoji insertion for your OS.
2 ปีที่แล้ว
@@Indently So simply copy from somewhere and paste into code ? Ok, its seem easy. Btw thx for this video and video called "6 CLEAN Tips To IMPROVE Your Python Functions" , I learned a lot today. I subscribe you today.
I feel like the most useful case where you'd use strip() was left out of this video. When used with no parameters, it strips spaces from the beginning and the end of a string. It's used all the time as the first step in sanitizing data from user input. I loved this video regardless though! I did not know about some of these, namely the weird fill ones
Lol, I never knew that! I always just use split() with join haha
Also the difference between strip and removeprefix: the first one takes a list of characters that may be removed multiple times, while the second one just removes the parameter as a single string.
@@StampleD2147AI Using split() and join() is still useful when trying to remove multiple whitespaces between words.
And also removes new line character (
), thats handy when reading from a file.
Honestly, the format method deserves a video on it's own.
And f-string as well....
.format() should only be considered for legacy code. F-strings are far superior and should be chosen in every case they can be used… much like List Comprehensions should be chosen wherever possible.
One of the greatest videos about python strings I have watched on TH-cam. It is comprehensive!
One thing I want to add is the difference between lstrip and removeprefix.
The first one removes all the characters specified in its arguments starting from the left of the string until it faces a character that is not in the list of characters specified in its argument. So, print(‘Luigi gui guard’.lstrip(‘Luig ‘)) will print “ard”
The second one removes the substring passed to it. So, print(‘Luigi gui guard’.removeprefix(‘Luigi ‘)) will print “gui guard”
The same thing apply for rstrip and removesuffix
I enjoy watching your videos. Keep the great work!
I typed out every string method as I followed this video! omg we did it! Thank you for such a valuable video!!
viewer: str = "{subject} is: {action}."
print(viewer.format(subject="Midnight Anna", action="subscribing!"))
it took you 50 minutes. I spent 3 hours going through every excercise and trying them out in some code. Thanks for your efforts. Love from UK.
This really helped me get an understanding of writing code on the basic level and complete problem sets. Thank you brother👍
The lstrip() was presented here very shortly and used only in one scenario. It is important to add that if the text was "someemos text", it would return " text". If you want to remove only the "some" from "someemos text", you can use removeprefix(). Be careful with this.
Last thing someone mentioned it in comments was: "What if you didn't give it any parameters?" -> It would delete spaces only on the left side, if there had been some spaces ofc
Thanks for video!.
1. For isalnum() also "_" is valid
2. ascii is pronounced as "aski"
"_" isnt valid for isalnum() just checked 😊
@@MuslimMan377 and neither is "1_000"
finally a good course from a special italian dude ! grazie
I enjoy these types of videos. I've used Python for years now but find myself using methods I'm more familiar with, and making them work instead of using the correct method and saving time. Keep up the great work!
I’m the same, finding ideas like this to record is what I really enjoy doing, and even better if they help people :)
one thing that makes sense for learning is to logically group operations together, like
print(text.center(20,'*'))
print(text.ljust(20,'*'))
print(text.rjust(20,'*'))
3 alignments that take the exact same parameters.
also, isspace() counts ALL whitespace as spaces - so tabs and linefeeds count as well, more useful than testing only for the space character.
Really nice video, thanks.
on the endswith() you can also use another string not a single char, i.e. “apple”.endswith(“ple”)
yea, it's a bit misleading, since afaik python doesn't specifically have single characters and all these functions work with strings
.replace() .startswith .endswith() etc
Love this video series - I'm documenting every single bit of them in my IDE as reference material
As usual, I learned something new from this video! It's a really useful summary!
brother this is the best video when i seen, short but all methods understandable
Great Vid! I'm learning Data Analytics rn using Python. Your content is helping me out. Thank you!
Thanks for getting straight to the point with every form sir 🎉❤
This was very consice and easy to follow; thank you for the time stamps.
Love this, really nice refresher, and some that I was not aware of. Thank you.
Wazzaaap, even though the index was my best one for some personal reasons , I found both center and expandtabs very useful in my current project, thanks to you as always, and happy new year!
Bruv , Make a cheat sheet for all 47 methods . You have covered everything . We need to have a cheat-sheet with examples handy.
This video is literally GOLD !!!
i think this is the most useful video i've seen today thanks for your effort 😍
Thanks for the nice and helpful info.💚
I think it's worth mentioning that neither isdecimal() nor isnumeric() nor isdigit() return True for a line '-1', regardles the line is perfectly fine for int().
Great video. Mot likely I'll have to come back eventually hahaha I really like your channel.
Love videos like this. Thanks for sharing!
wow bro thanks greets from Uzbekistan🙌👍
A must-have video for beginners. thanks
thank you for making this video!
Great explanation and very useful
8:27 those numbers are Chinese
its been a year! and still a wonderful video :)
thanks for sharing man, good explanation
Thank you bro, im making sure im all refreshed for my final tomorrow lol
this is so good, Thx for that
You are superb ma bro ❤ i really understand your explanation
You are the best. Everything is well explained
🤩
Thank you very much, your are a gift!!!
Very interesting and usefull ! Thanks
Thanks for the knowledge...................... it's just insane lecture
thank you for all explanations
5:15 in python 3.6 and later, often f-strings are cleaner than .format()
Thanks a lot :)
Thank you, this video is very informative.
Very useful. Thanks 👍
print('Interesting and helpful!)
Very very good lecture
8:21 these are actually Chinese digis btw
my brother in Christ that’s mandarin. Great vid btw 9:17
Amazing content ty
TH-cam says that two videos in the playlist are hidden - can you tell us what they are or unhide them?
Very useful thank you sir❤
What's the difference between casefold() and lower()?
casefold is more aggresive than lower -> example with german ß, casefold will make it ss but lower wont do anything
@@dzendys_ Thank you for the quick response :).
Thanks for sharing, Big help!
BTW, 8:30 those are Chinese numbers! hahhah
Would be cool to do the same with DICTs and LISTs. Many thanks!
Creating a function to run desired string function against each item on the list should solve this
great video .
do more method vidoes
Hi, could you make a video on functions of python from basic to advanced, and nested functions and class methods nested functions
Thank you very much sir.
very nice video
I didn't know there was an "isAshi()" method 🤣🤣🤣 (7:05)
Me neither, I never heard "ASCII" pronounced that way... ;-)
I ❤ your videos! Good job
Thank you!
I LOVE YOU!☺
Looking for some DATABASE functions like CRUD!!!
Thanks dude
rely very useful 😍😍
Why do we need to use translate/maketrans? The replace method is really easier!
good one
pretty useful videos, just in case, #17 are CHINESE NUMBERS!!
8:28 they are Chinese btw *
I remembered to comment. Was that wazzzaaap speedy?
Hellooo, 15:32 Guys. I loove this video
THANKS
No problem
Can someone give a use case where .isprintable() would be important? I'm sure it is useful, but I can't think of anything.
Disregard, despite the internet not having anything, ChatGPT gave some good use cases for normalizing strings before tokenizing and feeding it into NLP models and such.
detects \t
\v \u \b ... in one function call, returns False if found any of them.
can not test just on "\\" or chr(92) in text which could be normal.
no need for
if "\t" in text or "
" in text or "
" in text .... :
Hello . Thanks
Gracias
Note guys these methods do not alter the actual data that variable is constant...
Why exactly does .format_map(dict) exist? Couldn't you just do .format(**dict)?
Is casefold different from lower in any way?
Yes
Lower only lowers english words
Casefold takes every case and lowers it
Like β is ss
At least I think it's like that
You could've used enumerate in the loop at the start!!
The count would not display properly with the code above because of the if check. But you're welcome to share some code and show me otherwise :)
@@Indently Ahh I didn't see the count before. After watching the video though, I thought would it be better to do
if not method.startswith("__")
instead of if not "__" in method
as it would allow functions to have a __ inside of them, as well as not checking the whole string for the characters
@@Indently Here ya go. Thanks for the video.
def print_methods(obj):
methods = [m for m in dir(obj) if '_' not in m]
for i, method in enumerate(methods):
print(i + 1, method, sep=": ")
Isn’t this just a chatgpt output?
@@Indently Which one lmao
I don't like to use "format()", just ues f-string, it's mort ez to understand and read
0:52 xDD i saw that
Hi there, Great topic for strings, but if I want run the code in start of video it is not working code is as follow:
def get_string_methods():
i: int = 0
for method in dir(str):
if not in method:
i += 1
print(i)
print(i ,method, sep=': ')
Is there any thing missing in the code?
I learn something new
Hey is it just me or is VS Code faster in code suggestions eg AI
can you make a finger counting app
What your IDE you use?
Nice
which compiler u using?
Probably CPython
.lower and .casefold look similar to me
startswith()
Cool
Only 50 minutes to record?
cool
How insert emoji into python code? :-)
Can you be more specific? Because you can directly type -> 🔥 for example and it will be in your code.
@@Indently Specific? So, I dont know how to do it. You use at 13:49 some emoji as some character of string. But how I can type it? Its need for that some addon with browsing allowed emoji or what?
You write "you can directly type" but how to directly type emoji of fire on keyboard?
Now I understand what you mean. On Mac I can do it by using a shortcut which gives me a small emoji table. You would have to search on Google whether there's an option for quick emoji insertion for your OS.
@@Indently So simply copy from somewhere and paste into code ? Ok, its seem easy.
Btw thx for this video and video called "6 CLEAN Tips To IMPROVE Your Python Functions" , I learned a lot today. I subscribe you today.
That is Bacon Baby.
what is the difference between replace() and maketrans()/ translate()
The c in ascii should be pronounced like a k, not sh.