Contents of this page:
Options:
Special Features:
Class modules are translated into Python code modules with a single class whose name is the nane of the VB class. By default, this class is a new style Python class (inherits from Object). All methods in the class are converted to unbound methods of the class. Properties are converted to Python properties but an error is raised if the property has both Let and Set decorators. Since Python has no equivalent of the Set keyword, the Property Set method is treated in the same way as a Property Let.
Attributes defined at the class level are assumed to be class attributes in the Python class. By default, the conversion respects the Public/Private scope of both attributes and methods but this can be disabled if desired.
VB | Python |
---|---|
|
|
Here are the options in the INI file:
[Classes] # Yes or No, whether to use new style classes for all classes UseNewStyleClasses = Yes
In addition to these specific options, some General options apply:
[General] # Yes or No, whether to respect Private status of variables RespectPrivateStatus = Yes # Prefix to use to tag data as private (Python normally uses __ but VB convention is m) PrivateDataPrefix = __ # Yes or No, whether to try to automatically extract docstrings from the code TryToExtractDocStrings = Yes
By default, all classes are created as new style Python classes (inheriting from Object). Old style classes can be created by setting the UseNewStyleClasses option to No.
VB | Python |
---|---|
|
|
Syntax: RespectPrivateStatus = Yes | No
By default, variables or methods defined as Private (which is the default in VB), will be marked as private in the Python module also. Private Python variables will be prefixed with a private marker (two underscores by default). Since Private is the default in VB, this can lead to a lot of hidden variables in the Python code. The RespectPrivateStatus option allows you to turn off the Private/Public switch.
VB | Python |
---|---|
|
|
Syntax: PrivateDataPrefix = prefix
If RespectPrivateStatus is set then each Private variable will be prefixed with the string specified by the PrivateDataPrefix option. By default this is two underscores, __, which means that Python will use name mangling to ensure that the names really are private. Changing this option allows names to converted to some other convention (eg m) which marks names but does not enforce privacy.
VB | Python |
---|---|
|
|
Syntax: TryToExtractDocStrings = Yes | No
If TryToExtractDocStrings is set then any contiguous block of comment lines found at the start of the module are interpretted as a docstring and added to the class definition. The docstring terminates with the first non-comment line.
VB | Python |
---|---|
|
|
Property Let, Get and Set methods are grouped using Python 2.2's property decorator. The accessor functions are automatically called get<Name> and set<Name>. No checking is performed to ensure that these names do not collide with other class methods.
VB | Python |
---|---|
|
|
If the VB class includes a Class_Initialize method, then this is translated to an __init__ method in the Python class.
VB | Python |
---|---|
|
|
If the VB class includes a Class_Terminate method, then this is translated to an __del__ method in the Python class. Although the Python __del__ method will be called upon object removal the exact details of when this is called are not guaranteed to match those in the VB program.
VB | Python |
---|---|
|
|