> For the complete documentation index, see [llms.txt](https://smallso.gitbook.io/tencent-cloud-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/client/select-routine.md).

# select\_routine 方法

## 简要

选择一个给定无服务器云函数的指定例程并返回给定无服务器云函数例程的 Python 原生函数实例。对该函数实例的调用等同于对给定无服务器云函数例程的调用，其关键字参数将作为给定无服务器云函数例程的关键字参数。

```python
def select_routine(self,
    region_id: str,
    namespace_name: str,
    function_name: str,
    routine_name: str,
    function_version: str = None,
    function_async: bool = False
)
```

{% content-ref url="/pages/-M238eWqdKCF8lEGGB3s" %}
[使用例程组织无服务器云函数](/tencent-cloud-sdk/python-best-practices/serverless-functions/native-invoke/routine.md)
{% endcontent-ref %}

## 参数

该方法的参数和参数描述如下：

| 参数                | 类型   | 必选 | 描述                                                                           |
| ----------------- | ---- | -- | ---------------------------------------------------------------------------- |
| region\_id        | str  | 是  | <p>选择的无服务器云函数所在数据中心的唯一标识符。</p><p>例如：<code>ap-shanghai</code></p>             |
| namespace\_name   | str  | 是  | <p>选择的无服务器云函数所在命名空间的名称。</p><p>例如：<code>default</code></p>                    |
| function\_name    | str  | 是  | <p>选择的无服务器云函数名称。</p><p>例如：<code>arithmetic</code></p>                        |
| routine\_name     | str  | 是  | <p>选择的无服务器云函数的例程的名称。</p><p>例如：<code>addend</code></p>                        |
| function\_version | str  | 否  | <p>选择的无服务器云函数版本名称。</p><p>如果该参数被忽略或设置为 <code>None</code>，默认为最新版本。</p>         |
| function\_async   | bool | 否  | <p>选择的无服务器云函数是否以异步的方式运行。</p><p>如果该参数被忽略或设置为 <code>None</code>，默认以同步方式运行。</p> |

## 返回值

该方法返回给定无服务器云函数例程的 Python 原生函数实例。

返回的函数实例将在内部调用方法 `routine_invoke` 实现对给定无服务器云函数例程的调用，其函数实例的返回值与方法 `routine_invoke` 的返回值一致。

{% content-ref url="/pages/-M23-4RP1co255UXMiay" %}
[routine\_invoke 方法](/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/client/routine-invoke.md)
{% endcontent-ref %}

## 异常

该方法预期行为不会主动引发任何异常。

## 示例

下面我们将通过一段 Python 代码向您演示如何使用该方法：

```python
addend = function_client.select_routine(
    region_id = 'ap-shanghai',
    namespace_name = 'default',
    function_name = 'arithmetic',
    routine_name = 'addend'
)

return_value: int = addend(
    value1 = 10,
    value2 = 20
)
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-serverless-functions >= 0.1.5
