User Tools

Site Tools


other:python:misc_by_jyp

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
Last revision Both sides next revision
other:python:misc_by_jyp [2023/12/08 15:36]
jypeter Added the efficient looping section
other:python:misc_by_jyp [2024/04/17 09:25]
jypeter [Useful python stuff] Added the Extra tutorials section
Line 5: Line 5:
 </​WRAP>​ </​WRAP>​
  
 +===== Extra tutorials =====
  
 +Only **when you have already read all the content of this page several times**, and you are looking for new ideas
 +
 +  * [[https://​medium.com/​@yaduvanshineelam09/​ultimate-python-cheat-sheet-practical-python-for-everyday-tasks-8a33abc0892f|Ultimate Python Cheat Sheet: Practical Python For Everyday Tasks]]
 ===== Reading/​setting environments variables ===== ===== Reading/​setting environments variables =====
  
Line 314: Line 318:
  
  
-===== Efficient looping with numpy, map and itertools =====+===== Efficient looping with numpy, mapitertools ​and list comprehension ​=====
  
-<wrap hi>Big, nested, explicit loops should be avoided at all cost</​wrap>,​ in order to reduce a script execution time!+<wrap hi>Big, nested, explicit ​''​for'' ​loops should be avoided at all cost</​wrap>,​ in order to reduce a script execution time!
  
   * **''​numpy''​ arrays** should be used when dealing with //numerical data//   * **''​numpy''​ arrays** should be used when dealing with //numerical data//
Line 358: Line 362:
 ... ...
 A0$, A0!, A1$, A1!, B0$, B0!, B1$, B1!,</​code>​ A0$, A0!, A1$, A1!, B0$, B0!, B1$, B1!,</​code>​
 +
 +  * The [[https://​docs.python.org/​3/​tutorial/​datastructures.html?​highlight=comprehension#​list-comprehensions|list comprehension]] (aka //implicit loops//) can also be used to generate lists from lists
 +    * Example: converting a list of integers to a list of strings\\ Note: in that case, you should rather use the ''​map''​ function detailed above
 +      * <​code>>>>​ my_ints = [1, 2, 3]
 +
 +>>>​ [ str(ii) for ii in my_ints ]
 +['​1',​ '​2',​ '​3'​]</​code>​
 ===== numpy related stuff ===== ===== numpy related stuff =====
  
other/python/misc_by_jyp.txt · Last modified: 2024/04/19 12:02 by jypeter