Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,211,264 members, 8,011,372 topics. Date: Sunday, 24 November 2024 at 12:08 AM

Python Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Programming (63154 Views)

Anyone That Know Python Programming Should Help Me To Check The Eorr This / Support Python Programming With Android Devices :qpython E.t.c / What Can Python Programming Language Build? (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply) (Go Down)

Python Programming by jacob05(m): 6:43pm On Sep 27, 2008
>>>print "Hello, World"


>>> print "Has any body tried his or her hands in python and what are your experiences and views using it"
Re: Python Programming by louis400(m): 10:20pm On Sep 27, 2008
Jacob, Python is an interactive language, if you do that thing you said , you will get an output Hello World, in python in the output operator is print but in php it is "print" and "echo"
So when you try that >>>> print "hello, world" you will get Output Hello World.

2 Likes

Re: Python Programming by Nobody: 11:15pm On Oct 06, 2008
python is very easy to learn and i bet you it's easier compared to php.

simpler tags and introduces you to indentations if you dont use it, also has support for lists, tuples and dictionaries

just download the latest version of python from python.org, install it and start writing your programs

You might also want to try out the QT implementation of python
PyQt from riverbankcomputing.com

install both and you can start craeting complex GUI programs in minutes
Re: Python Programming by Seun(m): 1:38am On Oct 09, 2008
I love Python. How about using this thread to exchange python tips?

1 Like

Re: Python Programming by webstar(m): 8:49am On Oct 09, 2008
That will be kool, perl can also come along i guess.
Re: Python Programming by alexis(m): 9:51am On Oct 09, 2008
Python - I finally fell truly in love when I met you in 2006, where have you been? If only my instructor introduced me to you earlier instead of those ugly girls called QBasic, Fotran, Pascal. C looked kind of pretty, she was always smiling. Java was a strict babe with a label "You must do it my way". But then you came along and swept me off my feet.

Python is a powerful yet easy to use programming language developed by Guido van Rossum, first released over a decade ago in 1991. With Python, you can quickly write a small project. But Python also scales up nicely and can be used for mission-critical, commercial applications.

Python doesn't offer revolutionary new features. Rather, it combines many of the best design principles and ideas from many different programming languages. It's simple and powerful. More than any other language, it gets out of the way so that you can think about the problem, not the language. Programming in Python just feels right.

So, what's the big deal about python as compared to other languages.

1. Python is freaking easy to use - The major goal of any programming language is to bridge the gap between the programmer's brain and the computer. Most of the popular languages you've probably heard of, like C, C++, C#, and Java, are considered high-level languages, which means that they're closer to human language than machine language. And they are. But Python, with its clear and simple rules, is even closer to English than any of these. Creating Python programming is so straightforward that it's been called "programming at the speed of thought."

Python's ease of use translates into productivity for professional programmers. Python programs are shorter and take less time to create than programs in many other popular languages. In fact, Python programs are typically 3 to 5 times shorter than equivalent Java programs, and often 5 to 10 times shorter than equivalent C++ programs. There's even some evidence to suggest that a single Python programmer can finish in two months what takes two C++ programmers more than a year to complete.


2. Python is POWERFUL - Python is powerful enough to attract hundreds of thousands of programmers from around the world as well as companies such as Google, Hewlett-Packard, IBM, Industrial Light + Magic, Microsoft, NASA, Red Hat, Verizon, Xerox, and Yahoo!. Python is also used as a tool by professional game programmers. Activision, Electronic Arts, and Infogrames all publish games that incorporate Python.


3. Python Is Object-Oriented - OOP is basically a shift in the way programmers think about solving problems with computers. It embodies an intuitive way of representing information and actions in a program. It's not the only way to write programs, but for most large projects, it's the way to go.

Languages like C#, Java, and Python are all object-oriented. But Python does them one better. In C# and Java, OOP is not optional. This makes short programs unnecessarily complex, and it requires a bunch of explanation before a new programmer can do anything significant. Python takes a different approach. In Python, using OOP techniques is optional. You have all of OOP's power at your disposal, but you can use it when you need it. Got a short program that doesn't really require OOP? No problem. Got a large project with a team of programmers that demands OOP? That'll work too. Python gives you power and flexibility.


4. Python Is a "Glue" Language - Python can be integrated with other languages such as C, C++, and Java. This means that a programmer can take advantage of work already done in another language while using Python. It also means that he or she can leverage the strengths of other languages, such as the extra speed that C or C++ can offer, while still enjoying the ease of development that's a hallmark of Python programming. Python can call native codes in other languages and receive output back, gosh - it's sweet.


5. Python Runs Everywhere - SO, your Computer instructor told you only java is platform independent eh?, well, he lied!, grin. Python runs on everything from a Palm to a Cray. And if you don't happen to have a supercomputer in the den, you can still run Python on Windows, DOS, Macintosh®, or Linux machines. And that's just the top of the list. Python can run on practically every operating system in existence.

Python programs are platform independent, which means that regardless of the operating system you use to create your program, it'll run on any other computer with Python. So if you write a game on your PC, you can e-mail a copy to your friend who runs Linux or to your aunt who has a Mac, and the program will work (as long as your friend and Aunt have Python on their computers).


6. Python Has a Strong Community - You will be amazed at the number of people and companies that use python i.e. google, yahoo and even plain old microsh$t.


7. Python Is Free and Open Source - Python is free. You can install it on your computer and never pay a penny. But Python's license lets you do much more than that. You can copy or modify Python. You can even resell Python if you want (but don't quit your day job just yet). Embracing open-source ideals like this is part of what makes Python so popular and successful.


Let me not take up a lot of space in one post. Python is unique!.

12 Likes 2 Shares

Re: Python Programming by alexis(m): 10:01am On Oct 09, 2008
Anyone has any public work in python, scripts and program they can share. Or lets' code short and simple snippets in python, what say you guys?
Re: Python Programming by webstar(m): 1:14pm On Oct 10, 2008
I think we re good to go,
Re: Python Programming by alexis(m): 4:09pm On Oct 10, 2008
I haven't done anything with python on the public domain. All my work are internal to the companies I have worked for. But I can share some source code and perhaps start a short tutorial on python

PYTHON TUTORIAL

SETTING UP PYTHON

Setting up or installing python is pretty simple. Go to http://www.python.org/download/ and download the python version for your OS. I reckon most people use windows. Download the Windows installer, once the download is completed, install python as you would install any other windows application.

For other OS users i.e. Linux and MAC - most times python comes installed by default. If not, don't panic - python is a breeze to install. For linux users, it depends on the flavor you are running. For Ubuntu and debian fans, a simple apt-get install python does the trick (You have to be connected the internet). For redhat/centos fans - yum does the trick, i.e yum install python. Again you have to be connected to the Internet.

I rather you compile from source, so download tarball from python website and compile it yourself.

For MAC users, please refer to [url]http://homepages.cwi.nl/~jack/macpython/index.html[/url] for your download and install.

Now, we have have python downloaded and installed, what next? Test to see if python is working. How do you do that. For all ya unix/linux/mac users, fire up your shell/terminal and type python, hit enter. If python is installed correctly, you will enter the python interactive shell. The same works on windows, load your command prompt and type python and press enter; it should load the Python interactive shell.

Now we have python and it's interactive shell working. Oya - clap for yourself  wink.

I hear you asking, so how do I write a python program - don't worry my dear friend because python programs are just bunch of text files saved with a .py extension. You can use your favorite text editor to write your python program but I recommend notepad++ (http://notepad-plus.sourceforge.net) for windows, textmate for MAC (http://macromates.com) or textwrangler (http://www.barebones.com/products/textwrangler/). For linux/unix, there is plain old emacs (http://www.gnu.org/software/emacs/).

So let us write our very first python program. We all know the Hello World program you see in most programming books right? Well, let's do something different. We will code python to ask for your name, your age and who was your childhood super hero. Ready?

Guess what - we can write the entire program using just 7 lines of code. So, fire-up your text editor and type in the following and save it as program1.py. Create a folder/directory anywhere on your computer and name it codes, save program1.py in it.

# A Simple program to demonstrate how easy it is to use python
# Alex Dehaini - 10/10/2008

# Get name from user
name = raw_input("What is your name: "wink #Line 1

# Get user age
age = raw_input("How old are you: "wink #Line 2

# Ask the user for their favorite childhood super hero
superhero = raw_input("\nWho is your favorite childhood super hero: "wink #Line 3

# Print output to the users screen

print "Hi, " + name  #Line 4
print "You are", age  #Line 5
print "Your childhood hero", superhero, "is very very strong"  #Line 6

raw_input("\n\nPress enter to exit "wink  #Line 7


I added several comments and lines but the actual program is just 7 line.


HOW TO RUN THE PROGRAM

Use your command prompt or terminal  - go into your codes folder and type program1.py and hit enter. Enter your name, age and your favorite super hero and watch python answer you.

Don't worry if you don't understand the program for now, I will explain in subsequent post. However, the program is self-explanatory. See if you can make sense out of it.

Enjoy!

7 Likes

Re: Python Programming by Nobody: 6:55pm On Oct 10, 2008
I havent done much with python, i am a beginner/intermediate and i am falling for this language big time

Its simple, and with very few lines, you can have a complex program.
PHP seems simple to me but this is simpler.

I have been able to put up this software that will go will an online store
Its meant to check new orders and harvest it if there is.

a lot went into this and i developed  it in 3 weeks, thats fast looking at the fact that i am a beginner/intermediate in python

NOTE FOR BEGINNERS: Please stay of tkinter, it doesn't give that professional look, I used QT

3 Likes

Re: Python Programming by webstar(m): 8:16pm On Oct 10, 2008
Thats a nice programe but how does this work, it connects to the site DB or does it need access by the site owner, can it brute force ?
Re: Python Programming by Nobody: 8:48pm On Oct 11, 2008
i first made it such that it connects to the remote database directly but later faced a problem with my webhost, even though they support remote db connection, they require that u manually add ip to their whitelist and they have no support for wildcards. so i had to tunnel in through a web page

The webpage expects a username/password and then the
webpage checks the IP address prefix
if passed, checks useragent
if passed, does some other check (which i dont want to share, cos we have geeks here)
then grants access

About ur brute force, maybe if you explain better, I will be able to answer that.
Re: Python Programming by urihsab: 6:33am On Oct 12, 2008
I highly recommend this Python Book to those who want to learn this programming language.
Re: Python Programming by dami9ja(m): 7:44pm On Oct 12, 2008
oh Python!  kiss Great work guys. Am a newbie tho, but am loving every bit of this.
Re: Python Programming by Seun(m): 11:37am On Oct 13, 2008
My favorite web framework is CherryPy: http://www.cherrypy.org/. 
It's pythonic and comes with a fast multi-threaded python webserver written in Python.

My favorite HTML Templating tool is the built in string.Template() function, + cgi.escape()wink

4 Likes 3 Shares

Re: Python Programming by alexis(m): 1:03pm On Oct 13, 2008
If you use cherrypy, then you will love web2py http://mdp.cti.depaul.edu/.

Then there is django http://www.djangoproject.com/

Seun - done any work with python?
Re: Python Programming by Wordsmith(m): 5:16pm On Oct 13, 2008
Has anyone developed desktop apps aside the web using Python?
Re: Python Programming by Nobody: 7:24pm On Oct 14, 2008
all these web2py, django, cherrypy etc look to me like python modules looking at the way you have to import them into python before you can use them.

Can anyone give a summarized step as to how to get my apache webserver to run python, if possible, else give how to make it run on my localhost.

i googled for it but, i dont like what i am getting.
Re: Python Programming by pystar: 10:01pm On Oct 14, 2008
@alexis
I have coded alot of webapps using web2py, what stuff have you done with this framework? maybe we can compare notes?
Also your webapps that you coded in python can be hosted absolutely free using GOOGLE APP ENGINE, the package even comes with a free domain name, although django 0.96 is the official supported framework u can port yuor web2py apps onto the engine with little changes (this is mainly due to the query engine GQL)
Re: Python Programming by Seun(m): 12:18pm On Oct 15, 2008
There are three things
alexis:

If you use cherrypy, then you will love web2py http://mdp.cti.depaul.edu/.

Then there is django http://www.djangoproject.com/

Seun - done any work with python?

There are a few things I look for in a web framework:
1) Straightforward request dispatcher that supports clean urls.
2) Straightforward handling of GET and POST variables of all types.
3) Straightforward support for manual manipulation of cookies.
4) Performance.

In your opinion, does web2py satisfy these requirements?

What I hate most in a web framework:
1) Trying to design my database or write my queries for me.
2) Forcing me to subclass objects (I don't do OOP).
3) Being slow.

I think reason (1) is why I don't use django. SQL is a neater way to process data than OOP.

1 Like 1 Share

Re: Python Programming by Wordsmith(m): 2:15pm On Oct 15, 2008
No one's answered my question. . .
Re: Python Programming by pystar: 5:16pm On Oct 15, 2008
@wordsmith
I wrote a minimalistic chat server and client in python, i can send you the code if you wish, i just used it to tighten my network programming skills.
Re: Python Programming by webstar(m): 9:28am On Oct 16, 2008
Dont Say u do this or that, if you really think you have done, post it and let people see but hide the key thing if u wish. For the database handling, SQL is the best and for server scripting stuff, PHP is the best, THank you.
Re: Python Programming by Nobody: 9:54am On Oct 16, 2008
THIS ONE THAT EVERY ONE IS FLEXING PYTHONIC MUSCLES AND NEGLECTING MY BEGINNER'S QUESTION

I CARRY YANSH FOR UNA O

@webstar

SQL is the query language you use to communicate with a database i.e every database uses sql
Re: Python Programming by Seun(m): 3:09am On Oct 17, 2008
Can anyone give a summarized step as to how to get my apache webserver to run python
Error. Don't use apache if you don't have to.

if possible, else give how to make it run on my localhost.
As I mentioned earlier, CherryPy comes with a built-in multi-threaded python web server. www.cherrypy.org

Has anyone developed desktop apps aside the web using Python?
I think it would be a challenge to write a desktop app with python, unless the app is open source.
The GUI framework that comes with Python isn't very popular. It is possible, but it's a challenge.
Re: Python Programming by pystar: 4:32am On Oct 17, 2008
I dont think building a desktop app in python is that difficult as long as you dont use Tcl/TK. Using a gui builder like "Python card" makes you draw your GUI just like VB and code the logic is python, and you can also use "wxPython", which is very good and has very concise documentation and templates. Just google the stuff.
Re: Python Programming by Nobody: 8:42am On Oct 17, 2008
yes, thats right, stay off tkinter because it's ugly

I use pyqt and it also comes with QT designer that lets you draft your GUI easily and you can even cook up your methods right from QT designer itself and even when you feel you are carrying out a simple task the hard way, you can still use ur traditional python

I intend to try out WxPython later on and see whats good for me.

Seun:


As I mentioned earlier, CherryPy comes with a built-in multi-threaded python web server. www.cherrypy.org


Well, i'll see to that

and whats the challenge if i may ask
Re: Python Programming by Seun(m): 8:45am On Oct 17, 2008
For some applications, the ugliness may be irrelevant, but such applications are usually web friendly.
Re: Python Programming by pystar: 9:08am On Oct 17, 2008
@webdezzi
I dont think that you have to use cherrypy because it comes with an inbuilt server, every python web framework worth its salt comes with an inbuilt server. I dont see you deploying your front facing web app with cherrypy since, its only a development server and not a production server. I dont see anything wrong with Apache as long as you dont use mod_python (its too computationally expensive to run it, since every request to your webapp initiates a new python process), i use apache and mod_wsgi (the code is hosted on google for easy download) or apache and mod_fcgi. If you hate Apache so much you can use lightTpd or Ngnix which are two relatively new web servers and have a smaller memory foot print than Apache.
If you need any help on setting it up, get in touch.
Re: Python Programming by Seun(m): 11:05pm On Oct 18, 2008
I don't see you deploying your front facing web app with cherrypy since, its only a development server and not a production server
Says who? It's multithreaded, it's fast, and it automatically reloads when you update your web app or any configuration file. What more does a production server require?
Re: Python Programming by Seun(m): 1:36am On Oct 29, 2008
By the way, TkInter is probably not a bad toolkit. If I ever have to use a GUI, I'm going to try TK.
Compared to WxPython and others, it's very lightweight and that's always a good thing in my book.

2 Likes

Re: Python Programming by dami9ja(m): 2:57pm On Oct 30, 2008
Alexis, Where art thou? Come c0ntinue ur tutorials naw! cry

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply)

Meet Dare Obasanjo Who Works With Microsoft / Build A JAMB Result Checking Website To Win 150,000 Naira / Funny Programming Memes. Just For Laughs

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 73
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.