View previous topic :: View next topic |
Author |
Message |
Grubbish Just Arrived

Joined: 23 Nov 2005 Posts: 0 Location: wouldn't you like to know;-)

|
Posted: Wed Dec 07, 2005 10:55 pm Post subject: Real applications to python |
|
|
Are there any real applications to learning python? I'm just curious because what i've read thus far, though not alot, doesn't seem at all helpful....
|
|
Back to top |
|
 |
Stormhawk Trusted SF Member


Joined: 26 Aug 2003 Posts: 31 Location: Warwickshire, England, UK

|
Posted: Wed Dec 07, 2005 11:23 pm Post subject: |
|
|
Python is an incredibly useful language.
For a start, its similarity to languages such as C++ (and Java) allow rapid prototyping of complex class hierarchies, which can be changed and tested rapidly in Python, whereas in C++ or Java, you'd have to recompile the hierarchy every time you wanted to test it.
Python also has modules which support web scripting, making it as versatile as PHP in that department.
Python has arbitrary precision mathematical operations, allowing scientific computation to be performed easily.
Python's syntax is closer to the English language than many programming languages, making it easy to learn, and even easier to read and understand if you are not already a competent Python programmer.
With the vast quantity of modules included in the standard library, and available on the web, Python can do just about anything, and automates most programming tasks. The Twisted framework provides excellent networking capability, and Python itself is reasonably fast for an interpreted language.
In conclusion, I've listed just a few of Python's benefits. Many large companies (Google included) use Python. It is, I would say, one of the fastest growing languages, with an ever increasing userbase, and jumping on the bandwagon can only be a good thing!
|
|
Back to top |
|
 |
Grubbish Just Arrived

Joined: 23 Nov 2005 Posts: 0 Location: wouldn't you like to know;-)

|
Posted: Fri Dec 09, 2005 6:29 am Post subject: |
|
|
Do you know of any sites that have pre-made code that I could look at? All the tutorials I've found only show commands and don't show sample programs.....
|
|
Back to top |
|
 |
comrade Just Arrived


Joined: 15 Feb 2005 Posts: 0

|
|
Back to top |
|
 |
Stormhawk Trusted SF Member


Joined: 26 Aug 2003 Posts: 31 Location: Warwickshire, England, UK

|
Posted: Fri Dec 09, 2005 3:18 pm Post subject: |
|
|
As it happens, I'm writing one right now. Its basically a frontend to SCP, the secure copy program which is part of OpenSSH, allowing me to synchronise local and remote versions of a directory structure. I wrote it mainly because I update my website HTML and PHP code by writing it locally and using scp to transfer it to the server, but with large sites it can take some time to transfer the entire site, so I automated the process of finding out which files have been locally modified since the last sync, and uploading only those using scp.
I created two new modules in order to help with this. One which uses pexpect (http://pexpect.sourceforge.net) to interface with SSH and SCP, and one which extends tkSimpleDialog's Dialog class and askstring() function to prompt for a password (basically the same as prompting for a string, except it is displayed as '*'s instead of the actual characters).
Note that the upload all option currently works, but the Synchronise option does not yet; I need to add code to stat the local and remote files and check their modification times, and also to cache the remote stat results after an upload so that subsequent uploads do not necessarily always incur the overhead of remote stats...
Anyway, the code as it is so far is available at
http://www.coldblue.net/sitesync-0.9a.tar.gz
and a screenshot at
http://www.coldblue.net/sitesync.png
Hope this helps with your endeavour to learn Python!
|
|
Back to top |
|
 |
comrade Just Arrived


Joined: 15 Feb 2005 Posts: 0

|
Posted: Fri Dec 09, 2005 4:19 pm Post subject: |
|
|
Out of curiosity why didn't you leverage the already existing (python) code of rsync/rdiff-backup?
(Ahh..speaking of a app to look at. rdiff-backup is great
|
|
Back to top |
|
 |
Stormhawk Trusted SF Member


Joined: 26 Aug 2003 Posts: 31 Location: Warwickshire, England, UK

|
Posted: Fri Dec 09, 2005 5:18 pm Post subject: |
|
|
I wanted to use SSH, basically. I don't allow FTP or rsync or other unencrypted transfer protocols on my server, except HTTP of course!
Also, I'm sure there are already modules which interface with SSH, but I didn't need full generality, just the ability to run a remote command (stat) and use scp, so I wrote a module to do just that.
|
|
Back to top |
|
 |
|