my net house

WAHEGURU….! in Python

Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of dotted module names saves the authors of multi-module packages like NumPy or the Python Imaging Library from having to worry about each other’s module names.

Suppose you want to design a collection of modules (a “package”) for the uniform handling of sound files and sound data. There are many different sound file formats (usually recognized by their extension, for example: .wav, .aiff, .au), so you may need to create and maintain a growing collection of modules for the conversion between the various file formats. There are also many different operations you might want to perform on sound data (such as mixing, adding echo, applying an equalizer function, creating an artificial stereo effect), so in addition you will be writing a never-ending stream of modules to perform these operations. Here’s a possible structure for your package (expressed in terms of a hierarchical filesystem):

sound/                          Top-level package               Initialize the sound package
      formats/                  Subpackage for file format conversions
      effects/                  Subpackage for sound effects
      filters/                  Subpackage for filters

When importing the package, Python searches through the directories on sys.path looking for the package subdirectory.

The files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.

Users of the package can import individual modules from the package, for example:

import sound.effects.echo

This loads the submodule sound.effects.echo. It must be referenced with its full name.

sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)

An alternative way of importing the submodule is:

from sound.effects import echo

This also loads the submodule echo, and makes it available without its package prefix, so it can be used as follows:

echo.echofilter(input, output, delay=0.7, atten=4)

Yet another variation is to import the desired function or variable directly:

from sound.effects.echo import echofilter

Again, this loads the submodule echo, but this makes its function echofilter() directly available:

echofilter(input, output, delay=0.7, atten=4)

Note that when using from package import item, the item can be either a submodule (or subpackage) of the package, or some other name defined in the package, like a function, class or variable. The import statement first tests whether the item is defined in the package; if not, it assumes it is a module and attempts to load it. If it fails to find it, an ImportError exception is raised.

Contrarily, when using syntax like import item.subitem.subsubitem, each item except for the last must be a package; the last item can be a module or a package but can’t be a class or function or variable defined in the previous item.

6.4.1. Importing * From a Package

Now what happens when the user writes from sound.effects import *? Ideally, one would hope that this somehow goes out to the filesystem, finds which submodules are present in the package, and imports them all. This could take a long time and importing sub-modules might have unwanted side-effects that should only happen when the sub-module is explicitly imported.

The only solution is for the package author to provide an explicit index of the package. The import statement uses the following convention: if a package’s code defines a list named __all__, it is taken to be the list of module names that should be imported when from package import * is encountered. It is up to the package author to keep this list up-to-date when a new version of the package is released. Package authors may also decide not to support it, if they don’t see a use for importing * from their package. For example, the file sound/effects/ could contain the following code:

__all__ = ["echo", "surround", "reverse"]

This would mean that from sound.effects import * would import the three named submodules of the sound package.

If __all__ is not defined, the statement from sound.effects import * does not import all submodules from the package sound.effects into the current namespace; it only ensures that the package sound.effects has been imported (possibly running any initialization code in and then imports whatever names are defined in the package. This includes any names defined (and submodules explicitly loaded) by It also includes any submodules of the package that were explicitly loaded by previous import statements. Consider this code:

import sound.effects.echo
import sound.effects.surround
from sound.effects import *

In this example, the echo and surround modules are imported in the current namespace because they are defined in the sound.effects package when the from...import statement is executed. (This also works when __all__ is defined.)

Although certain modules are designed to export only names that follow certain patterns when you use import *, it is still considered bad practise in production code.

Remember, there is nothing wrong with using from Package import specific_submodule! In fact, this is the recommended notation unless the importing module needs to use submodules with the same name from different packages.

6.4.2. Intra-package References

When packages are structured into subpackages (as with the sound package in the example), you can use absolute imports to refer to submodules of siblings packages. For example, if the module sound.filters.vocoder needs to use the echo module in the sound.effects package, it can use from sound.effects import echo.

You can also write relative imports, with the from module import name form of import statement. These imports use leading dots to indicate the current and parent packages involved in the relative import. From the surround module for example, you might use:

from . import echo
from .. import formats
from ..filters import equalizer

Note that relative imports are based on the name of the current module. Since the name of the main module is always "__main__", modules intended for use as the main module of a Python application must always use absolute imports.

6.4.3. Packages in Multiple Directories

Packages support one more special attribute, __path__. This is initialized to be a list containing the name of the directory holding the package’s before the code in that file is executed. This variable can be modified; doing so affects future searches for modules and subpackages contained in the package.

While this feature is not often needed, it can be used to extend the set of modules found in a package.

How Toptal Web Engineering Community is revoluting IT industry?

Globalization lead to moving lots of people from various places to do the work they love and want to make amazing future in specific industry, IT industry is one of that too but most part of information technology industry is oriented around “work from your place/city/country/”. One can set-up office at home to fetch work from any location in the world, Complete it within a required time and get paid. Which seems like a great plan for client as well as for Computer guy(Developer,Freelancer,programmer) Such criteria lead to freelancing industry which has created great influence over society, Due to that most of the people  believe in “work for yourself” term that resulted quality work and great innovations by individuals.

Job portal work like a bridge between Client and Freelancer which should have great standards for Jobs and Freelancers. I believe Toptal is one of them because of it’s well defined selection process. Which makes the freelancers to not just be serious about work but also connects the clients with best Developers for their work.

From the top view Toptal is creating a great community of developers and companies who just love their work and believe in great careers. A combined goal leads to well prepared future and better values. In the information age everyone wants to work with smart people to learn well and get notified intellectually as well. Just like Thomas  Edison who brought great people together to invent great things which worked very well and no doubt Toptal is doing same on world level. Would love to be part of such community!



Cython in Easy Way, Be cool

Ok Be cool there is lot of buzzing supposed to be happened in my mind because there have to be,

Why I am going to learn about Cython?

1 . Sometimes people say my Favourite language is Damn! Slow! (which is not true if you know about Generators and futures and multiprocessing modules, Let’s just save this for some other day)

2. If I got to use it at any job any day in the field of Data-Analysis or Number-crunching computations.

3. Cyhton is Sexy, I love sexy things,🙂😉

4. Portability is good for you if you are Server administrator in day and Android-Developer at night, Or even Web-developer in Weekends.[So cython can help you everywhere]

5. You have lots of C++/C code but you can read it


Slide1> C+Python = Cython

You will not get it’s need in first place unless you are from NASA😉


Slide2> Why we should/must love Python

{import antigravity}

Slide3> C+P….. = Cython

Do I need to learn C if I have to go with Cython?


Slide4> Cython is made for Python Programmers to achieve the Speed of C and Productivity of Python,

Aha! I feel Like I can create Whole universe now(If you understood above statement)


Slide5> Where to start if you want to write programs in Cython?

Rember (C+Python = Cython) or (Python+C = Cython)😉

So let’s Start With Python…! yay!!


A very Simple Python Function(Don’t try at home😉 )

def sum_text(double number_range):

“This function explains lot about my lazyness”
return sum([i*i for i in xrange(number_range)])

When you will run it in ipython uisng %timeit sum_text(100000000) function your system Can crash/hang if you don’t have good RAM like 10 GB

It will take around 15.6 seconds.

So now we need Cython to optimise it.

Again Using Ipython

cpdef double sum_text_cython(int number_range):
“This is cython(!100% but…), It works😀 ”

cdef int i
return sum([i*i for i in xrange(number_range)])

Image of above thing:


%timeit sum_text_cython(100000000)

1 loops, best of 3: 3.43 s per loop

So it is about "2.5 times" faster, Yeah!!! (That's what I mean!)

For the information this Example is Just for information, It can produce lots of other errors

Continued.... (Going for dinner) Come with monte-CarloSimulation
Now really going for dinner...

Ok Now really thing is  we need to take things in real life, Like how to use Cython when You want to do real code in Python as well.

So Write  a .pyx file with simple Python code.

p = [i*i for i in xrange(number_range)]
return sum(p)

So this is simple Python thing, save it hellocython.pyx

NEVER SAVE IT  “cython.pyx” file.

$ easycython hellocython.pyx

It will generate hellocython.c file and then also compile that into .so file.

Nextslide> So we only have Python code but Cython does understand it well.

nxtSlide> Let’s make code more faster:

def sum_text(int number_range):
cdef int i
p = [i*i for i in xrange(number_range)]
return sum(p)

This above is not even 100% pure Cython function but  it is 2.5 times faster.😀 with .so file.

nxtslide> Now we can easily import this into our regular Python call.

create normal file.

import hellocython

print hellocython.sum_text(100000)

Now we can call Our results both Cython = C+Python

[Next is Cython using Multi-threaded] AND [Convert it into presentation] Add more Cython examples and make GitHub repository…

A reusable function

def fetch_uids(address,password,folder,d):
mail = IMAP4_SSL(‘’)
mail.login(address, password)
interval = (“%d-%b-%Y”)
result, data = mail.uid(‘search’, None,'(SENTSINCE {date})’.format(date=interval))
return data



Now I can define variables according to my project and using the function call I can make my function more reusable:

for daily analysis inbox I can call:



for daily analysis sentbox I can call:


Same as I can change the value of ‘days’ which make more sense.



ElasticSearch and Python

Ok elasticsearch: A search engine on steroids. Yeah that’s really true all the time. O it should be. I am thinking about making my own search engine to create damn awesome things. GOOGLE is so lame in these days,😛

Ok let%s talk about various things we need to know about elasticsearch.
It is as easy as abc

Read more of this post

Welcome to Human Race, You will never win, It never Ends :P

It’s kind of quite funny all the time we see people around us telling you what to do, what are you, Who you think you are but you are not that,…….,

Pretending to be like they like you or sometimes they love you.

It nice feeling all the time even when someone is saying with bad words and you know how bad those could be.

I find myself super-curious about things, Super duper and trupper.
My curiosity leads me to various things those I never thought would be so beautiful or so ugly, It seems this is life, simple,cool,nice,bumpy or just Lifeeeeeeeeeeeeeeeeeeeeeeeeeeeee………………………………….

Why sometimes we think about past, it never exist anymore,
why we even think about about Future,,,,,,,,,,,,,,,,,,?
It does not, Real thing is Present, Yes, Present!
If future is now! Just right there in-front of my eyes, then with who in this whole world we are competing? With ourselves or with Outsiders(it could be anyone)

if we are competing with outsiders that could make sense at some level, for example If I say Albert Einstein did great inventions even in the age of 24 or 25 and I am 25 and I have not done anything great yet, Oh may be that thought could help me to work hard moe=re? ummmmmmm at some level, but Einstein never learned to drive(bike or car) in his whole life, I was only 14 when I was Damn! good drivers, At this Age I might have been completed thousands of KMS by self. Now we can also consider that we can’t compare driving and Science, Yeah we can’t,😛 Mad drivers kill less people than mad Scientists who have done mad inventions.(Guns,Nuclear many more…..) Even driving, cars is the invention of science. So my real point was that we can’t compete with anyone at any way.

Now other form of competition comes is compete with your self, How even I can do that? I and me both are same. I have only one soul and one body so How Can I compete myself. Is it something like improve yourself, Break your own records or do your stuff? Oh that’s really more crazy I guess,But I enjoy that! wow, Writing all the bull shit that lives in your brain on Blog is awesome.😀😀😀😛😛😛

Just a post

To many days has been passed and I have not written a single thing, That’s Rude!

Ok I am enjoying my journey of life and and as much as I can, I am learning.
Now there are few things I need to complete to achieve my Goals more securely and fast.

1. Proper Daily Schedule(Includes Exercise/Fun/Programming)
2. Balanced Diet.
3. A Daily Game, Physical Activity.
4. A new Network with Entrepreneurs.
5. A very Much Working BIM Software
6. The Great Career!

This Hostapd hotspot works for me

Flask for vitualenc

Today something happened it can be considered as bug also.
In the virtual env when I install flask after activation of virtual environment it goes to the installation successfully but when I try to “import flask” does not come up, May be problem in virtualenv of flsk bug but when I do following things do work.

You may need/not-need to use Sudo according to the Nature of your environment.

$ flask/bin/pip install flask
$ flask/bin/pip install flask-login
$ flask/bin/pip install flask-openid
$ flask/bin/pip install flask-mail
$ flask/bin/pip install flask-sqlalchemy
$ flask/bin/pip install sqlalchemy-migrate
$ flask/bin/pip install flask-whooshalchemy
$ flask/bin/pip install flask-wtf
$ flask/bin/pip install flask-babel
$ flask/bin/pip install guess_language
$ flask/bin/pip install flipflop
$ flask/bin/pip install coverage
OMG after writing too much post I did not even made smiely, here it is.😀😀😀

Instantiation Python classes

Ok I wrote a great article in instanseation Python classes but I guess it is deleted somehow.😦😛

Following was the refrence for Future:


Get every new post delivered to your Inbox.

%d bloggers like this: