Skip to content

symartin/python-tips-and-tricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python tips and tricks

GitHub license

Description

GitHub license

Some python snippets/examples and jupyter notebooks I made over the time that could be useful (hopefully) to someone 😀.

PyQt5

Generic QWidget and QObject.

  • zmq_server: Simple Qt objects to bridge Qt and ZMQ in the case of a request-reply pattern (REQ/REP):
  • icons: Utility class to create QIcons easily from a library of icons

Utilities

  • flattenable_dict.py: Subclass of the dict class to allow a dictionary to be flattened and unflattened as a list of lists

Jupyter notebooks

This section is quite old, and it is far to be my best work.

  • Selection ROI.ipynb the purpose of this code is to demonstrate how to simply make a Bokeh graph communicate with the Jupyter python kernel (without using the heavy framework Bokeh Server).

  • Hdf5.ipynb A simple function to extract the image data from HDF5 file generated by the STXM experiment at Synchrotron SOLEIL

Code style

this code respect most of the PEP8 (and following) guidance, except for the line break at 79 (or 80) characters. The hard-break is at 120 and except for natural or easy break before 80, the line should break inbetween 80 and 100. (because, nobody use 12" screen anymore, come-on !). obviously, web link cannot be broke

In addition, one the major problem in coding style is to be coherent with the different libraries, which, for historical reasons, have different styles. It is clearly the case between the python and the Qt or the Logging library for example. To reconcile those two worlds, It has been chosen to follow library guideline over the PEP8 for all related code.

One can read the following blog explaining this choice and how to implement it :

Finally, the comments follow sphinx style and reStructuredText standard.

Licence

Copyright

  • Copyright (c) 2019-2023 Sylvain Martin

About

Some python snippets/examples and jupyter notebooks

Topics

Resources

License

Stars

Watchers

Forks