Helpful Information
 
 
Category: Development Articles
Python 101 (part 3): A Twist In The Tail

this sounds all well and good.
but what am i actually supposed to do with this 'python' language?
i'm assuming(maybe wrongly) that i can use it for scripting to the web. if so, what web server supports it? can it easily connect to a relational database(Oracle, SQL Server) , does it support xml? Does it have a nice IDE or am i creating my files in notepad?
I don't want to sound sarcastic and i definitely appreciate the three articles the author wrote, but i guess maybe because i program in VB i'm not seeing the big picture.

Thanks

Python is a multi purpose scripting language - you can use it for virtually any programming task you care to mention. It's great for writing small GUI applications (it has support for TKinter which is an easy to use GUI building API) and it's good for web scripting (in the same way as Perl is) too. You can use it to write admin scritps for unix machines, IRC clients on windows, telnet servers on Linux - whatever takes your fancy really.

The advantage of Python over something like Visual Basic is that Python is cross platform - the majority of python scripts will work on any platform that can host a python interpreter. It is also a great rapid prototype / development tool as it encourages reusable programming.

Python can even be used for writing Java programs thanks to JPython (or Jython) - a version of the Python language that compiles python scripts to executable java bytecode, allowing them to run on any java virtual machine and giving them access to Java's extensive class libraries.

In answer to your questions...

"what web server supports it?" - many web servers that allow you to write Perl CGI scripts will also let you run Python scripts - alternatively you can set up Python for use with Microsoft's ASP technology, or use Zope which is a Python "object publishing system" for use on the web.

"it easily connect to a relational database(Oracle, SQL Server)" - yes, there are python moduels available that let you do this (see www.python.org)

"does it support xml?" - yes, Python has exellent XML support - see the xml module in Python 2.0.

"Does it have a nice IDE or am i creating my files in notepad?" - there are several IDE's available (many written in Python) but any text editor will do the job just fine.

In the 2nd while loop example I receive the following error.
<br />

<br />
File &quot;./while01.py&quot;, line 12, in ?
<br />
factorial = factorial * num
<br />
OverflowError: integer multiplication
<br />

<br />
Anyone want to tell me why?
<br />

<br />
tm
<br />

I understand that this is a multi-purpose language, and I can use it for almost anything that I want to create. I also understand that this series of articles is meant to give us a basic understanding of how the language operates. But the author is spending alot of time on basic data-crunching concepts, and not enough time on what we can use these concepts for. I'd like to see an actual project or program walked through in one of the upcoming articles. So far the article's are great. Pick up the pace a bit, and please keep up the good work!

Integer overflow.

Change the definition of factorial from:

factorial=1

to

factorial=1L

try www.python.org or www.zope.org for more information on python. Zope is an open source application server written in python. There are also very useful and active irc conversations ongoing on 24x7 in #zope and #python.

An easy way to increase the strength of the prime number tester is to add this bit of code to the program:
After
num = input(Gimme... )
write
from math import sqrt
i = sqrt(num)
i = int(i)
for count in range(2,i)
.... et cetera
Whereas my computer had memory errors at around 4.9 million the above method encounters errors at around 25 trillion. So it is able to check numbers that are n**2 as large as the first method.

Python 101 \(part 3\): A Twist In The Tail (http://www.devshed.com/c/a/Python/Python-101-part-3-A-Twist-In-The-Tail)

Find out more about adding flow control to your Python programs with the "for" and "while" loops, see how the range() function can be used to generate number ranges, and learn all about list objects. And bring an old flame along for the ride.

Please discuss this article in this thread. You can read the article here (http://www.devshed.com/c/a/Python/Python-101-part-3-A-Twist-In-The-Tail).










privacy (GDPR)