1
1
submitted 5 months ago by cypherpunks@lemmy.ml to c/python@lemmy.ml
2
1
Python 3.13 gets a JIT (tonybaloney.github.io)
submitted 8 months ago by ylai@lemmy.ml to c/python@lemmy.ml
3
1
submitted 8 months ago by cypherpunks@lemmy.ml to c/python@lemmy.ml
4
1
submitted 9 months ago by Xer0@lemmy.ml to c/python@lemmy.ml

Just wondering if anyone is part of any Python chats, communities, forums etc, and which ones are good to join?

5
1
submitted 9 months ago by xiffu@kbin.social to c/python@lemmy.ml

Join chat rooms and explore programming content on Chat-to.dev.

6
1
submitted 10 months ago by ylai@lemmy.ml to c/python@lemmy.ml
7
1
submitted 10 months ago by ylai@lemmy.ml to c/python@lemmy.ml
8
1
submitted 10 months ago* (last edited 10 months ago) by makeasnek@lemmy.ml to c/python@lemmy.ml

I am working on a new django project which will use a MySQL database. Obviously there are several tables and attributes items in those tables have. I realize I could just document those attributes in the code itself, but more than one codebase may be accessing this database. I would rather have a more comprehensive solution to document relationships, expected CASEing of the text, allowed characters, etc.

I know UML exists, but it seems there are 1,000+ tools which do UML modeling, not all of which will gracefully do an SQL database.

Examples of things I want to document:

  • For a "user profile" there are various attributes: username (primary key), friendly name, etc
  • For a "task" - id (primary key), name (letters numbers and spaces only, max 56 characters), owner (a single username (foreign key(), assignees (zero or more usernames (list of foreign keys)), etc

Here's what I need:

  • GUI for building flowchart/model/whatever you call it showing each table and each attribute in each table, with ability to add notes to table or attribute. Attributes must have ability to be relational just like in a database.
  • FOSS only, must run on Linux. No "free" web-based garbage that will end up behind a paywall 5 years from now ie draw.io
  • Must store source files for this model in a text/xml/json/something file which can easily be put into our git repo
  • Must not be so tightly coupled to MySQL that is requires a database connection to work or couldn't be used if we switch to a non-MySQL backent. If it has templates for and knowledge about MySQL databases that's great but it shouldn't require them to be useful.

What do you suggest for this?

9
1
submitted 11 months ago by loki@lemmy.ml to c/python@lemmy.ml
10
1
The fraud was in the code (newsletter.mollywhite.net)
submitted 11 months ago by ylai@lemmy.ml to c/python@lemmy.ml
11
1
submitted 11 months ago by cypherpunks@lemmy.ml to c/python@lemmy.ml
12
1
submitted 1 year ago by nathanpc@lemmy.ml to c/python@lemmy.ml

Hello Python community! There are a lot of resources online targeted at beginners that want to learn Python but very rarely do you see articles talking about moving to Python when you already have tons of experience in other languages like Ruby, and especially, many years of Perl experience and is interested in moving to Python.

I'm not looking for information on how to program in Python, that's really easy to find and most of the learning curve will be learning about the standard libraries and overcoming the years of muscle memory from other languages. I'm looking for information on the following topics:

  • What's the recommended project structure for a library or a program that'll be distributed via PyPI?
  • What are the general best practices to follow when writing "clean Python code"?
  • What's the most commonly followed style guide for the language?
  • How does import work internally and how does it perform its path lookup for local files (specifically for importing modules internal to a project)?
  • How to properly set up pyenv for a project? (This one is tricky for me because the Python community loves pyenv and I'm used to having packages globally installed in Ruby and Perl)
13
1
submitted 1 year ago by Ajsra@lemmy.ml to c/python@lemmy.ml
14
1
submitted 1 year ago* (last edited 1 year ago) by SurpriseCandid8978@lemmy.ca to c/python@lemmy.ml

Hi,

Does Anyone have any great resources to learn python for a non-programmer? Youtube? Free online courses, etc?

Im starting out and there is a lot out there. They all look good too.

So far, i got python installed lol.

Thanks,

Edit: thanks everyone. I have some homework to do and check out all the resources !

15
1
submitted 1 year ago by uthredii@lemmy.ml to c/python@lemmy.ml
16
1
17
1
submitted 1 year ago by aswin@lemmy.sdf.org to c/python@lemmy.ml

Pyscan v0.1.4 | GitHub

Pyscan is the fastest CLI tool to find dependency vulnerabilities in your python projects.

  • blazingly fast scanner that can be used within large projects.
  • automatically finds requirements.txt, pyproject.toml or, the source code.
  • can be integrated into existing build processes.
  • In its early stage, thus hasn't been battle-hardened yet.

Install

pip install pyscan-rs

look out for the "-rs" part or

cargo install pyscan

Usage

Go to your python source directory (or wherever you keep your requirements.txt/pyproject.toml) and run:

> pyscan

or

> pyscan -d path/to/src

Pyscan is a tool written in Rust that uses OSV, which is an open source vulnerabilities database, which inspired me to make this tool.

18
1
Compiling typed Python (bernsteinbear.com)
submitted 1 year ago by pumpkin@sh.itjust.works to c/python@lemmy.ml
19
1
submitted 1 year ago by Limeey@lemmy.world to c/python@lemmy.ml

I switched from notebook to labs recently and I'm missing how the notebook name is displayed in notebooks. it seems like the only way to know which notebook I'm in now is through the tab, but if I have multiple tabs open it compresses them.

Is there any extension or something that will display the notebook name (and make it easily editable) like in notebooks?

20
1
21
1
submitted 1 year ago by pumpkin@sh.itjust.works to c/python@lemmy.ml
22
1
submitted 1 year ago by radarsat1@lemmy.ml to c/python@lemmy.ml

Let's say I have a context manager that provides a resource that then mutates on exit:

from contextlib import contextmanager

@contextmanager
def context():
    x = ['hi']
    yield x
    x[0] = 'there'

I found that if I want to make another context class that uses this, such that the context (before mutation) is valid, I have to pass it in:

class Example1:
    def __init__(self, obj):
        self.obj = obj
    def use_obj(self):
        print(self.obj)
    def __enter__(self):
        print("start")
        return self
    def __exit__(self, *exc):
        print("end")

with context() as x:
    with Example1(x) as y:
        y.use_obj()

prints:

start
['hi']
end

However, what I don't like is, let's say that obj is an internal detail of my class. I don't want the user to have to define it beforehand and pass it in.

The only way I can figure how to do this is by calling the context manager's __enter__() explicitly:

class Example2:
    def use_obj(self):
        print(self.obj)
    def __enter__(self):
        print("start")
        self.ctx = context()
        self.obj = self.ctx.__enter__()
        return self
    def __exit__(self, *exc):
        print("end")
        self.ctx.__exit__(None, None, None)

with Example2() as y:
    y.use_obj()

which also prints,

start
['hi']
end

For comparison, just as some other random attempt, the following doesn't work because the context ends when self.obj is created:

class Example3:
    def use_obj(self):
        print(self.obj)
    def __enter__(self):
        print("start")
        with context() as x:
            self.obj = x
        return self
    def __exit__(self, *exc):
        print("end")

with Example3() as y:
    y.use_obj()

which prints,

start
['there']
end

Okay, so my point is that Example2 is the right solution here. But, it's really ugly. So my question is, is there a better way to write Example2?

23
1

I'm setting up a new laptop and considering which of the (many) environment managers to use this time around. My standard has been miniconda, since a big plus for me is the ability to set and download specific python version for different projects all in one tool. I also quite like having global access to different environments (i.e. environments aren't tied to specific projects). I typically have a standard GenDataSci environment always available for initially testing things out, then if I know I'll be continuing as a single project I'll make a stand alone environment for it.

But I've also used poetry for tighter control and reproducibility when I'm actually packaging to publish on PyPI. Hatch looks interesting as well but I can't tell if it includes the ability to have separate python version installs for each environment.

What workflows and managers are people using now?

24
1
submitted 1 year ago by gwilikers@lemmy.ml to c/python@lemmy.ml

Brendan Metcalfe's intro series to list comprehensions is one of the best I've come across. In addition to showing how to use them, he compares it to other similar methods and shows why LCs can be more effective. Wanted to share his stuff here.

25
1

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

Some surprising, but valid, python syntax examples.

view more: next ›

Python

3065 readers
28 users here now

News and discussions about the programming language Python


founded 5 years ago
MODERATORS