Show more

I was rewatching Star Wars recently (kids are now interested) and it reminded me of (tenuous link warning!) when I decided to explore __copy__() in Python and dive a bit deeper

Copy->Clones->Storm Troopers->there’s the tenuous link

Anyway, here’s the article for those interested - note the image with Lego storm troopers has been there since I published this article!

thepythoncodingbook.com/2022/0

Some more tree behaviours.

Clicking a node to move the cursor now works.

Labels can now have a 'icon' used to show expand state. You call set allow_expand=False for leaf nodes.

This core functionality will for the base of a tree control to browse a directory.

#textualtree #python

@MahmutRuzi Same with me. I joined a research group for my PhD which used MATLAB, so I learnt to code using MATLAB

When I set up my own research group years later, I had tons of MATLAB scripts so I got my students to learn and use MATLAB too…

When a colleague suggested using this up and coming language called Python (this was c.2005), I remember thinking, nah, can’t be bothered to re-write all this library in another language.

And after all, licenses weren’t a problem as grant funders paid for them!!

A (lengthy) Mastodon #introduction.

I'm Thomas, a Python Core Developer and Googler from Amsterdam (NL). I'm on the Python Steering Council and the #PSF Board of Directors, and I'm the 3.12/3.13 Release Manager. I hang out on #python on libera (IRC) as well. I also have #cats (#Savannah and #Bengal).

I usually toot/boost about #python, especially #governance and non-profit support of #python. A little thread with examples (and cat pictures at the end)👇

@peterdrake in fact, this is what comes out in 3.11 when running that line in a script:

(x**2 for x in range(10))[3]
Traceback (most recent call last):
File "/Users/stephengruppetta/PycharmProjects/Testing/test.py", line 1, in <module>
(x**2 for x in range(10))[3]
~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'generator' object is not subscriptable

@peterdrake although this one is clearly **not** fixed in 3.10, or 3.11! Maybe in 3.12?! - Having said that, the missing comma only comes out in the one-liner version, and not if the generator is assigned to a variable name

But yes, error messages are not Python's strongest feature!

@peterdrake True, although have you seen the latest improvements in error messages (in 3.10 and 3.11), the Python core team is doing some great work on that (as well as speed)

@MahmutRuzi The reality is that MATLAB is mostly still around because many academics (mostly) have decades of scripts they rely on and get their students to learn MATLAB and create more scripts the lab relies on…

Python can do whatever MATLAB can do, often better and faster and much less expensive, plus Python can do a lot more (think outside the scientific fields, especially)

Plus you get a lot more support from the community in Python. So I would expect the trend away from MATLAB towards Python to carry on in the academic community, too, despite resistance from those who don’t want to switch because of the library of scripts they have!

I can’t see any benefit of MATLAB over Python, personally!

@MahmutRuzi We need to be careful with the distinctions between “easy language to code in” and “easy language to learn coding”.

The easiest language to code in is the one you’re used to using most. After over a decade of using MATLAB, when I first switched to Python I found MATLAB easier–I had been using it for 15 years, Python only 15 day! But now there’s on doubt that I find Python easier.

In terms of easiest to learn, the three languages you mention are similar as they’re all very high level languages (as opposed to Java or C++, say). But of the 3, Python is the one with the deepest and broadest footprint and with the largest community (and is free, of course)

@CodingKurzgeschichten It depends a lot who the audience is–for an increasing number of use-cases for programming (not just software development), Python is the only language they will even need…

…and beginners can definitely learn about OOP and functional and other paradigms in Python - in fact being a multi-paradigm language should have been another of those bullet points!

Why is Python the ideal language for beginners to learn?

Let's look at the main reasons:

• It's more accessible for a beginner, allowing you to focus on programming concepts and not language detail. Too many give up coding early on–Python makes this less likely

• It's very powerful–which means you can write any program you'll need and it scales well as you deal with more complex programs and larger data sets

• It's very broad–it has applications in very many fields and not just a narrow scope. It also has libraries for very many fields!

• As it's very popular, it has a large user-base which is very helpful, so you'll find a lot of resources (not just mine!) and a lot of help from the community

• It's a language that's still improving and progressing rapidly. Latest speed improvements is just one example

--

The main thing you're learning is programming, and not a programming language. The language itself is "just" a tool, but you don't want the tool to get in the way of learning, as would happen with some other languages.

Once you become proficient in programming in one language, it's easier to switch to/learn other languages

So my advice is, yes, start with Python and stick with it until you feel you're very proficient. If and when you need other languages, they'll be easier to learn then…

Thinking about where to set up the Teaching Python podcast on Mastodon. Any servers focused on education?

Hello everybody,

This is the page of the pandas project. There's a chance we may migrate to a purpose-built Scientific Python instance later, but for now we're here

Follow for news on releases, meetings, and on how to contribute!

#introduction

Duck typing for #Python programmers is like air for humans or water for fish. It's so ubiquitous that it's sometimes hard to identify.

pym.dev/duck-typing

When overloading binary operators in #Python, also remember to implement right-hand methods (e.g. __radd__) for your operations where appropriate (float needs this one for extending int also):

>>> x + y
4.0
>>> x.__add__(y)
NotImplemented
>>> y.__radd__(x)
4.0

Show thread

A while ago, my son asked me how to draw using the two-point perspective technique…

“I haven’t got the slightest idea”, was my honest answer (kids need to know we don’t know everything, after all)

Could have left it at that. Instead we went on YouTube, one thing led to another, and…

…anyway, here’s the answer, using a program which uses Python’s turtle

thepythoncodingbook.com/2022/0

Hi everyone! I'm Marlene and here's my introductory toot❤️ 👋🏾

I'm software engineer and Pythonista, currently working remotely for Voltron Data. I was on the board of the PSF and just joined as the vice chair of the ACM Practitioner board. I'm also an organizer for PyCon Africa 🌍

I love computers, open source and learning. I'm also a big fan of creating coding and experiment with AI and ML a lot! I'd love to connect with other #python people here❤️ ✨

Implemented scroll tracking the cursor.

Also added a hover effect that highlights the sub-tree under the cursor.

What do you think?

#Python #TextualTree

Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.