Toon posts:

[Python] Waar is goed voor?

Pagina: 1
Acties:
  • 310 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik vroeg me eigenlijk af, python is leuk maar waar is het nou eigenlijk goed voor? je zult toch voor alle doeleinden wel een betere taal vinden niet?

  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
DJ_PP: Je zult toch voor alle doeleinden wel een betere taal vinden niet?
Aan welke doeleinden denk je dan en aan welke talen?

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


Verwijderd

Topicstarter
Op woensdag 26 december 2001 17:39 schreef mbravenboer het volgende:

[..]

Aan welke doeleinden denk je dan en aan welke talen?
nee ik vraag meer waar is Python nou echt goed in?

  • Johannes
  • Registratie: Juni 2000
  • Laatst online: 10-05 16:54
Ik zal maar ff een stukje van mezelf op de frontpage bij de software update van Python 2.2 hier c/p-en.
Om maar eens ff een advertentiepraatje voor Python te houden :P :

Wat is Python?
Python is een interpreted, OO programmeertaal. Het is ontworpen om modulair te zijn, heeft exceptions(error handling), dynamische, high level typen en classes. Het heeft een heel erg duidelijke syntax, waarbij indent verplicht is:
code:
1
2
3
4
5
while 1: 
    if 0: 
    module.do_something() 

module.do_something_else()


Zoals je ziet levert het verplicht zijn van indents nette code op. Verder heeft Python interfaces naar allerlei systeem functies, libraries en GUI libs(waarvan de standaard TKinter is). Python is zelf makkelijk uit te breiden in C of C++, maar het kan ook gebruikt worden in C, C++ of Java programma's, als scriptingtaal. Uiteindelijk is Python ook nog portable, het draait op Mac, DOS, Win9x, WinNT, OS/2 en veel soorten Unix, waaronder natuurlijk Linux

/reclamepraatje

Maar waar kun je Python nou eigenlijk voor gebruiken?
Ik gebruik het vooral als vervanger van shell scripting, en het voordeel is dat ik de scripts op allebei de platforms van m'n dualboot systeempje kan draaien. Ik ben ook de laatste tijd bezig met het schrijven van een IRC client in C++(erg origineel, ik weet het), en hierbij gebruik ik Python als IRC scripting taal.

Een laatste voordeel van Python is dat de code die je erin schrijft vergeleken met de code voor hetzelfde in C++, vaak zo'n 5 tot 10 keer kleiner is, waardoor ontwikkeling ook veel sneller gaat.

Uit volle borst op weg naar nergens / Zonder reden zonder doel
Met m'n zeden en m'n zonden / En mijn angstig voorgevoel
Laat mij mijn kont tegen de krib / Laat mij dit goddeloze lied
Hef jij je handen maar ten hemel / Maar red mij niet


  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
Check de docs ;) .

Ik heb een paar interessante stukken uit de FAQ gevist en indien nodig wat nadruk gelegd op punten die ik goed vind.

Zie voor meer vragen: http://www.python.org/doc/FAQ.html . Het stuk over het design van Python vind je misschien ook interessant.
What is Python good for?

Python is used in many situations where a great deal of dynamism, ease of use, power, and flexibility are required.

In the area of basic text manipulation core Python (without any non-core extensions) is easier to use and is roughly as fast as just about any language, and this makes Python good for many system administration type tasks and for CGI programming and other application areas that manipulate text and strings and such.

When augmented with standard extensions (such as PIL, COM, Numeric, oracledb, kjbuckets, tkinter, win32api, etc.) or special purpose extensions (that you write, perhaps using helper tools such as SWIG, or using object protocols such as ILU/CORBA or COM) Python becomes a very convenient "glue" or "steering" language that helps make heterogeneous collections of unrelated software packages work together. For example by combining Numeric with oracledb you can help your SQL database do statistical analysis, or even Fourier transforms. One of the features that makes Python excel in the "glue language" role is Python's simple, usable, and powerful C language runtime API.

Many developers also use Python extensively as a graphical user interface development aide.
Is Python a good language in a class for beginning programmers?

Yes. This long answer attempts to address any concerns you might have with teaching Python as a programmer's first language. <knip>

It is still common to start students with a procedural (subset of a) statically typed language such as Pascal, C, or a subset of C++ or Java. I think that students may be better served by learning Python as their first language. Python has a very simple and consistent syntax and a large standard library. Most importantly, using Python in a beginning programming course permits students to concentrate on important programming skills, such as problem decomposition and data type design.

With Python, students can be quickly introduced to basic concepts such as loops and procedures. They can even probably work with user-defined objects in their very first course. They could implement a tree structure as nested Python lists, for example. They could be introduced to objects in their first course if desired. For a student who has never programmed before, using a statically typed language seems unnatural. It presents additional complexity that the student must master and slows the pace of the course. The students are trying to learn to think like a computer, decompose problems, design consistent interfaces, and encapsulate data. While learning to use a statically typed language is important, it is not necessarily the best topic to address in the students' first programming course.

Many other aspects of Python make it a good first language. Python has a large standard library (like Java) so that students can be assigned programming projects very early in the course that do something. Assignments aren't restricted to the standard four-function calculator and check balancing programs. By using the standard library, students can gain the satisfaction of working on realistic applications as they learn the fundamentals of programming. Using the standard library also teaches students about code reuse.

Python's interactive interpreter also enables students to test language features while they're programming. They can keep a window with the interpreter running while they enter their programs' source in another window. <knip>

With the interpreter, documentation is never far from the student as he's programming.

<knip>

If your department is currently using Pascal because it was designed to be a teaching language, then you'll be happy to know that Guido van Rossum designed Python to be simple to teach to everyone but powerful enough to implement real world applications. Python makes a good language for first time programmers because that was one of Python's design goals. There are papers at http://www.python.org/doc/essays/ on the Python website by Python's creator explaining his objectives for the language. One that may interest you is titled "Computer Programming for Everybody" http://www.python.org/doc/essays/cp4e.html

<knip>

While Python, its source code, and its IDEs are are freely available, this consideration consideration should not rule out other languages. There are other free languages (Java, free C compilers), and many companies are willing to waive some or all of their fees for student programming tools if it guarantees that a whole graduating class will know how to use their tools. That is, if one of the requirements for the language that will be taught is that it be freely available, then Python qualifies, but this requirement does not preclude other languages.

While Python jobs may not be as prevalent as C/C++/Java jobs, teachers should not worry about teaching students critical job skills in their first course. The skills that win students a job are those they learn in their senior classes and internships. Their first programming courses are there to lay a solid foundation in programming fundamentals. The primary question in choosing the language for such a course should be which language permits the students to learn this material without hindering or limiting them.

Another argument for Python is that there are many tasks for which something like C++ is overkill. That's where languages like Python, Perl, Tcl, and Visual Basic thrive. It's critical for students to know something about these languages. (Every employer for whom I've worked used at least one such language.) Of the languages listed above, Python probably makes the best language in a programming curriculum since its syntax is simple, consistent, and not unlike other languages (C/C++/Java) that are probably in the curriculum. By starting students with Python, a department simultaneously lays the foundations for other programming courses and introduces students to the type of language that is often used as a "glue" language. As an added bonus, Python can be used to interface with Microsoft's COM components (thanks to Mark Hammond). There is also Jython, a Java implementation of the Python interpreter, that can be used to connect Java components.

If you currently start students with Pascal or C/C++ or Java, you may be worried they will have trouble learning a statically typed language after starting with Python. I think that this fear most often stems from the fact that the teacher started with a statically typed language, and we tend to like to teach others in the same way we were taught. In reality, the transition from Python to one of these other languages is quite simple.

To motivate a statically typed language such as C++, begin the course by explaining that unlike Python, their first language, C++ is compiled to a machine dependent executable. Explain that the point is to make a very fast executable. To permit the compiler to make optimizations, programmers must help it by specifying the "types" of variables. By restricting each variable to a specific type, the compiler can reduce the book-keeping it has to do to permit dynamic types. The compiler also has to resolve references at compile time. Thus, the language gains speed by sacrificing some of Python's dynamic features. Then again, the C++ compiler provides type safety and catches many bugs at compile time instead of run time (a critical consideration for many commercial applications). C++ is also designed for very large programs where one may want to guarantee that others don't touch an object's implementation. C++ provides very strong language features to separate an object's implementation from its interface. Explain why this separation is a good thing.

The first day of a C++ course could then be a whirlwind introduction to what C++ requires and provides. The point here is that after a semester or two of Python, students are hopefully competent programmers. They know how to handle loops and write procedures. They've also worked with objects, thought about the benefits of consistent interfaces, and used the technique of subclassing to specialize behavior. Thus, a whirlwind introduction to C++ could show them how objects and subclassing looks in C++. The potentially difficult concepts of object-oriented design were taught without the additional obstacles presented by a language such as C++ or Java. When learning one of these languages, the students would already understand the "road map." They understand objects; they would just be learning how objects fit in a statically typed languages. Language requirements and compiler errors that seem unnatural to beginning programmers make sense in this new context. Many students will find it helpful to be able to write a fast prototype of their algorithms in Python. Thus, they can test and debug their ideas before they attempt to write the code in the new language, saving the effort of working with C++ types for when they've discovered a working solution for their assignments. When they get annoyed with the rigidity of types, they'll be happy to learn about containers and templates to regain some of the lost flexibility Python afforded them. Students may also gain an appreciation for the fact that no language is best for every task. They'll see that C++ is faster, but they'll know that they can gain flexibility and development speed with a Python when execution speed isn't critical.
Vanwege de voordelen van Python zie ik het veel gebruikt worden als 'scripting' taal waarmee je applicaties die gebouwd zijn in statisch getypeerde talen zoals Java dynamischer kan maken. De compacte syntax en de combinatie van paradigma's leent zich hier uitstekend voor...

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • sebas
  • Registratie: April 2000
  • Laatst online: 16-12-2025
verplichte kost is als je je met python bezig houdt ook http://www.zope.org

lees daar maar eens wat het is en wat je ermee allemaal kan, erg koele app, ik werk er zelf veel mee.

* sebas heeft alleen als echt scriptkiddo nog problemen met python, maargoed, dat ligt denk ik aan mezelf.

[ot] is het copy pasten van enorme lappen manuals en doc's ineens in de mode gekomen?

Everyone complains of his memory, no one of his judgement.


  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
Sebas: is het copy pasten van enorme lappen manuals en doc's ineens in de mode gekomen?
De tekst komt uit een veel grotere pagina. Omdat het waarschijnlijk niet gelezen zal worden als ik ernaar verwijs heb ik het hier neer gezet. Bovendien kon ik zo aangeven welke stukken is relevant/interessant vond. Of dit een mode is weet ik niet, handig/nuttig vond ik het in dit geval wel :+ .

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • sebas
  • Registratie: April 2000
  • Laatst online: 16-12-2025
klopt ook wel, alleen vind ik het hier dan zo irritant als ik vier uur moet scrollen voordat ik de laatste reactie zie.

bovendien vind ik dat je je iets meer had kunnen beperken, maargoed geen gezeik meer van mijn kant ;)


prettige kerst nog :P

Everyone complains of his memory, no one of his judgement.


Verwijderd

Topicstarter
Sebas schreef het volgende:
prettige kerst nog :P
jij ook

  • dusty
  • Registratie: Mei 2000
  • Laatst online: 21-02 00:06

dusty

Celebrate Life!

Op woensdag 26 december 2001 19:37 schreef Sebas het volgende:
klopt ook wel, alleen vind ik het hier dan zo irritant als ik vier uur moet scrollen voordat ik de laatste reactie zie.
Hebben ze een "end" knop voor uitgevonden.

Back In Black!
"Je moet haar alleen aan de ketting leggen" - MueR


Verwijderd

Topicstarter
Op donderdag 27 december 2001 07:04 schreef dusty het volgende:

[..]

Hebben ze een "end" knop voor uitgevonden.
waar zit die dan :P?

Verwijderd

ff over python. Ik vind python zeer goed. maar er is een probleempje. Het word altijd opgeslagen als .py
Een bestand met daarin een Python programma openen (de naam van zo'n bestand dient op .py te eindigen)


dit stukje tekst komt uit een niet officieel python tutorial

Verwijderd

Python is voor veel doel einde goed. Het voor veel gebruikt in de bio/medische sector.
Wij krijgen het op school (Bio-Informatica) omdat het een relatief makkelijk te leren taal is en omdat het platform onafhankelijk is (zoals de meeste talen). Het heeft goede ondersteuning op alle platformen en bijna alle op Unix/Linux gebaseerde distributies hebben standaard python, dit is wel handig aangezien wij veel Unix/Linus gebruiken :P.

  • .oisyn
  • Registratie: September 2000
  • Laatst online: 22:07

.oisyn

Moderator Devschuur®

Demotivational Speaker

Laten we even geen oude koeien uit de sloot halen :)

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.

Pagina: 1

Dit topic is gesloten.