ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
8. Unix Specific Services
8.1 posix -- The most common POSIX system calls
8.2 pwd -- The password database
8.3 grp -- The group database
8.4 crypt -- Function to check Unix passwords
8.5 dl -- Call C functions in shared objects
8.5.1 Dl Objects
8.6 dbm -- Simple ``database'' interface
8.7 gdbm -- GNU's reinterpretation of dbm
8.8 termios -- POSIX style tty control
8.9 tty -- Terminal control functions
8.10 pty -- Pseudo-terminal utilities
8.11 fcntl -- The fcntl() and ioctl() system calls
8.12 pipes -- Interface to shell pipelines
8.13 posixfile -- File-like objects with locking support
8.14 resource -- Resource usage information
8.15 nis -- Interface to Sun's NIS (Yellow Pages)
8.16 syslog -- Unix syslog library routines
8.17 commands -- Utilities for running commands

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference >> 8. Unix Specific Services
ActivePython 2.4 documentation

8.5 dl -- Call C functions in shared objects

Availability: Unix.

The dl module defines an interface to the dlopen() function, which is the most common interface on Unix platforms for handling dynamically linked libraries. It allows the program to call arbitrary functions in such a library.

Warning: The dl module bypasses the Python type system and error handling. If used incorrectly it may cause segmentation faults, crashes or other incorrect behaviour.

Note: This module will not work unless sizeof(int) == sizeof(long) == sizeof(char *) If this is not the case, SystemError will be raised on import.

The dl module defines the following function:

open( name[, mode = RTLD_LAZY])
Open a shared object file, and return a handle. Mode signifies late binding (RTLD_LAZY) or immediate binding (RTLD_NOW). Default is RTLD_LAZY. Note that some systems do not support RTLD_NOW.

Return value is a dlobject.

The dl module defines the following constants:

RTLD_LAZY
Useful as an argument to open().

RTLD_NOW
Useful as an argument to open(). Note that on systems which do not support immediate binding, this constant will not appear in the module. For maximum portability, use hasattr() to determine if the system supports immediate binding.

The dl module defines the following exception:

exception error
Exception raised when an error has occurred inside the dynamic loading and linking routines.

Example:

>>> import dl, time
>>> a=dl.open('/lib/libc.so.6')
>>> a.call('time'), time.time()
(929723914, 929723914.498)

This example was tried on a Debian GNU/Linux system, and is a good example of the fact that using this module is usually a bad alternative.



See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved