[Tutor] beginning to code

Bill BILL_NOSPAM at whoknows.net
Thu Sep 21 18:43:48 EDT 2017


Stefan Ram wrote:
> Just as Python's »string[::-1]« appears "obfuscated"
>    to readers who don't know Python.

I understand string[::-1] after only studying python for a day or two 
(I've only been studying it for 2 weeks at this point).  A student could 
study C++ for a semester or more and not encounter templates until they 
studied data structures.  So in short, I don't believe that the example 
you chose from Python and the one you chose from C++, were at similar 
levels (not even close).

>
>    It was the answer to the question "How can I express the
>    class I'm in in, when I can't write that classes name
>    literally? So, »S« is »example«.
>
>    It works like this: The type of »&f« is »void ( example::*
>    )()«. So, the function-declaration template »T« infers »C«
>    to be »example«, and the type of »T( &f )« is »example«,
>    which then is transferred to the name »S« using typedef.
>
>    This is obvious for C++ programmers, but it takes a lot
>    of time to become a C++ programmer, maybe more than it
>    takes to become a Python programmer.
>




More information about the Python-list mailing list