Posts

Showing posts from December, 2012

setting up a new project in django

Here in this post, I am going to write how to start writing a web application using django. And before you start, I believe you have already downloaded and installed django. If not then please do refer http://usepython.blogspot.com/2012/12/getting-started-with-django.html . So we are ready to go? Now open terminal and lets create a new django project: $ django-admin.py startproject testProject This should create a django web project. That is you will see a directory created in the current working directory of the terminal. The directory will have a structure as follows: testProject: - manage.py - testProject - __init__.py - settings.py - urls.py - wsgi.py Since we have created a new project, change directory using the command: $cd testProject and run the project using the command: $ python manage.py runserver In the command line, you should see something like: Val

Welcome to write php

A warm welcome to writephp.blogspot.com. This is my new blog where I will be writing about php. Its the hot cake for the web programmers. And has been used extensively in web development. And also being a web developer I use php extensive in my work place. I have been using standard php also known as core php among developers, codeigniter and yii. So I thought of sharing my tips and tricks with all of you through this blog. Hope the blog will be fruitful to you. Happy Programming !!!

installing nltk

Image
nltk- 'natural language tool kit' is a very good language processing tool available for python. It has above 50 corpora,lexical resource like WordNet, and text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning. For more on it you can visit the official site too. Official site of NLTK : http://nltk.org/ Here in this post I will be helping you with installing nltk. To install nltk, use the command sudo apt-get install python-nltk or you can use easy_install sudo easy_install nltk or if you have python-pip you can even use sudo pip install nltk . This installs the nltk module for you. Just installing the module is not sufficient for natural language processing quick start. We need the data files of nltk which can be downloaded from https://github.com/nltk/nltk_data/tree/gh-pages or you can choose the data you want to use from https://github.com/nltk . But here we are going to use the nltk downloader that comes with nltk mod

Writing your own python modules

Image
Here in this post I will be helping you with writing your own custom modules. Well module is a python file with .py extension. The module can have class definitions, function definitions. Lets start by creating one. Lets create a file mymodule.py with a fovourite text editor, mine is 'geany'. And lets write the following function in it. def hello(): print "Hello Function" And save it. We have successfully created a module here. Lets use the module. Open your python interpreter in the directory where your python module is. And then import the module using import mymodule and to use the function use mymodule.hello() This should print Hello Function on your screen. The function only can also be imported as from mymodule import hello and the function can be called as hello() . i.e. no need to use the module name any more. Not only function but also the modules can have class definitions. Lets take at the following example. Create a new module mymodule1.py and write th

choosing python ide

Image
Once you started writing python, you just don't use a simple text editor like notepad/gedit for writing large applications. But need an IDE [integrated development environment]. Here are a list of some ide that you may want to use: 1. Aptana Studio : The professional, open source development tool for the open web. Develop and test your entire web application using a single environment. With support for the latest browser technology specs such as HTML5, CSS3, JavaScript, Ruby, Rails, PHP and Python. We've got you covered! 2. Eclipse with pydev: Eclipse is a very versatile IDE that’s been around for a very long time. It’s a time tested offering and is very solid all around. Eclipse is like a sandbox IDE; it can support any language as long as somebody has baked in the support through a package. Such is the case with PyDev, a package that allows you to turn Eclipse into a very useful Python IDE. 3. Pycharm : PyCharm is an IDE created by JetBrains. You might remember these guys as

Getting started with Django setup

Image
First things first, before you start coding be sure you have the minimal setup done. Here in this post I am simply going to explain how you can start using django for your web development purpose. In this post I am going to explain installing django in linux machines. I am a ubuntu user and like almost any of the linux distros ubuntu comes with python too. Since we already have python with us. It is good to go and install django. But if you don't have python then you need not worry not, just you need is to type the following command to get python installed: ubuntu$ sudo apt-get install pytho For fedora fedora$ sudo yum install python By now definitely you have python in your system. Now its time to install djanog. Installing django is super easy if you have easy_install or pip in your system. Even if you don't have them in ubuntu you can use: ubuntu$ sudo apt-get install python-django If you really want to use the setup tools of python [easy_install/pip] then you can proceed w

Google App Engine Datastore insert,select operation

Image
Here in this post I am going to show a google app engine program which does insert operation and delete operation on google app engine datastore. The program code is as follows: from google.appengine.ext import db class Person(db.Model): name=db.StringProperty() age=db.IntegerProperty() person1=Person(key_name='1',name='Amit Sana',age=24) person1.put() person2=Person(key_name='2',name='Samantha Sharma',age=28) person2.put() per=Person.all() for p in per: print p.name print p.age Explanation: The first line of the code is a simple import statement. The second,third and fourth line are for the class definition of Person which extends the db.Model class. And also we can easily understand name is of type String and age is of type Integer which are clear from db.StringProperty() and db.IntegerProperty. The next line of code creates an instance of the class Person passing some parameters: key_name, name and age. 'key_name' is an identif

Welcome to use python

Image
First of all I would like to welcome you all to this very new blog usepython.blogspot.com. The main purpose of this blog is to help people with using python the way one wants. Here by I don't think there is any need to tell about python for my supposition is that you know atleast what python is. Though not a pro, I will be trying to post from very beginning to advanced python usage. In this I will be posting posts randomly sometimes using the standard python libraries, sometimes I will be posting django contents, sometimes it may be on gae [google app engine ], natural language processing using nltk and more... I believe this and promise of making this blog useful as far as possible. :)