Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

seabass069

macrumors regular
Original poster
Oct 5, 2005
226
0
Has anyone used the Python programming language? My friend was told she should learn this language. Someone at her work told her she should learn this language first, before learning other programming languages.
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
It's a good language and it forces structured programming and blocks of code. You must indent to succeed.

There are many tutorials and books on it.
 

therevolution

macrumors 6502
May 12, 2003
468
0
It's definitely a good choice for a first language. Its syntax is relatively simple. The interpreter is useful as well - with it, you can type in code one line at a time and get immediate feedback on what's happening. It's a very nice learning tool.
 

findhornriver

macrumors newbie
Oct 1, 2006
16
0
Maine
I would recommend wxPython. It is cross platform oop and very easy to use. Far easier than objective-c or c++! Write a program on your mac and it will port straight to a windows/linux box.

Uses the full python language but adds a wxWidgets framework that integrates well. It's fast, very productive, makes osx apps (with py2app) as well as windows .exe's (with py2exe). It's free too.

Altogether a simple oop language for any programming task. BTW, it works on intel or ppc macs... dunno why more people are not using it really.

I recommend the book wxPython in Action by Noel Rappin and Robin Dunn. You will be writing osx/windows apps in no time at all!
 

Kunimodi

macrumors member
Sep 8, 2006
65
0
Ashland, OR, USA
findhornriver said:
I would recommend wxPython. It is cross platform oop and very easy to use. Far easier than objective-c or c++! Write a program on your mac and it will port straight to a windows/linux box.

Uses the full python language but adds a wxWidgets framework that integrates well. It's fast, very productive, makes osx apps (with py2app) as well as windows .exe's (with py2exe). It's free too.

Altogether a simple oop language for any programming task. BTW, it works on intel or ppc macs... dunno why more people are not using it really.

I recommend the book wxPython in Action by Noel Rappin and Robin Dunn. You will be writing osx/windows apps in no time at all!
The stock Python (version 2.3.5 -- without readline support -- damn, Apple, catch up already ;) ) includes wxPython.
 

rtharper

macrumors regular
Sep 6, 2006
201
0
Oxford, UK
findhornriver said:
Altogether a simple oop language for any programming task. BTW, it works on intel or ppc macs... dunno why more people are not using it really.

Indentation as syntax has been known to cause some weird issues if you have multiple programmers scripting cross platform on different text editors, for one.

Also, it's still not as fast as lisp, c, c++, perl, java, etc, although pretty fast for an interpreted language.
 

Kunimodi

macrumors member
Sep 8, 2006
65
0
Ashland, OR, USA
rtharper said:
Indentation as syntax has been known to cause some weird issues if you have multiple programmers scripting cross platform on different text editors, for one.

Also, it's still not as fast as lisp, c, c++, perl, java, etc, although pretty fast for an interpreted language.

Python is not slow with proper usage (where it counts). Calling a library function has a small overhead, but once it is there it is native C (or C++) speed. Using libraries like NumPy you can write code that outpaces similar Java programs. It is also very easy to write C extensions and this allows for very quick prototyping in Python, followed by some profiling and then selective reimplementation in C if warranted. This approach can produce efficient results with much reduced development time.

I don't know what exactly you're refering to regarding cross platform indentation issues, but I'd like to know the details. Identation is purely a local issue -- it does not cross modules or even blocks of code. Different platforms sometimes have different line end character(s), but tabs and spaces are the same respective characters (except for EBCDIC).
 

findhornriver

macrumors newbie
Oct 1, 2006
16
0
Maine
rtharper said:
Indentation as syntax has been known to cause some weird issues if you have multiple programmers scripting cross platform on different text editors, for one.

Also, it's still not as fast as lisp, c, c++, perl, java, etc, although pretty fast for an interpreted language.

I've never seen or heard of indentation being an issue. The standard is 4 spaces for an indentation. That's not difficult whatever editor you are using. Most editors that I have used let you set up a TAB to equal and write 4 spaces in the code.

Speed. It's quite fast enough for just about any task (3D Quake lookalikes excepted). It's remarkably fast actually. And, with the ease of creating full GUI applications, it's a great language.
 

blenderxgrid

macrumors newbie
Oct 2, 2006
2
0
I work with Blender, which uses Python as its scripting language, and it's proven to be extremely useful. I remember reading an article many years ago entitled, "Python: the easiest scripting language you'll never use."

Contrary to that, I've found it quite useful and I use it on at least a weekly basis. Especially when I start geting around to coding a Plug in that will allow Blender users to submit jobs to Xgrid from within the application. But that's a ways and a lot free time off...
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
findhornriver said:
I've never seen or heard of indentation being an issue. The standard is 4 spaces for an indentation. That's not difficult whatever editor you are using. Most editors that I have used let you set up a TAB to equal and write 4 spaces in the code.
...

Standard indentation? That would be nice. Having written C code with 5 other team members, our code came from 3 different editors and the standard was different for each editor before the editors were customised to the developers' preferences.

I can see that there would be problems but when editing Python, editors should be more careful to force the output to use a specific spacing for all Python code.

Otherwise, where are those "pretty" programmes which re-formatted code way back when?
 

rtharper

macrumors regular
Sep 6, 2006
201
0
Oxford, UK
findhornriver said:
I've never seen or heard of indentation being an issue. The standard is 4 spaces for an indentation. That's not difficult whatever editor you are using. Most editors that I have used let you set up a TAB to equal and write 4 spaces in the code.

That's news to me. Use emacs and you'll quickly find that's not the case for several different uses. It has a Python mode, now, but not everyone is using emacs =)

Some text editors for source code will insert spaces. Others will insert tab characters. Tab characters have also, across different platforms, been used to both represent 8 spaces and 5 spaces. So yes, it is different =p I don't have firsthand knowledge of significant issues, but secondhand accounts from people that have switched to Lua.

findhornriver said:
Speed. It's quite fast enough for just about any task (3D Quake lookalikes excepted). It's remarkably fast actually. And, with the ease of creating full GUI applications, it's a great language.

Kunimodi said:
Python is not slow with proper usage (where it counts). Calling a library function has a small overhead, but once it is there it is native C (or C++) speed. Using libraries like NumPy you can write code that outpaces similar Java programs. It is also very easy to write C extensions and this allows for very quick prototyping in Python, followed by some profiling and then selective reimplementation in C if warranted. This approach can produce efficient results with much reduced development time.

I agree with you both that python is not slow in absolute terms, especially for an interpreted, garbage collected language. As someone that has written GUI apps in Perl versus C++, though, I can tell you there is a difference between interpreted and compiled performance even in those cases. And you can say many things about Perl, it's performance is similar to Python's for nearly all tasks.

You talked about implementation of C functions to hook in Python. I agree that that can result in very fast performance, I have seen such with Lua. However, for certain intensive tasks I would ask that at what point does it just make more sense to do more in C (sorry, I'm a big C fan =).

Like I said before, no matter how fast it is it doesn't beat a lot of other languages already out there for large, non-trivial tasks.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I've considered learning Python, but with knowledge in PHP and some in Perl, I decided to skip it and go straight to Ruby (and Rails).
 

findhornriver

macrumors newbie
Oct 1, 2006
16
0
Maine
@rtharper

You are a keen C programmer and I applaud that. I stated programming in C about 14 years ago and too enjoy the language. So please do not get me wrong. There's nothing wrong with C, but I think we are talking cross purposes.

Obviously, C is compiled and very fast. I am not refuting that it is a clear winner against Python in that area. But, as I said in my first post and will underline now, C is not nearly as easy to program a GUI as wxPython (which is Python with wxWidgets). Anyone using wxPython will tell you that it is much easier, not only to create interfaces, not only to write extensive programs, but to read the code and maintain the code years later.

Yes, an _experienced_ C or C++ programmer will do the same but only after years on the job. The disadvantage here is learning curve. Python is easier to learn and will get someone up and running, programming complete Windows, Linux and OSX (intel or ppc) apps in a far shorter time... far shorter.

Productivity is often more important than utter speed. Maintainability is often far more important than cpu time. Many apps do not need raw speed in CPU terms, they need speed in development terms. They need code that is more easily extended, maintained. Python is one such language that helps in these areas. It should be promoted for those reasons.

So lets get back to the original thread:-

"Has anyone used the Python programming language? My friend was told she should learn this language. Someone at her work told her she should learn this language first, before learning other programming languages."


Yes, it is a very good language. Quite fast enough for most work. Easy to learn and very efficient. Try wxPython... it creates full cross platform GUI apps which will run on Windows, Linux and OSX without any re-writing. It uses the operating systems look and feel so you would not know that the program had been written on anything but that system. I think, once you try it and learn a little, you will be very pleased. It will also help you develop skills for other languages you might try later on. Some curly bracket people have problems with indentation but take no notice ;-) It's no reason not to try the language and enjoy the huge benefits of rapid application development.
 

rtharper

macrumors regular
Sep 6, 2006
201
0
Oxford, UK
findhornriver said:
"Has anyone used the Python programming language? My friend was told she should learn this language. Someone at her work told her she should learn this language first, before learning other programming languages."


Yes, it is a very good language. Quite fast enough for most work. Easy to learn and very efficient. Try wxPython... it creates full cross platform GUI apps which will run on Windows, Linux and OSX without any re-writing. It uses the operating systems look and feel so you would not know that the program had been written on anything but that system. I think, once you try it and learn a little, you will be very pleased. It will also help you develop skills for other languages you might try later on. Some curly bracket people have problems with indentation but take no notice ;-) It's no reason not to try the language and enjoy the huge benefits of rapid application development.

Sorry for the thread derailment. You're totally right. Python is becoming popular so pragmatically speaking it's best learned whether you like it or not :D . It's very easy to learn and read, and lets you play around with a lot of different paradigms for one language (i.e. it has the features of several different types of languages combined). You'll feel comfortable transitioning to most other high-level programming languages in terms of concept, if not syntax (Python's is similar, but has its own distinct quirks, too =)).

If this is your first programming language, you'll be pleased with how fast you can write non-trivial applications without a whole lot of wading through "bureaucratic" code, and just say what you want to do. Enjoy python!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.