- Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Notice: This DevSite page will soon be deleted per b/133171590. Please add this sample to GitHub if it is relevant still:
https://developers.google.com/api-client-library/python/reference/interactive_help
Interactive Help
You can use Python's help()
function in an interactive Python shell to view PyDoc generated documentation at the command-line. This is particularly useful to explore API methods. To do this, construct a service object for the API you are interested in and call help on the objects you construct.
From the command-line, start Python, build a service object, and get help on the service:
$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from googleapiclient.discovery import build >>> service = build("latitude", "v1") >>> help(service)Help on Resource in module googleapiclient.discovery object:
class Resource(builtin.object)
| A class for interacting with a resource.
|
| Methods defined here:
|
| init(self)
|
| currentLocation = methodResource(self)
| A collection resource.
|
| location = methodResource(self)
| A collection resource.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| dict
| dictionary for instance variables (if defined)
|
| weakref
| list of weak references to the object (if defined)
Note: The build()
function generates a service object at run time, so the initial help information describing an object is too generic to be useful. You can ignore the help header when looking for API-specific details.
The help command above output lists currentLocation
and location
as collection resources. Get help on the location
collection:
>>> help(service.location())Help on Resource in module googleapiclient.discovery object:
class Resource(builtin.object)
| A class for interacting with a resource.
|
| Methods defined here:
|
| init(self)
|
| delete = method(self, **kwargs)
| Deletes a location from the user's location history.
|
| Args:
| locationId: string, Timestamp of the location to delete (ms since epoch). (required)
|
| get = method(self, **kwargs)
| Reads a location from the user's location history.
|
| Args:
| locationId: string, Timestamp of the location to read (ms since epoch). (required)
| granularity: string, Granularity of the location to return.
|
| Returns:
| An object of the form
|
| { # A Location resource identifies a user's position at a particular time. It may include metadata about the user's position, such as a venue if the location was recorded at the time of a check-in.
| "kind": "latitude#location", # Kind of this item.
| "altitude": "", # Altitude of the location, in meters. Optional.
| "longitude": "", # Longitude of the location, in decimal degrees.
| "activityId": "", # Unique ID of the Buzz message that corresponds to the check-in associated with this location. Available only for check-in locations. Optional.
| "latitude": "", # Latitude of the location, in decimal degrees.
| "altitudeAccuracy": "", # Accuracy of the altitude value, in meters. Optional.
| "timestampMs": "", # Timestamp of the Location Resource, in milliseconds since the epoch (UTC). This is also the Location Resource's unique id.
| "speed": "", # Ground speed of the user at the time this location was recorded, in meters per second. Non-negative. Optional.
| "heading": "", # Direction of travel of the user when this location was recorded. In degrees, clockwise relative to true north. Optional.
| "accuracy": "", # Accuracy of the latitude and longitude coordinates, in non-negative meters. Optional.
| }
|
...
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| dict
| dictionary for instance variables (if defined)
|
| weakref
| list of weak references to the object (if defined)
The help output lists delete
as a method. Get help on the delete
method:
>>> help(service.location().delete)Help on method method in module googleapiclient.discovery:
method(self, **kwargs) method of googleapiclient.discovery.Resource instance
Deletes a location from the user's location history.Args: locationId: string, Timestamp of the location to delete (ms since epoch). (required)</pre>
For each method, the arguments are listed along with their types and descriptions. For example, the
list
method hasmin_time
,max_results
,max_time
, andgranularity
arguments.The
(required)
flag indicates that the argument must be supplied when calling the method; otherwise the argument is optional.Method arguments may also be flagged as
(repeated)
which indicates that you may pass in a Python list of values for that argument.