Learning Python - Page 1
Forum section: electronics / general

author: rstofer
author_rank: Super Contributor
timestamp: October 08, 2022, 03:38:33 pm
content: There are a lot of educational resources dedicated to teaching Python (courses at udemy, among others) but one I hadn't seen was the courseware from Amazon. They have quite a collection of courses.Here is a decent program covering both Python and Data Analytics for just $10https://www.amazon.com/dp/B0B96MY9M8The good news is that it uses Google Colab which means there is no need to set up a Python environment unless you want to.

author: madires
author_rank: Super Contributor
timestamp: October 08, 2022, 05:24:44 pm
content: Free and nice interactive online course:https://www.learnpython.org/

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 08, 2022, 06:49:59 pm
content: For those a bit more advanced, try this:https://www.youtube.com/c/PythonSimplified/videos

author: RoGeorge
author_rank: Super Contributor
timestamp: October 08, 2022, 06:58:00 pm
content: I like how this guy explains, very clear way of building an understanding,i.e. his tutorials about classes and decorators are one of the best on YT.https://www.youtube.com/c/ClearCode/videos11 hours teaching Python from zero, with examples and exercises.Has timestamp links in the video description to jump at the needed chapter.QuoteThe ultimate introduction to Python in 2022 [ + Exercises ]Other more advanced topics:7 simple tips for python beginnershttps://youtu.be/ESTf0ut14N0Understanding classes and object-oriented programming [Python Tutorial]https://youtu.be/_vr5faCXFo8Understanding decorators [Python tutorial]https://youtu.be/nVdF7QT-GggCreating 10 Apps in Python [ with PySimpleGui ]https://youtu.be/kQ8DGP9p2LYLearn Python by making games [ Trailer ]

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: October 08, 2022, 07:11:03 pm
content: I found Python is a little C like except for some keywords and indentation.I just got stuck into a website design and grabbed info as I needed it using internet search.Got there in the end.

author: MikeK
author_rank: Super Contributor
timestamp: October 08, 2022, 07:26:24 pm
content: "Automate the Boring Stuff With Python" is free online:https://automatetheboringstuff.com/

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 08, 2022, 07:30:33 pm
content: Quote from: MikeK on October 08, 2022, 07:26:24 pm

author: Picuino
author_rank: Super Contributor
timestamp: October 08, 2022, 07:52:13 pm
content: https://docs.python.org/3/tutorial/This is the official tutorial. In multiple languages.All documentation:https://docs.python.org/3/

author: rstofer
author_rank: Super Contributor
timestamp: October 09, 2022, 06:30:20 pm
content: There are dozens of sites offering beginner Python, no doubt. But does the same program spend the last half of the material on Data Analysis with Matplotlib, Pandas, SQL, and other tasks like building a recommender, scraping the web?None of these topics are taught in great depth, they are simply introductions for beginners. But it's a place to start. In fact, it seems like a perfect place to start before taking a more formal course. It'll be a few days before I complete the program. Let's see what I think after I do the work.

author: RoGeorge
author_rank: Super Contributor
timestamp: October 10, 2022, 01:02:55 am
content: For Pandas, Matplotlib and other popular modules on top of Python, Corey Schafer has a good tutorials channel:https://www.youtube.com/c/Coreyms

author: eti
author_rank: Super Contributor
timestamp: October 10, 2022, 07:50:12 am
content: Quote from: nigelwright7557 on October 08, 2022, 07:11:03 pmLike C? 🤔Nope. C has speed, and is compiled.

author: westfw
author_rank: Super Contributor
timestamp: October 10, 2022, 09:26:08 am
content: As I’ve told people: I know python now, which means that I can write python programs that look a lot like C code…Wrapping your head around all of existing libraries that you OUGHT to be using is a separate skill :-(

author: rstofer
author_rank: Super Contributor
timestamp: October 10, 2022, 02:34:22 pm
content: Quote from: westfw on October 10, 2022, 09:26:08 amIn my view, Python is all about the quality libraries. I'm not sure the world needed another programming language but I do enjoy being able to build on the work of others.If I can make PL/I look like Fortran, I should have no problem making Python look like C.

author: DiTBho
author_rank: Super Contributor
timestamp: October 13, 2022, 07:48:22 am
content: Quote from: westfw on October 10, 2022, 09:26:08 amWorse still, when people integrate that pythong-look-like-C crap into X11 appsOk, I am the kind of person who managed to patch, hack and compile Xsdl for X11 with some python code to "compose" single applications into a nicer screen.What? Seriously WHAT?Yeah, It is called "rootless X11 server" and it requires more complex interaction with OS GUI subsystem.if you did things right thenyou shouldwrite a lot of OS-specific code at X.Org side, otherwise each X11-window (one fo each X11 app) will render inside a SDL window, but since I am lazy and evil and bad ... well I just created a monster (C code) that needs an X11 server instance for each window, and then a second monster (python code) that "composes" that crap into a single window.... and ... voila, the last greatest *hit is served!No doubt it's the worst shit on earth which also requires crappy bash script because sdl also requiresxkbdcompfor start and putxkbdcompotherwise it will immediately fail to createcolormapand crash down with just a death funeral "sorry, no screens found" string.()So ... no doubt it sucks! but hey? at least I don't suggest other people to write that bad thingsNext gen: please, don't do this!

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: November 27, 2022, 12:08:06 pm
content: Quote from: eti on October 10, 2022, 07:50:12 amI meant in structure.I quickly moved from C to Python.

author: rstofer
author_rank: Super Contributor
timestamp: November 27, 2022, 04:26:20 pm
content: Amazon had a short life in the training arena. They are getting out of the courseware business on December 9th. OTOH, there are many other resources.The more I play with machine learning, the more impressed I am with the libraries. Numpy, Tensorflow, Keras, and all the others are simply amazing.

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 27, 2022, 05:48:41 pm
content: Quote from: rstofer on November 27, 2022, 04:26:20 pmcan it make coffee for me by just typing a single line of MakeMeCoffee()? given enough effort from people in a certain language infrastructure, it can make wonder, however crappy the language design philosophy from the beginning.. (i'm not saying Python is crappy) the wonder is not in the library, its in the makers who created them...TensorFlow for CNumpy is written in C

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 27, 2022, 09:29:21 pm
content: Like I keep harping so often, one of the nicest thing about Python is that it can interface to native libraries using only standard Python, with no additional native code or changes to the native code needed. It means you can create Python bindings to a native library writing only a bit of Python, using e.g. the built-inctypesand perhapsstructmodules.To me, it means you only write Python code for the topmost "business" logic: in my case, mostly graphical user interfaces. I used to do a lot of backend web server coding, though.(There is one interesting Python tricks when using Python under FastCGI, that I'd love to see used more. If your Python page engine acts like a FastCGI server, you can preload things like the site navigation structure into an object, and then just fork the entire Python process when serving a new client request, like FastCGI servers normally do (with the same implied resource checking limitations and checks suggested). This cuts down on latency, and means common I/O (to find out the navigation structure to properly implement menus and paths and such) is not unnecessarily duplicated. Makes a significant difference in practice. You can even drop privileges based on a quick prefix URL check, before doing any work for the request, and make security bugs slightly less dangerous that way.)It also means that Python examples where you do serious data processing or computation (without dedicated libraries like numpy/scipy), are not useful.You want to use Python where its strengths lie, and those are mainly in the high-level concepts.Because of that, I recommend learning early how to effectively use Python with GUI toolkits. Currently, I recommend Qt5, via either PySide2 or PyQt5 bindings. The two are very similar, and really only differ in their dynamic UI building facilities. QtPy (a Python package) is a thin loader layer on top of either, that provides the same interface to both, by implementing a minimaluicclass that PyQt5 provides when using PySide2 bindings.The main reason for that recommendation is so that you get comfortable how to use 1) derived classes to add your own desired functionality, and 2) event-driven programming model.With Python and Qt5, I also recommend keeping user interfaces as XML .ui files (that you can save from e.g. Qt Designer), and loading and constructing them at run time using the aforementioneduicclass. For maintenance and adaptability reasons, I strenuously recommend against using any Designer or similar utilities to generate the Python code needed to implement an user interface: that shit is write-only. It looks nice-ish, and you can make tiny changes, but major revamping is always a complete rewrite. With .ui files, you just switch to another one, and only have to make sure the existing element names are all implemented and match.If you dislike Qt, then Gtk is also a possibility, but it looks very, very similar to Qt Python code. Gtk differs from Qt in that there is just one set of bindings, the ones provided by GObject Introspection, aka GI or gir. In current Linux distributions, these are packages namedgir1.2-library, and a Pythongimodule (in Linux, typicallypython3-gipackage) builds the bindings to the library using the GI files. It is quite nifty, actually. (All you need isimport gi;gi.require_version('Gtk','3.0')(for Gtk 3.x); andfrom gi.repository import Gtk. Same for any other library that you have GI for.)The UI builder for Gtk is called Glade, and it too saves .ui files (not compatible with Qt ones) that you can load and instantiate at run time.Because current Python interpreters can only run one thread of Python code within each process simultaneously, you will soon have to learn to do distributed processing using process-based parallelism.Personally, I heavily use a Python I/O thread, and PythonQueueor toolkit-specific event dispatching to communicate between the main UI thread and the I/O thread. For communication with a microcontroller or similar, I often use two I/O threads and full-duplex asynchronous comms. (In Linux, with native serial and USB Serial, I exclusively usetermios, not any serial library.) For computation, that/those I/O threads communicate with other processes that do the heavy computation, using the Pythonsubprocessmodule. Note that when using libraries like numpy/scipy/fftw etc., the library code can run concurrently to Python code in a different thread, which means that there is no problem using e.g. multiple Python threads for computation using these libraries. It is only Python code that cannot run concurrently in different threads in the same process: different processes, or Python and native code, thread-parallelizes just fine.If you want Python examples (noting that I only have Linux OS available right now), let me know: I really like to help others learn, and if you can come up with an interesting example scenario, I'd be happy to give it a try. It's even better if others are willing to point out weaknesses and suggest changes in my suggestions, because then I learn myself too. I'm of the opinion that one never knows all nor enough, and can and should always keep learning.

author: Picuino
author_rank: Super Contributor
timestamp: November 27, 2022, 09:50:58 pm
content: Quote from: Mechatrommer on November 27, 2022, 05:48:41 pmSo... don't program in Python.Moreover, considering that in the end the C code is actually compiled to machine code, what you should learn and use is the Assembler, which is the closest thing to the final machine code.The bad thing about that argument is that it convinces almost nobody. Every language has its niche and for high-level logic a high-level interpreted language is much more flexible and makes programming much easier, such as Python.