이전 항목

16. 추가된 추수 도전과제

다음 항목

1. The dot notation

현재 문서

주의사항

해당 문서는 중요 변경 작업 중에 있습니다. 일부 문서에 텍스트가 빠져있거나, 불어로 플레이스홀더(placeholder) 자리차지만 되어 있을 수 있습니다.

Introduction to OOP in Python with Reeborg

As you know, Reeborg is in poor shape. It can only turn to its left, its compass is broken as it can only be used to determine whether or not Reeborg is facing North. Reeborg cannot turn its head left, so it cannot find out if there is a wall to its left without turning its entire body. Finally, it leaks oil which is bad for itself and the environment.

Using the power of Object-Oriented Programming, you will learn how to fix Reeborg and how to give it additional capabilities.

For advanced programmers!

If you are not a beginner Python programmer and are experimenting on your own based on what you already know, you may find that some advanced but valid Python code you write will occasionally raise some unexpected exceptions. The reason is that most of the code powering Reeborg’s world is written in Javascript and there’s only a thin layer that has been written in Python using Brython. As a result some Javascript objects, methods or attributes are not directly available. Furthermore, animations are done by cloning and saving the world state as a JSON string; if you attempt to create your own class using some objects already present, you may unknowingly create a circular reference which will prevent the cloning and raise an exception.

I could have written the entire program in Python using Brython ... but it would have made the situation worse if I had tried to use the result to enable programmers to use Javascript or CoffeeScript as their language of choice – which they can do now.