Learn Python @property in 7 minutes! ⚙️

Поделиться
HTML-код
  • Опубликовано: 6 янв 2025

Комментарии • 22

  • @BroCodez
    @BroCodez  6 месяцев назад +10

    # @property = Decorator used to define a method as a property (it can be accessed like an attribute)
    # Benefit: Add additional logic when you read, write, or delete attributes
    # Gives you a getter, setter, and deleter method
    class Rectangle:
    def __init__(self, width, height):
    self._width = width
    self._height = height
    @property
    def width(self):
    return f"{self._width:.1f}cm"
    @property
    def height(self):
    return f"{self._height:.1f}cm"
    @width.setter
    def width(self, new_width):
    if new_width > 0:
    self._width = new_width
    else:
    print("Width must be greater than zero")
    @height.setter
    def height(self, new_height):
    if new_height > 0:
    self._height = new_height
    else:
    print("Height must be greater than zero")
    @width.deleter
    def width(self):
    del self._width
    print("Width has been deleted")
    @height.deleter
    def height(self):
    del self._height
    print("Height has been deleted")
    rectangle = Rectangle(3, 4)

  • @Omikronik
    @Omikronik 6 месяцев назад +3

    İm a full time dev now but i remember your react tutorial was very helpful when i was working on college assignments in the past, glad to see you're keeping it up still

  • @olgaklimenko944
    @olgaklimenko944 2 месяца назад +1

    Please continue with python videos,very helpful ❤

  • @Diamond_Hanz
    @Diamond_Hanz 6 месяцев назад +2

    Bro code is amazing....keep it up! I remember when u had 10k followers! Amazing

  • @vortexofficial123
    @vortexofficial123 6 месяцев назад +4

    Hello mate i m still following your full python course which is great you re like an angel bro love you .

  • @compositeboson123
    @compositeboson123 6 месяцев назад +5

    thanks brogrammer
    edit: also this is a reminder that you should update pycharm or it will lose its charm (sorry I had to do it even tho this is second time)

  • @bathuudamdin
    @bathuudamdin 5 месяцев назад

    Love your work Bro, keep them coming 😊

  • @falcon_map
    @falcon_map 6 месяцев назад +1

    Hello !Are you planning to continue the JavaScript course?

  • @KishanPatel-gq1sw
    @KishanPatel-gq1sw 6 месяцев назад +2

    Django backend framework tutorial plsssssssssssss

  • @shricharanramesh7149
    @shricharanramesh7149 6 месяцев назад +1

    Bro please make a video on java spring boot

  • @zany4164
    @zany4164 6 месяцев назад +1

    @BroCodez can you make c++ game developer pls

  • @shortshub6826
    @shortshub6826 6 месяцев назад +1

    Bro bring adv java and spring boot course🗿

  • @reddysaichalla
    @reddysaichalla 6 месяцев назад

    Bro can you upload react full tuts

  • @hansginzel5973
    @hansginzel5973 2 дня назад

    The video could be half the length if you chose square instead of rectangle 😀

  • @SumitRanjanBahalia
    @SumitRanjanBahalia 6 месяцев назад

    Bro please start backend course

  • @petertoth4799
    @petertoth4799 6 месяцев назад

    Message for the algorithm!

  • @olivergrim7634
    @olivergrim7634 6 месяцев назад

    WOOOOOOOOOOOOOOOOOOOO MORE PYTHON :ddddddddddddddddddddddddDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

  • @felixiyy
    @felixiyy 6 месяцев назад +1

    Bro ily UwU >

  • @oceanofemotion1
    @oceanofemotion1 6 месяцев назад

    Bro can you convert your video in others language ❤

  • @NexusXPeace
    @NexusXPeace 6 месяцев назад

    5th comment

  • @HungVu-sh8rr
    @HungVu-sh8rr 6 месяцев назад

    I have a hard time understand thí