Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

pyargs

Create keyword argument for Python function

Syntax

kwa = pyargs(argKey,argValue)

Description

example

kwa = pyargs(argKey,argValue) creates one or more pyargs keyword arguments to pass to a Python® function.

Examples

collapse all

Create a calendar.

cal = py.calendar.TextCalendar;

Display the calendar for December 2014.

formatmonth(cal,int32(2014),int32(12))
ans = 

  Python str with no properties.

       December 2014
Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Display the function signature from the Python documentation for the calendar.TextCalendar.formatmonth function.

py.help('calendar.TextCalendar.formatmonth')
Help on method formatmonth in calendar.TextCalendar:

calendar.TextCalendar.formatmonth = formatmonth(self, theyear, themonth, w=0, l=0) unbound calendar.TextCalendar method
    Return a month's calendar string (multi-line).

Notice that arguments w and l are optional, with default values of 0.

Now display the function signatures in MATLAB®.

methods(cal,'-full')

Search the output for the formatmonth function signature.

lhs formatmonth(self, theyear, themonth, w, l, pyargs)

Change the value of the line spacing argument l to 2 using a pyargs argument.

formatmonth(cal,int32(2014),int32(12),pyargs('l',int32(2)))
ans = 

  Python str with no properties.

       December 2014

Mo Tu We Th Fr Sa Su

 1  2  3  4  5  6  7

 8  9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

29 30 31

Input Arguments

collapse all

Python function keyword arguments specified as one or more comma-separated pairs of argKey,argValue arguments. argKey is the Python function key name and is a string or character vector. argValue is the argument value, represented by any type. Use the function argument list to identify argKey and argValue. You can specify several key and value pair arguments in any order as argKey1,argValue1,...,argKeyN,argValueN.

Example: 'length',int32(2)

Introduced in R2014b

Was this topic helpful?