• 0

What is a dot operator in Python? And how powerful is it!?


Question


What is a dot operator in Python? And how powerful is it!?

 

well - if we say that almost everything in Python is an object. And furthermore - every object has certain attributes and methods.

 

In python - the typical connection between the attributes or the methods with the object is let us say named or we  an also say indicated _with_ - or let us say _by_ a “dot” (”.”) written between the attributes or the methods and the object. Let us illustrate this formal behavior in python with a little example; if we look at lessie the dog. This dog - we can say does alot of things:

 

during the whole live of a typical dog  we ca admit that - he runs, walks, bites, sleeps and lots of other thigns more.
Here’s how we can spell out the above mentioend behaviour in a so called object-oriented style - well we might write this:

Lessie = Dog()
Lessie.walks()
Lessie.wows()
Lessie.runs()
Lessie.bites()
Lessie.eats()

and so forth and so forth and so forth and so forth

 

Well besides the above mentioened things - we can say that Lessie has additionaly and furthermore lets say different attributes and different qualities.


the question is: can objects have even more objects that belong to them,


Lessie.head.hair()
Lessie.head.hair.color = "browm";
Lessie.head.mouth.theeth.length.()


quesiton: can objects have even other objects that also do belong to them - in other words - do they are able to have a connection to the object with their own methods or attributes:

 

1 answer to this question

Recommended Posts

  • 0

You can chain methods by returning an instance of self on a method call. You cannot chain objects as the dot operator is not an accessor for dictionaries. There are ways to hack an implementation of it, if you were so inclined, but I'd argue it'd be better to utilise the built-in native accessor syntax. There are many reasons to perform method chaining, mostly around quality of life for developers using your library. Not many reasons to use object chaining with the dot accessor other than you like how it looks.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • AeroGlass looks much better than that, Microsoft must bring it back !!!
    • I mean… it still looks the same, pretty much.
    • I can’t stand Musk, but he did not design it any more than he engineers Space X rockets. Stop helping give the clown credit for things he wants people to believe he did when in fact, he did not. https://en.wikipedia.org/wiki/Franz_von_Holzhausen
    • Steam Next Fest is back with demos from hundreds of upcoming games to try out by Pulasthi Ariyasinghe The June showcase week is just behind us, and Valve has timed its latest demo event to land right after it. The June edition of the 2025 Steam Next Fest has just gone live, and that means PC gamers have another classic trade show experience to witness. The festival is once again hosting hundreds of gameplay slices from upcoming games. While the majority of demos are by indie developers showing off their work, several major publishers are involved in the festivities to show off their wares too. If you tuned into the plethora of game showcase events last week, there should be plenty of titles you recognize from the demos. The newly opened event can be accessed from its dedicated Steam Next Fest hub page over here. It features handy categories to sort through by genre, theme, and feature, while also offering a very intricate filtering system to remove or focus on specific types of games. Some demos that have already begun trending for this edition of Steam Next Fest include Stellar Blade, Jump Ship, Pioner, Dead as Disco, Escape from Duckov, Wildgate, Ninja Gaiden: Ragebound, Neon Abyss 2, and so much more. "We host Next Fest three times a year (February, June, October) as a way to give developers from around the world a captive audience for their demos on games they haven't released yet," says Valve about its recurring event. "If you already have a bunch of genres that are your faves, feel free to search that way. BUT we also encourage you to try something new." The June 2025 edition of the Steam Next Fest is slated to end on June 16 at 10 AM PT. For those wanting some discounted games, keep in mind that following this event, Valve will officially kick off the massive 2025 Steam Summer Sale on June 26. Find the complete schedule for Valve's upcoming Steam sales and events for the year here.
  • Recent Achievements

    • Dedicated
      MadMung0 earned a badge
      Dedicated
    • Rookie
      CHUNWEI went up a rank
      Rookie
    • Enthusiast
      the420kid went up a rank
      Enthusiast
    • Conversation Starter
      NeoToad777 earned a badge
      Conversation Starter
    • Week One Done
      VicByrd earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      507
    2. 2
      ATLien_0
      267
    3. 3
      +FloatingFatMan
      262
    4. 4
      Edouard
      203
    5. 5
      snowy owl
      178
  • Tell a friend

    Love Neowin? Tell a friend!