Python के पहले से घोषित constants कुछ अजीब-से हैं
Python के built-in constants जैसे `True`, `False`, `None`, `Ellipsis`, और `__debug__` का handling कुछ हैरान करने वाले edge cases उजागर करता है, जैसे compile time पर conditional code का हट जाना या शुरुआती versions में booleans को reassign करने जैसी ऐतिहासिक विचित्रताएँ। Commenters इन उदाहरणों का उपयोग Python के broader design trade-offs की पड़ताल के लिए करते हैं: इसका जमा हुआ “baggage,” type और async systems के अजीब कोने, और notoriously messy packaging, बनाम scripting, data work, और glue code के लिए एक accessible, batteries-included language के रूप में इसकी ताकत। यह चर्चा Python की तुलना PHP, JavaScript, Ruby, और Haskell जैसी भाषाओं से भी करती है, और theoretical language elegance, backward compatibility, तथा scale पर pragmatic usability के बीच बार-बार उभरने वाले तनावों को उजागर करती है.
विशेष constants और conditional compilation
- चर्चा Python के “pre-declared constants” पर केंद्रित है:
True,False,None(keywords) बनामEllipsis,NotImplemented,__debug__(special treatment वाले identifiers). __debug__को खास तौर पर अजीब बताया गया है:if __debug__:वाले blocksPYTHONOPTIMIZE/-Oके तहत पूरी तरह compile-out हो जाते हैं, जिससेassertके साथ यह conditional compilation का एक रूप बन जाता है।- यही कारण है कि
__debug__को assign करना forbidden है: code हटाते समय compiler इसे constant मानकर चलता है। - कई commenters मानते हैं कि उन्होंने
__debug__के बारे में कभी नहीं सुना था, याassertके साथ इसके interaction के बारे में भी नहीं, और note करते हैं कि critical checks के लिएassertका (गलत) उपयोग real security bugs पैदा कर सकता है। - 3.15 में आने वाला
TYPE_CHECKINGभी एक और pre-declared constant के रूप में mention किया गया है, जोEllipsis/NotImplementedकी तरह behave करता है।
Booleans और design “baggage” की ऐतिहासिक विचित्रताएँ
- शुरुआती Python में
True/Falseनहीं थे; users इन्हें1/0के रूप में define करते थे। Python 2 में उन्हें reassign किया जा सकता था; Python 3 ने उन्हें keywords बना दिया। boolअभी भीintका subclass है, जो लोगों को आज भी चौंकाता है और bugs का कारण बना है।- व्यापक मुद्दा: किसी language में
bool/null को बाद में fit करना कठिन होता है; C और Python को उदाहरण के तौर पर cite किया गया है। - भाषा-डिज़ाइन से जुड़ी कुछ और regrets भी discuss हुईं: built-in multidimensional arrays, bit arrays, और standardized small vector types का अभाव।
Python बनाम अन्य भाषाएँ और evolution
- एक पक्ष का तर्क है कि Python पुरानी, धीमी, brittle है, weak typing और chaotic packaging के साथ; उनका कहना है कि PHP जैसी communities ने अधिक आक्रामक रूप से evolve किया है और बेहतर सबक सीखे हैं (जैसे enforced types, unified tooling)।
- दूसरे लोग Python में हुए कई बड़े improvements की सूची देते हैं: type hints, async/await, performance work, f-strings, pattern matching, dict merge operators, dataclasses, GIL removal work,
pathlib, आदि। - एक आलोचनात्मक दृष्टिकोण यह मानता है कि ये features अक्सर key semantics के बिना ideas को copy करते हैं (non-enforced types, non-exhaustive pattern matching, async “function coloring”), और इन्हें “anti-features” कहा जाता है।
- JavaScript, PHP, Ruby, Racket/Scheme/Haskell से comparisons बार-बार आते हैं; इस पर मतभेद हैं कि कौन-सी language “weirder,” अधिक consistent, या अधिक beginner-friendly है।
Beginner-friendliness और उपयोग के क्षेत्र
- कुछ लोग कहते हैं कि Python edge cases से इतना भरा है कि वह अच्छी first language नहीं है; दूसरे तर्क देते हैं कि इसका REPL, batteries-included stdlib, readability, और Windows support इसे teaching और “glue” language के लिए उत्कृष्ट बनाते हैं।
- Significant indentation, truthiness, और duck typing को कुछ लोग “weird” कहते हैं, जबकि अन्य इन्हें “consistent and learnable” मानते हैं।
Ecosystem, packaging, और imports
- dependency management, virtualenvs, और fragmented tooling पर बहुत शिकायतें हैं; uv को एक बड़ा सुधार माना गया है लेकिन अभी standard नहीं है।
- import semantics (
__name__ == "__main__", packages बनाम filesystem,__init__.py, relative imports) कुछ लोगों को unintuitive लगते हैं, लेकिन Python के module model के अनुरूप होने के कारण defended भी किए जाते हैं.