I Use THIS Trick In Python EVERY Single Day

preview_player
Показать описание
I use this trick in Python every single day. #code #python #programming
Рекомендации по теме
Комментарии
Автор

This is really streamlined and convenient. JS feels so bulky compared to that.

Kommentierer
Автор

Wow. Using f strings everywhere but have never known this. Thank you!

JordanMetroidManiac
Автор

Beautiful formatting for English speaking countries ;) In some countries, e.g. German speaking ones, the comma is used to separated the decimals.

arzigogolato
Автор

Should start out as percent = 37.51 ... If you name the variable percent then that's what format should be stored, and not a decimal that needs converted.

Jim-tvtk
Автор

Is there a compilation of all these f string formatting features...

Redditard
Автор

Showing a sub unit percent without a leading zero is a sin

DrDeuteron
Автор

Does the formatting acocunt for localization?

ShiloBuff
Автор

Where is the doc for this formatting ?

Akonitx
Автор

Ive learned that in a calculus course, but hey doesn't seen to be widespread

joaovmlsilva
Автор

and much better to also add another variable storing the actual data to make the float value variable. It could be a try and except block if it is user input or something else linking to a database or api.

davidcalebpaterson
Автор

I knew about the comma and the number trick, didn't know I could combine them nor the percent tsign.

xxlarrytfvwxx
Автор

Great Tip :D but How are the commas dealt like? Like can I use it with Indian Numbering system? Like this (1, 00, 00, 000) or is it just the international one? Like (10, 000, 000).

prathamkalgutkar
Автор

Very similar to java string formatting

badgerzzbadgerzz
Автор

Huh I have used python for years and never had a clue this was possible, thanks

paulosullivan
Автор

x = 5000
print(f"{x:, }")



It's really help

But there is a way to do 100k
Or 100m

shalevforfor
Автор

bro put a watermark on the python standard library

caffeine
Автор

I was practicing and get trouble with that code...i can't have the result even that python don't raise error.please help

class Polygone:

    def perimeter(self):

        print("Perimeter")

 

class Rectangle(Polygone):

    def __init__(self, length, width):

      self.length = length

      self.width = width

 

    def perimeter(self):

        return 2 * self.length * self.width

 

class Square(Polygone):

    def perimeter(self):

        return  4 * self.side

 

class Triangle(Polygone):

    def __init__(self, a, b, c):

        self.a = a

        self.b = b

        self.c = c

 

        def perimeter(self):

            return a + b + c

 

triang = Triangle(8, 9, 0)

triang.perimeter

Maesdy
Автор

So, you code every day and you format strings like that every time you code. What is your job man?

kirillberezin
Автор

It doesn’t result in less code so it’s completely useless (unless you care about the number of sf/dp)

itsmaxim