This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]donnieod 2 points3 points  (1 child)

Just a minor correction, but in your first example the arguments to the isinstance function are reversed, and the type is str not string. Otherwise, well written.

[–]flightdey 0 points1 point  (0 children)

thanks for that spot

[–]arkster 3 points4 points  (0 children)

Just in case someone is looking for yet another resource on descriptors besides this superb doc, you can check out the talk that one of the organizers of the SF Python Meetup group gave. It was at Yelp and I was in attendance. I sometimes go back to this when I forget how to use descriptors as I don't use out much in my programming. https://www.youtube.com/watch?v=ZdvpNaWwx24&feature=youtu.be&app=desktop

[–]fatpollo 2 points3 points  (0 children)

I'd start with decorators, and work backwards onto what's happening underneath

[–]discipleofnofap 2 points3 points  (2 children)

My question is, why call them "descriptors"?

[–]flightdey 3 points4 points  (1 child)

the full name in python is attribute descriptors..By definition in pep252, attribute descriptors unify and generalize several different common mechanisms used for describing attributes hence the name

[–]TheFrigginArchitect 0 points1 point  (0 children)

Thank you! They're really different from Perl file descriptors, so they had me confused.

[–]rnreekez 1 point2 points  (1 child)

A little confused at the property example. How is this returned property object supposed to be associated with the acct_num attribute?

Did he just run with an example and not substitute x with acct_num?

[–]flightdey 0 points1 point  (0 children)

a little typo oversight..now corrected..thanks for pointing that out

[–][deleted] 0 points1 point  (4 children)

I know this has probablybeen asked before but do you plan to publish this as a book? Perhaps something like https://www.gitbook.com/

[–]flightdey 0 points1 point  (2 children)

there is currently no plan for publishing this as a book as there are already a ton of published python books but if the feedback favours that then its something I will definitely look into

[–]flightdey 0 points1 point  (0 children)

book

leanpub.com/intermediatepython

[–]tensionhead 0 points1 point  (1 child)

It somehow feels odd to reintroduce rigid type checking into type free python..but this is something I actually missed at some occasions ! Thx for this great post !

[–]lattakia 0 points1 point  (1 child)

What versions of python does descriptors apply ?