teaching:progappchim:notions_avancees

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
teaching:progappchim:notions_avancees [2021/11/01 03:50] villersdteaching:progappchim:notions_avancees [2023/05/02 10:36] (Version actuelle) – [Générateurs et "yield"] villersd
Ligne 6: Ligne 6:
 ==== Itertools, zip,... ==== ==== Itertools, zip,... ====
   * [[https://medium.com/techtofreedom/7-levels-of-using-the-zip-function-in-python-a4bd22ee8bcd|7 Levels of Using the Zip Function in Python]]   * [[https://medium.com/techtofreedom/7-levels-of-using-the-zip-function-in-python-a4bd22ee8bcd|7 Levels of Using the Zip Function in Python]]
 +  * itertools.cycle() est une méthode utile pour répéter ou parcourir sans fin les éléments d'une liste ou d'une table itérativitertools.accumulate()
 +  * itertools.accumulate prend un itérable et une fonction d'accumulation, puis renvoie un itérateur.
 +
 ===== Générateurs et "yield" ===== ===== Générateurs et "yield" =====
   * [[http://fr.openclassrooms.com/informatique/cours/pratiques-avancees-et-meconnues-en-python/les-generateurs-2]]   * [[http://fr.openclassrooms.com/informatique/cours/pratiques-avancees-et-meconnues-en-python/les-generateurs-2]]
Ligne 13: Ligne 16:
   * [[http://code.activestate.com/recipes/580628-pluggable-python-generators/]]   * [[http://code.activestate.com/recipes/580628-pluggable-python-generators/]]
   * [[http://www.datadependence.com/2016/08/pythonic-code-video-series-yield-generators/|Processing Large Data Sets With Yield and Generators]]   * [[http://www.datadependence.com/2016/08/pythonic-code-video-series-yield-generators/|Processing Large Data Sets With Yield and Generators]]
 +  * [[https://levelup.gitconnected.com/return-vs-yield-in-python-a-short-comic-f714465a0e92|Return VS Yield in Python — A Short Comic]] Liu Zuo Lin, 04/2023, Medium
 +
  
 ===== Liste en compréhension ===== ===== Liste en compréhension =====
Ligne 22: Ligne 27:
   * [[https://gist.github.com/bearfrieze/a746c6f12d8bada03589]]   * [[https://gist.github.com/bearfrieze/a746c6f12d8bada03589]]
   * [[https://medium.com/code-85/a-beginners-guide-to-python-list-comprehensions-7dbb0039f065|A Beginner’s Guide to Python List Comprehensions]] (Jonathan Hsu, Medium, 23/04/2020)   * [[https://medium.com/code-85/a-beginners-guide-to-python-list-comprehensions-7dbb0039f065|A Beginner’s Guide to Python List Comprehensions]] (Jonathan Hsu, Medium, 23/04/2020)
 +  * [[https://iam-akshay.medium.com/python-one-liner-superb-tricks-c611aad98553|Python one-liner superb tricks]] Akshay Jain, Medium, 16/04/2022
 +  * [[https://theanup.medium.com/10-powerful-python-one-liners-for-daily-use-8733dac0bc2c|15 Powerful Python One-Liners for Daily Use]] Anup Das, Medium, 22/11/2022
 +
 +==== One-line if - then - else (ternary operator) ====
 +<code python>
 +u = 10
 +v = 100
 +reponse = "u plus grand que v" if u > v else "v plus grand ou égal à u"
 +print(reponse)
 +</code>
 +
  
 ===== map, filter, reduce, lambda, pipe ===== ===== map, filter, reduce, lambda, pipe =====
   * [[https://towardsdatascience.com/write-clean-python-code-using-pipes-1239a0f3abf5|Write Clean Python Code Using Pipes - A Short and Clean Approach to Processing Iterables]] Khuyen Tran, medium, october 2021   * [[https://towardsdatascience.com/write-clean-python-code-using-pipes-1239a0f3abf5|Write Clean Python Code Using Pipes - A Short and Clean Approach to Processing Iterables]] Khuyen Tran, medium, october 2021
 +  * [[https://towardsdatascience.com/comparing-list-comprehensions-vs-built-in-functions-in-python-which-is-better-1e2c9646fafe|Comparing List Comprehensions vs. Built-In Functions in Python: Which Is Better?
 +An in-depth analysis of syntax, readability, and performance]] Thomas A Dorfer, Medium, 21/03/2023
   * ...   * ...
 +
 +===== Walrus operator =====
 +FIXME
 +
 +===== Le rôle du caractère underscore en Python =====
 +  * [[https://www.datacamp.com/community/tutorials/role-underscore-python|Role of Underscore(_) in Python Tutorial - In this tutorial, you're going to learn about the uses of underscore(_) in python]] Hafeezul Kareem Shaik, Medium (DataCmap) October 26th, 2018
 +  * [[https://www.geeksforgeeks.org/underscore-_-python/]]
  
 ===== Transformations et manipulations de chaînes (string) ===== ===== Transformations et manipulations de chaînes (string) =====
Ligne 58: Ligne 83:
   * [[http://linuxfr.org/news/travailler-avec-des-expressions-rationnelles]]   * [[http://linuxfr.org/news/travailler-avec-des-expressions-rationnelles]]
   * [[https://fr.wikipedia.org/wiki/Expression_rationnelle]]   * [[https://fr.wikipedia.org/wiki/Expression_rationnelle]]
 +  * [[http://www.analyticsvidhya.com/blog/2015/06/regular-expression-python/|Beginners Tutorial for Regular Expressions in Python]]
 +  * [[https://medium.com/@valeria.aynbinder.edu/python-regular-expressions-cheat-sheet-cd0992c36f6f|Python Regular Expressions — cheat sheet - Many code examples + useful tips]] Valeria Aynbinder, Medium, 17/03/2022
   * ...   * ...
 ===== Décorateurs ===== ===== Décorateurs =====
Ligne 101: Ligne 128:
 ===== Interface utilisateur graphique (GUI) ===== ===== Interface utilisateur graphique (GUI) =====
   * [[https://medium.com/analytics-vidhya/how-to-build-your-first-desktop-application-in-python-7568c7d74311|How to build your first Desktop Application in Python]] Ampofo Amoh - Gyebi, Medium, 12/12/2020   * [[https://medium.com/analytics-vidhya/how-to-build-your-first-desktop-application-in-python-7568c7d74311|How to build your first Desktop Application in Python]] Ampofo Amoh - Gyebi, Medium, 12/12/2020
 +
 +===== emails =====
 +smtplib et poplib :
 +  * [[https://twitter.com/driscollis/status/1508506999268552713]]
 +  * [[https://twitter.com/driscollis/status/1508570173606928386]]
 +
 +<code python>
 +import smtplib 
 +
 +HOST = "smtp.mydomain.com"
 +SUBJECT = "Test email from Python"
 +TO = "mike@mydomain.com"
 +FROM = "python@mydomain.com"
 +text = "blah blah blah"
 +BODY = "\r\n".join((
 +    f"From: {FROM}",
 +    f"To: {TO}",
 +    f"Subject: {SUBJECT}",
 +    "",
 +    text) 
 +)
 +server = smtplib.SMTP(HOST)
 +server.sendmail(FROM, [TO], BODY)
 +server.quit() 
 +</code>
 +
 +<code python>
 +import poplib
 +
 +mailbox = poplib.POP3('pop3.host.com')
 +mailbox.user("USERNAME")
 +mailbox.pass_("PASSWORD")
 +numMessages = len(mailbox.list()[1])
 +for i in range(numMessages):
 +    for j in mailbox.retr(i+1)[1]:
 +    print(j) 
 +</code>
 +
 +===== Création et gestion de packages =====
 +  * [[https://medium.com/jacklee26/how-to-create-the-first-python-package-de6464799bc3|How to create the first python package]] ChenChih, Medium, Dec 18, 2021
  
 ===== Références ===== ===== Références =====
  • teaching/progappchim/notions_avancees.1635735013.txt.gz
  • Dernière modification : 2021/11/01 03:50
  • de villersd