Python Blog Posts

How to call python code in c# applications

.net supports 98 languages as a whole and python is one of the scripting language among all.In this article i will demonstrate how to call a python program from c# application.I do not want to go much deep into the theory, i will just show you hands-on.This will be helpful to the people who already have atleast some knowledge on c# as well as on python.
Steps:
a)create one python file named pythonNetC.py and add the below content to the file
class Calculator:
def add(self,argsA,argsB):
return argsA+argsB
def sub(self,argsA,argsB):

1 Likes 1612 Views
Python Functions

A Python Function is a sequence of statements which are executed when it is called. So we can call that function wherever we want without rewriting that statements again and again.
Python function has following things to follow
a name to function i.e identifier (Required)
arguments to function (Optional)
body i.e statements inside a function (Required)
return something (Optional)
Below are the two examples of python functions.

0 Likes 1103 Views
Python Iterator and creating our own iterators

In this article we are going to know more about Python iterators and how to create our own iterators in Python.
What is an iterator
An iterator is an object that produces a series of values for iteration. More precisely if i is an iterator then for each call to next(i) will produces an element and raise StopIteration exception when all series elements are iterated.
So lets see the below example
n_list = [1,2,3,4,5]
n_iterator = iter(n_list)
print(next(n_iterator))

0 Likes 1015 Views
Python logging basics concepts

Python logging is a standard library and can be used in many ways, in this article I am focusing on below things.
Why Logging required.
Basics of logging
Logging module usage.
Why Logging required
While we start implementing our python modules we will use print() to check its working as expected. In the middle of our scripts also we will add some print statement for debugging and all.
But if we start thinking on a large application point of view with multiple levels of modules its difficult to maintain or understand print statements output. So python provides a standard library called logging.

0 Likes 1172 Views