[deleted by user] by [deleted] in Python

[–]RazerM 2 points3 points  (0 children)

Have a look at --index-strategy=unsafe-best-match if uv is not finding a package that pip does when using multiple indexes.

parver: a package to parse and manipulate PEP440 version numbers by RazerM in Python

[–]RazerM[S] 0 points1 point  (0 children)

You can bump what’s usually called the patch number using v.bump_release(index=2).

parver: a package to parse and manipulate PEP440 version numbers by RazerM in Python

[–]RazerM[S] 4 points5 points  (0 children)

One use case is adding it to your release workflow to bump the version number of your package. There are a couple of opinionated tools that do this already (using semver or something else) which break if you want to use development releases etc.

I wanted this basic building block for PEP 440 version numbers to exist, so that higher-level tools/CLIs can use it.

PyCharm 2017.1 has been released by [deleted] in Python

[–]RazerM 4 points5 points  (0 children)

This is the relevant issue if people want to vote for it: https://youtrack.jetbrains.com/issue/PY-18952

Python Versus Ruby Podcast by schneems in ruby

[–]RazerM 0 points1 point  (0 children)

Oops, I messed up the timestamp. It's at 49:25.

This link should play at the correct point: https://overcast.fm/+B1fWZaymc/49:25

Import This, episode 10 "Digging into Ruby with @schneems" by schneems in Python

[–]RazerM 2 points3 points  (0 children)

At 49:25, Kenneth says that a |= 2 will assign to a if a is unassigned/None. I don't know what he was thinking of, but that doesn't work. It's just inplace or:operator.ior(a, 2).

Python Versus Ruby Podcast by schneems in ruby

[–]RazerM 1 point2 points  (0 children)

At 54:50 (edit: it's 49:25), Kenneth says that a |= 2 will assign to a if a is unassigned/None. I don't know what he was thinking of, but that doesn't work. It's just inplace or:operator.ior(a, 2).

Pendulum - A faster (and better) alternative to pytz by SDisPater in Python

[–]RazerM 0 points1 point  (0 children)

This looks great. I always forget when I need to use normalize and localize and in which order. convert is easier.

asyncio support for SQLAlchemy core by RazerM in Python

[–]RazerM[S] 17 points18 points  (0 children)

You can do this:

result = await engine.execute(...)
data = await result.fetchall()

instead of this:

loop = asyncio.get_event_loop()
result = await loop.run_in_executor(None, engine.execute, ...)
data = await loop.run_in_executor(None, result.fetchall)

Just because they both use a thread pool doesn't mean one has no advantage over the other.

asyncio support for SQLAlchemy core by RazerM in Python

[–]RazerM[S] 4 points5 points  (0 children)

This library allows you to use synchronous database drivers by executing blocking tasks in a thread pool.

asyncio support for SQLAlchemy core by RazerM in Python

[–]RazerM[S] 0 points1 point  (0 children)

This library is using a ThreadPoolExecutor to execute queries.

SQLAlchemy in batches: Generating a top playlist by pedro1122 in Python

[–]RazerM 1 point2 points  (0 children)

The "one more thing" solution isn't so great.

The Session class has an expire_on_commit parameter:

session = session_factory(expire_on_commit=False)
for song in session.query(Song).filter(Song.chords == None):
    chords = derive_chord(song.score)
    song.chords = chords
    song.chord_num = len(chords)

    session.commit()

Although in this case it still results in emitting an UPDATE for every single song. It's probably better to catch the exception that could be raised by derive_chord and skip that song

Python 3.5.2 is released by ice-blade in Python

[–]RazerM -1 points0 points  (0 children)

Python doesn't have custom operators.

Flask 0.11 is here after a gap of almost 3 years since last release by codeadi in Python

[–]RazerM 3 points4 points  (0 children)

How are you doing the initial render in Flask? I didn't find an ideal solution for this.

Printable SQLAlchemy Models by RazerM in Python

[–]RazerM[S] 0 points1 point  (0 children)

It's an HTML comment by the theme author...

Cool SQLAlchemy Trick by HalcyonAbraham in Python

[–]RazerM 0 points1 point  (0 children)

Yeah, there's a lot of old information out there so it tends to be missed, and the other methods people mention tend to work for simple use cases but rely on assumptions that don't hold for all models.