Learning Python

From BF2 Technical Information Wiki
Revision as of 22:57, 9 September 2017 by UTurista (talk | contribs) (Creating page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Python is an open source, interpreted, very high level, dynamic, object-oriented programming language (whew!). A few other languages of this type are Perl, PHP, and Ruby. Among these languages, Python is particularly good at integrating with lower-level languages such as C/C++ and Java (Python can even run on top of a Java Virtual Machine, if you want).

Taking advantage of this ability to integrate with other languages, the Battlefield 2 game includes a core engine written in C++ that is inaccessible to developers (other than EA and DICE), and an embedded Python interpreter; non-EA/DICE developers are able to modify many aspects of how BF2 behaves, as well as add new behaviors, by modifying existing Python programs that are part of BF2, or by writing entirely new ones.


Some good resources for information about the Python language itself:


Python cookbooks, idioms, and design patterns


Some good printed books on Python:


Whether you are new to Python or are an experienced Pythonista trying to debug a program, you'll find that it's handy to have a regular Python interpreter (as opposed to the one embedded in BF2) installed on your PC to experiment with. The Python embedded in Battlefield 2 is an old version, 2.3.4; if you install a current version to experiment with be aware that there may be some differences between how it behaves and how BF2 Python behaves. The best places to download Python from are:


There are quite a few good IDEs (Integrated Development Environments) for Python. IDEs are (highly) glorified text editors that offer lots of features that are especially useful to programmers, such as integrated debuggers, class browsers, language documentation, automatic color-coding and line completion, etc. Some of the more noteworthy ones designed for use with Python:

  • IDLE: Included with the standard Python distribution; pretty basic, but fine if you're just starting out.
  • SPE: A full-featured open source Python IDE.
  • Boa Constructor: Another full-featured open source IDE.
  • Komodo: A very good commercial IDE (low-cost non-commercial version available).
  • BlackAdder: Another commercial IDE (free non-commercial version available).
  • Wing IDE: Yet another commercial IDE (low-cost "personal" version available).