Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
python [2019/01/11 00:17]
root [Logging Config via ini File]
python [2019/05/09 05:49] (current)
root [Setting up Local Environments]
Line 16: Line 16:
 <code python> <code python>
 source <​folder>/​bin/​activate source <​folder>/​bin/​activate
 +</​code>​
 +
 +== Language Basics == 
 +
 +**Printing:​**
 +
 +variables can be appended with comma  (plus for string)
 +<code python>
 +print ("​file:​ " + name  + " last modified: ", last_modified,​ "year ", year)
 +<​code> ​
 +
 +The basic python **print** command includes a newline ​
 +<code python>
 +print("​hello without newline",​ end=''​) ​
 </​code>​ </​code>​
 == Try/Catch ==  == Try/Catch == 
Line 28: Line 42:
 </​code>​ </​code>​
  
 +
 +== File Processing and Samba Shared Folders == 
 +
 +
 +Python (on windows) can access a shared folder in the following format:
 +<code python>
 +import os
 +
 +path = '​\\\\seljy1-s0022\\Shared folder\\CCARE PROD\\History\\'​
 +
 +files = []
 +# r=root, d=directories,​ f = files
 +for r, d, f in os.walk(path):​
 +    for file in f:
 +        print( "file: " + file)
 +</​code> ​       ​
 +        ​
 == Logging ==  == Logging == 
  
Line 172: Line 203:
 r = requests.post(url,​ data=payload,​ headers=headers)4 r = requests.post(url,​ data=payload,​ headers=headers)4
 </​code>​ </​code>​
 +== Python Testing == 
 +* pytest https://​docs.pytest.org/​en/​latest/​
 +<code python>
 +def inc(x):
 +    return x + 1
 +
 +
 +def test_answer():​
 +    assert inc(3) == 5
 +</​code> ​   ​
 +
 +
 +
 == Python Transpiler ==  == Python Transpiler == 
 * [[https://​github.com/​atsepkov/​RapydScript | RapydScript]] is a pre-compiler for JavaScript. The syntax is very similar to Python, but allows JavaScript as well. This project was written as a cleaner alternative to CoffeeScript. * [[https://​github.com/​atsepkov/​RapydScript | RapydScript]] is a pre-compiler for JavaScript. The syntax is very similar to Python, but allows JavaScript as well. This project was written as a cleaner alternative to CoffeeScript.
 
python.1547194650.txt.gz · Last modified: 2019/01/11 00:17 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd