Python

6681 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
226
 
 

cross-posted from: https://programming.dev/post/8025145

2023-12-29 by Novica Nakov:

I notice that Ctrl+Enter for running the code in Python and in R is not the same thing.

Read the whole article

227
11
CPython Type System Internals: Video Series (codeconfessions.substack.com)
submitted 1 year ago by ericjmorey to c/python
228
229
 
 

Hi,

As CSS do not have a color-overlay[^1] filter.

There is some heavy work around:

https://isotropic.co/tool/hex-color-to-css-filter/

that use a combination of CSS filter to target the desired color...

Those online calculators are neat, but I would like an offline version, in case the provided one become inaccessible.

I've downloaded the zip of https://codepen.io/sosuke/pen/Pjoqqp

But it doesn't work locally.. :/

So I would like to know, if someone know one in 🐍 Python ? or how can I make one then ?

Or if someone know another way to have the color-overlay[^1] effect in html\css, I'm all ears !

Thank.

[^1]: To apply like in Photoshop a color on the shape of the image (so not on the parts that have transparency.

230
231
232
 
 

These stubs have only been out in a pypi package for about 2 months so many people do not know about them yet.

233
234
8
Home - PyOhio 2023 (www.pyohio.org)
submitted 1 year ago by jnovinger to c/python
 
 

Via https://mas.to/@mpirnat/111592702753147583

Looks like talks are already live!

235
 
 

I have developed a project in #python to follow #RSS feeds and send an email with daily news. It is more an excuse to practice python, git and design patterns than a real project, but feel free to use it if you find it useful. Suggestions, opinions and feedback are welcome.

https://github.com/xurxia/newswave

236
 
 

Hi, When im working with some big dataframes and I need to create some columns based on functions. So i have some code like this

Def function(row): function

And then I run the function on the df as

df['new column'] = df.apply(function, axis=1)

But I do this with 10 or more columns/functions at time. I don't think this is efficient because each time a column is created it had to parce the entire data frame. There's a way to create all the columns at the same time while parsing the rows only once?

Thanks for any help.

237
20
Python 3.11.7 is now available (pythoninsider.blogspot.com)
submitted 1 year ago* (last edited 1 year ago) by mac to c/python
 
 

Major new features and changes:

  • PEP 657 – Include Fine-Grained Error Locations in Tracebacks
  • PEP 654 – Exception Groups and except*
  • PEP 673 – Self Type
  • PEP 646 – Variadic Generics
  • PEP 680 – tomllib: Support for Parsing TOML in the Standard Library
  • PEP 675 – Arbitrary Literal String Type
  • PEP 655 – Marking individual TypedDict items as required or potentially-missing
  • bpo-46752 – Introduce task groups to asyncio
  • PEP 681 – Data Class Transforms
  • bpo-433030– Atomic grouping ((?>…)) and possessive quantifiers (*+, ++, ?+, {m,n}+) are now supported in regular expressions. The Faster Cpython Project is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See Faster CPython for details.
238
239
34
Real-world match/case (nedbatchelder.com)
submitted 1 year ago by jnovinger to c/python
240
 
 

Made a Mastodon bot using Mastodon.PY and I'm so happy it works! πŸ˜…

I just got this random idea in my head and decided to see if I could create it, so I built a working slots that uses the 4 image uploads to show the results. It will automatically grant you 10000 Coins the first time and playing costs 50 coins per play. The prices go from 25 to 750, every play adds 25 into the jackpot that starts at 500 when it gets won and 4 jokers will give jackpot. It will say the results in text too and it saves all wallet-amounts to file too which it can load back on restart however it gets killed. πŸ˜…

Sorry, just wanted to share this somewhere. πŸ˜… I hope it's fine here.

I am however not really promoting it, not even sure how it will do under pressure (probably get throttled by Mastodon eventually) and it might either stop working or switch account to one of it's own (it's currently just using a personal infobot for testing) depending how it goes... I'm assuming if I give it a 5 plays per day per user limit it could be manageable... πŸ€·β€β™‚οΈ

(If you still want to try it, please do not abuse or spam it or I will have to take it offline, but the command to play on Mastodon is: "@[email protected] !slots"

Anyway, thanks for reading about my victory! πŸ˜…

241
15
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/python
 
 

Hello, im looking for some beginer-intermediate knowledge in python. I'm interested in more text rather than video based courses preferably with exersises.

242
243
26
submitted 1 year ago by mac to c/python
244
8
submitted 1 year ago* (last edited 1 year ago) by jnovinger to c/python
 
 

As seen in https://news.ycombinator.com/item?id=38561682

Memray tracks and reports memory allocations, both in Python code and in compiled extension modules.

245
 
 

cross-posted from: https://programming.dev/post/6990204

Richard McElreath has made his course materials available on GitHub.

However, the course follows the 2nd edition of McElreath's book Statistical Rethinking which is not available in a free digital format.

After watching the first lecture in the Statistical Rethinking 2023 YouTube Playlist, I might go ahead and purchase the text and use this course instead of Trevor Hastie and Rob Tibshirani's An Introduction to Statistical Learning (with Applications in R or Python) course.

I also like that this resource has made an explicit attempt to provide code examples in Julia as well as the more popular Python and R.

I wasn't sure who Richard McElreath was so I did a quick search which revealed his position as Director of the Department of Human Behavior, Ecology and Culture at the Max Planck Institute for Evolutionary Anthropology in Leipzig.

246
 
 

cross-posted from: https://programming.dev/post/6942085

Book (Free)

The resource on statistical methods recommended to me the most has been An Introduction to Statistical Learning (with Applications in R or Python) by Gareth James, Daniela Witten, Trevor Hastie, Rob Tibshirani, and Jonathan Taylor. Its free to download and has been kept up to date. (The latest edition is from 2022.)

Online Course (Free with optional payment for "Verified Track")

For those that prefer a structured online course StanfordOnline: Statistical Learning with R by Trevor Hastie and Robert Tibshirani uses An Introduction to Statistical Learning (with Applications in R) as the course textbook.

More In-Depth Book

Individuals with advanced training in the mathematical sciences may wish to use The Elements of Statistical Learning (Data Mining, Inference, and Prediction) by Trevor Hastie, Robert Tibshirani, and Jerome Friedman which provides a more comprehensive and detailed treatment of a wider range topics in statistical learning.

247
38
Flask Mega-Tutorial, 2024 Edition (blog.miguelgrinberg.com)
submitted 1 year ago by norambna to c/python
 
 

A new, larger revision of the written content to cover the releases of Flask 3.0 and SQLAlchemy 2.0 (Yes, technically I'm releasing this update a month before 2024, in December 2023)

248
 
 

i was trying to parse a string with pyparsing so all the words were separated from the punctuation signs, i was using this expression to do it:

OneOrMore(Word(alphanums)) + OneOrMore(Char(printables))

But when i parse the following string with this expression:

return abc(1, ULLONG_MAX)

All the words inside the parentheses get split:

['return', 'abc', '(', '1', ',', 'U', 'L', 'L', 'O', 'N', '_', 'M', 'A', 'X', ')', ';']

But if i use this expression:

OneOrMore(Word(alphanums)) + OneOrMore(Char(string.punctuation))

Only a part of the string gets parsed:

['return', 'abc', '(']

What is wrong with those expressions?

249
 
 

Python's standard logging API violates PEP-8 and this #PEP proposes to fix this. Feedback and criticism of all sort is welcome.

250
view more: β€Ή prev next β€Ί