Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66872
| Date | 2014-02-22 14:30 +1100 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: New to working with APIs, any good tutorials/books/guides? |
| References | <53080f5d$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7250.1393041395.18130.python-list@python.org> (permalink) |
On 22Feb2014 02:45, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Fri, 21 Feb 2014 12:12:00 -0800, ApathyBear wrote: > > [...] or in any other language > > for that matter? If an API is defining rules in C, is all hope lost for > > trying to use it in python? > > If an API is defined for a C library or function, then, no, you can't use > it in Python, or Lisp, or Ruby, just as you can't use a Lisp function in > C or Forth or Pascal. Not unless one or the other language makes special > provision to allow such cross-language communication. What Steven says is true, at the simplest level. However, MANY popular APIs that come with (for example) C libraries and which are documented in terms of a C programming interface have Python modules whose entire purpose in life is to present a Python API which in turn accesses the C API for you. For one example, consider the "bsddb" Python 2 module, which is part of the standard library: if you have Python 2, you have the bsddb module: http://docs.python.org/2/library/bsddb.html#module-bsddb The BSD dbm libraries are C libraries with a C API. However, the bsddb module is a Python module which contains python calls which operate on BSD dbm files. If you're using Python, you can use this module, which of course has a _Python_ API, to use the BSD dbm library. So: if you have some library which has a C API, it is possible that there is a Python module which interfaces to it, and that module will have a Python API. You may need to fetch such a module from a third place, such as PyPI. Cheers, -- Cameron Simpson <cs@zip.com.au> Who are all you people and why are you in my computer? - Kibo
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
New to working with APIs, any good tutorials/books/guides? ApathyBear <nirchernia@gmail.com> - 2014-02-20 23:59 -0800
Re: New to working with APIs, any good tutorials/books/guides? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 09:19 +0000
Re:New to working with APIs, any good tutorials/books/guides? Dave Angel <davea@davea.name> - 2014-02-21 06:49 -0500
Re: New to working with APIs, any good tutorials/books/guides? ApathyBear <nirchernia@gmail.com> - 2014-02-21 12:12 -0800
Re: New to working with APIs, any good tutorials/books/guides? Joel Goldstick <joel.goldstick@gmail.com> - 2014-02-21 15:21 -0500
Re: New to working with APIs, any good tutorials/books/guides? Roy Smith <roy@panix.com> - 2014-02-21 20:52 -0500
Re: New to working with APIs, any good tutorials/books/guides? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 02:45 +0000
Re: New to working with APIs, any good tutorials/books/guides? Cameron Simpson <cs@zip.com.au> - 2014-02-22 14:30 +1100
csiph-web