Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Friday, August 26, 2011

Start PYTHON in LINUX

1.    Install gedit in your linux distro.
                         Every GNOME Linux distro have gedit. Because gedit is the official text editor 
                         of the GNOME desktop environment.

2.    Run gedit so we can fix few default setting:
             2.1 Open  'edit>preferences' select the 'editor' tab
             2.2 Changed tab width to 4
             2.3 Select 'insert spaces instead of tabs'
             2.4 Turn on “automatic indentation” as well
             2.5 Now, view tab turn on “display line numbers”.

3.    Open your 'Terminal program', run python.


◦     If you run python and its not there, install 'python 2' not 'python 3'.
◦     Type 'exit()' or 'ctrl+d' and get out of python.

Note :
  1.    Use gedit because it is simple and same on all computer/environment.
  2.    Never use 'Vim' or 'Emacs' these are for a better programmer.
  3.    Do not try to install 'python 3', it's not for beginners.

Sunday, February 27, 2011

why should we use python

1. Although no one language is the right choice for every possible situation, Python is a good choice for a large number of programming problems.

2. It’s a true cross-platform language, running equally well on Windows, Linux/UNIX, and Macintosh platforms, as well as others, ranging from supercomputers to cell phones.

3. It can be used to develop small applications and rapid prototypes, but it scales well to permit development of large programs.

4. It comes with a powerful and easy-to-use graphical user interface (GUI) toolkit, web programming libraries, and more. And it’s free.

5. Python is a very expressive language. Expressive in this context means that a single line of Python code can do more than a single line of code in most other languages.advantages is the fewer lines of code you have to write, the faster you can complete the project. the easier the program will be to maintain and debug.

6. Python is easy to use. Types are associated with objects, not variables.
Python typically operates at a much higher level of abstraction.  Syntax rules are very simple.


What Python doesn’t do as well :

1. Python doesn’t have the most libraries.
2. Python doesn’t check variable types at compile time.
         >>> x = “2”
>>> print(x)
'2'
>>> x = int(x)
>>> x = int(x)
2                                 (x is now integer 2)

3. Python is not the fastest language.

                         A possible drawback with Python is its speed of execution. It isn’t a fully compiled language. Instead, it’s first semicompiled to an internal byte-code form, which is then executed by a Python interpreter.

                  There are some tasks, such as string parsing using regular expressions, for which Python has efficient implementations and is as fast as, or faster than, any C program you’re likely to write. Nevertheless, most of the time, using Python results in slower programs than a language like C. But you should keep this in perspective. Modern computers have so much computing power that for the vast majority of applications, the speed of the program isn’t as important as the speed of development, and Python programs can typically be written much more quickly.

Python is a modern, high-level language, with many features:
  1. Dynamic typing
  2. Simple, consistent syntax and semantics
  3. Multiplatform
  4. Well-planned design and evolution of features
  5. Highly modular
  6. Suited for both rapid development and large-scale programming
  7. Reasonably fast and easily extended with C or C++ modules for higher speeds
  8. Easy access to various GUI toolkits
  9. Built-in advanced features such as persistent object storage, advanced hashtables, expandable class syntax, universal comparison functions, and so forth
  10. Powerful included libraries such as numeric processing, image manipulation, user interfaces, web scripting, and others
  11. Supported by a dynamic Python community
  12. Can be integrated with a number of other languages to let you take advantage of the strengths of both while obviating their weaknesses.

Wednesday, February 2, 2011

Python's high-level toolbox

           Unlike some scripting languages,  Python's high-level toolbox makes Python useful for
substantial development projects. Some of the things i find is given below:

Dynamic typing
     Python keeps track of the kinds of objects your program uses when it runs; it doesn't require complicated type and size declarations in your code.

Built-in object types
     Python provides commonly used data structures such as lists, dictionaries, and strings, as
an intrinsic part of the language; as we'll see, they're both flexible and easy to use.

Built-in tools
     To process all those object types, Python comes with powerful and standard operations, including concatenation (joining collections), slicing (extracting sections), sorting, mapping, and more.

Library utilities
      For more specific tasks, Python also comes with a large collection of precoded library tools that support everything from regular-expression matching to networking to object persistence.

Third-party utilities
      Because Python is freeware, it encourages developers to contribute precoded tools that support tasks beyond Python's built-ins; you'll find free support for COM, imaging, CORBA ORBs, XML, and much more.

 Automatic memory management
         Python automatically allocates and reclaims ("garbage collects") objects when no longer used, and most grow and shrink on demand; Python, not you, keeps track of low-level memory details.

Programming-in-the-large support
          Finally, for building larger systems, Python includes tools such as modules, classes, and exceptions; they allow you to organize systems into components, do OOP, and handle events gracefully.

Python is widely used in cyber world..

1. High Performance Computing (HPC)
  • Parallel Python (pp) module 
  • PyMOL 
  • VTK 
  • SciPy 
2. Browser
  • Django 
  • Writing a django app 
  • TurboGears 
  • CherryPy 
  • Zope 
  • Writing a Zope product 
  • Plone 
  • Writing a plugin for trac 
3. Web Services
  • XMLRPC 
  • simplexmlrpcserver 
  • xmlrpclib 
  • SOAP 
  • Flickr (Beej's API?) 
  • Google Calendar/GData (w/ ElementTree) 
  • Amazon 
  • Yahoo 
4. System Administration
  • SNMP 
  • LDAP 
  • python-ldap 
  • Luma (extending?) 
  • User/Group management 
5. GUI Frameworks
  • wxPython 
  • PyQT 
  • PyGTK

    Saturday, January 1, 2011

    Hello World compared in C# and IronPython

    A small Hello World app in C#

    using System;
    class Hello
    {
    private string _msg;
    public Hello()
    {
    _msg = "Hello World";
    }
    public Hello(string msg)
    {
    _msg = msg;
    }
    public void SayHello()
    {
    Console.WriteLine(
    _msg);
    }
    public static void Main()
    {
    Hello app = new Hello();
    app.SayHello();
    }
    }


    Equivalent in IronPython

    class Hello(object):
        def __init__(self, msg='hello world'):
            self.msg = msg

            def SayHello(self):
               print self.msg

    app = Hello ()
    app.SayHello()