software:python
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
software:python [2020/12/26 20:08] – superwizard | software:python [2020/12/27 05:23] (current) – [Plotly] superwizard | ||
---|---|---|---|
Line 384: | Line 384: | ||
Example 3 | Example 3 | ||
+ | < | ||
import re re.sub(' | import re re.sub(' | ||
• string1 - Result: 3.11899876595 | • string1 - Result: 3.11899876595 | ||
• string2 - Result: 2.78014397621 | • string2 - Result: 2.78014397621 | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Access Dates ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Access Dates | Access Dates | ||
Line 408: | Line 414: | ||
From < | From < | ||
- | |||
Line 415: | Line 420: | ||
From < | From < | ||
- | |||
- | |||
- | |||
- | |||
</ | </ | ||
Line 448: | Line 449: | ||
From < | From < | ||
- | |||
- | |||
</ | </ | ||
- | <WRAP center round box 60%> | + | ====== Parsing text with Python ====== |
+ | |||
+ | <WRAP center round box > | ||
2019-07-11 | 2019-07-11 | ||
Line 466: | Line 467: | ||
+ | </ | ||
+ | |||
+ | ====== DataFrames ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2019-08-14 | 2019-08-14 | ||
Line 475: | Line 481: | ||
+ | </ | ||
+ | |||
+ | ====== Backblaze ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2019-7-11 | 2019-7-11 | ||
Line 520: | Line 531: | ||
From < | From < | ||
+ | </ | ||
+ | ====== Regular Expression ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2019-05-29 | 2019-05-29 | ||
- | ValidIpAddressRegex = " | + | |
From < | From < | ||
+ | < | ||
\b(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | \b(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | ||
(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | ||
(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | ||
(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]? | ||
+ | </ | ||
From < | From < | ||
Line 542: | Line 560: | ||
From < | From < | ||
- | |||
- | |||
- | |||
- | |||
</ | </ | ||
- | ====== | + | ====== |
<WRAP center round box > | <WRAP center round box > | ||
Line 555: | Line 569: | ||
str.rpartition(sep) | str.rpartition(sep) | ||
+ | |||
Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty strings, followed by the string itself. | Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty strings, followed by the string itself. | ||
From < | From < | ||
+ | </ | ||
+ | ====== The built-in os module has a number of useful functions ====== | ||
+ | |||
+ | <WRAP center round box > | ||
The built-in os module has a number of useful functions that can be used to list directory contents and filter the results. To get a list of all the files and folders in a particular directory in the filesystem, use os.listdir() in legacy versions of Python or os.scandir() in Python 3.x. os.scandir() is the preferred method to use if you also want to get file and directory properties such as file size and modification date. | The built-in os module has a number of useful functions that can be used to list directory contents and filter the results. To get a list of all the files and folders in a particular directory in the filesystem, use os.listdir() in legacy versions of Python or os.scandir() in Python 3.x. os.scandir() is the preferred method to use if you also want to get file and directory properties such as file size and modification date. | ||
Line 565: | Line 584: | ||
+ | </ | ||
+ | |||
+ | ====== Splitting, Concatenating, | ||
+ | |||
+ | <WRAP center round box > | ||
2019-05-20 | 2019-05-20 | ||
Line 572: | Line 596: | ||
+ | </ | ||
+ | |||
+ | ====== Regex Testor ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Regex Testor | Regex Testor | ||
Line 577: | Line 606: | ||
https:// | https:// | ||
+ | </ | ||
+ | |||
+ | ====== processdokuwikifile ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2019-05-15 | 2019-05-15 | ||
+ | < | ||
def processdokuwikifile(in_file, | def processdokuwikifile(in_file, | ||
""" | """ | ||
- | #with open(' | + | #with open(' |
with open(par_out_file,' | with open(par_out_file,' | ||
out = csv.writer(out_file) | out = csv.writer(out_file) | ||
- | #with open(' | + | #with open(' |
- | #with open(' | + | #with open(' |
- | with open(in_file,' | + | with open(in_file,' |
+ | </ | ||
Line 607: | Line 643: | ||
From < | From < | ||
+ | </ | ||
+ | ====== PASS BY OBJECT REFERENCE (Case in python): ====== | ||
+ | <WRAP center round box > | ||
2019-04-08 | 2019-04-08 | ||
Line 614: | Line 653: | ||
PASS BY OBJECT REFERENCE (Case in python): | PASS BY OBJECT REFERENCE (Case in python): | ||
Here, " | Here, " | ||
+ | < | ||
def append_one(li): | def append_one(li): | ||
li.append(1) | li.append(1) | ||
Line 619: | Line 659: | ||
append_one(x) | append_one(x) | ||
print x | print x | ||
+ | </ | ||
+ | |||
Here, the statement x = [0] makes a variable x (box) that points towards the object [0] | Here, the statement x = [0] makes a variable x (box) that points towards the object [0] | ||
On the function being called, a new box li is created. The contents of li is the SAME as the contents of box x. Both the boxes contain the same object. That is, both the variables point to the same object in memory. Hence, any change to the object pointed at by li will also be reflected by the object pointed at by x. | On the function being called, a new box li is created. The contents of li is the SAME as the contents of box x. Both the boxes contain the same object. That is, both the variables point to the same object in memory. Hence, any change to the object pointed at by li will also be reflected by the object pointed at by x. | ||
Line 626: | Line 668: | ||
If the variable li is reassigned in the function, then li will point to a seperate object in memory. x however, will continue pointing to the same object in memory it was pointing to earlier. | If the variable li is reassigned in the function, then li will point to a seperate object in memory. x however, will continue pointing to the same object in memory it was pointing to earlier. | ||
Example: | Example: | ||
+ | < | ||
def append_one(li): | def append_one(li): | ||
li = [0, 1] | li = [0, 1] | ||
Line 631: | Line 674: | ||
append_one(x) | append_one(x) | ||
print x | print x | ||
+ | </ | ||
The output of the program will be: | The output of the program will be: | ||
[0] | [0] | ||
From < | From < | ||
+ | </ | ||
+ | ====== Plotly ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2019-03-31 | 2019-03-31 | ||
Plotly | Plotly | ||
+ | < | ||
1962_2006_walmart_store_openings.csv Update 1962_2006_walmart_store_openings.csv 4 years ago | 1962_2006_walmart_store_openings.csv Update 1962_2006_walmart_store_openings.csv 4 years ago | ||
2010_alcohol_consumption_by_country.csv Create 2010_alcohol_consumption_by_country.csv 3 years ago | 2010_alcohol_consumption_by_country.csv Create 2010_alcohol_consumption_by_country.csv 3 years ago | ||
2011_february_aa_flight_paths.csv Create 2011_february_aa_flight_paths.csv 4 years ago | 2011_february_aa_flight_paths.csv Create 2011_february_aa_flight_paths.csv 4 years ago | ||
2011_february_us_airport_traffic.csv Create 2011_february_us_airport_traffic.csv 4 years ago | 2011_february_us_airport_traffic.csv Create 2011_february_us_airport_traffic.csv 4 years ago | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Python write to CSV ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2019-03-29 | 2019-03-29 | ||
Line 655: | Line 711: | ||
Python write to CSV | Python write to CSV | ||
+ | < | ||
import csv | import csv | ||
with open(..., ' | with open(..., ' | ||
wr = csv.writer(myfile, | wr = csv.writer(myfile, | ||
wr.writerow(mylist) | wr.writerow(mylist) | ||
+ | </ | ||
From < | From < | ||
+ | < | ||
with open(iniFile.absolute(), | with open(iniFile.absolute(), | ||
#spamwriter = csv.writer(iniSettings, | #spamwriter = csv.writer(iniSettings, | ||
Line 672: | Line 731: | ||
for val in folder_list: | for val in folder_list: | ||
spamwriter.writerow(val) | spamwriter.writerow(val) | ||
+ | </ | ||
you can also use wr.writerows(list) – tovmeod Dec 25 '11 at 22:29 | you can also use wr.writerows(list) – tovmeod Dec 25 '11 at 22:29 | ||
Line 678: | Line 738: | ||
From < | From < | ||
+ | </ | ||
+ | ====== CSV in Python adding an extra carriage return, on Windows ====== | ||
+ | |||
+ | <WRAP center round box > | ||
CSV in Python adding an extra carriage return, on Windows | CSV in Python adding an extra carriage return, on Windows | ||
One of the possible fixes in Python3, as described in @YiboYang' | One of the possible fixes in Python3, as described in @YiboYang' | ||
+ | < | ||
f = open(path_to_file, | f = open(path_to_file, | ||
writer = csv.writer(f) | writer = csv.writer(f) | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Examples of simple type checking in Python: ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2019-02-17 | 2019-02-17 | ||
Examples of simple type checking in Python: | Examples of simple type checking in Python: | ||
+ | < | ||
assert type(variable_name) == int | assert type(variable_name) == int | ||
assert type(variable_name) == bool | assert type(variable_name) == bool | ||
assert type(variable_name) == list | assert type(variable_name) == list | ||
+ | </ | ||
From < | From < | ||
Use type | Use type | ||
+ | < | ||
>>> | >>> | ||
<type ' | <type ' | ||
Line 704: | Line 779: | ||
>>> | >>> | ||
' | ' | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== isinstance() ====== | ||
+ | |||
+ | <WRAP center round box > | ||
With one argument, return the type of an object. The return value is a type object. The isinstance() built-in function is recommended for testing | With one argument, return the type of an object. The return value is a type object. The isinstance() built-in function is recommended for testing | ||
Line 712: | Line 793: | ||
• Syntax: | • Syntax: | ||
+ | < | ||
isinstance(object, | isinstance(object, | ||
+ | </ | ||
The isinstance() takes two parameters: | The isinstance() takes two parameters: | ||
+ | < | ||
object : object to be checked | object : object to be checked | ||
classinfo : class, type, or tuple of classes and types | classinfo : class, type, or tuple of classes and types | ||
+ | </ | ||
From < | From < | ||
- | |||
- | |||
- | |||
</ | </ | ||
- | <WRAP center round box 60%> | + | ====== graph-cli ====== |
+ | |||
+ | <WRAP center round box > | ||
2019-01-05 | 2019-01-05 | ||
Line 736: | Line 820: | ||
+ | </ | ||
+ | |||
+ | ====== copy2 ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-12-25 | 2018-12-25 | ||
Line 742: | Line 831: | ||
As with the previous methods, | As with the previous methods, | ||
The syntax is as follows: | The syntax is as follows: | ||
+ | < | ||
shutil.copy2(src_file, | shutil.copy2(src_file, | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Start of String Only: \A ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Start of String Only: \A | Start of String Only: \A | ||
Line 751: | Line 847: | ||
From < | From < | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== Decimals interact well with much of the rest of Python ====== | ||
+ | |||
+ | <WRAP center round box > | ||
decimal — Decimal fixed point and floating point arithmetic | decimal — Decimal fixed point and floating point arithmetic | ||
Line 757: | Line 859: | ||
Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: | Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: | ||
+ | < | ||
>>> | >>> | ||
>>> | >>> | ||
Line 764: | Line 867: | ||
>>> | >>> | ||
Decimal(' | Decimal(' | ||
+ | </ | ||
From < | From < | ||
Decimals interact well with much of the rest of Python. Here is a small decimal floating point flying circus: | Decimals interact well with much of the rest of Python. Here is a small decimal floating point flying circus: | ||
+ | < | ||
>>> | >>> | ||
>>> | >>> | ||
Line 776: | Line 881: | ||
[Decimal(' | [Decimal(' | ||
| | ||
+ | </ | ||
From < | From < | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== splitting a number into the integer and decimal parts ====== | ||
+ | |||
+ | <WRAP center round box > | ||
+ | |||
splitting a number into the integer and decimal parts | splitting a number into the integer and decimal parts | ||
+ | < | ||
>>> | >>> | ||
>>> | >>> | ||
Line 788: | Line 902: | ||
147.0 | 147.0 | ||
>>> | >>> | ||
+ | </ | ||
If you want the integer part as an integer and not a float, use int(a// | If you want the integer part as an integer and not a float, use int(a// | ||
EDIT: Remember that the decimal part of a float number is approximate, | EDIT: Remember that the decimal part of a float number is approximate, | ||
Line 793: | Line 908: | ||
From < | From < | ||
+ | < | ||
import math | import math | ||
x = 1234.5678 | x = 1234.5678 | ||
math.modf(x) # (0.5678000000000338, | math.modf(x) # (0.5678000000000338, | ||
+ | </ | ||
From < | From < | ||
Line 801: | Line 918: | ||
Create a date object: | Create a date object: | ||
+ | < | ||
import datetime | import datetime | ||
x = datetime.datetime(2020, | x = datetime.datetime(2020, | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Module datetime provides ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Module datetime provides classes for manipulating date and time in more object oriented way. One of them is datetime.datetime.now which return number of seconds since the epoch. | Module datetime provides classes for manipulating date and time in more object oriented way. One of them is datetime.datetime.now which return number of seconds since the epoch. | ||
+ | < | ||
import datetime; | import datetime; | ||
ts = datetime.datetime.now().timestamp() | ts = datetime.datetime.now().timestamp() | ||
print(ts) | print(ts) | ||
# 1545665588.52 | # 1545665588.52 | ||
+ | </ | ||
+ | |||
From < | From < | ||
+ | < | ||
x = int(datetime.datetime(2070, | x = int(datetime.datetime(2070, | ||
print(x) | print(x) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Example 2: Right justify string and fill the remaining spaces ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Example 2: Right justify string and fill the remaining spaces | Example 2: Right justify string and fill the remaining spaces | ||
+ | < | ||
# example string | # example string | ||
string = ' | string = ' | ||
Line 830: | Line 965: | ||
# print right justified string | # print right justified string | ||
print(string.rjust(width, | print(string.rjust(width, | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | ====== Practical Business Python ====== | ||
+ | <WRAP center round box > | ||
2018-12-24 | 2018-12-24 | ||
Practical Business Python | Practical Business Python | ||
- | |||
pbpython/ | pbpython/ | ||
Line 846: | Line 983: | ||
+ | </ | ||
+ | ====== The divmod() returns ====== | ||
+ | <WRAP center round box > | ||
Line 857: | Line 997: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== numpy ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-11-18 | 2018-11-18 | ||
+ | < | ||
pip install numpy | pip install numpy | ||
+ | </ | ||
From < | From < | ||
+ | < | ||
pip3.6 install numpy | pip3.6 install numpy | ||
pip3.6 install scipy | pip3.6 install scipy | ||
Line 870: | Line 1018: | ||
Install opencv-python instead of cv2. | Install opencv-python instead of cv2. | ||
pip install opencv-python | pip install opencv-python | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== compare the use of lambda ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Line 880: | Line 1034: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Key Functions ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Key Functions | Key Functions | ||
Line 895: | Line 1054: | ||
This image was created with the following code. | This image was created with the following code. | ||
+ | < | ||
1 import operator | 1 import operator | ||
2 import pylab | 2 import pylab | ||
Line 922: | Line 1082: | ||
26 pylab.grid() | 26 pylab.grid() | ||
27 pylab.title(" | 27 pylab.title(" | ||
+ | </ | ||
From < | From < | ||
Line 927: | Line 1088: | ||
As already said, | As already said, | ||
Change: | Change: | ||
+ | < | ||
key=lambda(k, | key=lambda(k, | ||
+ | </ | ||
To: | To: | ||
+ | < | ||
key=lambda k, v: sort_order.index(k) | key=lambda k, v: sort_order.index(k) | ||
+ | </ | ||
From < | From < | ||
Line 936: | Line 1101: | ||
</ | </ | ||
- | <WRAP center round box 60%> | + | ====== What problem does pandas solve? ====== |
+ | |||
+ | <WRAP center round box > | ||
2018-11-15 | 2018-11-15 | ||
Line 946: | Line 1113: | ||
NumPy | NumPy | ||
+ | < | ||
NumPy is the fundamental package for scientific computing with Python. It contains among other things: | NumPy is the fundamental package for scientific computing with Python. It contains among other things: | ||
• a powerful N-dimensional array object | • a powerful N-dimensional array object | ||
Line 951: | Line 1119: | ||
• tools for integrating C/C++ and Fortran code | • tools for integrating C/C++ and Fortran code | ||
• useful linear algebra, Fourier transform, and random number capabilities | • useful linear algebra, Fourier transform, and random number capabilities | ||
+ | </ | ||
From < | From < | ||
Line 957: | Line 1126: | ||
From < | From < | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== scikit-learn ====== | ||
+ | |||
+ | <WRAP center round box > | ||
scikit-learn | scikit-learn | ||
Line 972: | Line 1147: | ||
From < | From < | ||
+ | </ | ||
+ | ====== python read fails on special characters ====== | ||
+ | <WRAP center round box > | ||
2018-11-06 | 2018-11-06 | ||
Line 987: | Line 1165: | ||
From < | From < | ||
+ | </ | ||
+ | ====== idle args ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-10-31 | 2018-10-31 | ||
Line 1002: | Line 1184: | ||
Pending application of a patch, the following will work to only add args to sys.argv when running from an Idle editor. | Pending application of a patch, the following will work to only add args to sys.argv when running from an Idle editor. | ||
+ | < | ||
import sys | import sys | ||
# ... | # ... | ||
Line 1016: | Line 1199: | ||
except: | except: | ||
sys.argv = [sys.argv[0], | sys.argv = [sys.argv[0], | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | ====== Auto detect IDLE and prompt for command-line argument values ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2018-10-31 | 2018-10-31 | ||
Line 1025: | Line 1214: | ||
Auto detect IDLE and prompt for command-line argument values | Auto detect IDLE and prompt for command-line argument values | ||
- | #! / | + | < |
+ | c#! / | ||
import sys | import sys | ||
def ok(x=None): | def ok(x=None): | ||
Line 1041: | Line 1231: | ||
root.bind("< | root.bind("< | ||
e.focus() | e.focus() | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== print the files deleted ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Line 1049: | Line 1245: | ||
Python Script | Python Script | ||
Here's a Python script that will also print the files deleted | Here's a Python script that will also print the files deleted | ||
+ | < | ||
import os | import os | ||
for line in open(" | for line in open(" | ||
Line 1060: | Line 1257: | ||
except OSError: | except OSError: | ||
pass | pass | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== delete directories ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Here's an alternative Python script that is case sensitive and will also delete directories included in the list | Here's an alternative Python script that is case sensitive and will also delete directories included in the list | ||
+ | < | ||
import os | import os | ||
import shutil | import shutil | ||
Line 1085: | Line 1290: | ||
# | # | ||
pass | pass | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== checkpoints ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-10-06 | 2018-10-06 | ||
GLOB | GLOB | ||
+ | < | ||
def delete_previous_checkpoints(self, | def delete_previous_checkpoints(self, | ||
""" | """ | ||
Line 1109: | Line 1321: | ||
ckpt_file_nm = self.get_checkpoint_location() + '/ | ckpt_file_nm = self.get_checkpoint_location() + '/ | ||
os.remove(ckpt_file_nm) | os.remove(ckpt_file_nm) | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | ====== argparse ====== | ||
+ | <WRAP center round box > | ||
2018-10-06 | 2018-10-06 | ||
Line 1120: | Line 1336: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Argparse Tutorial ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
Argparse Tutorial | Argparse Tutorial | ||
Line 1127: | Line 1349: | ||
From < | From < | ||
+ | < | ||
*args and **kwargs in Python | *args and **kwargs in Python | ||
*args | *args | ||
+ | </ | ||
The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function. It is used to pass a non-keyworded, | The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function. It is used to pass a non-keyworded, | ||
Line 1134: | Line 1358: | ||
+ | </ | ||
+ | |||
+ | ====== recursive ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-10-03 | 2018-10-03 | ||
Line 1143: | Line 1372: | ||
From < | From < | ||
+ | I have successfully used | ||
+ | < | ||
+ | for i in d.rglob(' | ||
+ | </ | ||
+ | |||
+ | < | ||
for i in d.iglob(' | for i in d.iglob(' | ||
+ | </ | ||
The “**” pattern means “this directory and all subdirectories, | The “**” pattern means “this directory and all subdirectories, | ||
Line 1149: | Line 1385: | ||
From < | From < | ||
+ | < | ||
errno.ENOTEMPTY | errno.ENOTEMPTY | ||
Directory not empty | Directory not empty | ||
+ | </ | ||
From < | From < | ||
+ | < | ||
errno.EACCES¶ | errno.EACCES¶ | ||
Permission denied | Permission denied | ||
+ | </ | ||
From < | From < | ||
+ | < | ||
except OSError as e: | except OSError as e: | ||
if e.errno not in _IGNORED_ERROS: | if e.errno not in _IGNORED_ERROS: | ||
raise | raise | ||
return False | return False | ||
+ | </ | ||
From < | From < | ||
+ | < | ||
except OSError as e: | except OSError as e: | ||
if e.errno != EINVAL and strict: | if e.errno != EINVAL and strict: | ||
raise | raise | ||
+ | </ | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== walktree ====== | ||
+ | |||
+ | <WRAP center round box > | ||
2018-10-01 | 2018-10-01 | ||
Line 1199: | Line 1448: | ||
+ | </ | ||
+ | |||
+ | ====== Dropbox in python ====== | ||
+ | |||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2018-09-29 | 2018-09-29 | ||
Dropbox in python | Dropbox in python | ||
+ | < | ||
from pathlib import Path | from pathlib import Path | ||
import arrow | import arrow | ||
Line 1215: | Line 1471: | ||
#remove it | #remove it | ||
pass | pass | ||
+ | </ | ||
From < | From < | ||
Line 1223: | Line 1479: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== CSV Toolkit Overview ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2018-09-04 | 2018-09-04 | ||
Line 1231: | Line 1493: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== What is Bonobo? ====== | ||
+ | |||
+ | <WRAP center round box > | ||
What is Bonobo? | What is Bonobo? | ||
Bonobo is a lightweight Extract-Transform-Load (ETL) framework for Python 3.5+. | Bonobo is a lightweight Extract-Transform-Load (ETL) framework for Python 3.5+. | ||
Line 1242: | Line 1509: | ||
From < | From < | ||
+ | </ | ||
+ | |||
+ | ====== Awesome Python ====== | ||
+ | |||
+ | <WRAP center round box > | ||
Awesome Python | Awesome Python | ||
A curated list of awesome Python frameworks, libraries, software and resources. | A curated list of awesome Python frameworks, libraries, software and resources. | ||
Line 1257: | Line 1529: | ||
From < | From < | ||
+ | </ | ||
+ | ====== Python data visualization: | ||
+ | |||
+ | <WRAP center round box > | ||
2018-09-04 | 2018-09-04 | ||
Line 1266: | Line 1542: | ||
From < | From < | ||
+ | </ | ||
+ | ====== Best way to sort txt file using csv tools in python ====== | ||
+ | |||
+ | |||
+ | <WRAP center round box > | ||
2018-09-04 | 2018-09-04 | ||
Line 1274: | Line 1555: | ||
From < | From < | ||
+ | < | ||
import csv | import csv | ||
import operator | import operator | ||
Line 1290: | Line 1572: | ||
sortedlist=sorted(f, | sortedlist=sorted(f, | ||
print(sortedlist) | print(sortedlist) | ||
+ | </ | ||
From < | From < | ||
Line 1297: | Line 1580: | ||
2018-08-10 | 2018-08-10 | ||
The sys.path list contains the list of directories which will be searched for modules at runtime: | The sys.path list contains the list of directories which will be searched for modules at runtime: | ||
+ | < | ||
python -v | python -v | ||
>>> | >>> | ||
>>> | >>> | ||
['', | ['', | ||
+ | |||
+ | </ | ||
From < | From < | ||
For speedtest - / | For speedtest - / | ||
- | |||
</ | </ | ||
software/python.1609013319.txt.gz · Last modified: 2020/12/26 20:08 by superwizard