Feb 21, 2017 12:44 PM
(This post was last modified: Feb 21, 2017 12:45 PM by (╯°□°)╯︵ ┻━━┻.)
|
Python
Proper String Formatting |
|
Feb 21, 2017 01:02 PM
(This post was last modified: Feb 21, 2017 01:02 PM by SIM-1866423.)
Jump into 3.6 now im fan of f-strings right now, huh wat is wrong with you !
(Feb 21, 2017 01:02 PM)SIM-1866423 Wrote: Jump into 3.6 now im fan of f-strings right now, huh wat is wrong with you ! Yeah, f-strings look really cool but most of my clients are on 3.5 so anything that I update needs to be compatible.
I agree. I'm pretty well known on here for being a Python 3 fuckboi, and 3.6 did some great things with asyncio, but when it comes down to writing modules that you want people to use, then writing it for 3.3+ is the best way to go (or at least 3.5 which has been around for a couple of years almost).
SRPP Discord Server
I am a professional network/cloud security architect. My Old Tutorials (Feb 21, 2017 08:24 PM)mattdax Wrote: IMO i personally like the commas and + over format(). Just to me it looks so much easier to understand and makes more sense, however I am always open minded if someone cared to explain to me why .format() is better. Not every object can be concatenated together. If you look at my first example, try doing: Code first_name = "Ron"This one wont error. Code print("Your name is {0} {1} and your age is {2}.".format(first_name, last_name, age))(Feb 21, 2017 08:27 PM)(╯°□°)╯︵ ┻━━┻ Wrote: Not every object can be concatenated together. If you look at my first example, try doing: Right, but in that case you could just use commas and you wouldn't need worry about casting. (Feb 21, 2017 08:49 PM)mattdax Wrote: Right, but in that case you could just use commas and you wouldn't need worry about casting. Can you map a dictionary with commas? Or a class? Honestly one of the best features of format(). (Feb 21, 2017 06:51 PM)Goodies Wrote: I agree. I'm pretty well known on here for being a Python 3 fuckboi, and 3.6 did some great things with asyncio, but when it comes down to writing modules that you want people to use, then writing it for 3.3+ is the best way to go (or at least 3.5 which has been around for a couple of years almost). Nothing wrong with being a python 3 fuckboi, in basic terms, its literally the future of python. (Mar 1, 2017 08:24 PM)IChoseDogLeading Wrote: Thanks for that just starting out, this helped a lot No problem! Anything else you think that would be helpful? I'm currently working on a semi-intermediate subject but I'm trying to explain it in a way that anybody should be able to understand. |
|
|


![[Image: Fa9hxyj.png]](https://i.imgur.com/Fa9hxyj.png)
![[Image: hRMRea8.png]](https://i.imgur.com/hRMRea8.png)
![[Image: AiyrizQ.png]](https://i.imgur.com/AiyrizQ.png)
![[Image: ouURNlq.png]](https://i.imgur.com/ouURNlq.png)
