14 Great Quotes About Python Programming Language

A collection of quotes about Python programming language!

The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death.

- Guido van Rossum


My favorite language for maintainability is Python. It has simple, clean syntax, object encapsulation, good library support, and optional named parameters.

- Bram Cohen


As it seems to me, in Perl you have to be an expert to correctly make a nested data structure like, say, a list of hashes of instances. In Python, you have to be an idiot not to be able to do it, because you just write it down.

- Peter Norvig


In many ways, it's a dull language, borrowing solid old concepts from many other languages & styles: boring syntax, unsurprising semantics, few automatic coercions, etc etc. But that's one of the things I like about Python.

- Tim Peters


Everyone knows that any scripting language shootout that doesn't show Python as the best language is faulty by design.

- Max M


Every sufficiently advanced LISP application will eventually reimplement Python.

- Hodgson's Law


The  canonical, "Python is a great first language", elicited, "Python is a great last language!"

- Noah Spurrier


Python is the "most powerful language you can still read".

- Paul Dubois


"Python tricks" is a tough one, cuz the language is so clean. E.g., C makes an art of confusing pointers with arrays and strings, which leads to lotsa neat pointer tricks; APL mistakes everything for an array, leading to neat one-liners; and Perl confuses everything period, making each line a joyous adventure ;-)

 - Tim Peters


Python is a truly wonderful language. When somebody comes up with a good idea it takes about 1 minute and five lines to program something that almost does what you want. Then it takes only an hour to extend the script to 300 lines, after which it still does almost what you want.

- Jack Jansen


Python is an experiment in how much freedom programmers need. Too much freedom and nobody can read another's code; too little and expressiveness is endangered.

- Guido van Rossum


I suggested holding a "Python Object Oriented Programming Seminar", but the acronym was unpopular.

- Joseph Strout


PYTHON = (P)rogrammers (Y)earning (T)o (H)omestead (O)ur (N)oosphere.

- Sean McGrath


Abstraction is one of those notions that Python tosses out the window, yet expresses very well.

- Gordon McMillan,


Surprisingly enough, Python has taught me more about Lisp than Lisp ever did ;-).

- Glyph Lefkowitz


Sources:
Starship Python
Scott's space

Importing & Exporting JSON Data To mongoDB!

mongoimport imports JSON, CSV or TSV data to mongoDB. If You are importing JSON data from a file to db, the file should have only one document per line and there shouldn't be any delimiters at the end of file. If You have a file sample.json like this
{"num":1,"status":"ok"}
{"num":2,"status":"ok"}
{"num":3,"status":"ok"}
{"num":4,"status":"ok"}
You can directly import it into db using
mongoimport --db <db> --collections <collection> --file sample.json
This is straight forward and works well. But some third party services provide data in the form of JSON array like this
[
{"num":1,"status":"ok"},
{"num":2,"status":"ok"},
{"num":3,"status":"ok"},
{"num":4,"status":"ok"},
]
If You try to import it, it throws FailedToParse error. For this, You need to pass additional param jsonArray.
mongoimport --db <db> --collections <collection> --file sample.json --jsonArray
If You want to export Your collection as a json dump, You can use mongoexport command
mongoexport --db <db> --collections <collection> --out sample.json
This exports data into JSON format with one document in a row.

If You pass jsonArray as an optional parameter, it will export the collection as a jsonArray
mongoexport --db <db> --collections <collection> --out sample.json --jsonArray
If You are lazy to type, You can use
mongoexport --d <db> --c <collection> --o sample.json --jsonArray

References:: mongoDB docs - mongoimport, mongoexport

7 Easter Eggs Hiding In Your Emacs!

I just came across this xkcd comic about Real programmers.


I started emacs invoked butterfly command and that's my first easter egg. Later I digged around and found several games & a few other easter eggs. Here are a few of them.
M-x butterfly: Flip the desired bit on the drive platter.

M-x doctor: Switch to *doctor* buffer and start giving psychotherapy.

M-x zone: zone out completely.

M-x life: runs Conway's "Life" cellular automaton.

M-x studlify-buffer: stUdlIfY-RegioN stUdlIfY-CaSeS thE region.

M-x landmark: Start or resume an Landmark game.

M-x animate-birthday-present: Return a birthday present.

M-x yow: Return or display a random Zippy quotation.
Notes:
1. yow was removed in Emacs 22 due to copyright problems. But you can get it manually.

   Download quotes file to your .emacs.d directory
   M-! wget bit.ly/emacs-yow -O ~/.emacs.d/yow.txt.gz

   Specify the path of file in Your init file
   (setq yow-file "~/.emacs.d/yow.txt.gz")

2. To know about each of the easter eggs, you can use help
   C-h f RET <function> RET


More articles about Emacs

BangPypers - Python Dev Sprint

Here is the definition of sprint from Wikipedia:



On 3rd Saturday of every month there will be a meetup for Python developers in Bangalore(BangPypers) to have talks and workshops. This month instead of talks/workshops, a dev sprint was held. The basic idea was to encourage Python developers to contribute to any open source projects or work on their open source projects.

I was working on Nidaba, a project to extract information from StackOverflow dumps. I went to the meetup and gave a brief description about it. Several people were interested to work. I helped them a bit on getting started and the issues to solve. 

By the end of event, I got one pull request which fixed a typo in setup file. Few people helped in adding couple of utility functions for the project. A couple of them were interested to continue working on with it in the coming weekends. In the end PSSI sponsored T-shirt :) 

Here are a few snapshots of event.




ది పైథాన్ పారడాక్స్ (The Python Paradox)

ఆగస్టు 2004 లో ఈ వ్యాసం పాల్ గ్రాహం  ఆంగ్లం లో వ్రాసారు. ఇది తెలుగు అనువాదం.

"మీరు ఒక Java ప్రాజెక్ట్  కన్నా Python ప్రాజెక్ట్ మీద పని చేయడానికి తెలివైన  ప్రోగ్రామర్లను  పొందవచ్చు" అని నేను ఇటీవల చర్చ లో అన్న మాటలకు ప్రజలు చాలా  అప్సెట్ అయ్యారు.

దానికి అర్థం  Java  ప్రోగ్రామర్లు మొద్దు అని కాదు. Python ప్రోగ్రామర్లు స్మార్ట్ గా  ఉంటారు అని. ఒక కొత్త ప్రోగ్రామింగ్ భాష నేర్చుకోవడం కష్టమైన పని. ప్రజలు ఒక ఉద్యోగం పొందటానికి Python నేర్చుకోరు. వారు పైథాన్ ఎందుకు నేర్చుకుంటారంటే వారికి స్వచ్ఛంగా ప్రోగ్రామ్మింగ్ అంటే  ఇష్టం మరియు వారికి ఇప్పటికే తెలిసిన భాషలు సంతృప్తి ఇవ్వకపోవడం వలన. అందువల్లే  కంపెనీలు Python ప్రోగ్రామర్లను నియమించుకుంటాయి. ఈ concept కి ఒక మంచి పేరు ఏది తట్టలేదు, అందుకే నేను దీన్నిPython పారడాక్స్ అని పిలుస్తాను.  ఒక సంస్థ software వ్రాయడానికి తులనాత్మకంగా esoteric భాషను  ఎంచుకుంటే, వారు మంచి ప్రోగ్రామర్లను  నియమించుకుంటారు. ఎందుకంటే అలాంటి బాష నేర్చుకోవాలని చాలా కొద్ది మందే కుతూహలంగా ఉంటారు. ప్రోగ్రామర్లకి ఈ పారడాక్స్ మరింత వర్తిస్తుంది. మీరు ఒక మంచి ఉద్యోగం పొందడానికి నేర్చుకునే భాష, ప్రజలు కేవలం ఉద్యోగం పొందడానికి  మాత్రమే నేర్చుకోలేదు.

కేవలం కొన్ని తెలివైన కంపెనీలు మాత్రమె ఇప్పటివరకు ఈ విషయాన్ని గ్రహించాయి. కానీ ఇక్కడ ఇంకో రకమైన ఎంపిక జరగుతోంది. సరిగ్గా  అటువంటి కంపెనీలలోనే  ప్రోగ్రామర్లు పని చేయాలనీ కోరుకుంటున్నారు. ఉదాహరణకు, గూగుల్ Java ప్రోగ్రామింగ్ ఉద్యోగాలు ప్రకటన ఇచ్చినప్పుడు, వారు Python అనుభవం తప్పనిసరిగా అడుగుతున్నారు.

అన్ని భాషలు విస్తృతంగా ఉపయోగించిన  నా  స్నేహితుడు, దాదాపు అన్ని ప్రాజెక్ట్ ల  కొరకు Python ఉపయోగిస్తాడు. అందుకు ప్రధాన కారణం source code చదవటానికి చాల అనువుగా ఉండటం. ఆ ఒక్క కారణానికి మరొక భాషను ఎంచుకోవడం ఒక అల్పమైన కారణం అని మీరు అనుకోవచ్చు. కాని అది అనుకున్నంత అల్పమైన కారణం కాదు. ఎందుకంటే source code ను రాయడం కంటే చదవడం లో ఎక్కువ సమయం వెచ్చిస్తారు. ఒక శిల్పి మట్టి ముద్దల్ని పేర్చుకు పోయినట్లు మీరు కూడా source code blobs ని పేర్చుకుంటూపోతారు. అస్తవ్యస్తంగా పేర్చిన మట్టి ముద్దలు శిల్పిని  చికాకుపరిచినట్లే, చదవటానికి అనువుగా లేని ఒక భాష, ప్రోగ్రామర్ ని చికాకు పరుస్తుంది.

Source code అవలక్షణం ప్రస్తావన వద్ద, ప్రజలు Perl ను గుర్తు చేసుకుంటారు. కానీ నేను మాట్లాడేది Perl యొక్క ఉపరిభాగ సంబంధిత  అందం గురించి కాదు. నిజమైన  అవలక్షణం కఠినంగ కనిపించే వాక్యనిర్మాణం కాదు, కానీ తప్పు patterns ని అనుసరించి ప్రోగ్రమ్స్  వ్రాయటం. Perl ఒక కార్టూన్ పాత్ర తిట్లు వల్లే  ఉండవచ్చు, కానీ కొన్ని చోట్ల అది Python ను అధిగమించిన సందర్భాలు ఉన్నాయి.

ఇప్పటివరకు, ఏమైనప్పటికీ. రెండు భాషలు కదిలే లక్ష్యాలు .  కానీ ఈ రెండు భాషలు కుడా Ruby, (Icon, Joy, J , Lisp & Small Talk) మాదిరి,  నిజంగా ప్రోగ్రామింగ్ పట్టించుకుని,  ఉపయోగించే   ప్రజలచే రూపొందించబడినవి అన్న సత్యాన్ని గుర్తిస్తున్నాయి.

Generate Sphinx Friendly Docstrings For Python Functions In Emacs!

Today, I went to Django REST Framework Workshop. After the workshop is completed,  and we were discussing about Emacs, Krace showed this cool plugin sphinx-doc, it inserts docstring skeleton for Python functions/methods as per the requirement of the Sphinx documentation generator.


Installation:

To install it from MELPA, run "M-x package-list-packages", search for "sphinx-doc" , mark it with i and press x to install.

Configuration:

Add these lines to Your emacs config to enable sphinx-doc-mode.
(add-hook 'python-mode-hook (lambda ()
                  (require 'sphinx-doc)
                  (sphinx-doc-mode t)))
If you document your code(infact you should), this plugin saves quite a few strokes! 

Django Tips & Tricks #2 - Check If App Is Production Ready

Before deploying Your Django app, You need to make sure security, logging and other issues are taken care. Django provides a simple deployment checklist which helps a lot. In development version Django provides --deploy option, which does some security checks. You can run it with
python manage.py check --deploy --settings=production_settings
I have just created a new project and Django identified 6 security issues in it.
→ python manage.py check --deploy                               
System check identified some issues:
WARNINGS:
?: (security.W001) You do not have 'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE_CLASSES so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, and SECURE_SSL_REDIRECT settings will have no effect.?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE_CLASSES, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token.
?: (security.W017) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE_CLASSES, but you have not set CSRF_COOKIE_HTTPONLY to True. Using an HttpOnly CSRF cookie makes it more difficult for cross-site scripting attacks to steal the CSRF token.
?: (security.W018) You should not have DEBUG set to True in deployment.
?: (security.W019) You have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE_CLASSES, but X_FRAME_OPTIONS is not set to 'DENY'. The default is 'SAMEORIGIN', but unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.

System check identified 6 issues (0 silenced).

However this doesn't identify issues like absence of 404.html, 500.html templates, email setup, admin emails,  presence of print, pdb statements. There is a Django package called django-production-ready which checks for these issues.

To the new project just created, I have added a new file, which has a print & pdb statements. I have installed django-production ready, added prodready  to installed apps and ran is_it_ready management command which produced a neat log of all issues.
→ python manage.py is_it_ready
--------------------
Production ready: No
--------------------
Possible errors:
    * Enter valid email address in ADMINS section
    * Enter valid email address in MANAGERS section
    * Template 404.html does not exist
    * Template 500.html does not exist
    * Setup E-mail host
    * Set a valid email for SERVER_EMAIL
    * Set a valid email for DEFAULT_FROM_EMAIL
    * You have one or more ipdb import  statements
    * You have one or more print statements
This comes in handy to quickly make sure a lot of issues are taken care and the app is ready for deployment!

Search, Play & Download YouTube Videos From Command Line

If You are using Linux,  You might be familiar with youtube-dl, a small command-line program to download videos from YouTube and a few more sites. But You need to go to YouTube, grab the url and then give it to youtube-dl to download it.

mps-youtube, a terminal based YouTube player makes it possible to browse, play & download videos right from the terminal.

You can install it using pip
pip install mps-youtube
and start using in with
mpsyt
It is better to set an alias for this
alias yt="mpsyt"
By default it is configured to search music category and stream audio only. You can change it
set music_search false
set show_video true
To get help, just press h.
To search for videos about Katy Perry, type /katy perry.
To stream a song, enter the number of the song and enter.
To download a video, type d <number> and it shows all the available formats, then you can select any video of your choice and download it.

Here are a few screenshots of it.




Mirror A Website (Or Part Of Website) In Split Second!

Occasionally it is necessary for developers to mirror a website. It is super easy to do this in no time.

1. Getting A Copy Of Original Site:

You can use the powerful tool wget for this. If you are familiar with *nix, you might have used it to fetch a single page or files to your system. But wget is capable of doing lot more than that. To download an entire site, you can use
wget --recursive --page-requisites --convert-links www.avilpage.com
# if you are lazy to type use
# wget -rpk www.avilpage.com
This downloads all components(sounds, images etc)  of www.avilpage.com and make links in downloaded  HTML/CSS to point to local files.

If you want to mirror only a part of website say 2014 November archives only, then you can pass no-parent argument.
wget --recursive --page-requisites --convert-links --no-parent www.avilpage.com/2014/11/
#wget -rpknp www.avilpage.com/2014/11
This downloads all the urls that follow 2014/11.

In addition to that there are a hell lot of options you can pass like number of retries, time to wait, lot of HTTP options, FTP options and so on.

2. Serving The Mirror Website:

If you are familiar with Python, you might have heard of http.server. With a single command it starts running a basic web server. If you run the following command, 
python -m http.server 8000  #Python 3
or
python -m SimpleHTTPServer 8000 #Python 2
it starts serving files on port 8000. If you are on LAN, all others can access this mirrored website from their browser by specifying the IP & PORT. 

However this is just a basic server and not suitable for deployment. For that you can use Apache or Nginx to serve website.

As wget fetches pages, start server. While wget is downloading the pages, you can browse through the downloaded pages. 

[Telugu] యండమూరి అంతర్ముఖం సినిమా

తెలుగు పుస్తకాలు, నవలలు చదివేవారు యండమూరి రాసిన  " అంతర్ముఖం " నవల పేరు విని వుంటారు. కాని యండమూరి ఆ పుస్తకాన్ని సినిమా గా తీసినట్లు చాల మందికి తెలియదు. ఈ సినిమా  YouTube లో అప్లోడ్ చేసారు. IMHO, సినిమా క్వాలిటీ,  ఆక్టర్స్ వగైరా వగైరా ఏమి బాగలెవు.