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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Should I go from CamelCase to snake_case for Python wrappers for C++?

1 点作者 aleclm将近 3 年前
I have a data structure which is used in several places:<p>1. C++: `struct` with CamelCase fields<p>2. YAML serialization (our file format): dictionaries with CamelCase keys (derived from C++);<p>3. Documentation: describes the file format, so the same as YAML;<p>4. Python wrappers: should I stick with CamelCase or convert field names to snake_case?<p>5. TypeScript wrappers: should I stick with CamelCase or convert field names to dromedaryCase?<p>I can easily make the conversion, but I suspect it will make it harder to lookup things in the documentation, which would make Python and TypeScript somewhat second class citizens.<p>On the other hand, if the wrappers do not conform with common practices of the language they are targeting, they feel somewhat second class citizens too.<p>What do you think?

1 comment

eesmith将近 3 年前
Stay with CamelCase, for exactly the reasons you mention.<p>See for example Python&#x27;s unittest and xml.sax.saxutils, which follow the Java naming conventions of JUnit and the Java implementation of SAX, respectively.