How to create your first python module – Part 2

In the part 1 of this tutorial I have shown you how to create a python module and then install it in the python local path. In this tutorial I will show you how to share your python module with the rest of the world so the other programmer can use the module you have created as well.

First of all you will need to register an account with so you can upload your module and share it with the rest of the world. Go ahead and register with pypi with the same author name you have entered into the file of the previous module.

Next open up the windows command prompt and then browsed to the folder where you have kept the python module and type in the below command into the command prompt

python register

Select 1 after you have been presented with below screen

login to pipy
login to pypi

Enter the username and password you have just created on pypi then press enter.

Register PyPI
Register PyPI (Status of 200 means OK)

That is it! Now it is time to upload the python module to PyPI with below command.

upload module
upload module

Now that python module is up there for the world to use, you can start to create your own module now and share it with the rest of the world after this tutorial. With that this concludes the two part series of how to create your very first python module tutorial, hope you like this one!

How to create your first python module – Part 1

Today I am going to show you how to create a simple python module which you can then use it in your python program again and again. Before we create a python module lets create a main python module folder where we can then keep all our python modules in one place. Create the main module folder either in the c or d drive in your computer, then create a folder inside that main folder to keep our new python module.

Main Module
Main module and module folder

Next create a new python project in NetBeans IDE 8.1 just like the previous tutorial (refer to

Create a new module
Create a new module

You can either delete the default .py file in the project and create a brand new empty module or turn that default file into module. In this tutorial I will delete the default file and create an empty python module. Right click on then delete then right click on the project folder and select New->Empty Module. Enter the module name then click on Finish. Next we will enter a few lines of code into the NetBeans editor plus a few lines of comment that explain what this module is for…

#This is the “" module, and it provides one function called
#sumUpNumber() which will sum up all the numbers you have put into it

def sumUpNumber(*args):
    #Your input will be any number, any length of parameters 
    #into this function and it will return the total
    total = 0
    for arg in args:
        total += arg
    return total

Next copy the file and paste it in PythonModule->summation folder which you have just created. Create a new file with Notepad++ Editor which is another IDE I often use to do the coding job. Enter below code into that empty file and save it in the PythonModule->summation folder as Those code that you have entered below will become the metadata of your module distribution.

from distutils.core import setup

	name = 'summation',
	version = '1.0.0',
	py_modules = ['summation'],
	author = 'choose',
	author_email = '',
	url = '',
	description = 'Module for number summation',

That is it for the part! Next open up the windows command prompt and browser to the summation folder where those two files are and type in below command then press enter.

distribute module
distribute module

This will create the distribution package for the summation module.

Next install the distribution into your local copy of Python with this command

Install Module
Install Module

Now this module should be inside the python’s site-packages, it is time to import the module into a new python program and runs it. Create a new python project in NetBeans IDE 8.1 then enter below code and Run the program!

from summation import sumUpNumber

if __name__ == "__main__":

It works! The outcome is as follow:-

NetBeans Output Pane
NetBeans Output Pane

So there it is, you have created your first module in python and then install it in the python’s site-packages folder so you can then import and use that module in your other python programming again and again! After you have created your first module, then what’s next? Go ahead and read the second part of this tutorial!

Iterate through array list in Python 3.5

Hi people, if you read my previous article about Python 3.5 then you know that I am going to create a game with Python (maybe with Panda3D or PyGame) and distribute it on the gaming market place. However before we can create game we need to know some basic about python 3 and in this post I am going to continue with the basic python tutorial first. Today we are going to talk about how to iterate through an array list in Python 3.5.

There are two method we can use to iterate through a list in Python, we can either use the while loop or the for loop. First I am going to show you how to do it with the while loop.

 hello = ["Hello", "World", "!"]
 count = 0
 while(count < len(hello)):
     count += 1

Use the while loop to iterate requires we to create an extra counter which is ‘count’ in this example.

Now lets take a look at the for loop.

 hello = ["Hello", "World", "!"]
 for item in hello:

The above for loop will produce the same outcome


but there is no counter involves in the for loop. Therefore I would have preferred to use the for loop instead of the while loop unless for some special reason not to use it.

If you are using NetBeans IDE 8.1 then the complete code for this program is as follow:

if __name__ == "__main__":
    hello = ["Hello", "World", "!"]
    for item in hello:

Also notice that the python’s build in function print method will print each item in the list in a new line, if you want to print it in one single line then you can use below program instead.

if __name__ == "__main__":
    hello = ["Hello", "World", "!"]
    hello_string = ""
    for item in hello:
        hello_string += item + " "

I hope you do enjoy with this tutorial and wish you good luck in your Python 3 learning! This blog will be updated at least once per day so if you are into game design do come back and read the next article.

How to set up python platform in NetBeans 8.1

I am creating a desktop gaming project in python 3.5 using NetBeans IDE and would like to show you how to install python plugin to NetBeans to create a python platform for my project.

Python plugin installation process is really simple in NetBeans 8.1, with your Internet connection ready, all you need to do is go to Tools->Plugins then type in python to the search box then thick on python when this plugin shows on the left pane and finally click on the Install button to complete the installation job. NetBeans will recommend extra plugins that you will need to run the python program besides the python plugin if you have not yet selected them, select those plugins as well and download the entire python platform package!

After you have installed the plugins, restart the NetBeans IDE and go to File->New Project and select Python->Python Project – Ant then click Next. In the next page fill in the Project Name as well as fill in the path to the folder which you would like to keep all your project folders, select your python platform (Python 2 or 3) and leave the rest as default then click on Finish to create your very first python project.

Select Python Platform
Select Python Ant Platform
Create New Python Project
Create New Python Project

I just entered below code into the python code editor, then select Run->Run Project to run the project on the python 3 platform and see the outcome in the output pane below the code editor.

Python 3 Array
Python 3 Array
Output Pane
Output Pane

NetBeans 8.1 is a free IDE which we can use to create project written in various programming language and it also has lots of plugins that we can download to further help us in our software development.