So many nuances with string methods :)

The str.replace() method takes an optional count argument so you for example can only replace the first match:

>>> s = "hello world, hello again"
>>> s.replace("hello", "bye")
'bye world, bye again'
>>> s.replace("hello", "bye", 1)
'bye world, hello again'

#python

@karenshancock if you want to use programming for mathematical and scientific applications, then Python is perfect because all the tools it has in that area, starting from modules such as NumPy (Numerical Python) and Matplotlib (plotting) and many others.

You can use typing.get_type_hints() (or __annotations__) to get the type annotations of an object.

#python

Do you know the offside rule? Here's a step-by-step tutorial to write a Python Offside Rule Quiz using Object-Oriented Programming

I score 10 out of 10 all the time. How about you?

Great article for anyone:
- who wants to learn object-oriented programming
- who wants to learn the offside rule

thepythoncodingbook.com/2022/1

Offside Rule Quiz using Python's `turtle`. I scored 10 out of 10. No need for VAR if I'm the referee, then?!

Article coming soon*

small print:
*soon is a relative term

#LearnToCode

There are so many fascinating insights in this article by Lambert Meertens about design principles and decisions in Python's precursor languages, B and ABC.

Here's one of them which says so much about Python and about "language wars" some still have today.

Context: It's early 80s, talking about deciding to only allow integers as array indices, despite the fact it violated one of their design principles, with Guido van Rossum joining the ABC team at around this time:

"This design decision had been driven by fear: we had been concerned that aiming too high would make our language unimplementable on the small personal computers that were starting to appear on the market. But Dewar, in particular, convinced me that this meant we were designing for the past, not the future."

And this observation should be seen in the context of another consideration that the designers of B and ABC had, which was common with another high-level language they were exposed to at the time. Here's the quote:

"The design of SETL was predicated on the philosophy that, as computers became faster and faster, human time would be more valuable than computer time "and that the efficiency of the tool set SETL provided should not be measured in terms of speed of computation, but in their conceptual power."

Some still have the debate nowadays about whether computer time or programmer time are more precious. Although this still depends on the case, more and more applications are programmer-time limited today.

But in the past, most (all?) applications were computer-time limited. Way back in the very early days it could take several hours to get the result of a program execution–no wonder languages at the time prioritised computation speed over development speed.

But things have moved on. Python took off because it came at a time when the switch over between computer-time limited applications and programmer-time limited ones was happening as computers became faster.

Yes, we still need the languages that prioritise computer-time today – there are still applications that need them, but the shift has happened and languages such as Python which prioritise the programmers' time over the computer's time will get more and more relevant (they already are, of course)

Article in Inference

inference-review.com/article/t

@SignalsAndSorcery The static v. dynamic typing debate is one that will go on forever. There's a place for both, I feel, depending on the use case…

When does talking about sound like Philosophy 101?

Teaching `None` in (or similar in other languages) is one of them

`stuff = None`

I can be heard saying the following when teaching (not quite, but dramatising a bit for effect!)

"`stuff` is not empty. But we want it to be empty. But we need to put something in. So we put Python's way of representing nothing. But `None` is still an object. So it's still something. But it's something that represents nothingness. Is that all clear?!"

It's a bit like when you're told to listen to silence in a meditation exercise?!

Latest @pythonbytes episode is out with your #python news, just in time for your holiday travel:

#311: Catching Memory Leaks with ... pytest?

pythonbytes.fm/episodes/show/3

By @brianokken and @mkennedy + special guest @murilocunha

@miko@snug.moe A great starting point usually is trying to automate a task you do often that's a bit repetitive (read: boring). You'll be motivated knowing how much time it will save you in the long run

@miko@snug.moe are you new to programming, though, or is it just that you want to use your skill and not sure how?

— Code Wars: Episode IV – The Language Wars —

Which is better? Java or Python or Javascript or C++ or Rust or Julia or …

You often see the language wars being waged on many fronts – books, online tutorials, and of course here on social media

Each language has its pros & cons, strengths & weaknesses

The reason there isn't one language to rule them all (I'm mixing my fictional references!) is because all have or had a place

The language that's best for one purpose may not be the ideal for another

Where do I stand on this?

Although you only ever see me post about Python, and all my current work is in Python, you may (or may not) be surprised to know that I won't participate in this feud

Yes, I think Python is a brilliant language – and lots has been written elsewhere about this

But the "language A is better than language B" argument or the "language Z is rubbish" line doesn't lead to anything fruitful. Ever!

So these childish debates are not for me, sorry!

Think of the programming language as a tool to achieve your objective. What matters is achieving your objective and not which tools you use

Of course, some tools are more suited for certain objectives…

On the other hand, if you know how to use one particular tool very well and want to use it for most of your tasks, there's nothing too wrong about that, either!

---
Coming Soon: Code Wars Episode V

---

As I've been re-watching the Star Wars trilogy of trilogies (kids are now interested, so I'm doing it for them!), I thought of creating a Code Wars series – where are the battles relating to programming fought?

So, we start with Episode IV, of course. Here it comes…

I'm still surprised at how many hits this article gets every day, so let me reshare it here in case it's of interest to anyone.

It's rather niche, but it's a fun tutorial to follow even if it's not really your field:

Recreating any image from sines and cosines

thepythoncodingbook.com/2021/0

@danielfeldroy For example, although I don't post the exact same content, I don't see the same trend - way more people interact on Twitter than here to my posts - but I've only started tweeting in Apr this year, so all my followers (I had 308 in April) are from the last 6 months or so…

Hey #introduction, I am a software developer and coach.

I love building practical tools that make other people's lives easier.

And I am passionate about helping people build their Python, developer and mindset skills to succeed in their tech careers.

I do this via Pybites, which I co-founded back in 2016 with Julian Sequeira (hope he joins me here soon haha ...)

@danielfeldroy But you need to take into account that 100% of your Mastodon followers are recent whereas I suspect most of the Twitter followers are not "recent" and will include dormant accounts

@folkerschamel @bacon I'd second that thought. Unless you have specific needs to use a specific language, Python is a great language to learn coding through. It's got both depth and breadth

Show older
Qoto Mastodon

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