Skip to content

Commit

Permalink
new post for bpython
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-ruehe committed Sep 29, 2024
1 parent b36908b commit a95fe46
Show file tree
Hide file tree
Showing 95 changed files with 702 additions and 4,097 deletions.
2 changes: 1 addition & 1 deletion content/posts/2016-03-03-lametric-local-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'LaMetric & local push'
author: Alex
type: posts
date: 2016-03-03T18:55:08+00:00
url: /lametric-local-push/
url: /posts/lametric-local-push/
categories:
- Tutorial
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: LaMetric Firmware 1.6.0 and local push
author: Alex
type: posts
date: 2016-07-17T20:25:28+00:00
url: /lametric-firmware-1-6-0-and-local-push/
url: /posts/lametric-firmware-1-6-0-and-local-push/
categories:
- Tutorial
tags:
Expand Down
2 changes: 1 addition & 1 deletion content/posts/2016-07-24-log-your-played-itunes-tracks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Log your played iTunes tracks
author: Alex
type: posts
date: 2016-07-24T07:21:38+00:00
url: /log-your-played-itunes-tracks/
url: /posts/log-your-played-itunes-tracks/
categories:
- Tutorial
tags:
Expand Down
2 changes: 1 addition & 1 deletion content/posts/2016-09-06-review-bragi-the-dash.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'Review: Bragi – The Dash'
author: Alex
type: posts
date: 2016-09-06T10:13:02+00:00
url: /review-bragi-the-dash/
url: /posts/review-bragi-the-dash/
featured_image: /wp-content/uploads/2016/09/bragi_dash_black-e1473156872973.jpg
categories:
- Review
Expand Down
2 changes: 1 addition & 1 deletion content/posts/2017-01-31-lametric-firmware-1-7-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: LaMetric Firmware 1.7.5
author: Alex
type: posts
date: 2017-01-31T22:37:29+00:00
url: /lametric-firmware-1-7-5/
url: /posts/lametric-firmware-1-7-5/
categories:
- Article
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Show Download and Upload speed on your LaMetric Time
author: Alex
type: posts
date: 2017-02-06T13:13:57+00:00
url: /show-download-and-upload-speed-on-your-lametric-time/
url: /posts/show-download-and-upload-speed-on-your-lametric-time/
categories:
- Tutorial
tags:
Expand Down
2 changes: 1 addition & 1 deletion content/posts/2017-02-10-quickfolders-a-bitbar-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: QuickFolders – a BitBar plugin
author: Alex
type: posts
date: 2017-02-10T13:23:47+00:00
url: /quickfolders-a-bitbar-plugin/
url: /posts/quickfolders-a-bitbar-plugin/
categories:
- Article
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Run Jupyter Notebooks as a Service on macOS
author: Alex
type: posts
date: 2017-08-31T04:16:40+00:00
url: /run-jupyter-notebooks-as-a-service-on-macos/
url: /posts/run-jupyter-notebooks-as-a-service-on-macos/
categories:
- Tutorial
tags:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Using one bpython with multiple virtual environments
author: Alex
type: posts
date: 2024-09-29T20:49:33+02:00
url: /posts/bpython-with-multiple-virtual-environments/
categories:
- Tutorial
tags:
- Python
- TIL
- venv
- REPL
---

I finally realized that I should change the default Python REPL. There are many REPLs that offer a much better experience—[ipython](https://ipython.org/), [bpython](https://bpython-interpreter.org/), and [ptpython](https://github.com/prompt-toolkit/ptpython) are probably the most well-known. In the past, I used ipython because I worked on many projects that involved Jupyter notebooks, so it came essentially for free whenever I installed the necessary packages.

However, in recent years, I've been working on a lot of projects that don't rely on Jupyter, meaning ipython wasn’t installed by default. This meant I always had to manually install it in any virtual environment where I wanted to use it—which I didn’t like, as I prefer to keep only project-specific dependencies in a virtual environment.

As a result, I relied on the plain old `python` REPL, with all its shortcomings—especially the difficulty of pasting code snippets (which, thankfully, will be improved with [Python 3.13](https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-better-interactive-interpreter)).

Today, I started wondering if there was a way to use a REPL like `bpython` in every environment I have. You can install it once with [`pipx`](https://github.com/pypa/pipx) and use it everywhere, but it won't find any packages by default. While searching online, I came across a promising post on [Stack Overflow](https://stackoverflow.com/a/22182421). Although the post was from 2014 and the exact approach didn't work, with a bit of fiddling, I found a solution that seems to work. I added the following function to my `.zshrc`:


```zsh
function bp() {
if test -n "$VIRTUAL_ENV"
then
PP=".$(python -c 'import sys; print(":".join(sys.path))')"
PYTHONPATH=${PP} bpython "$@"
else
bpython "$@"
fi
}
```

Now, I can simply type `bp`, and it will either start `bpython` directly or, if a virtual environment is active, it will set the `PYTHONPATH` to include the venv directory before starting the REPL.
28 changes: 28 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ languageCode = 'en-us'
title = "Alex' Blog"
theme = 'archie'

pygmentsstyle = "monokai"
pygmentscodefences = true
pygmentscodefencesguesssyntax = true

[pagination]
pagerSize = 5

[[params.social]]
name = "GitHub"
icon = "github"
url = "https://github.com/alex-ruehe"


[[menu.main]]
name = "Home"
url = "/"
weight = 1

[[menu.main]]
name = "All posts"
url = "/posts"
weight = 2

[[menu.main]]
name = "Tags"
url = "/tags"
weight = 4

[params]
mode = "toggle"
useCDN=false
customcss = ["css/carousel.css"]
74 changes: 7 additions & 67 deletions public/categories/article/index.html
Original file line number Diff line number Diff line change
@@ -1,67 +1,7 @@
<!DOCTYPE html>
<html><head lang="en">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Article - Alex&#39; Blog</title><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="" />
<meta property="og:image" content=""/>
<link rel="alternate" type="application/rss+xml" href="https://dfghj.de/categories/article/index.xml" title="Alex' Blog" />
<meta property="og:title" content="Article" />
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://dfghj.de/categories/article/" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Article"/>
<meta name="twitter:description" content=""/>


<link href="https://dfghj.de/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css" rel="stylesheet">



<link rel="stylesheet" type="text/css" media="screen" href="https://dfghj.de/css/main.ac08a4c9714baa859217f92f051deb58df2938ec352b506df655005dcaf98cc0.css" />










<link rel="stylesheet" type="text/css" href="https://dfghj.de/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css">

</head>
<body>
<div class="content"><header>
<div class="main">
<a href="https://dfghj.de">Alex&#39; Blog</a>
</div>
<nav>


</nav>
</header>


<h1>Entries tagged - "Article"</h1>


<ul class="posts"><li class="post">
<a href="/quickfolders-a-bitbar-plugin/">QuickFolders – a BitBar plugin</a> <span class="meta">Feb 10, 2017</span>
</li><li class="post">
<a href="/lametric-firmware-1-7-5/">LaMetric Firmware 1.7.5</a> <span class="meta">Jan 31, 2017</span>
</li></ul>
<footer>
<div style="display:flex"></div>
<div class="footer-info">
2023 <a
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a>
</div>
</footer>


</div>
</body>
</html>
<!doctype html><html><head lang=en><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>Article - Alex' Blog</title><meta name=viewport content="width=device-width,initial-scale=1">
<meta name=description content><meta property="og:image" content><link rel=alternate type=application/rss+xml href=http://localhost:1313/categories/article/index.xml title="Alex' Blog"><meta property="og:url" content="http://localhost:1313/categories/article/"><meta property="og:site_name" content="Alex' Blog"><meta property="og:title" content="Article"><meta property="og:locale" content="en_us"><meta property="og:type" content="website"><meta name=twitter:card content="summary"><meta name=twitter:title content="Article"><script src=http://localhost:1313/js/feather.min.js></script><link href=http://localhost:1313/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css rel=stylesheet><link rel=stylesheet type=text/css media=screen href=http://localhost:1313/css/main.5cebd7d4fb2b97856af8d32a6def16164fcf7d844e98e236fcb3559655020373.css><link id=darkModeStyle rel=stylesheet type=text/css href=http://localhost:1313/css/dark.d22e2a2879d933a4b781535fc4c4c716e9f9d35ea4986dd0cbabda82effc4bdd.css disabled><link rel=stylesheet type=text/css href=http://localhost:1313/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css></head><body><div class=content><header><div class=main><a href=http://localhost:1313/>Alex' Blog</a></div><nav><a href=/>Home</a>
<a href=/posts>All posts</a>
<a href=/tags>Tags</a>
| <span id=dark-mode-toggle onclick=toggleTheme()></span>
<script src=http://localhost:1313/js/themetoggle.js></script></nav></header><h1>Entries tagged - "Article"</h1><ul class=posts><li class=post><a href=/posts/quickfolders-a-bitbar-plugin/>QuickFolders – a BitBar plugin</a> <span class=meta>Feb 10, 2017</span></li><li class=post><a href=/posts/lametric-firmware-1-7-5/>LaMetric Firmware 1.7.5</a> <span class=meta>Jan 31, 2017</span></li></ul><footer><div style=display:flex><a class=soc href=https://github.com/alex-ruehe rel=me title=GitHub><i data-feather=github></i></a>
<a class=border></a></div><div class=footer-info>2024 <a href=https://github.com/athul/archie>Archie Theme</a> | Built with <a href=https://gohugo.io>Hugo</a></div></footer><script>feather.replace()</script></div></body></html>
28 changes: 1 addition & 27 deletions public/categories/article/index.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Article on Alex&#39; Blog</title>
<link>https://dfghj.de/categories/article/</link>
<description>Recent content in Article on Alex&#39; Blog</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Fri, 10 Feb 2017 13:23:47 +0000</lastBuildDate>
<atom:link href="https://dfghj.de/categories/article/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>QuickFolders – a BitBar plugin</title>
<link>https://dfghj.de/quickfolders-a-bitbar-plugin/</link>
<pubDate>Fri, 10 Feb 2017 13:23:47 +0000</pubDate>
<guid>https://dfghj.de/quickfolders-a-bitbar-plugin/</guid>
<description>I’m a big fan of BitBar, an application that allows you to “Put anything in your Mac OS X menu bar” (macOS nowadays). People have already created more than 250 plugins which allow you to show plenty of information in the menubar. Basically any script that can be executed on the terminal and has some kind of output can be used to display this output.
This is how my BitBar output looks at the moment:</description>
</item>
<item>
<title>LaMetric Firmware 1.7.5</title>
<link>https://dfghj.de/lametric-firmware-1-7-5/</link>
<pubDate>Tue, 31 Jan 2017 22:37:29 +0000</pubDate>
<guid>https://dfghj.de/lametric-firmware-1-7-5/</guid>
<description>A new firmware for the LaMetric Time is out – version 1.7.5 has some nice things to offer for those of us who would like to use the device in home automation (sadly the documentation is not yet updated). While this has been announced in the change log for 1.7.4, there have been some bugs and there are still one or two things that needs fixing, but that’s just minor stuff.</description>
</item>
</channel>
</rss>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Article on Alex' Blog</title><link>http://localhost:1313/categories/article/</link><description>Recent content in Article on Alex' Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 10 Feb 2017 13:23:47 +0000</lastBuildDate><atom:link href="http://localhost:1313/categories/article/index.xml" rel="self" type="application/rss+xml"/><item><title>QuickFolders – a BitBar plugin</title><link>http://localhost:1313/posts/quickfolders-a-bitbar-plugin/</link><pubDate>Fri, 10 Feb 2017 13:23:47 +0000</pubDate><guid>http://localhost:1313/posts/quickfolders-a-bitbar-plugin/</guid><description>&lt;p>I’m a big fan of &lt;!-- raw HTML omitted -->BitBar&lt;!-- raw HTML omitted -->, an application that allows you to “Put anything in your Mac OS X menu bar” (macOS nowadays). People have already created more than 250 plugins which allow you to show plenty of information in the menubar. Basically any script that can be executed on the terminal and has some kind of output can be used to display this output.&lt;/p></description></item><item><title>LaMetric Firmware 1.7.5</title><link>http://localhost:1313/posts/lametric-firmware-1-7-5/</link><pubDate>Tue, 31 Jan 2017 22:37:29 +0000</pubDate><guid>http://localhost:1313/posts/lametric-firmware-1-7-5/</guid><description>&lt;p>A new firmware for the LaMetric Time is out – &lt;a href="http://firmware.lametric.com">version 1.7.5&lt;/a> has some nice things to offer for those of us who would like to use the device in home automation (sadly the documentation is not yet updated). While this has been announced in the change log for 1.7.4, there have been some bugs and there are still one or two things that needs fixing, but that’s just minor stuff.&lt;/p></description></item></channel></rss>
91 changes: 7 additions & 84 deletions public/categories/index.html
Original file line number Diff line number Diff line change
@@ -1,84 +1,7 @@
<!DOCTYPE html>
<html><head lang="en">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Categories - Alex&#39; Blog</title><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="" />
<meta property="og:image" content=""/>
<link rel="alternate" type="application/rss+xml" href="https://dfghj.de/categories/index.xml" title="Alex' Blog" />
<meta property="og:title" content="Categories" />
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://dfghj.de/categories/" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Categories"/>
<meta name="twitter:description" content=""/>


<link href="https://dfghj.de/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css" rel="stylesheet">



<link rel="stylesheet" type="text/css" media="screen" href="https://dfghj.de/css/main.ac08a4c9714baa859217f92f051deb58df2938ec352b506df655005dcaf98cc0.css" />










<link rel="stylesheet" type="text/css" href="https://dfghj.de/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css">

</head>
<body>
<div class="content"><header>
<div class="main">
<a href="https://dfghj.de">Alex&#39; Blog</a>
</div>
<nav>


</nav>
</header>

<h1 class="page-title">All tags</h1>








<div class="tag-cloud">
<ul class="tags">



<li><a style="font-size: 1rem;" href="https://dfghj.decategories/tutorial/">tutorial</a></li>



<li><a style="font-size: 1rem;" href="https://dfghj.decategories/article/">article</a></li>



<li><a style="font-size: 1rem;" href="https://dfghj.decategories/review/">review</a></li>

</ul>
</div>
<footer>
<div style="display:flex"></div>
<div class="footer-info">
2023 <a
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a>
</div>
</footer>


</div>
</body>
</html>
<!doctype html><html><head lang=en><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>Categories - Alex' Blog</title><meta name=viewport content="width=device-width,initial-scale=1">
<meta name=description content><meta property="og:image" content><link rel=alternate type=application/rss+xml href=http://localhost:1313/categories/index.xml title="Alex' Blog"><meta property="og:url" content="http://localhost:1313/categories/"><meta property="og:site_name" content="Alex' Blog"><meta property="og:title" content="Categories"><meta property="og:locale" content="en_us"><meta property="og:type" content="website"><meta name=twitter:card content="summary"><meta name=twitter:title content="Categories"><script src=http://localhost:1313/js/feather.min.js></script><link href=http://localhost:1313/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css rel=stylesheet><link rel=stylesheet type=text/css media=screen href=http://localhost:1313/css/main.5cebd7d4fb2b97856af8d32a6def16164fcf7d844e98e236fcb3559655020373.css><link id=darkModeStyle rel=stylesheet type=text/css href=http://localhost:1313/css/dark.d22e2a2879d933a4b781535fc4c4c716e9f9d35ea4986dd0cbabda82effc4bdd.css disabled><link rel=stylesheet type=text/css href=http://localhost:1313/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css></head><body><div class=content><header><div class=main><a href=http://localhost:1313/>Alex' Blog</a></div><nav><a href=/>Home</a>
<a href=/posts>All posts</a>
<a href=/tags>Tags</a>
| <span id=dark-mode-toggle onclick=toggleTheme()></span>
<script src=http://localhost:1313/js/themetoggle.js></script></nav></header><h1 class=page-title>All tags</h1><div class=tag-cloud><ul class=tags><li><a style=font-size:1rem href=http://localhost:1313/categories/tutorial/>tutorial</a></li><li><a style=font-size:1rem href=http://localhost:1313/categories/article/>article</a></li><li><a style=font-size:1rem href=http://localhost:1313/categories/review/>review</a></li></ul></div><footer><div style=display:flex><a class=soc href=https://github.com/alex-ruehe rel=me title=GitHub><i data-feather=github></i></a>
<a class=border></a></div><div class=footer-info>2024 <a href=https://github.com/athul/archie>Archie Theme</a> | Built with <a href=https://gohugo.io>Hugo</a></div></footer><script>feather.replace()</script></div></body></html>
Loading

0 comments on commit a95fe46

Please sign in to comment.