+1 -1 +7
Vote on this proposal

Python idioms

by Atul S Khot (speaking)

Section
Core Python
Technical level
Intermediate

Objective

Every programming language has its idioms... Studying these idioms helps one to write elegant code.

Description

Every language brings its own culture, hacks - and style with it...
And the stuff you absolutely have to know for getting something done...
Idiomatic code is also very elegant...

While learning python, I think this would fill in the need... The coroutines stuff in python is super stuff...
Also the list copy as

def y = x[:]

While comparing with other languages - here is what I mean...

C/C++ have extensive idioms - for example,
while( d++ = s++); is how strcpy is defined in C... (Or "executing around the pointer" idiom in C++
http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Execute-Around_Pointer)

Perl has so many - (The first time I saw Schwartzian transform - my eyes popped out
http://en.wikipedia.org/wiki/Schwartzian_transform ;-)

Java's try/finally - and list -> array conversion
MyClass[] arr = myList.toArray(new MyClass[0]);
- and many others...

Speaker bio

I have been writing code for the last 16 years - in various languages - and know many idioms for them.

Please see more about me at
http://lnkd.in/fNUepH

Comments


  • 1

    [-] Noufal Ibrahim 601 days ago

    This proposal is too vague and the example provided is wrong. Please flesh it out and provide something more concrete.


    • 1

      [-] Atul S Khot 601 days ago

      Not sure why it is vague - every language has idioms - and as example I have given a chosen few samples in languages I code...
      I have also listed one python idiom... The talk would cover python idioms - and possibly compare and contrast these against similar idioms in other popular languages... I don't know which example you mean is wrong - please elaborate...


  • 1

    [-] Noufal Ibrahim 601 days ago

    def y = x[:] is not valid python.

    The point I'm trying to make is that I'm not exactly sure what I'd learn if I attended this session. I can't decide whether to upvote or downvote it. Not enough information.


  • 1

    [-] Atul S Khot 601 days ago

    Hi Noufal,
    I tried it out - you are right - it should have read like

    z = [1,2] t = z[:] t [1, 2]

    My apologies ;-) I think I need to practice more python...

    I am not a Python programmer - but somehow love the language - found it very appealing - started to learn it on my own -

         Having said this - a session on python idioms would do very well indeed...

    --- cheerio atul


  • 1

    [-] Atul S Khot 601 days ago

    Oops I think the formatter ate up the new lines - I mean all the three assignments should be on separate lines...

    --- cheerio atul

Login with Twitter or Google to leave a comment →