Show more

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

How often have you used the function range() in Python? It’s often something you use early on as you learn about the for loop…

But… did you know it’s not really a function, after all?!

Have a look at the docs or use help() to check…

range is a class. And therefore range() creates an instance of the class as is always the case with a class.

So, my question is: “Does it matter?”

Technically, it does. A function is not a class – they’re different things

But in practice, what matters is how it behaves and not what it is!

This is a key principle in Python when thinking about data types. What they do and how they behave matters more that what they are!

So you can use range() like a function, even though it’s not!

When you learn to code, in Python or other languages,, you start by learning about the tools you’ll need and the rules for each one of those tools. You learn the syntax of the for loop and what it does, for example. With time, you also learn when to use this tool and when not to use it.

What’s more challenging in the early and not-so-early days when you learn Python coding is to join the dots between the various topics you learn and to view them as a coherent set of tools all working together.

Making the transition from knowing how to use lots of separate programming tools to seeing those tools as aspects of the same story is one of the rites of passage to move from beginner to intermediate, whichever way you define beginner and intermediate.

What has helped me get this type of understanding is good analogies. Here’s the one that works for me:

thepythoncodingbook.com/2021/0

Just started reading this bad boy! Turns out there are tons of stuff I didn’t know about #pytest .

Great job @brianokken.

I wrote some #python code today to integrate Mastodon into my stream deck. Now we can announce new @talkpython and @pythonbytes episode in the click of a button, see image.

You've possible heard the quote which says that "Debugging is like being the detective in a crime movie where you are also the murderer”

A while ago, I decided to take this quote a bit more literally, but no, not "fully literally" (if you know what I mean - I didn't commit any crimes, just to be clear!)

Don't take this article too seriously, though!

–> Debugging Python Code Is Like Detective Work — Let’s Investigate

thepythoncodingbook.com/2022/0

@hynek suspicion correct. This is an issue - same with markdown which I can use here but most servers will strip out. As a poster you cannot guarantee how your post will be viewed across the network. But I guess that’s just the way it is

Show thread

This is a QT (although I suspect only those on qoto server will see it as such?
@hynek

Hynek Schlawack  
Since being wrong in public is fun, here’s predictions re tech criticism towards Mastodon: perf: top ops/sre folks are making it work. #skinInThe...

Here’s a “from-the-archives” post

I’ve been recently having more and more conversations – some privately and some publicly – on using the turtle module for more than just drawing circles and patterns!

Some of you may know this is one of my favourite topics – in this example, we’re using it to visualise how sines and cosines are linked to the motion in a circle

How many children (and adults) learn about sines and cosines but don’t know what they really are?

thepythoncodingbook.com/2022/0

Are you comfortable with the difference between positional arguments and keyword (or named) arguments when calling a Python function?

And which order to use them in?

Here’s the second article in the Intermediate Python Function series, hot off the press, so to speak

thepythoncodingbook.com/2022/1

Everything in #Python has a type... even things you might not expect to have a type.

Like None

>>> type(None)
<class 'NoneType'>

Or NotImplemented

>>> type(NotImplemented)
<class 'NotImplementedType'>

Or... type?

>>> type(type)
<class 'type'>

@s_gruppetta I find it very nice, it's replaced a lot of the crufty matplotlib boilerplate I've accumulated over the years for creating publication-ready figures. You can always drop back down to "raw" matplotlib if you need to do something very specific.

I’ll be mostly posting about in the data analysis and science and related domains here…

…but for those learning to code, whatever the final aim, it’s good to get a broad perspective

So here’s something different to learn about or consolidate the key data structures in Python - lists, tuples, dictionaries, and sets

Here’s the link to the article for those who want a “diversion” from more serious-looking exercises!

thepythoncodingbook.com/2021/1

I think a good way to show code (until we wait for all servers to have Markdown like , at least) is to show a generated code image (from one of several online tools, or screenshot if you must) and add the code as the ALT text/description of the image, as in the quoted toot.

If, as in this case, the code is too long for the ALT text (this will only happen for long code snippets like this) the code could go in an unlisted reply to the toot with the image (or in the same toot, if you prefer/have space)

I think it’s useful to have both a properly-formatted version for those who just want to read code and text which people can copy-paste

gist and other solutions means you need to leave the site - not ideal, I think

Stephen Gruppetta  
Here’s the code for the plot in the previous post - put in your own image file, of course! You can get the text from the images’s ALT text

We are doing an episode on "Mastodon for #Python (and open source) devs".

We'll be live streaming it on Monday.

youtube.com/watch?v=LhBfMoR3bv

Hope you can join @mkennedy, @foosel, @simon, and @astrojuanlu

Show more
Qoto Mastodon

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