Python का इतिहास और विशेषताएँ
In this page:
Python का इतिहास
डच programmer Guido van Rossum ने दिसंबर 1989 में क्रिसमस के हफ़्ते को भरने के लिए एक शौकिया project के रूप में Python को design करना शुरू किया, और 1991 में version 0.9.0 सार्वजनिक रूप से जारी किया।
इसका नाम साँप से नहीं, बल्कि ब्रिटिश कॉमेडी समूह Monty Python से आया है, जो van Rossum के ऐसी भाषा बनाने के लक्ष्य को दर्शाता है जो खुद को बहुत गंभीरता से न ले।
उदाहरण: History of Python
# Created by Guido van Rossum, first released in 1991
# Named after the comedy troupe Monty Python, not the snake
print("Python: born 1991, named after Monty Python")
Interpreted भाषा
क्योंकि interpreter code को सीधे चलाता है और अलग compile step की ज़रूरत नहीं होती, आप एक line बदलकर तुरंत script दोबारा चला सकते हैं और असर देख सकते हैं।
यही तेज़ feedback loop बड़ी वजह है कि Python prototyping, scripting और पढ़ाने के लिए इतनी productive लगती है।
उदाहरण: Interpreted Language
x = 5
print(x)
# Change the value above and rerun -- no compile step needed
x = 10
print(x)
Dynamic Typing
Python में आप कभी int x या String name नहीं लिखते — interpreter assignment के दाईं ओर की value को देखता है और variable को उसी value के type से जोड़ देता है।
इससे code लिखना छोटा हो जाता है, लेकिन इसका मतलब यह भी है कि type से जुड़े bugs program चलने से पहले पकड़े जाने के बजाय runtime पर सामने आते हैं।
उदाहरण: Dynamic Typing
x = 5 # x starts out as an integer
print(type(x)) # shows <class 'int'>
x = "hello" # same variable is reassigned to a string
print(type(x)) # shows <class 'str'>, proving Python is dynamically typed
Object-Oriented Programming
Object-oriented programming आपको संबंधित data और व्यवहार (behavior) को classes में एक साथ बाँधने देती है, जिसे Python procedural और functional शैलियों के साथ पूरी तरह support करती है।
इस लचीलेपन का मतलब है कि आप सरल scripts से शुरू करके, project की जटिलता बढ़ने पर पूरी class-based design तक पहुँच सकते हैं।
उदाहरण: Object-Oriented Programming
class Dog: # define a Dog class
def __init__(self, name): # constructor runs when a new Dog is created
self.name = name # store the dog's name on the instance
def bark(self): # method that prints a bark message
print(self.name, "says woof")
Dog("Rex").bark() # create a Dog named Rex and call its bark method
Standard Library Support
Python की standard library में file I/O, regular expressions, networking, JSON parsing और math जैसे कामों के लिए modules आते हैं — सब अपने-आप install हो जाते हैं, अलग से कुछ download करने की ज़रूरत नहीं।
यह 'batteries included' सोच ही बड़ी वजह है कि सरल scripts बिना किसी third-party dependency के लिखी जा सकती हैं।
उदाहरण: Standard Library Support
import json # module to convert Python objects to JSON text
import math # module with math constants and functions
data = json.dumps({"pi": math.pi}) # convert a dict containing pi to a JSON string
print(data)
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: