501
0
submitted 2 years ago* (last edited 2 years ago) by xmpp@fosstodon.org to c/python@programming.dev

#XMPP + #Google Summer of Code 2023

Edward initiated discussion session on "Communication & Messaging of the #Future" with 9 participants.

We discussed connection of platforms, importance of information, cultivating community, influence of #AI and #healthy communication. Great exchange!

@RocketChat @python @gnuoctave Société des arts technologiques #openmrs

#chat #gsoc2023
#interoperability #federation #jabber #standards

502
7
503
8
504
9
Calling Rust from Python (blog.frankel.ch)
505
14

How to take a few images and create custom graphics with Pillow - memes, info-graphics, custom banners and the like.

506
17

Examples of how to use amateur astrophotography and machine vision USB cameras with Python (or IronPython sometimes).

507
-6
First steps (programming.dev)

publicado de forma cruzada desde: https://programming.dev/post/4003441

I'm just trying to learn about how python and django works.

508
21
509
69
510
13
511
4
512
12
513
12
514
106
Python 3.12.0 (www.python.org)
515
32
516
22

A blog post on choosing more specific types rather than general ones like list and dict.

517
22
submitted 2 years ago* (last edited 2 years ago) by 0WN3D@lemmy.cafe to c/python@programming.dev

I know what I am asking is rather niche, but it has been bugging me for quite a while. Suppose I have the following function:

def foo(return_more: bool):
   ....
    if return_more:
        return data, more_data
   return data

You can imagine it is a function that may return more data if given a flag.

How should I typehint this function? When I use the function in both ways

data = foo(False)

data, more_data = foo(True)

either the first or the 2nd statement would say that the function cannot be assigned due to wrong size of return tuple.

Is having variable signature an anti-pattern? Is Python's typehinting mechanism not powerful enough and thus I am forced to ignore this error?

Edit: Thanks for all the suggestions. I was enlightened by this suggestion about the existence of overload and this solution fit my requirements perfectly

from typing import overload, Literal

@overload
def foo(return_more: Literal[False]) -> Data: ...

@overload
def foo(return_more: Literal[True]) -> tuple[Data, OtherData]: ...

def foo(return_more: bool) -> Data | tuple[Data, OtherData]:
   ....
    if return_more:
        return data, more_data
   return data

a = foo(False)
a,b = foo(True)
a,b = foo(False) # correctly identified as illegal
518
10

Constant modules are modules that often contains variables that you want to use in many places without relying on hard coded values. Sometime you store paths (often relatives).

Is it a good thing to use pathlib.Path() object is modules dedicated to constant?

Or is there anything that you should know before choosing to do so?

I would say the same question appears for using re.compile() in constants.

Any advise?

519
-9

Stream du samedi après-midi lancé sur https://www.twitch.tv/formamac 🍎

- 12H00 : Lunch code,

- 14H00 : Stream 3310.

Aujourd'hui : discussion, debrief de l'actualité et suite du mooc Python (module 2.5).

On fera également le point sur la GBJam 11 😉

#stream #streaming #twitch #python @python @pythonhub @chevrierfranckjeannic @pythonbytes

520
23
521
21
522
35
submitted 3 years ago* (last edited 3 years ago) by nikaro@jlai.lu to c/python@programming.dev

This is like Interface in Go (or Java, i don't speak Java but the article say so).

523
9
submitted 3 years ago* (last edited 3 years ago) by Shady_Shiroe@lemmy.world to c/python@programming.dev

I am assisting in making a wiki for an old game, and we ripped the avatar GIFs from the games shop and want to have a catalog of them. What I need to do is to crop all the borders which are identical from 3,170 GIFs and maybe make background transparent.

I haven't used python in years, but I managed to cobble up something that almost works as a single image test, only issue is that it crops and outputs only the first frame:

from PIL import Image

if __name__ == "__main__":
    input_loc = "AvatarShopImages/80001.gif"
    output_loc = "Output/80001.gif"
    im = Image.open(input_loc)
    im = im.crop((4, 4, 94, 94))
    im.save(output_loc)

If it looks weird, it is because I copy/pasted some code and edited a lot out of it.

524
9
Jupyter notebook (programming.dev)

Hi,

Is it ok to use Jupyter notebook exclusively for creating notes. I do not need to run any codes in cells, just taking notes.

Currently, I run notebook using 'jupyter-notebook'. Then, use Kernel > Shutdown option. And, create notes.

I think there will be commandline option, but cannot find any. Any advise on this?

Thanks,

525
21
submitted 3 years ago* (last edited 3 years ago) by wasabi@feddit.de to c/python@programming.dev

I have seen some people prefer to create a list of strings by using thing = list[str]() instead of thing: list[str] = []. I think it looks kinda weird, but maybe that's just because I have never seen that syntax before. Does that have any downsides?

It is also possible to use this for dicts: thing = dict[str, SomeClass](). Looks equally weird to me. Is that widely used? Would you use it? Would you point it out in a code review?

view more: ‹ prev next ›

Python

8022 readers
2 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 3 years ago
MODERATORS