TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why should bottlepy stick to a file?

98 点作者 Al0neStar超过 5 年前

16 条评论

fermigier超过 5 年前
I&#x27;ve learned recently, to my astonishment (I&#x27;ve been using Flask for the last 10 years and Bottle briefly before) that both names are puns on the WSGI acronym (which is pronounced &quot;woos-ghee&quot;, and sounds similar to &quot;whisky&quot;).<p>In Flask&#x27;s case, it&#x27;s indirect, as Armin admitted in the 2011 presentation (<a href="http:&#x2F;&#x2F;mitsuhiko.pocoo.org&#x2F;flask-pycon-2011.pdf" rel="nofollow">http:&#x2F;&#x2F;mitsuhiko.pocoo.org&#x2F;flask-pycon-2011.pdf</a>): &quot;Wordplay on Bottle, probably a mistake&quot;.
hermanradtke超过 5 年前
The (admittedly biased) history of bottle and flask from the author was fascinating <a href="https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;issues&#x2F;1158#issuecomment-526602488" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;issues&#x2F;1158#issuecomment-...</a>
评论 #22019262 未加载
评论 #22019107 未加载
timeattack超过 5 年前
I don&#x27;t quite get those arguments [1]:<p>&gt; The single-file restriction is an effective save-guard against feature creep. [...] We are able reject pull requests simply because they would add too many lines or add too much complexity, and that&#x27;s nice.<p>bottle.py is already 4425 lines of code [2].<p>So, despite they say they reject pull requests because they add too many lines, it&#x27;s also can be said that they reject pull requests because file is too big already and merging PR makes it even harder to maintain.<p>&gt; A single file is easier to debug and understand. [...] You can read the entirety of bottle.py in an hour or so. Most of it is pretty easy to understand. Try that with flask&#x2F;pyramid&#x2F;django [...]<p>Why not at least to just split it to 1 section per 1 file, which they emulate right now by using section-delimiting comments [3]? Will it make code much harder to understand? Or will it make code easier to understand?<p>Also, from a developer perspective, what about navigation to the correct section quickly. E.g. if developer wants to add a new Exception, how he can efficiently go to the specific section? If it wouldn&#x27;t be single file, developer could jump to required file by typing couple of letters in fuzzy file opener it his editor of choice.<p>No one forces developers plunge into a feature creep apart from their own, and it actually doesn&#x27;t matter is there a single file or not. Some prefer to write as many code as they can in one single line. I doubt that they do it to ease maintenance and to avoid feature creep.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;issues&#x2F;1158#issuecomment-526602488" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;issues&#x2F;1158#issuecomment-...</a> [2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;blob&#x2F;master&#x2F;bottle.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;blob&#x2F;master&#x2F;bottle.py</a> [3]: <a href="https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;blob&#x2F;332215b2b1b3de5a321ba9f3497777fc93662893&#x2F;bottle.py#L262-L264" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bottlepy&#x2F;bottle&#x2F;blob&#x2F;332215b2b1b3de5a321b...</a>
评论 #22020268 未加载
评论 #22020270 未加载
QuadrupleA超过 5 年前
Title is confusing, maybe &quot;keep to a single file&quot;? Had to read a while before I realized it wasn&#x27;t some kind of file-clinging code barnacle.<p>First I&#x27;ve heard about bottle, I&#x27;m intrigued - as a longtime Flask user who is occasionally frustrated with its OOP-zeal it might be up my alley.
dlbucci超过 5 年前
Back in college, Bottle was where I started to understand how web servers worked. I had written PHP but had zero idea how it worked (or how to write it) and eventually I tried Django, but couldn&#x27;t configure it to send static files. Once I tried bottle though, it just clicked. It was so simple and I loved that there was little magic. It being a single file that I just dragged into a folder was a BIG part of the simplicity for me, too. I mostly write nodejs these days (express sorta scratches the same itch), but I have fond memories of bottle. In fact, my old personal site (<a href="http:&#x2F;&#x2F;www.superftc.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.superftc.com&#x2F;</a>) is still a bottle app to this day.
评论 #22019117 未加载
oefrha超过 5 年前
I have a relatively popular single-Python-file, no-dependency-beyond-PSL project myself (slightly smaller than bottle.py, ~3.5k lines). It would certainly be shorter and easier to develop if I added a bunch of dependencies, but I’ve resisted the urge over time, and being able to just download a single file and use it with any Python installation that’s less than five years old is ultimately worth the effort IMO. Also got me closer to some lower level PSL modules.
评论 #22026306 未加载
rs23296008n1超过 5 年前
Bottlepy is like one of those plucky little mammals living amongst giants. It is nimble and quick with small footprints.<p>I use it for quickly deploying endpoints for specific tasks such as a miniscule CDN and the obligatory blog. Great for home automation as well.
umvi超过 5 年前
I don&#x27;t blame him. I made the same design choice for my python library[1]. I also don&#x27;t use any non-native libraries in the single file. I&#x27;m sorry to say it&#x27;s a much better experience for users if they don&#x27;t have to deal with pip if they don&#x27;t want to. I myself have been burned many times trying to install some python module for hours and failing because of some dependency issue.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;RPGillespie6&#x2F;fastcov" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RPGillespie6&#x2F;fastcov</a>
INTPenis超过 5 年前
Bottle was my 3rd python web framework that I tried and I really liked the idea.<p>But then I learned about Flask blueprints and now I can&#x27;t live without them.<p>Imagine that I can make a lambda function that only loads selective blueprints, selective parts of my API, into AWS.<p>That&#x27;s very powerful for off loading bottlenecks.<p>Is it possible to do blueprints with bottle? Because seeing as they&#x27;ve cemented the single file policy, it would make sense to have some sort of plugin system.
评论 #22019086 未加载
rcarmo超过 5 年前
I love Bottle because it’s a single file and I can read through all of it to (re)understand it. It has all the essentials and nearly zero cruft, and I’ve been using it for ages - it runs my personal website, many API servers I wrote, and the odd minimal system daemon[0].<p>I rather like the single-file approach for small, focused software - imapbackup[1] and piku[2] were written to be easy to deploy and customize, and there certainly is a place for drop-in-and-forget libraries like bottle (I wish there were more like it, in other fields).<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;azure-k3s-cluster&#x2F;blob&#x2F;master&#x2F;cloud-config&#x2F;master.yml#L15" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;azure-k3s-cluster&#x2F;blob&#x2F;master&#x2F;clou...</a><p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;imapbackup" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;imapbackup</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;piku" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;piku</a>
kerkeslager超过 5 年前
Kudos to Bottle for keeping their code simple and auditable. I&#x27;ve been writing small projects in Bottle for a while.
mirkonasato超过 5 年前
I never used Bottle and don&#x27;t doubt the comments saying it&#x27;s a great framework, but I&#x27;m more interested on the &quot;single file&quot; approach in general.<p>bottle.py may be a single file but it&#x27;s 4,425 lines long. That doesn&#x27;t strike me as particularly simple. Any project could potentially be &quot;a single file&quot; if it&#x27;s a very long file.<p>Why would splitting it into a few separate files make it more complex? There&#x27;s a reason why every modern programming language supports modules, and that&#x27;s precisely to break down complexity into smaller, simpler units.
评论 #22019378 未加载
评论 #22020216 未加载
jrockway超过 5 年前
Arguments like this are why I gave up on scripting languages. &quot;go build&quot; generates one statically-linked binary that you can send anywhere. You can build a Windows binary from your Raspberry Pi or vice-versa. It is how everything should work, because distributing (and cross-compiling) is something you should have to spend 0 time thinking about. Now I spend 0 time thinking about it.
评论 #22019887 未加载
jc_sec超过 5 年前
Huge fan of bottle. I use it for a lot of things.
Too超过 5 年前
If this is a design decision for a library it means the package and distribution manager for the language is broken.
评论 #22019215 未加载
sandGorgon超过 5 年前
The singlefile-ness of Bottle is no longer unique. For example, the modern day Fastapi built on async ASGI (and ranks top in framework benchmarks) is also single file.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tiangolo&#x2F;fastapi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tiangolo&#x2F;fastapi</a><p>or Fastapi for that matter - <a href="https:&#x2F;&#x2F;github.com&#x2F;encode&#x2F;starlette" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;encode&#x2F;starlette</a><p>However, it is a bit tricky to run Bottle with production grade servers like gunicorn&#x2F;uwsgi.
评论 #22018915 未加载
评论 #22018931 未加载