Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan 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 a pyargs keyword argument to pass to a Python® function.

Examples

collapse all

Create a calendar.

cal = py.calendar.TextCalendar;

Display 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

Read 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).

Arguments w and l are optional, with default values of 0.

Read the function signature in MATLAB®.

methods(cal,'-full')
lhs formatmonth(self, theyear, themonth, w, l, pyargs)

Search the output for the formatmonth function signature. You can use the pyargs argument instead of the optional w and l arguments.

Change the line spacing, l, 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?