The client-side Slice-to-Python mapping defines how Slice data types are translated to Python types, and how clients invoke operations, pass parameters, and handle errors. Much of the Python mapping is intuitive. For example, Slice sequences map to Python lists, so there is essentially nothing new you have to learn in order to use Slice sequences in Python.
The Python API to the Ice run time is fully thread-safe. Obviously, you must still synchronize access to data from different threads. For example, if you have two threads sharing a sequence, you cannot safely have one thread insert into the sequence while another thread is iterating over the sequence. However, you only need to concern yourself with concurrent access to your own data — the Ice run time itself is fully thread safe, and none of the Ice API calls require you to acquire or release a lock before you safely can make the call.
Much of what appears in this chapter is reference material. We suggest that you skim the material on the initial reading and refer back to specific sections as needed. However, we recommend that you read at least the mappings for exceptions, interfaces, and operations in detail because these sections cover how to call operations from a client, pass parameters, and handle exceptions.
In order to use the Python mapping, you should need no more than the Slice definition of your application and knowledge of the Python mapping rules. In particular, looking through the generated code in order to discern how to use the Python mapping is likely to be inefficient, due to the amount of detail. Of course, occasionally, you may want to refer to the generated code to confirm a detail of the mapping, but we recommend that you otherwise use the material presented here to see how to write your client-side code.
All of the APIs for the Ice run time are nested in the
Ice module, to avoid clashes with definitions for other libraries or applications. Some of the contents of the
Ice module are generated from Slice definitions; other parts of the
Ice module provide special-purpose definitions that do not have a corresponding Slice definition. We will incrementally cover the contents of the
Ice module throughout the remainder of the manual.
A Python application can load the Ice run time using the
If the statement executes without error, the Ice run time is loaded and available for use. You can determine the version of the Ice run time you have just loaded by calling the
icever = Ice.stringVersion()
- Python Mapping for Identifiers
- Python Mapping for Modules
- Python Mapping for Built-In Types
- Python Mapping for Enumerations
- Python Mapping for Structures
- Python Mapping for Sequences
- Python Mapping for Dictionaries
- Python Mapping for Constants
- Python Mapping for Exceptions
- Python Mapping for Interfaces
- Python Mapping for Operations
- Python Mapping for Classes
- Asynchronous Method Invocation (AMI) in Python
- Code Generation in Python
- Using Slice Checksums in Python
- Example of a File System Client in Python