Posted in Python

Python Post #6 Python One Liners ᕕ( ᐛ )ᕗ ✎✐✎✐✎✐✎✐✎✐✎✐


Performing one-liners directly on the Command Prompt can be accomplished by using Python’s -cmd flag (-c for short), and typically requires the import of one or more modules. 


How to Write One-liners in Python?

One-Liners are hard to comprehend, especially in Python. Given a sample one can come up with their own One Liner. Though they are not recommended while actual coding… It is pretty fun to condense normal code to utter gibberish and make the system.. Well I don’t know…Hang maybe

So assuming that you are familiar with the basics of Python and the changes made from Python 2 and Python 3… The only stable versions I am aware of…Let me dive to Pointers on One Liners in Python…

(*•̀ᴗ•́*)و ̑̑

  • So first thing first…As we all know that Python is considered a lazy language…And for a Good Reason too! The blocks of code are distinguished by indentation and not braces,This kinda makes it hard to Create one liners with multiple loops and functions…So let’s stick with a Single never ending for loop 

while 1:…*Gibberish*…

  • And then we have this concept of Recursive function…A Function call inside a function…A pretty convenient thing considering my goal here…Use lambda functions…Since they are preferable than having an actual function definition inside a infinite loop… 
  • And OFC…How can I forget one of my favorite modules…import random…try and read the documentation of this module …since that was where I got most of these one liners 

random.choice(“set of characters to choose from”)


So here are a few… assuming that by now you have installed either a Python2 or Python3 .. Copy these and paste in the Command Prompt 


python -c “while 1:import random;print random.choice(‘|-_+=\\/’), ”

python -c “while 1: locals().setdefault(‘i’,60); import time,random; print(‘ ‘*i+”+’ ‘*(80-i-1)+’|’);time.sleep(.2); i+=random.randint(-2,2)”

python -c “while 1:import random;print “random.randint(0,100)”, map(lambda n:(lambda f:f(f,n))(lambda f,n:{True:lambda:1, False:lambda:n*f(f,n-1)}[n<=1]()),range(0,20))"

python -c “import random,time; p=lambda:random.choice(‘♥♦♣♠’);[print ‘[{}|{}|{}]’.format(p(),p(),p(),t=time.sleep(.2)), for i in range (20)]”


python -c “while 1: locals().setdefault(‘i’,60); import time,random; print(‘ ‘*i+”+’ ‘*(80-i-1)+’|’); time.sleep(.1); i+=random.randint(-2,2)”

python -c “import random,time; p=lambda:random.choice(‘♥♦♣♠’);[print(‘[{}|{}|{}]’ .format(p(),p(),p(),t=time.sleep(.1)),end= ‘\r’) for i in range (20)]”

python -c “import random;n=random.randint(1,99); [(lambda a:print(‘Y’ if a==n else ‘H’ if a>n else ‘L’))(int(input())) for i in range(6)]”

python -c “while 1:import random; print(random.choice(‘|-_+=\\/’), end=”)”


Posted in Off Topic

Temporary Conclusion Maybe … (◕‿◕✿)


You’ve tried to comprehend this blog and might have decided to continue or start with programming. Maybe it will be a career for you, or maybe it will be a hobby… You’ll need some pointers to make sure you continue on the right track and get the most enjoyment out of your newly chosen activity…


I’ve been programming for a considerable amount of time… pretty long actually!! So long that there was this period of time that I considered it incredibly boring to me… At the time that I wrote a draft for this post, I knew about 12 programming languages and could learn new ones in about a day to a week depending on how quirky they were…

( . _ . ) ( l: ) ( .-. ) ( :l ) ( . _ . )

Eventually though things just became grey and couldn’t hold my interest anymore… This doesn’t mean I think programming is boring, or that you will think it’s boring, only that I had found it uninteresting …


What I discovered after I managed to process this train of thought is that … It’s not the languages that matter but what you do with them….


People who can code in the world of technology companies are as common as finding ants in an ant hill(I know its a weird analogy, well deal with it…)  and get no respect.On the other hand, people who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines.

~(˘▾˘~)(ノ◕ヮ◕)ノ*:・゚✧ ✧゚・: *ヽ(◕ヮ◕ヽ)(~˘▾˘)~
Finally, I’ll say that learning to create software changes you and makes you different. You may find that people treat you harshly because you can create software, maybe using words like “Nerd.” Maybe you’ll find that because you can dissect their logic that they hate arguing with you. You may even find that simply knowing how a computer works makes you annoying and weird to them.

To this I have just one piece of advice: They can just Drop Dead…!!

(╯°□°)╯︵( .o.)

The world needs more weird people who know how things work and who love to figuring it all out! When they treat you like this, just remember that this is your journey, not theirs. Being different is not a crime, and people who tell you as such are just jealous that you’ve picked up a skill they never even in their wildest dreams could acquire.


You can code. 

They cannot.
And that, is pretty damn cool.!!!

Posted in Python

Python Post #5 Python Mini Project Source Codes (づ。◕‿‿◕。)づ

ԅ[ •́ ﹏├┬┴┬┴


Well if you were like me and Python is your first language then you would most probably be able relate to this …

You are trying to learn programming and many people suggested to learn Python as the first language. You take their advice, you download Python and get all set up. Maybe you take a tutorial or two in order to learn some basic syntax… Now you are sitting in front of your computer and you are wondering what to do next. I suggest you start on some projects and get programming to learn more Python. I have compiled a few available projects myself… and will include the source code in this post.

Refrain from looking at the source code, even when your stuck. If you get to the point where you have nowhere else to look, take a tiny peak but then go straight back and start doing your work again. If your programs works and our source code doesn’t match, pat yourself on the back! Then look at my source code versus yours and see how you can shorten and make your programs better or if you feel that you came up with a better solution let me know of it.

My way of doing it, is probably not the best way,so go on and explore and  experiment!

✧٩(•́⌄•́๑)و ✧


Posted in Rant Alert

Rant Alert #1 ヽ(´∇´)ノ(∇´ノ)ヽ( )ノ(ヽ´∇)ヽ(´∇`)ノ

̿̿ ̿̿ ̿̿ ̿’̿’\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿

Is copying and pasting code dangerous? Should control-c and control-v be treated not as essential programming keyboard shortcuts, but registered weapons?

Some times I end up pondering over this question,Am I really a developer or just a good googler. Thinking over it I am not so sure of the answer anymore. 


This is a really profound question that deserved an answer. I’ve felt the same way sometimes when playing a video game. It’ll get hard as I progress through the levels, but not crushingly hard. Each level I squeak by with the online cheat codes, I have found myself asking, “Did I deserve to pass that level? I’m not sure I could do it again.”

If you also felt or are feeling the same way ,well then I would like to share the following! Something that I was told when I discussed this with someone I look up to …

(⁄ ⁄^⁄ᗨ⁄^⁄ ⁄)

  1. First, remember you are not alone. I think that we grow when we are outside our comfort zone. If it’s not breaking you down, it’s not building you up.
  2. Second, anything that you want to be good at is worth practicing. Do Code Katas. Do a Project Euler problem every few weeks, if not weekly.
  3. Third, try programming for a day without Googling. Then two days, maybe a week. See how it feels. Remember that there was a time we programmed without copying our work.
  4. Fourth, think about the problem, deeply. Read about algorithms, read Programming Pearls, read about Design Patterns. Rather than copying code from Stack Overflow, copy patterns from the greats.
  5. Fifth, get involved. Go to Nerd Dinners, meet with others who feel the same way you do about technology. Stretch.You have no idea on the amount of info you get this way.


Posted in Python

Python Post #4 Python OpenCV (≖͞_≖̥)



So then, as mentioned earlier there are various possibilities in Python and it is just a library away! In this post, I will let you know how to install a randomly selected library and then go about on the basis of its functionalities … Maybe 
*Fingers Crossed*
Okay so the winner of today’s lot picking is 

OpenCV… Well, it could be worse (in the sense, not much to discuss on !)…

Okay , so before going about OpenCV basics along with its installation, let me give a basic overview on OpenCV …

OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
Python is a general purpose programming language started by Guido van Rossum that became very popular very quickly, mainly because of its simplicity and code readability. It enables the programmer to express ideas in fewer lines of code without reducing readability.
Compared to languages like C/C++, Python is slower. That said, Python can be easily extended with C/C++, which allows us to write computationally intensive code in C/C++ and create Python wrappers that can be used as Python modules. This gives us two advantages: first, the code is as fast as the original C/C++ code (since it is the actual C++ code working in the background) and second, it easier to code in Python than C/C++. OpenCV-Python is a Python wrapper for the original OpenCV C++ implementation.
OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations . All the OpenCV array structures are converted to and from Numpy arrays. This also makes it easier to integrate with other libraries that use Numpy such as SciPy .
To Install:
Depending on your version of Python Download and the type of computer you use these are the corresponding downloads, Hopefully, they work properly…

(ノ^◡^)ノ︵ ʌɔuǝdo
PS. If you are as confused as I was when I first went around figuring out how to go about fixing the numerous bugs that just rose exponentially when I tried to rectify some others, well  trust me when I say this , Its easier to uninstall everything and start it from scratch. This would include uninstalling all Python related .msi or .exe file installations that you can find in your control panel, and installing the fool proof module list which I will provide shortly,and change the path settings(refer the previous Blogpost please.)

If there is anyone with other OS,I am sorry for not being considerate , If you tell me about it,maybe , I might help you.And if any of the links are nonfunctional please let me know.

If everything is functional, it will import cv2 module, otherwise, an error message will be shown.


Iff the above setup is done you can proceed further and be sure to understand what I have shared.


Posted in Python

Python Post #3 Python PyGame Ψ( ●`▽´● )Ψ

\\\ ٩(๑❛ワ❛๑)و ////

So far, all of our codes have only used text. The text is displayed on the screen as output and the user types in text from the keyboard as input. This is simple, and an easy way to learn to program. But from this post onward, plain text output won’t be the case. This post might teach you how to use the Pygame library to make games with graphics, animation, and sound.
In these posts, we’ll find the source code for simple programs that are not games but demonstrate the Pygame concepts I have tried to convey. Links to my drive will present the source code for a complete Pygame game using all the concepts you should have learned by then.
I should have mentioned this earlier…A software library is a code that is not meant to be run by itself but included in other programs to add new features. By using a library a programmer doesn’t have to write the entire program, but can make use of the work that another programmer has done before them.

Pygame is a software library that has modules for graphics, sound, and other features that games commonly use.

Okay so that being said , I am just gonna dive into the concepts,cause I am like super drained ,so yeah…,I hope you don’t feel like this is a compilation of some leaked out notes of a Mad Scientist.


Installing Pygame

Pygame does not come with Python. But like Python, Pygame is available for free. You will have to download and install Pygame, which is as easy as downloading and installing the Python interpreter,which you might have already done, assuming you have read the previous posts with sincerity and devotion .
I am gonna assume that you have the Windows operating system, but Pygame works the same for every operating system. You need to download the Pygame installer for your operating system and the version of Python you have installed (2.7). For Windows, download the msi file. (This is Pygame for Python 2.7 on Windows. If you installed a different version of Python (such as 2.5 or 2.4) download the .msi file for your version of Python.)

ps: I recommend downloading 2.7 pythons since it is the most (as far as I know) stable and has stable and legal versions of the libraries I had specified earlier.In case you have already downloaded a higher version and have gotten an error,I might not be able to help you.But if you do feel like negating my statement do comment your wishes or mail me or just ignore the following .
The current version of Pygame is 1.9.2. But if you see a newer version on the website, download and install the newer Pygame. For Mac OS X and Linux, follow the directions on the download page for installation instructions.
On Windows, double-click on the downloaded file to install Pygame. To check that Pygame is install correctly, type the following into the IDLE:
>>> import pygame
If nothing appears after you hit the Enter key, then you know Pygame has successfully been installed. 
If the error ImportError: No module named pygame appears, then try to install Pygame again (and make sure you typed import pygame correctly).

Check your paths right click on Computer(icon) got to Properties and click on Advanced system settings.Go to environmental variables.Update the following paths.
#Case sensitive #

Variable    Value
Path   ;C:\Python27(remove the previous version of python and  do this i.e.. change 34 to 27)
PYTHONPATH    C:\Python27

*Hope this helps you… let me know if it is otherwise*

Okay, so, this time, I will put a link here to my drive that has five small programs that demonstrate how to use the different features that Pygame provides. In one of them, you will use these features for a complete game written in Python with Pygame.
A video tutorial of how to install Pygame is available .

Go to Folder in Drive!

ԅ(≖‿≖ ;ԅ)
Posted in Python

Python Post #2 Python Additional Features (☆^_^☆)

┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴

I hope that you can understand the flow of the above function. If not please go to the previous post and read through the .py file that I have shared …
Okay then,just to recap ,I have tried to make sure to put as much python programming concepts in one executable file.I hope it was useful for whatever you were doing!
The file, if it had been studied with as much effort as was applied in the making,then you should be familiar with

  • Python variables
  • Conditionals
  • Class
  • File handling
  • Exception handling

(PS:I randomly update since I am not very comfortable with my incoherent .py files )

-(๑☆‿ ☆#)ᕗ

Now that we are familiar with the basic syntax of Python,we can now dive into a bunch of special libraries that have been a part of my toolbelt and should be a part of yours as well. So here they are:
1. Requests. The most famous http library written by kenneth reitz. It’s a must have for every python developer.
2. Scrapy. If you are involved in webscraping then this is a must have library for you. After using this library you won’t use any other.
3. wxPython. A GUI toolkit for python. I have primarily used it in place of tkinter. You will really love it.
4. OpenCV. OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It’s an image processing library for machines,like the eyes of an automated machine.
5. SQLAlchemy. A database library. Many love it and many hate it. The choice is yours.
6. BeautifulSoup. I know it’s slow but this xml and html parsing library is very useful for beginners.
7. Twisted. The most important tool for any network application developer. It has a very beautiful api and is used by a lot of famous python developers.
8. NumPy. How can we leave this very important library ? It provides some advance math functionalities to python.
9. SciPy. When we talk about NumPy then we have to talk about scipy. It is a library of algorithms and mathematical tools for python and has caused many scientists to switch from ruby to python.
10. matplotlib. A numerical plotting library. It is very useful for any data scientist or any data analyzer.
11. Pygame. Which developer does not like to play games and develop them ? This library will help you achieve your goal of 2d game development.
12. Scapy. A packet sniffer and analyzer for python made in python.
13. nltk. Natural Language Toolkit – I realize most people won’t be using this one, but it’s generic enough. It is a very useful library if you want to manipulate strings. But it’s capacity is beyond that. Do check it out.
14. nose. A testing framework for python. It is used by millions of python developers. It is a must have if you do test driven development.
15. SymPy. SymPy can do algebraic evaluation, differentiation, expansion, complex numbers, etc. It is contained in a pure Python distribution.
16. IPython. I just can’t stress enough how useful this tool is. It is a python prompt on steroids. It has completion, history, shell capabilities, and a lot more. Make sure that you take a look at it.