fixture def selenium(selenium): selenium.implicitly_wait(30) selenium.maximize_window() return selenium def test_one(selenium): try: selenium.get("http://www.python.org") assert "Python" in selenium.title elem = selenium.find_element_by_name("q") elem.send_keys("documentation") elem.send...
All DDL (Data Definition Language) statements are executed using a handle structure known as a cursor. The following examples show how to create the tables of the Employee Sample Database. You need them for the other examples. In a MySQL server, tables are very long-lived objects, and are...
import json import requests def handler (event, context): token = context.getToken() project_id = context.getProjectID() urn = 'urn:fss:xx-xxxxx-x:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:function:xxx:subfunction:latest' # Subfunction URN, which can be queried on the right of the topology on ...
The use_pure option and C extension were added in Connector/Python 2.1.1. The following example shows how to set use_pure to False. import mysql.connector cnx = mysql.connector.connect(user='scott', password='password', host='127.0.0.1', database='employees', use_pure=False) cnx.close...
You can also use theCode Blockparameter to define a function and call the function from theExpressionparameter. InPython, a function is defined with thedefstatement followed by the name of the function. A function can include required and optional arguments, or no arguments at all...
import ops import sys import re def ops_condition (o): print("It enters ops_condition") #configure eth condition to execute the ops script; status, err_str = o.interface.ifstat_subscribe("interface1", 1, "GigabitEthernet0/0/0", 2) return status def ops_execute (o): handle, err_des...
Here is an example of a simple blockchain in Python: import hashlib import json import random class Block: def __init__(self, timestamp, transactions, previous_hash): self.timestamp = timestamp self.transactions = transactions self.previous_hash = previous_hash self.nonce = random.randint(0...
, the administrator manages the router through a remote network and can upload a Python script to the router. Changes of important routes need to be monitored so that logs can be generated to communicate the changes of routes to users in a timely manner....
Note that you cannot install any Python packages into Docker-based project interpreters. Preparing an example Create a Python projectQuadraticEquation,addtheSolver.pyfile, and copy and paste the following code: importmathclassSolver:defdemo(self,a,b,c):d=b**2-4*a*cifd>0:disc=math.sqrt...
pip install -U yellowdog-python-examples If you're interested in including Jsonnet support, please see the Jsonnet Support section below. Script Installation with Pipx The commands can also be installed using pipx. This method requires Python 3.7+ and pipx to be installed. Pipx avoids the ...