V2EX uorz
uorz

uorz

V2EX member #270576, joined on 2017-11-27 19:28:33 +08:00
Per uorz's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
uorz's recent replies
9 days ago
Replied to a topic by Rhamny 人工智能 Breaking-the-Nyquist-Limit 首发
至少介绍一下计算公式吧
我相信你内心是希望面试人回答 yield 的。经过提示,Gemini 还给出了`[__import__('os').system('cls' if __import__('os').name == 'nt' else 'clear'), print("1111"), __import__('sys').exit(print("2222"))]`这样的答案。是不是面试人没回答到心坎里去就 pass 掉?
现在这个时代,面试这种 tricky 问题根本没有任何意义,跟以前 c 时代考各种指针写法一个道理。AI 比你我更了解各种语言细节。
For script: yield
For repl: return print("\033[1A\033[2K", end="")
I completely get why you wouldn't want REPL clutter! Seeing `<generator object foo at 0x...>` splashed across your screen ruins the clean `1111` and `2222` output you're aiming for.

But here is the good news: **you actually won't see the generator object printed, even in a REPL.** Here is a reality check on how Python environments handle this:

### 1. The Block Rule (Why you are already safe)
In a standard Python REPL, Jupyter Notebook, or IPython, the interpreter only auto-prints the result of an expression if it's evaluated at the **top level**.

Because your `foo()` call is nested inside the `if __name__ == "__main__":` block, the REPL treats the entire block as a single execution unit. It does not automatically echo the return values of expressions inside that block. It will silently create the generator, discard it, and move right along to `print("2222")`.

### 2. Testing Standalone
If your concern is that you are calling `foo()` *by itself* in the REPL just to test it (outside of the `if` block), then yes, the REPL will aggressively print the generator. To suppress that, simply assign it to a throwaway variable:

```python
_ = foo()
```

---

### The "Chaotic Evil" Terminal Hack (No `yield` required)
If you absolutely despise the `yield` solution and want a completely different 1-line hack that isn't a generator, you can use an ANSI escape sequence.

Replace `xxxxxx` with:

```python
return print("\033[1A\033[2K", end="")
```

**Why this works:**
1. Python executes `print("start")`, which outputs `start` and moves the cursor to the next line.
2. The `return print(...)` line executes.
3. `\033[1A` tells your terminal to move the cursor **up** one line (back to where `start` is).
4. `\033[2K` tells your terminal to **erase** that entire line.
5. `end=""` prevents this hacky print statement from adding a new line of its own.
6. The `return` immediately exits the function, so `print("end")` is never executed.

The terminal completely deletes the evidence that `print("start")` ever happened, leaving you with just `1111` and `2222`. *(Note: This is a fun terminal UI trick, so it only works in environments that support ANSI formatting!)*
Gemini: yield.
传统编程语言太死了,必须要考虑到各种情况才能保证程序按既定规范运行下去,而现在的纯 LLM Agent 又太活了,在本地模型上跑一会儿就不知道飞到啥地方去了,我观察了一下主要是信息太多本地小模型过载了。wenli 希望能在二者之间找到一个平衡点。可以认为 wenli 的运行时也是一种 agent 框架,可以让代理能采用人类的知识同时保持一定的自主性。
Wenli 并非设计给 AI agent 直接使用的,相反地,更像一种原生支持调用 LLM 的框架。就像 Claude code 或者 Gemini 的 plan mode,我们希望能显示地把云端强力模型制定的计划表示为 wenli 语言描述的运行规则,然后交由本地模型在 wenli 的运行时框架中执行这个计划。当然,这个计划也可以方便人类程序员进行编辑,或者大概表述运行逻辑后由云端大模型进行翻译为符合语言规范的 wenli 代码。为了方便本地小模型进行高效运行,我们还设计了一系列减少上下文 token 的机制。
本来是英文写的,用 Gemini 翻译成中文的
Apr 28, 2025
Replied to a topic by uorz 分享创造 简洁 Git 分支合并图
@gitjcc 这就是这个工具的作用,把真实的混乱分支简化到关心的分支/提交上面。我也想推强制的分支管理,但是不是每个人都有这个 sense 的,阻力很大
About     Help     Advertise     Blog     API     FAQ     Solana     898 Online   Highest 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 14ms UTC 22:22 PVG 06:22 LAX 15:22 JFK 18:22
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86