It's not magic: descriptors exposed

Video thumbnail (Frame 0) Video thumbnail (Frame 1077) Video thumbnail (Frame 1915) Video thumbnail (Frame 3853) Video thumbnail (Frame 5418) Video thumbnail (Frame 6204) Video thumbnail (Frame 7098) Video thumbnail (Frame 7967) Video thumbnail (Frame 8771) Video thumbnail (Frame 9560) Video thumbnail (Frame 10405) Video thumbnail (Frame 11204) Video thumbnail (Frame 12123) Video thumbnail (Frame 13098) Video thumbnail (Frame 13887) Video thumbnail (Frame 15523) Video thumbnail (Frame 17779) Video thumbnail (Frame 19642) Video thumbnail (Frame 20582) Video thumbnail (Frame 21563) Video thumbnail (Frame 22368) Video thumbnail (Frame 23387) Video thumbnail (Frame 24292) Video thumbnail (Frame 25478) Video thumbnail (Frame 26432) Video thumbnail (Frame 27192) Video thumbnail (Frame 28569) Video thumbnail (Frame 29530) Video thumbnail (Frame 32821) Video thumbnail (Frame 33606) Video thumbnail (Frame 34607) Video thumbnail (Frame 35458) Video thumbnail (Frame 36203) Video thumbnail (Frame 39112) Video thumbnail (Frame 40016) Video thumbnail (Frame 42205) Video thumbnail (Frame 43062) Video thumbnail (Frame 44355) Video thumbnail (Frame 45250) Video thumbnail (Frame 45993) Video thumbnail (Frame 46788) Video thumbnail (Frame 47840) Video thumbnail (Frame 48837) Video thumbnail (Frame 49573) Video thumbnail (Frame 50331) Video thumbnail (Frame 51852) Video thumbnail (Frame 52836) Video thumbnail (Frame 53827) Video thumbnail (Frame 54577) Video thumbnail (Frame 55859) Video thumbnail (Frame 56816) Video thumbnail (Frame 57652)
Video in TIB AV-Portal: It's not magic: descriptors exposed

Formal Metadata

It's not magic: descriptors exposed
Title of Series
Part Number
Number of Parts
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Facundo Batista - It's not magic: descriptors exposed This talk shows the Python Descriptors, detailing their behaviour with a detailed practical example, so we can understand the power and flexibility they give. As a bonus track, class decorators are explained. ----- This talk presents, using a detailed practical example, the Python Descriptos. The behaviour of descriptors mechanisms is detailed, showing their power and flexibility. Finally, as a bonus track and to complete the used practical example, class descriptors are explained.
Lecture/Conference Meeting/Interview Multiplication sign Video game
Lecture/Conference Energy level Whiteboard Game theory Theory
Group action Computer animation Clique-width Length Social class Game theory Physical system Wave packet Social class
Mechanism design Computer animation Clique-width Network topology Length Social class Twitter
Matching (graph theory) Computer animation Network topology Arithmetic mean Hypermedia Musical ensemble
Point (geometry) Computer animation Lecture/Conference Group action Number
Matching (graph theory) Computer animation Lecture/Conference Interior (topology) Group action
Scripting language Keyboard shortcut Computer animation Lecture/Conference Meeting/Interview Object (grammar) Attribute grammar Game theory Communications protocol Communications protocol Theory
Word Game controller Computer animation Object (grammar) Multiplication sign Set (mathematics) Code Normal (geometry) Attribute grammar Object (grammar) Control flow Attribute grammar
Scripting language Moment (mathematics) Code Amsterdam Ordnance Datum Attribute grammar Instance (computer science) Control flow Word Data mining Computer animation Personal digital assistant Object (grammar) Set (mathematics) Social class Form (programming) Social class
Slide rule Computer animation Euler angles Multiplication sign Cellular automaton Social class Attribute grammar Instance (computer science) Mereology Task (computing) Social class
Frequency Proof theory Computer animation Lecture/Conference Code Moment (mathematics) Social class Attribute grammar Software testing Instance (computer science) Instance (computer science)
Scripting language Computer animation Lecture/Conference Moment (mathematics) Set (mathematics) Social class Attribute grammar Instance (computer science) Implementation Theory Attribute grammar
Scripting language Inference Computer animation Characteristic polynomial Set (mathematics) Social class Attribute grammar Unicastingverfahren Instance (computer science) Instance (computer science) Implementation Social class
Area Web page Identifiability Information Multiplication sign Equaliser (mathematics) View (database) Moment (mathematics) Instance (computer science) Instance (computer science) Data dictionary Disk read-and-write head Degree (graph theory) Population density Computer animation Personal digital assistant Social class Social class
Group action Data storage device Instance (computer science) Instance (computer science) Attribute grammar Type theory Subject indexing Type theory Computer animation Lecture/Conference Personal digital assistant Social class Social class
Type theory Computer animation Personal digital assistant Different (Kate Ryan album) Moment (mathematics) Social class Game theory
Type theory Computer animation Personal digital assistant Different (Kate Ryan album) Social class Instance (computer science)
Scripting language Type theory Computer animation Personal digital assistant Set (mathematics) Social class
Computer animation Personal digital assistant Sampling (statistics) Social class Attribute grammar Instance (computer science) Complete metric space Endliche Modelltheorie Implementation Complete metric space
Point (geometry) Category of being Service (economics) Computer animation Lecture/Conference Blog Category of being Computer programming Theory
Game controller Computer animation Lecture/Conference Social class Staff (military) Right angle Number
Scripting language Computer animation Personal digital assistant Cellular automaton Multiplication sign Social class Instance (computer science) Whiteboard
Classical physics Computer animation Set (mathematics) Social class Instance (computer science) Social class
Clique-width Length Attribute grammar Instance (computer science) Instance (computer science) Mereology Number Number Computer animation Lecture/Conference Personal digital assistant String (computer science) Social class Physical system Social class
Scripting language Number Computer animation Clique-width Length Social class Attribute grammar Summierbarkeit Bounded variation Social class Attribute grammar Number
Scripting language Functional (mathematics) Mountain pass 3 (number) Mass Type theory Word Computer animation Angle Meeting/Interview Lecture/Conference Personal digital assistant Function (mathematics) Video game Social class Right angle Right angle Social class
Scripting language Casting (performing arts) Computer animation Point (geometry) Energy level Social class Endliche Modelltheorie Field (computer science) Endliche Modelltheorie Form (programming)
Trail Functional (mathematics) Trail Menu (computing) Category of being Computer animation Lecture/Conference Function (mathematics) Operator (mathematics) Social class Software testing Game theory Social class
Degree (graph theory) Casting (performing arts) Functional (mathematics) Computer animation Function (mathematics) Mountain pass 1 (number) Social class Normal (geometry) Social class
Dataflow Functional (mathematics) Instance (computer science) Disk read-and-write head Number Type theory Computer animation Bit rate Lecture/Conference Social class Game theory Glass float Social class
Point (geometry) Scripting language Computer animation Lecture/Conference Social class Quicksort Game theory Uniform boundedness principle Physical system
Scripting language View (database) Instance (computer science) Type theory Message passing Latent heat Computer animation Grand Unified Theory Lecture/Conference Meeting/Interview Internetworking Different (Kate Ryan album) Personal digital assistant
Metropolitan area network Raw image format Presentation of a group Mapping Line (geometry) Computer file Computer-generated imagery Maxima and minima Average Term (mathematics) Special unitary group System call Web 2.0 Bargaining problem Hypermedia Moment of inertia Cache (computing) Computer animation Arithmetic mean Ranking Summierbarkeit Scalable Coherent Interface
Exterior algebra Slide rule Lecture/Conference Right angle Computer programming
Point (geometry) Functional (mathematics) Arithmetic mean Computer animation Personal digital assistant Social class
Scripting language Dataflow Computer animation Lecture/Conference Personal digital assistant Moment (mathematics) Social class Cartesian coordinate system Mereology
Presentation of a group Computer animation Multiplication sign Social class Right angle Glass float Social class Form (programming)
Slide rule Computer animation Faculty (division) Social class Form (programming)
Casting (performing arts) Word Coefficient of determination Computer animation Social class Series (mathematics) Game theory Form (programming)
Computer animation Lecture/Conference Mountain pass Function (mathematics) Point (geometry) Dew point Video game Set (mathematics) Social class Normal (geometry) Right angle
Computer animation Personal digital assistant Social class Instance (computer science) Instance (computer science) Number
Area Computer animation Inheritance (object-oriented programming) Personal digital assistant Social class Instance (computer science) Instance (computer science) Proper map
Clique-width Multiplication sign Length Attribute grammar Machine vision Product (business) Number Crash (computing) Computer animation Lecture/Conference Personal digital assistant Social class Whiteboard Game theory
Scripting language Frequency Number Computer animation Clique-width Personal digital assistant Length Social class Attribute grammar Instance (computer science) Instance (computer science) Data dictionary
Message passing Computer animation Key (cryptography) Lecture/Conference Personal digital assistant Social class Instance (computer science) Instance (computer science) Number Software bug
Slide rule Run time (program lifecycle phase) Computer animation Social class Instance (computer science) Instance (computer science) Social class
Number Computer animation Clique-width Constructor (object-oriented programming) Length Social class Attribute grammar Social class
Number Computer animation Clique-width Equaliser (mathematics) Moment (mathematics) Length Social class Attribute grammar Social class
you know that he's still the Italian about life in the fifties there will be some time for questions at the end the hang on that kind of command line and at the end to thank you very much you
haven't yet what welcome tend to
be here thanks for the origin of according to the release of some conference I will be talking about the descriptors just trying to everybody understand the descriptive descriptive hot topic it normally the 50 thousand of that some presentations of
descriptive and I understood it a lot of theory and you get out of the percentage and say OK I kind of understand very rare that we
don't have a clue how to applies so we hot that this Hawking that is the other of this talk we decided to do it that way so all we like games board
games and road games and we that that as we are never level we we we not only
wanted to play what games 5 to create them to design a system where you can creative Oregon's so it's like playing the the the game it's like a myth of so we
want is not only to create the system bad we wanted to offer the people ways to create more and we wanted to offer them the possibility of creating more games in a simple way in a useful way so we wanted to do something we want to have power and the powers is where you encapsulated what the powers can do so for example you have training that this is useful power we use some useful power for a character and this if you have a strength you can walls or you can jump the whole it said that if you have matching you can do instead of see that this very simple defined and the power it's just a class it's just what you can do and the the the the action itself it's a cement of that of course according to some value to have more on this magic
it's that you can do it on and when you define a character you assessed defined what powers disconnected hats so this is a very
simple reason if you write it like this it will not work but we wanted to do this and we wanted the world from here so these
how do we use this very simple mechanisms for example you will instantiate a character that is mainly in the UK and essentially within that the 1st time and see how you can check if the if you really can break a wall you ask for this trend of the immediately it's where the power and also you can modify the you commodified variously the value of that power see that's how data cleaning modify that power
in the media so if I put much more power to be mean for example it will be
able to break the world
or for example this is there is a character that has both power so it has a power we have some strength and has some matching and the it's OK big band of can charm and treated very bad of cannot fight Saddleman but they
can just put more much you can download and from that point number the wife we'll be able to to to fight a aviaries that we
wanted to represent we
wanted to give this check the powers in the characters in a very simple way to manipulate working with them like number so you can get or you can set the powers in the character but also encapsulate when the power we be able to in that very same
translated friend in the park so
it's very weird way of doing things but is very simple so how will how we
these I mean we have we didn't do we didn't do it with match I mean this is not much excessive
we use of descriptors make that was so the idea here is that we will go now a little into the interior of the script on and then
we go back to 2 to the borrower game and see how long we've been applied theory so this is the last chance if you
want to give you 1 this
descriptor is so it is going
13 generates an idea we binding behavior of 1 who is said to be Texas has been overriden by methods into the script of protocol very very simple write this very
understand I mean you you already know how how it works then is to see what
we really are doing here in more simple what's Badia behind descriptors is that you'd think he'd take control of some normal Python behavior every time you do this set of finite reviewed in some object every time you get some attributes from some object for or they beat them you remote some of you In some
object we descriptors you get the possibility to execute Europe owned cold instead of normal Python behave so when I do some object that had to
be equal 42 in that case it's not a fight Kinshasa assigning the value 42 to that idiot in this notion but instead if I'm working with descriptors some goal of mine is being executed in the moment
how is how it's how was that you define descriptor with classes 40 class to be a script or you have to be you have to have some special In this case we haven't done that have been then the makes these descriptors may maybe this class and this this than the data these then that
it will be executed every time you access
that of the cell let's see if can really cold in there in the upper part I have the very same class that the last slide where I haven't done the gate and that then the gets every time of war then I find another class that is the task were used the descriptors and see that X the 6 class attitude that is very important because descriptor she is activated when you are using it again using the
dispute as a concept period X is a gas atom that
has an instance of the inner world of then I instances you any test
and the moment that they do see that makes the moment that they access that had to use my own code is being executed so this is the proof
that we descriptors I can get in the middle of the then execution for this is so far how are you doing I mean it's it's totally
crazy makes sense theory last you it
works if you use see how how is measured happens so we
have another special metaphor for script we haven't done research then the set is executed the moment I said the attribute that when the activity is to
get the script that is very similar but before I have it my descriptive
as it is in our market as bad as it has to be the set descriptive I use that descriptor unicast attributed and then when I said that a something my own cold there will be called see that they have to mention that for example in there than that gets I received the instances of a class and the class now that the instance belongs it sometimes uses for some characteristics is that because there is not normally In this set at the inference in this set I received that instances that is a C and the value that then sitting so I always also yeah receive this a big let's see both
working at the same time this and these example gold just this year descriptor
that has both metals down there get and then that's it see that and
then they get it even from the set what what they do then than that said receives a value and set as that value In this instance dictionary under them they're get dreams that value we get the following case it's not yet that is not the area and just return their agreed let's use it in the 2nd column I define a new class and the war to that has a class at you again because of the view that disagreed work with an instance of this page ieee instance telework to identify access afraid head of the body that then the it will be executed that we'll return hello unknown because these density still doesn't have the whose the moment they go ahead go ahead of the degree equal something that and said this executive and in this case it that information in the
instance and when I axis the attribute the just a storage and use of getting
you somehow again we have 2
types of descriptors we
have overriding descriptors and non this is where confusions start the but it's don't worry it's very simple they are assessed gasify groups because they behave very similar to the 1st where the behavior is different here index in the 1st column in the left we have an overriding descriptive see that we have a class that has both than the bid and then the set of in this case I use the descriptor here when I do see that the it executes the and when I do see that B equals something I execute this this is
very similar to what we saw before more than various similarity at at the same In the case of non
overriding descriptors weak you do not have a method the difference of not having a settlement of is that when I use this kind of stuff if I do I see that the of for-profit execute the game but the moment I do see that the equal something they had to review the of the
instance C s of a written by this value so from this point on see that this is wonderfully is no
longer the descriptor in this case ieee execute this than the and from this point on see that the this is still descriptor this is the only difference you have to be careful when you write your own descriptors because even if you don't want to hold any special
behavior in set you need to be careful that if you go specified and the 2nd year of the script that even maybe of a repeat of course it's the behavior that you may want to use on will we see a very common case where that behavior of non-member writing the script that use of by the you Norman
again just for completeness we have another special metal that this bound and then the as you may imagine it's at it is specified goal that is executed when you believe another so In this case when you build a seed of texts he you override this in our model by them behavior of removing that that there it but you shall execute sample of yours
OK 1 note here
because were in a womb my presented this example as you say 0 my guy yes you can do whatever you want with properties in the instead of using descriptive manually years you can do about the point of the talk is to the program of the scriptures that and
it's the I cannot make some this too complicated to so let's go
back to we services and blogs and see how we use these descriptors theory in in their work remember that is
that we have maybe out of
having power whereas which encapsulate where the power control and the character defining there the the followers of scarcity and then a naval tool chest instantiate the character try to see that character can rule some staff asking through all the power that the guards that but also modifying the values of the bar where like simple number this of course doesn't work future right these because some magic wand
that flowed from much here how
wait make this work appear
we make this work not only use descriptors but those cells just agree
so they DO behind all the magic is that we have this power script this is the 1st time I've presented descriptive for the we serve on boards OK case this is the only descriptive this descriptor
that has done the set and then they get when you instantiate that
you you get the name of the power and the class of the power so it can be matching and the classic for the following you define and the only thing that the best assessed the star In the instant dictionary very similar to the other example it's just the start
the instance of the power transductive receiving with the value of the I mean gas in the
case of the land that they had just retrieve the how we make to this power descriptive to reuse it by
other parts of the system we have to get a greater we have this at work
that gets this very simple to power class that you wrote and makes just being 4 1 on 1 on 1 hand it rich there's strings or magic passive power but also makes that these classes behaving make number and then we have
another class the correct that this character that grabs the
character you wrote and for the class attribute that you specify a they're out automatic Kelly combat them to read the script because there you didn't specify you should put
classes script sorry variation would just south of by the sum of descriptors so we have the money to get the numbers that
before going to more of the cold let's see all the
cases where descriptors I use in real life so by metals
is the most nor case
of use in this when you define a red white a metal what summit of real what is it therefore there is a function right and the function there where is defined as the function in the class so metals is it kind of class at 2 and these works like can picked up the descriptor it's in there this the best this matching so when you call what you when you call for that matter 1 tool that this industry especially the script that excessive use executed that calls this function you the final I've been itself in the front so the magic of ultimately galleon Saturn itself when you call in a metal is that by the script and this is are these are men that the descriptors so if you have In stands for I knew dual for that matter equal some seeing you override that name remember that you have 2 types of script than once if you have done that and get them and they said the descriptor was executed and if you have if you only have 1 delegate when you said that there you lost duration and descriptors metals works like that you fewer if you said a name your art or something with the name of the metal use the medallion words like that so the angle most of the mass
seeking models the generation of young locking them by the script of the very same way that I would do there the powers in the characters before he said the specified stuff and the caste level and it works how that is 1 of the other descriptors do you ever use is not note also work through descriptors with very detailed that it's not
implemented in Python really about the use of the descriptors API basically from C but it's also uses descriptors the because how are we going with the market so we have time for
their for the bonus track that is
where we get into the test the greater than the the end of the cold to make that the game World War before going into the that of the Gulf I wanted to present them at the level of desecrate the because it's not a common
topic just the current that I don't know if you ever have I the phrase raise a hand if the a category the reform awesome and raise a high if you saw a normal degrade the reform so this is very simple a category that is a function that receives the gas operators that and the advanced class is the same that the function
the greater but for classes and this staying constant if you
have edit Phaenician of for whatever for the class we defined by the if would have a class definition with a greater always not what defines full East they cast retirement by that they got which receive the cast with that with the final and the whatever the ones with the is this same than doing for we've 1 degree the for the very same thing the function of so how
do that we use it in their in Nevada game these is the power there is a big class the correct that I mentioned before that you just put it in the very simple to our class that you defined and makes it much see what it does this go it's not really simple but we can make it
the power receives a class the
class is this 1 that we have a and the power the great courage creates another class a new class with type function that in these very classy but also head flow and this is how the behavior of a number of is inserted the power and also rich history that class name the on dictionary that we use of later to which is also we had another classical rate of that was character that we applied to when we define character that the categorical chest gets their instead powers and if we have a class at the review in the class that you receive that have the same name of ever he history however like strain or much in this example it replaces it it replaces it would say that said that that it
replaces it we at this point out that this sort of power
script that is the other descriptor that we use in this in the system it replace it
with the power script that that holds the name of their of the Bauer and because of
this is how you are being able to write is very
simple goal to make more game without even noticing that descriptors In the back OK
that's all it wasn't that
fact because of that they want for you to take here is that
descriptors ILO's you to get into the normal behavior or when you get battery the when you said that and with the internet that we you have 2 types of
descriptors those to that of the printers and the difference is that in 1 case when you said that there will be called of descriptor is executed and in the other type of gut script when you say you when you said that the view the descriptor is removed from the instance of a written and also the idea of that I 1 for you to take from here is that is it's not the message that OK maybe it's useful for me to understand the course I made the some goes some way in and I need to understand that but that is something that you can really use In the case is that you want to get in the middle of the so they could mind and when you need to solve some specific stuff descriptors may be used useful for you In this
very M. presentation that this already published in the web you can see the goal you you can see I'm and and as you have discovered something bad that there is every all the calls for making
everything work so if you're interested based that into a couple of them by and start to play some linearly stuff
because I may be making sure then you can say whether it's said about uh and that's
what thinking let's say here
and if you have any questions and very
you know the answer and then I I I I I I I I I I I I
of I find this this with those things quite appealing because it's like an alternative to when you have to make the program to certain things that is of little much there I'm wondering how these 2 to the right of parties to to but the programming or doing everything more but yeah and it's not hard to the
bottle the costs you have to thinking like you are doing a tiny function calls I mean you have to correlate these and and and and only in the you have a course like this and
the understanding the only thing that you need to take in consideration that in the case for example of the way in the meaning that this thing equal whatever you're doing a function called at that point so when you
when you when you read the article and you know that your X axis in the script or you you know that in that case yeah into something to that part of the cold and that's
all you the moment you understand that you'll can easily follow the flow of execution so that when you are doing there was there was more referring
to the last part where you actually use a it's like to create the flowers SMSes movement those
so I was more referring to the 1 in the class right um
it's at work I have time to
review it says that it's of work at actually when we created the presentation is West 310 moral complex everything we we've form this is the way to make it simple idea that is not simple but if it does what it means you can you go to the
next slide when there is a kind I think this 1 looks like is looking at the name of the active you know they I showed you last the faculty find a class character Michael something science but the lady who equal to there is nothing to do with the actual that these yes if you
or a few misspelled the you will you do with it you can you could take the form of gene stands on the
caste name and William more novels thank you should check in series on the right and on the left to
be sure of what it really can
you could it would be better this word
I made this whole war games being whatever just to for dog we review these form for Fourier by this and used to to use descriptive somewhere is that there
is no reason to the user and the peak of the of the in the get and said before in the life and not so that the possible because it it because you can use them in you so
that when when they're in there and then the get and then the set forth as saying that they won't escape the yeah
over here yeah why not doing set of of the the the the the what Mario um I either remember number that I think that it's a case of worried that someone I don't remember where
I right right if you if you access the fuel we feel instance ability or
whatever said that the instance name undervalued you will recall and their their their descriptive so you don't even said that area to the
south mess with OK so how
do you deal with inheritance In when using glass descriptors well that's a very this is in the question because this is 1 case
where you cannot use proper because I mean you encapsulating coal and you want to use hair inheritance so you can have is probably more you need to use proper descriptors you set this it it just works there is no mention there you can have a very bottom gasses with the all those metals or whatever and the descriptor here is and were so basically you have to put across the greater
in both front and side crash but I say 1 created a
great about when you it in this case no in
classical writers for a character for example if there's some magic with applying
the primary either no I
know OK 0 if I didn't try
it I mean it's right remember this this whole board game power collector where assistance is for that reason vision with induces the production of anything so when I 0 I was in the time follow the goal now and I didn't try very similar 1 here in
the previous slide with yeah no with the power the greater is there any reason why are you are sending the value into the instance dictionary and not into the power of descriptor instance itself yes because the
power script we use we may be applied to different instances so this is normal behavior maybe not in this case but you may have noticed that that there is there is there is there to be applied to different periods
so you anomalies that are staffing to instance is what you normally seen that everybody above all what if the number of descriptor
wants to instance of what's to access the the same key in this instance it doesn't happen in this case
if you have that case you can the 3rd whatever 1 of the thank you it's I mean there is no by the message here is just put stuff in some places and use it I mean you could you could
have a global additionally we make the being dating stands and their name and access that we
all and dictionary instead of storing stuff in the instance you
come because you can send it to the that is pretty normal for the descriptors to mess with them we've been stands give me great to think
you have question can you explain more where we your initial is you know the descriptor was inside the class and for example in that denying its and can we change the descriptor during the run time of and not on the slide the previous 1 of them he on the class you need to know the yeah you mentioned in which is strength
and magic inside the class and noting the than during its irrational as you know this institution of the strength and magic they was the construction their instantiation via wireless it it needs to be processed and it's not the
presence of the if if it is not it doesn't work like a descriptor sorry so it is not the concept of you it doesn't work and so the massive Gulf have become as having
gay or say and being a descriptor only this is a secured that way and we that this 6 class at so also see here that in a moment of instantiation and doing so that this thing equal in strength and also this
very same moment I'm asking you to convey the descriptive called think you
might think that last questions but in and in
many lands that you're amounts which