9 Replies - 3085 Views - Last Post: 29 October 2012 - 06:29 PM Rate Topic: -----

#1 KBoogle  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 93
  • Joined: 15-April 10

What is Python best suited for?

Posted 29 October 2012 - 08:23 AM

Since you have to use the right tool for the right job, I'm wondering what would Python be most suitable for? I was looking at some of MIT's opencourseware and it seems most of their programming courses teach Python.
Is This A Good Question/Topic? 0
  • +

Replies To: What is Python best suited for?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: What is Python best suited for?

Posted 29 October 2012 - 08:26 AM

From the horse's mouth:


Quote

What is Python good for?

Python is a high-level general-purpose programming language that can be applied to many different classes of problems.

The language comes with a large standard library that covers areas such as string processing (regular expressions, Unicode, calculating differences between files), Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, CGI programming), software engineering (unit testing, logging, profiling, parsing Python code), and operating system interfaces (system calls, filesystems, TCP/IP sockets). Look at the table of contents for The Python Standard Library to get an idea of what’s available. A wide variety of third-party extensions are also available. Consult the Python Package Index to find packages of interest to you.



http://docs.python.o...python-good-for
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,466
  • Joined: 27-December 08

Re: What is Python best suited for?

Posted 29 October 2012 - 08:28 AM

Moved to Python.
Was This Post Helpful? 0
  • +
  • -

#4 KBoogle  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 93
  • Joined: 15-April 10

Re: What is Python best suited for?

Posted 29 October 2012 - 08:50 AM

So, it's a little bit of everything? It can be used for desktop apps, for web apps, for games, for commercial applications?

Maybe I'm misreading the quote but this seems to make Python like PHP (i.e, the double-clawed hammer of programming tools)?

Also, how does it compared to C++? Say, why would I (or rather, why did the professors at MIT) decided to teach Python instead of C++? If I learn Python as my first language, how transferable is that knowledge to other languages?
Was This Post Helpful? 0
  • +
  • -

#5 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7577
  • View blog
  • Posts: 12,737
  • Joined: 19-March 11

Re: What is Python best suited for?

Posted 29 October 2012 - 09:20 AM

I've used it mostly for small quick utilities. My girlfriend needed a temperature-humidity logger for her archive - built the logger on arduino and processed the data in python. She got thousands of image files from a vendor - scans of old city council minutes - which were simply numbered (1.tiff, 2.tiff, etc) so I wrote a few quick scripts to let her indicate the break points in the sequence came, and then create folders and move the files so her CMS could track the documents correctly. She's still doing the data entry, but my my calculations that's in the tens of thousands of keystrokes saved, with under a hundred lines of python.

At work, I've built some small tools in python - build/deploy scripts for the new website that we're developing, some attempts to automate documentation (which I really should return to), that sort of thing.

I've also used it for playing with math. For example, if you've done the first OCW python course, you'll remember the "McNuggets problem". There's an interesting algorithm for finding the maximal number which is not a solution of some diophantine equation in that form. This algorithm is very nicely expressed in python, and it turns out that you can solve this problem iteratively in time proportional to the smallest coefficient expressed in the set of terms, which is not what you'd expect from Guttag's presentation of the problem.


I wouldn't say it's anything at all like PHP. Closer to perl, really, although it's a lot nicer to work with and a lot less opaque to read. Nor is it much like C++ - python is a high-level language. (meaning, here, that you have no access to the machine level except through wrappers, there is no way and no need to address memory locations directly)

Learning python as your first language would probably prepare you to work well in modern high-level languages. Python has the capacity to work in a functional idiom (functions are first-class objects, meaning you can pass and return a function just as you can a variable or an object). This means that you can play with the ideas of lisp and its offshoots and languages like Ruby, Haskell, and so forth.

I'm still not sure I'd put someone into python as a first language. Java still seems reasonable to me for that role, but I could be convinced on this point.
Was This Post Helpful? 1
  • +
  • -

#6 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1150
  • View blog
  • Posts: 2,529
  • Joined: 05-May 05

Re: What is Python best suited for?

Posted 29 October 2012 - 09:21 AM

Quote

So, it's a little bit of everything? It can be used for desktop apps, for web apps, for games, for commercial applications?


I think it's used a lot in system administration. Parsing XML and all that Internet-type stuff is done easily in Python. I like to think of it as taking Perl's place. Most commercial games are built in C++, so I wouldn't say Python is used for gaming, although you can build a game in any language. There are some web app frameworks that are built in Python.

Quote

Also, how does it compared to C++? Say, why would I (or rather, why did the professors at MIT) decided to teach Python instead of C++? If I learn Python as my first language, how transferable is that knowledge to other languages?


Python is a good starting point for programming novices. Python has a functional aspect to it that makes it simple and elegant syntactically, yet it's still as powerful as a general-purpose language. If you think about it, checked exceptions and type checking is just a bunch of safety assurances that only become important in production software, not college homework so much. They're important to learn at some point, but I think they're nuances for students trying to learn first principles. It's nice not having to deal with a bunch of boilerplate.

At some point, students usually learn C/C++ for Systems Programming and Operating Systems. As most programmers would say, once you know a single language pretty well, it's not hard learning a new one. It really comes down to practicing in it. C/C++ is the exception in that you have to learn pointers, which seems to be troublesome for students initially, but beside that, it's not too much different from any other language. As far as the type system goes, Java/C/C++ requires that you declare types and that you're satisfying checks.

Quote

I wouldn't say it's anything at all like PHP. Closer to perl, really, although it's a lot nicer to work with and a lot less opaque to read.


We're seeing eye-to-eye Jon.

This post has been edited by blackcompe: 29 October 2012 - 09:23 AM

Was This Post Helpful? 2
  • +
  • -

#7 KBoogle  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 93
  • Joined: 15-April 10

Re: What is Python best suited for?

Posted 29 October 2012 - 09:39 AM

Thanks! That explains it better :)
Was This Post Helpful? 0
  • +
  • -

#8 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

Re: What is Python best suited for?

Posted 29 October 2012 - 10:28 AM

Python has great standard libraries, so it's a good language for those small tasks you need to solve from time to time. For instance, one of the students at my university wrote a small script to extract some data from an html file and print it in about five minutes.

It can be used for anything, though, large projects too. And don't listen to the people who claim that it's "too slow". Sure, C++ is faster, but with today's hardware, Python is usually more than fast enough.
Was This Post Helpful? 0
  • +
  • -

#9 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7577
  • View blog
  • Posts: 12,737
  • Joined: 19-March 11

Re: What is Python best suited for?

Posted 29 October 2012 - 10:35 AM

I have to say, I still use perl for a lot of tasks. The difference between the two is interesting. AS I think about it, I think perl is a language that lets you describe processes very well, while python lets you describe outcomes.

In perl, I think of the work as being more telling the computer what things to do, in what order. Python, at least when I do it right, feels to me like I'm telling the computer what I want the state of things to be when I'm done. This might explain why python is more suited to higher-level tasks, and also why python code tends to be cleaner.
Was This Post Helpful? 1
  • +
  • -

#10 SegFaulty  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 35
  • Joined: 11-October 10

Re: What is Python best suited for?

Posted 29 October 2012 - 06:29 PM

As Tayacan said, you can use it for large projects as well as small projects. In fact, there's a few programs for the Linux Desktop Environment GNOME that are written in Python that are quite large.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1