November 23, 2018 By Carlos Santana 2 min read

Develop Python Actions using Python 3.7

We are happy to announce that you can develop Python Actions using Python 3.7. You can use this version of Python by specifying the runtime in the CLI with “–kind python:3.7” or selecting Python 3 in the UI when creating a new Action.

What’s new in Python 3.7

The update for Python 3.7 provides a wide range of features, including the following:

  • Context variables

  • Data classes

  • Postponed evaluation of type annotations

  • Customization of access to module attributes

  • The time module gained support for functions with nanosecond resolution

For a complete list of changes, check out the Python 3.7 release notes.

Migrate your Actions to the new Python 3.7

IBM Cloud Functions continues to support creating new Actions using Python 3.6 and Python 2.7. But, it is encouraged to start taking advantage of the new features and performance gains Python 3.7 offers over older versions of Python.

The new Python 3.7 runtime comes with a new major semantic version of the Watson SDK 2.x; the older runtime kind “python:3.6” remains using Watson SDK 1.x to allow a smooth migration of your serverless application utilizing version 1.x of the Watson SDK to the new version 2.x.

In addition, the Python 3.7 runtime includes pip packages for IBM services such as “ibm_db,” “cloudant,” “ibm-cos-sdk,” and “ibmcloudsql.” For a complete list of pip packages included with the runtime, check the IBM Cloud Functions documentation.

New to IBM Cloud Functions?

Excellent! Welcome aboard. The best way to try out the service or get started quickly is to use a hello world action. To read more about using Python and Functions, check out the docs.

Download the IBM CLI and the Functions plugin. Create a file called hello.py that contains the following code:

def main(args):
name = args.get("name", "World")
greeting = "Hello " + name
return {"body": greeting}

Deploy your action as a web action:

ibmcloud fn action update helloPython hello.py --kind python:3.7 --web true

Get the URL for the web action and open it in your browser by running the following command.:

ibmcloud fn action get helloPython --url

More from Announcements

IBM and MuleSoft expand global relationship to accelerate modernization on IBM Power 

2 min read - As companies undergo digital transformation, they rely on APIs as the backbone for providing new services and customer experiences. While APIs can simplify application development and deliver integrated solutions, IT shops must have a robust solution to effectively manage and govern them to ensure that response times and costs are kept low for all applications. Many customers use Salesforce’s MuleSoft, named a leader by Gartner® in full lifecycle API management for seven consecutive times, to manage and secure APIs across…

IBM Consulting augments expertise with AWS Competencies: A win-win for clients 

3 min read - In today's dynamic economic landscape, businesses demand continuous innovation and speed of execution. At IBM Consulting®, our unwavering focus on partnerships and shared commitment to delivering enterprise-level solutions to mutual clients have been core to our success.   We are thrilled to announce that IBM® has recently gained five competencies from Amazon Web Services (AWS) in vital domains including Cloud Operations, Internet of Things (IoT), Life Sciences, Mainframe Modernization, and Telecommunications. With these credentials, IBM further establishes its position as a…

Probable Root Cause: Accelerating incident remediation with causal AI 

5 min read - It has been proven time and time again that a business application’s outages are very costly. The estimated cost of an average downtime can run USD 50,000 to 500,000 per hour, and more as businesses are actively moving to digitization. The complexity of applications is growing as well, so Site Reliability Engineers (SREs) require hours—and sometimes days—to identify and resolve problems.   To alleviate this problem, we have introduced the new feature Probable Root Cause as part of Intelligent Incident…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters