Featured post
Python readability through descriptive naming -
i have been using python year now, coming java background. found python quite easy learn because of focus on readability , simple design. thing don't understand python why language focuses heavily on readability, uses non-descriptive names modules, functions, constants etc.. 1 thing java descriptive class/attribute/method names (i objective-c more reason). seems python programmers in general seem have taken c type approach naming use short names possible everything. know wants little typing possible lot of programmers spend majority of time reading code rather writing find choice between short non-descriptive names , long descriptive names, easy 1 make. (i longer descriptive names xd)
a few examples, looking @ modules in standard library,
- sched — event scheduler, have been eventscheduler?
- asyncore — asynchronous socket handler, asynchronoussockethandler?
- imghdr — determine type of image, determineimagetype?
- pickle?
i know isn't huge issue find myself more not having meaning of new (or forgotten) module come across when in other languages objective-c or java can meaning straight away modules/functions/attributes definition. on note, people tend write code similar way standard library written can sure if standard library uses non-descriptive names average developer use more non-descriptive names.
i wondering know why is?
i guess there's balance struck between being descriptive , concise, , python's scripting background makes more concise java (because hobbyists lazy typing ;-) ). @ risk of sounding fanboy, python tries walk line between descriptive-but-long (java), , short-but-tricky (*cough*perl).
things used , understood can short, have str type rather asciistring or unicodestring (python2/3 respectively). more specialised functions, urllib.urlencode or random.normalvariate longer names.
the core language kept simple (e.g. there no character type, one-character strings). idea there's "one right way it", along duck typing, mean there's no need names do_something_with_type_a. and, while it's excuse, there clear documentation that's not obvious.
as itertools? module name doesn't matter, it's grouping of functions. of functions clearer (chain, cycle, repeat), less (islice, izip). suppose assume concepts "zipping" , "slicing" straightforward once you're familiar python.
sched/asyncore/imghdr: admittedly brief , undescriptive, i've never seen of them used. date days of 8-character filenames, , updating them has never been priority.
pickle: quirky, have once, it's obvious. couldn't call "serializer", because it's specific serialisation, not generic framework.
- Get link
- X
- Other Apps
Comments
Post a Comment