• 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

    • True, but if they make such an update, there is no guarantee that the method to disable it will be the same, meaning that this tool might not work until it is updated.
    • Wolfenstein TV show in development at Amazon by Usama Jawad Wolfenstein is a very popular game franchise with its roots going back almost 45 years to Castle Wolfenstein in 1981. Modern titles in the series are based on an alternate history where the Nazis won World War II, and players are tasked with taking on the mantle of the badass protagonist William "B.J." Blazkowicz and taking the fight to Axis forces. Here at Neowin, we are huge fans of Wolfenstein and its slick gunplay. Banking on the popularity of the series, Amazon MGM Studios is currently working on a Wolfenstein TV show. Patrick Somerville will serve at the helm as creator, writer, executive producer, and showrunner. He has apparently been a fan of the games since he was a child, and he will be joined by some other executive producers too, namely Jonah Nolan, Lisa Joy, and Athena Wickham. All three of these have previously worked together on HBO's Westworld. Wolfenstein's current developer MachineGames has also offered up Jerk Gustafsson as executive producer. Not much about the plot is currently known, but the logline of the TV series does aptly say that "The story of killing Nazis is evergreen". It is unknown if the series will star B.J. Blazkowicz with a storyline inspired from the games or if it will serve up a fresh take with new characters. This isn't Amazon's first foray into the world of TV shows based on video games. The company has previously produced the popular Fallout TV series based on the game franchise of the same name, and has other similar projects in development too. These include TV shows for God of War, Mass Effect, and a Warhammer 40,000 project starring Henry Cavill. The release date of the Wolfenstein TV show is currently unknown but it should be a strong addition to Amazon's already impressive slate of content. Source: Variety
    • seems pretty short sighted to just kick the can down the road like that. /s
  • Recent Achievements

    • First Post
      Electronic Person earned a badge
      First Post
    • Week One Done
      CyberCeps666 earned a badge
      Week One Done
    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
    • Dedicated
      Snake Doc earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      626
    2. 2
      ATLien_0
      242
    3. 3
      Xenon
      163
    4. 4
      neufuse
      130
    5. 5
      +FloatingFatMan
      124
  • Tell a friend

    Love Neowin? Tell a friend!