Discover and read the best of Twitter Threads about #Python

Most recents (24)

Python's "for" loops are single-purposed: they can loop over an iterable item-by-item. That's it.

The "for" loop itself can't loop in reverse or loop over multiple iterables.

For this reason, looping helpers are a VERY big deal in #Python.

Let's talk about looping helpers. 🧵
Want to loop over an iterable in the reverse direction? If it's a reversible iterable (lists, tuples, dictionaries, etc), you can use the reversed helper:

>>> colors = ["pink", "blue", "green"]
>>> for color in reversed(colors):
... print(color)
Note that the "for" loop isn't reversing here: reversed is!

The built-in reversed function accepts an iterable and returns a lazy iterable that provides each item from the original iterable in the reverse order.

>>> r = reversed(colors)
>>> next(r)
>>> next(r)
Read 12 tweets
One of my favorite topics is learning. This is giving me several benefits during my #SEO career.

How can we learn faster and better?

This thread will clarify some concepts and teach you that steady progress > perfection. 🧵
Let's start by saying that you don't need to learn everything.

Learning things by heart is overrated in the digital era, you have a PC for that stuff.

Don't waste your time with the useless details.
Some of you may be shocked, but you don't really need to learn all the human knowledge.

This is what schools unsuccessfully teach, learn by heart and forget logic.

This is the most toxic argument you can ever make.
Read 32 tweets
💻¿Dónde y cómo subir tu NIVEL de programación?

🚀 Te enseño como y lo mejor de forma GRATUITA

Super Hilo 👇🧵
Primero debes tener en cuenta
¿Qué quieres mejorar y por qué? 💻

Aqui te dejo lo necesario sea cual sea tu respuesta 👇
📌Estas empezando con HTML y CSS y quieres retos básicos de maquetado para practicar?

Frontedmentor es la mejor opción por su variedad de challenges y de distinta dificultad 👨‍💻
Read 14 tweets
More helpful examples in the #ElrondDevGuild. Scripts in #Python #Typescript, smart contract examples, and complete #dapp template. A must-have bookmark for every #Elrond #developer
Also, the Guild has opened its library. For now, there is an intro article for new $egld warriors. Check it out: It will have more 'scrolls' soon. Keep an eye on it!
Read 3 tweets
I recommend against using the file readlines method in #Python.

Many folks assume that readlines returns a lazy iterable (an iterator) of lines. But the readlines method returns a list, not an iterator!

These are equivalent:

lines = my_file.readlines()
lines = list(my_file)
If you need to lazily loop over lines in a file, you can loop over the file object itself to do that:

for line in my_file:

You can use a file like any other iterable. For example you can use it in a comprehension:

non_empty = [line for line in my_file if line.strip()]
When I need to make a list of all lines in a file, I use the list constructor:

lines = list(my_file)

I find that clearer than this:

lines = my_file.readlines()

☝ That second line can lead newer Pythonistas to assume this is okay:

for line in my_file.readlines():
Read 5 tweets
Cases of Mokeypox by Location (Casos de Viruela del Mono por Lugar) #MonkeyPox #RStats #IDtwitter #ViruelaDelMono #VirueladelSimio #VarioleSinge #VarioleDuSinge #DataScientist #elcarteldeSINADEF #Analytics $BAVA $BAVA.CO $SIGA #AI #100DaysofCode #AWS #TensorFlow #Python🧵(1/2) Image
Cumulative Cases of Monkeypox per Day (Acumulado de Casos de Viruela del Mono por Día) & Statistical Trend in the Count of Cases (Tendencia Estadística en Casos) #MonkeyPox #ViruelaDelMono #VirueladelSimio #VarioleSinge #VarioleDuSinge #IDtwitter $BAVA $BAVA.CO #RStats 🧵(2/2) Cumulative Confirmed Cases ...
Read 3 tweets
Best-of Machine Learning projects with Python 👇

[1/x] 🧵

#Python #MachineLearning #DataScience
Machine Learning Frameworks
56 projects…
Data Visualization
51 projects…
Read 30 tweets
One of the most important tips you could ever receive is about differentiation.

How to differentiate yourself and/or your career in a saturated market like #SEO?

A huge thread about differentiation and other arguments to make you think. 🧵
Let's start from scratch. You should offer a solid value proposition, why should I invest in you?

What can you offer that I am very unlikely to find elsewhere?

Start thinking about what you can do or what you can potentially learn.
Disclaimer: for niche websites on anything related to Display Ads and even affiliates, the US is always going to be the top choice.

This thread is referred to other scenarios, as you can build websites from wherever you like.
Read 46 tweets
Ever wondered "what's a float"?

floating point number (a.k.a. float): an object used for representing real numbers using a fairly accurate approximation

Let's talk about floats work in #Python!

Floating point numbers are an approximation of their decimal equivalents.

They're super useful for most uses, but they can't be relied on for exact precision.

You can't assume that an exact equality comparison with floating point numbers will work:

>>> 0.1 + 0.02 == 0.12
Adding 0.1 and 0.02 results in a number that is VERY slightly different from the 0.12 number that we'd expect:

>>> 0.1 + 0.02

This might seem like a huge problem, but it's usually not! This imprecision typically only causes trouble with strict equality.
Read 11 tweets
Evergreen content is one of my favorite #SEO topics.

It's super crucial for publishers and especially for niche websites.

A short thread about its relevance and why you should master research. 🧵
Evergreen refers to content that is not time-sensitive and is not particularly subject to seasonality or timeframes.

Search demand is constant through the years. They usually tackle recurring problems or super generic topics.
This type of content makes it easy to apply some advanced principles, as you want them to last.

Having good authors, good syntax with proper entities and a clear internal linking is the bare minimum for me.

This is very simple once you know the niche very well.
Read 12 tweets
Con el tiempo he reducido las siguientes librerías como parte de mi arsenal de entrevistas, edición #Python . A pesar de tener experiencia en otros, me gusta lo poco ceremonial par expresar soluciones. Chequen el 🧵 con información de cada recurso [1/X]
Mandatorio, sentirte comodo con las funciones built-in, que significa no ocupas importar nada para usarlas. Ofrece funciones fundamentales open (I/O para archivos), len (tomar length de contenedores), range (crear un iterable entre m y n).…
Alguna estructuras de datos ya vienen incluidas como built-in (e.g. diccionarios, listas, set), sin embargo compensa por las que faltan como el queue que viene bajo el nombre de deque en el siguiente…
Read 8 tweets
We often forget that being a web developer is not only about #html, #css or #javascript! #react or #angular! #python or #php!
Sure these helps you build wonderful looking websites but database and data structure is vital! Security is a must! Scalability is key!
Sure if you claim you are a #Frontend developer, you can easily say that you don’t have to worry about all the ‘backend’ stuff I just mentioned! And here is where I completely disagree! To be successful you have to understand the back end and how it works!
Understanding the database you are building a front page for helps you have a bigger picture of the wealth of data you have! How to present it and how to make it available!

Securing a database is the #dba job! Network system engineer secure the network where your site is!
Read 5 tweets
I love Python's pathlib module. 💖🐍🗃

Whenever I need to ask a question about a file path in #Python, I default to using pathlib.

Let's talk about some of my most common uses for pathlib and compare them to their non-pathlib alternatives. 🧵
Assume all the below examples include the "filename" and "path" variables defined like this:

>>> from pathlib import Path
>>> filename = "my_file.txt"
>>> path = Path(filename)

Also assume that we've imported os, glob, and os.path as needed:

>>> import glob, os, os.path
Get an absolute path (from a path that may be relative or may already be absolute).

💾 Old approach:

>>> filename = os.path.abspath(filename)

✨ pathlib approach:

>>> path = path.resolve()
Read 12 tweets
Mi ultimo año en @Dropbox he expandido mi conocimiento en #Python y a la vez he aprendido a codear en @golang . Les comparto un 🧵 con algunos recursos que me han sido extremadamente utiles
Para probar ideas me encanta el playground de @golang , me dio oportunidad de enfocar en solo features del lenguaje sin mezclar business logic del trabajo
Por lo general los lenguajes de programación tienden a tener lo que llaman "best practices" , o recomendaciones de como escribir código. Un colega en mi empresa sugirió leer la documentación de Effective GO…
Read 6 tweets
There are some factors to take into account when creating content.

Content outlines, briefs and templates give you a good way to minimize misunderstandings.

A short thread about processes in #SEO content creation.
Let's explain what all these terms are plus some examples.

Content briefs are essentially an overview, you define the purpose, audience and general guidelines for an article.

A good template is this one (by @danielkcheung):

@danielkcheung So briefs are your war strategy, and what you need to succeed.

The example I provided before is a very good one.

One problem is when you have to work with 100+ articles and of course, no way I am going to do it 100 times.
Read 14 tweets
Here's a deceptively fuzzy #Python term: mutable object. 🤔

mutable object: an object whose "value" can change

But what does "value" really mean?

Lists are mutable because a list object can be changed.

>>> numbers = [2, 1, 3]
>>> numbers.append(4)
>>> numbers
[2, 1, 3, 4]

If two variables refer to the same list, any change to the list will be reflected by both variables:

>>> x = numbers
>>> x.clear()
>>> numbers
Strings are immutable in #Python. That means that there is no way to "change" a string object in Python.

Try as hard as you might, you cannot change strings. You can only make NEW strings.

name = "Trey"
name = name + "!" # makes a new string
name += "!" # same as above
Read 12 tweets
Scraping is super important for a lot of tasks.

#SEO Specialists usually crawl their websites but scraping is not always one of the tools in their arsenal.

A short thread on what you can do with scraping and what's the difference with crawling. 🧵
In plain English, crawling is the act of discovering URLs on a website, so following the links on a page is extremely important.

Scraping is the extraction of data from a website, not all of them of course, just those of interest to achieve a goal.
As we know, crawling is aimed at creating indices of pages.

We care about scraping because we may be interested in extracting specific information from a page.
Read 10 tweets
A while back I was struggling to manage async creep in Textual ("async creep" is the tendency for all methods to become async).

A *single method* in asyncio allowed me to reverse that decision, and prevent asyncio creep. #Python

First, the reason why I disliked asyncing all the things.

The "await" keyword is boilerplate. Its existence is mostly for the language and doesn't help the developer.
Whether you do "await foo()" or "foo()" you are invoking the function. The majority of the time the await keyword is a burden placed on the developer to remember wether it is a coroutine or not.
Read 18 tweets
A quick recap for those #SEO professionals still lacking some motivation to study Semantic SEO.

The future of search engines lies in innovation, we're talking about corporations, after all.

This thread will show you some concepts and valid reasons. 🧵
Google is already using such technologies and we know it for sure.

Even if we were given the benefit of doubt, there wouldn't be any discussion either.

Innovation drives profit and we know that Google wants good-enough search results.

You cannot optimize your content for BERT/MUM/any other NLP algorithm.

The reason is quite simple, these models/algos are trying to understand and replicate how we humans interact.

Nonetheless, you can use a better syntax and put entities in a good position.
Read 32 tweets
All you really need is 1 application to get started in #coding.

A browser.

In a Chromebook, a smartphone, or any PC, you can learn and practice.


Here are 8 websites for writing code online, for FREE:
1) JSbin

Takes care of all your #javascript, #HTML, and #CSS. Has a built-in console as well.
2) GDB online

Debugger and Compiler. Support for many languages and versions including(but not limited to) #python, #javascript, Pascal, #HTML, #CSS, C, C++, Perl, Ruby, C#, and PHP.
Allows you to make multiple file programs.
Read 8 tweets

Learn 21 pandas tricks that will help you to work faster, write better pandas code, and impress your friends!

Click here to watch:
👉 👈

#Python #DataScience #DataAnalytics Image
Here are a few of my favorites from the video:

6. Convert one set of values to another
11. Read and write from compressed files
14. Transpose a wide DataFrame
16. Identify rows that are missing from a DataFrame
17. Use query to avoid intermediate variables
And if you haven't seen my top 25 pandas tricks, definitely check that out as well! 👇

Read 3 tweets
Module number 3️⃣ on our #Python standard lib tour is `argparse`

The argparse module makes it easy to write user-friendly command-line interfaces.

#PythonStdLib 🐍🔥

Here is an example of creating an argument parser with no arguments.

Why would you do that? Well, to find out what `argparse` gives you out of the box 📦!

You can see here that `argparse` gives you some help text and prints out your provided description
A common coding pattern for argument parsing is to put the argument parsing code into its own function or method and then return the parsed args.

Here's an example:
Read 8 tweets
Some other tips that I think are good for aspirant #SEO Specialists.

This will be a short thread for beginners or anyone that wants to start exploring the SEO realm. 🧵
Learn some popular tools but acknowledge that they don't give you a competitive advantage as a professional.

Everyone can buy them, it's how you use them that makes a difference.

I suggest you start with Semrush/Ahrefs and Screaming Frog/Sitebulb.
Experience different flavors of SEO and pick your favorite.

Content, PR outreach or Technical are just some of the choices you have.

Pick whatever suits you the best, don't over-optimize your career.
Read 18 tweets
The aifc module in #Python will be deprecated in Python 3.11

But it's still worth knowing about because so many people will still be able to use it.

This module provides support for reading and writing AIFF and AIFF-C files…

#PythonStdLib 🐍🔥

AIFF is Audio Interchange File Format, a format for storing digital audio samples in a file. AIFF-C is a newer version of the format that includes the ability to compress audio data.

You can read and write these files with #Python using the aifc module!
When you go create an AIFF file with #Python, you use much the same type of code as you would when you use Python's `wav` module.

Here's an example:
Read 5 tweets

Related hashtags

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!