Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'interfaces': 0.04; 'api.': 0.05; 'true,': 0.05; 'apis': 0.09; 'function,': 0.09; 'ruby,': 0.09; 'api': 0.11; 'python': 0.11; 'accesses': 0.16; 'api,': 0.16; 'bsd': 0.16; 'example)': 0.16; 'fetch': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'lisp': 0.16; 'lisp,': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'provision': 0.16; 'pypi.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simplest': 0.16; 'simpson': 0.16; 'subject:books': 0.16; 'subject:tutorials': 0.16; 'files.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'trying': 0.19; 'feb': 0.22; 'programming': 0.22; 'python?': 0.22; 'rules': 0.22; 'header:User-Agent:1': 0.23; 'documented': 0.24; 'module,': 0.24; 'cheers,': 0.24; 'subject:/': 0.26; '(for': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "d'aprano": 0.31; 'libraries': 0.31; 'steven': 0.31; 'interface': 0.32; 'says': 0.33; 'url:python': 0.33; 'fri,': 0.33; 'level.': 0.33; 'third': 0.33; 'subject:with': 0.35; "can't": 0.35; 'no,': 0.35; 'operate': 0.35; 'there': 0.35; 'library.': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'example,': 0.37; 'subject:New': 0.37; 'turn': 0.37; 'received:211': 0.38; 'url:library': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'then,': 0.60; 'hope': 0.61; 'lost': 0.61; 'entire': 0.61; 'course': 0.61; "you're": 0.61; 'you.': 0.62; 'content-disposition:inline': 0.62; 'such': 0.63; 'life': 0.66; 'special': 0.74; 'forth': 0.81; 'subject:good': 0.84 Date: Sat, 22 Feb 2014 14:30:10 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: New to working with APIs, any good tutorials/books/guides? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53080f5d$0$29985$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <53080f5d$0$29985$c3e8da3$5496439d@news.astraweb.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=HZAtEE08 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=4k2pvi01o8MA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=M1yejiiA3vQA:10 a=kZ7UWmmPAAAA:8 a=8AHkEIZyAAAA:8 a=M5Zkgs-0AjDetOncfmQA:9 a=CjuIK1q_8ugA:10 a=-HvVtth6-DsA:10 a=pyH5b1fOeEsA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393041395 news.xs4all.nl 2832 [2001:888:2000:d::a6]:42930 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66872 On 22Feb2014 02:45, Steven D'Aprano 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 Who are all you people and why are you in my computer? - Kibo