From 91668db130de16a0ee177cb58f77f497e8901612 Mon Sep 17 00:00:00 2001 From: Jose de Jesus Chavez Date: Fri, 26 Feb 2021 19:13:19 -0600 Subject: [PATCH] Update Commands --- docs/python/functools | 10 +++++++++ docs/python/tuples | 48 ++++++++++++++++++++++++++++++++++++++++ scripts/python/functools | 3 +++ scripts/python/tuples | 3 +++ 4 files changed, 64 insertions(+) create mode 100755 docs/python/functools create mode 100755 docs/python/tuples create mode 100755 scripts/python/functools create mode 100755 scripts/python/tuples diff --git a/docs/python/functools b/docs/python/functools new file mode 100755 index 0000000..185524c --- /dev/null +++ b/docs/python/functools @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "python + +Description: +functools + + +@cache +@total_ordering" diff --git a/docs/python/tuples b/docs/python/tuples new file mode 100755 index 0000000..4975417 --- /dev/null +++ b/docs/python/tuples @@ -0,0 +1,48 @@ +#!/bin/bash + +echo "python + +Description: +tuples + +Tuples are objects that can store a specific number of other objects in order. +They are immutable, meaning we can't add, remove, or replace objects on the fly. + +Tuples are used to store data; behavior cannot be associated with a tuple. +If we require behavior to manipulate a tuple, we hace to pass the tuple into +function. + +Examples: +stock = \"FB\", 177.46, 178.67, 175.79 +or +stock2 = (\"FB\", 177.46, 178.67, 175.79) + +Access to tuple: +stock = \"FB\", 177.46, 178.67, 175.79 +print(stock[2]) +or +stock = \"FB\", 177.46, 178.67, 175.79 +symbol, current, hight, low = stock +print(symbol) + + +Named tuples + +from collections import namedtuple + +Stock = namedtuple(\"Stock\", [\"symbol\", \"current\", \"high\", \"low\"]) +stock = Stock(\"FB\", 177.46, 178.67, 175.79) +stock.symbol + + +Dataclasses + +from dataclasses import dataclass + +@dataclass +class DataClassCard: + name: str + current: float + high: float + low: float +" diff --git a/scripts/python/functools b/scripts/python/functools new file mode 100755 index 0000000..81b7bb5 --- /dev/null +++ b/scripts/python/functools @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "New command created" diff --git a/scripts/python/tuples b/scripts/python/tuples new file mode 100755 index 0000000..81b7bb5 --- /dev/null +++ b/scripts/python/tuples @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "New command created"