calling an api in python code

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Apr 13 02:50:38 CEST 2015


On Mon, 13 Apr 2015 10:31 am, Pippo wrote:

> I am new in this matter.. I need some help to understand how do I call an
> api in python code?

Your question is too general. It is like:


"I am new to carpentry and wood-working. How do I use a tool?"

Which tool? Hammer, electric drill, hand saw, electric saw, screwdriver,
crowbar, something else?


The API tells you how to use a library. That's what API means: "Application
Programming Interface".

The API for integers includes:

  - add integers using the + operator: 1 + 2
  - multiply integers using the * operator: 3 * 4

The API for strings include:

  - use either single quotes to create a string: 'hello world'
  - or double quotes: "hello world"
  - call the upper() method with no arguments to return an uppercase 
    version   of the string: 'hello'.upper() -> 'HELLO'
  - call the split() method with no arguments to split the string
    on whitespace: 'hello world'.split() -> ['hello', 'world']
  - call the split() method with a string argument to split the string
    on that string: 'hello world'.split('o') -> ['hell', 'w', 'rld']

and so on and so on and so on. Can you ask a more specific question?


-- 
Steven




More information about the Python-list mailing list