[Twisted-Python] Request for help with Twisted bindings in M2Crypto

Daniel Sank sank.daniel at gmail.com
Tue Jul 26 01:26:44 MDT 2016


Glyph,

>> 2. I have no idea what a "task" is. I realize this is python and yay
duck-typing but not
>> specifying the expected behavior of an argument seems like a big
omission.

> Did you miss the part where it said "type: 0-argument callable" in the
documentation?

Yes :(

I can only guess that I missed it because the type is defined near the end
of the description line, whereas I'm used to seeing

def foo(x, y):
    """Do something.

    Args:
        x (int): blah blah
        y (banana): yadda yadda
    """

FWIW, now that I look at the code, the type specification is way more
visually apparent there than it is in the generated HTML.

tl,dr: I take it all back and thanks for pointing out the obvious.

> An interface is a very simple concept - an abstract description of what
an object is expected
> to provide if you're going to do something useful with it.

Indeed, a general understanding of interfaces is not the problem.

> In my view, interface definition is the primary activity of software
development

Agreed 100%.

> The fact that so many people seem to find either the basic idea of an
abstract type, or the concrete
> instantiation of that idea in the Zope Interface library, so horribly
confusing, makes me despair of
> ever communicating the actually *hard* stuff that Twisted gets up to in
its internals.

> I would very much like to understand *what* is so confusing about
"interfaces".  Is it, as Cory posited,
> just that the documentation is not properly linked?  Or is it that the
average Python developer needs
> a gentle introduction to the entire idea of abstract rather than concrete
types?  If they do - is it really
> Twisted's responsibility to provide it to them?  Should Zope Interface
just have a snazzier website?

Some years ago when I tried to understand Twisted's use of interfaces via
Twisted's own documentation (which included something about hair dryers and
voltage standards) I was puzzled by the fact that the examples didn't
really show me how to solve a useful problem (or I was too stupid to
understand that the examples did in fact do that) *despite the fact that I
knew what an interface was in general terms*. It was a case of
understanding the intent but none of the examples. A brief look at the zope
documentation just now makes me think the situation has improved.

The other problem was that interfaces were sprinkled somewhat haphazardly
around the code I was trying to understand (perspective broker) and it was
just plain hard to keep navigating around the code files to understand who
was implementing what interfaces. This could have been my own fault for not
having a editor set up. I don't know.

> Should Zope Interface just have a snazzier website?

I think the real issue is the need for compelling and simple examples.

- Daniel


P.S. Everything below here is completely off topic of this thread and I
probably shouldn't have written it.

> Given that Twisted is often translating network protocol data into Python
method calls, one needs both
> a working domain knowledge of the protocol involved and a robust
understanding of Python
> metaprogramming constructs.  It sounds here like where you fell down was
mostly in the "Python
> metaprogramming" area, where PB is especially intense.

> But it's also not really specific to Twisted either.  This is another
case where I'm not sure what to do
> except to refer people to the language reference and tell them to work
through it slowly.

> Unfortunately, framework code just looks like that

I spent a considerable amount of time reading the PB code, reproducing
parts of it myself, and talking to people on IRC and the mailing list to
understand a particularly weird issue in PB. See here for the bug I was
trying to fix (note in particular my first comment to the one existing
answer):

http://stackoverflow.com/questions/23421423/why-are-dummy-objects-created-in-twisteds-pb-system

I distinctly recall that near the end of my efforts you (Glyph) or someone
else more or less told me that the PB code was old, horrible, and that the
issues I was trying to understand were probably incidental complexity due
to poor design etc. You guys were joking around on IRC about how ridiculous
all the dummy object construction is. So, I think this *particular*
incident was
less due a lack of understanding of python metaprogramming and more due to
PB having some bizarre warts.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20160726/6fd03167/attachment-0002.html>


More information about the Twisted-Python mailing list