Convert single backtick code sections to triple backtick code sections for Arabic Guide articles (13 of 15) (#36240)
* fix: converted single to triple backticks13 * fix: added prefix Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: removed language in wrong place Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: add language postfix Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: removed language in wrong place Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@@ -21,63 +21,68 @@ localeTitle: كائنات بايثون
|
||||
|
||||
نحن اختبار `None` كائن هنا.
|
||||
|
||||
`>>> id(None)
|
||||
4550218168
|
||||
>>> type(None)
|
||||
<class 'NoneType'>
|
||||
>>> dir(None)
|
||||
[__bool__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
|
||||
>>> issubclass(type(None), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id(None)
|
||||
4550218168
|
||||
>>> type(None)
|
||||
<class 'NoneType'>
|
||||
>>> dir(None)
|
||||
[__bool__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
|
||||
>>> issubclass(type(None), object)
|
||||
True
|
||||
```
|
||||
|
||||
بعد ذلك ، دعونا نفحص `True` .
|
||||
|
||||
`>>> id(True)
|
||||
4550117616
|
||||
>>> type(True)
|
||||
<class 'bool'>
|
||||
>>> dir(True)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(True), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id(True)
|
||||
4550117616
|
||||
>>> type(True)
|
||||
<class 'bool'>
|
||||
>>> dir(True)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(True), object)
|
||||
True
|
||||
```
|
||||
|
||||
لا يوجد سبب لترك خارج `False` !
|
||||
|
||||
`>>> id(False)
|
||||
4550117584
|
||||
>>> type(False)
|
||||
<class 'bool'>
|
||||
>>> dir(False)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(False), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id(False)
|
||||
4550117584
|
||||
>>> type(False)
|
||||
<class 'bool'>
|
||||
>>> dir(False)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(False), object)
|
||||
True
|
||||
```
|
||||
|
||||
_سلاسل_ ، حتى عندما تم إنشاؤها بواسطة القيم الحرفية سلسلة ، هي أيضا _الكائنات_ .
|
||||
|
||||
`>>> id("Hello campers!")
|
||||
4570186864
|
||||
>>> type('Hello campers!')
|
||||
<class 'str'>
|
||||
>>> dir("Hello campers!")
|
||||
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
|
||||
>>> issubclass(type('Hello campers!'), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id("Hello campers!")
|
||||
4570186864
|
||||
>>> type('Hello campers!')
|
||||
<class 'str'>
|
||||
>>> dir("Hello campers!")
|
||||
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
|
||||
>>> issubclass(type('Hello campers!'), object)
|
||||
True
|
||||
```
|
||||
|
||||
الشيء نفسه مع _الأرقام_
|
||||
|
||||
`>>> id(42)
|
||||
4550495728
|
||||
>>> type(42)
|
||||
<class 'int'>
|
||||
>>> dir(42)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(42), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id(42)
|
||||
4550495728
|
||||
>>> type(42)
|
||||
<class 'int'>
|
||||
>>> dir(42)
|
||||
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
|
||||
>>> issubclass(type(42), object)
|
||||
True
|
||||
```
|
||||
|
||||
## وظائف هي كائنات أيضا
|
||||
|
||||
@@ -85,24 +90,26 @@ _سلاسل_ ، حتى عندما تم إنشاؤها بواسطة القيم ا
|
||||
|
||||
_تعتبر الدوال_ في Python أيضًا _كائنات_ تم إنشاؤها باستخدام _هوية_ _ونوع_ _وقيمة_ . هم أيضا يمكن أن تنتقل إلى _وظائف_ أخرى:
|
||||
|
||||
`>>> id(dir)
|
||||
4568035688
|
||||
>>> type(dir)
|
||||
<class 'builtin_function_or_method'>
|
||||
>>> dir(dir)
|
||||
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
|
||||
>>> issubclass(type(dir), object)
|
||||
True
|
||||
`
|
||||
```python
|
||||
>>> id(dir)
|
||||
4568035688
|
||||
>>> type(dir)
|
||||
<class 'builtin_function_or_method'>
|
||||
>>> dir(dir)
|
||||
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
|
||||
>>> issubclass(type(dir), object)
|
||||
True
|
||||
```
|
||||
|
||||
من الممكن أيضًا ربط الدالات بالاسم وتسمى الدالة المندمجة باستخدام هذا الاسم:
|
||||
|
||||
`>>> a = dir
|
||||
>>> print(a)
|
||||
<built-in function dir>
|
||||
>>> a(a)
|
||||
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
|
||||
`
|
||||
```python
|
||||
>>> a = dir
|
||||
>>> print(a)
|
||||
<built-in function dir>
|
||||
>>> a(a)
|
||||
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
|
||||
```
|
||||
|
||||
مصادر:
|
||||
|
||||
|
||||
@@ -14,66 +14,71 @@ localeTitle: نطاق بايثون
|
||||
* `stop` : قيمة التوقف الحصرية ، يتوقف النطاق عند توفير هذه القيمة أو أكبر (العدد الصحيح المطلوب).
|
||||
* `step` : القيمة المضافة إلى القيمة الحالية للحصول على القيمة التالية (عدد صحيح اختياري ، الإعداد الافتراضي إلى 1).
|
||||
|
||||
`>>> range(10) # Only the stop parameter is required.
|
||||
range(0, 10)
|
||||
>>> range(0, 10) # Default for start parameter is 0.
|
||||
range(0, 10)
|
||||
>>> range(0, 10, 1) # Default for step is 1\. Start parameter is required if
|
||||
step is needed.
|
||||
range(0, 10)
|
||||
`
|
||||
```python
|
||||
>>> range(10) # Only the stop parameter is required.
|
||||
range(0, 10)
|
||||
>>> range(0, 10) # Default for start parameter is 0.
|
||||
range(0, 10)
|
||||
>>> range(0, 10, 1) # Default for step is 1\. Start parameter is required if
|
||||
step is needed.
|
||||
range(0, 10)
|
||||
```
|
||||
|
||||
**أمثلة:**
|
||||
|
||||
ونظرًا لأن `ranges` متكررة ، يمكن تمريرها إلى `list` `tuple` لإنشاء هذه الأنواع من التسلسلات. باستخدام هذه الحقيقة ، يمكننا تصور بعض الأمثلة:
|
||||
|
||||
`>>> list(range(10)) # range as argument for list constructor.
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
>>> tuple(range(10)) # range as argument for tuple constructor.
|
||||
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
`
|
||||
```python
|
||||
>>> list(range(10)) # range as argument for list constructor.
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
>>> tuple(range(10)) # range as argument for tuple constructor.
|
||||
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
```
|
||||
|
||||
`ranges` طول الصفر:
|
||||
|
||||
`>>> list(range(10, 0)) # start greater than stop with postive step.
|
||||
[]
|
||||
>>> list(range(10, 10)) # start equal to stop with postive step.
|
||||
[]
|
||||
>>> list(range(10, 10, -1)) # start equal to stop with negative step.
|
||||
[]
|
||||
>>> list(range(0, 10, -1)) # start less than stop with negative step.
|
||||
[]
|
||||
`
|
||||
```python
|
||||
>>> list(range(10, 0)) # start greater than stop with postive step.
|
||||
[]
|
||||
>>> list(range(10, 10)) # start equal to stop with postive step.
|
||||
[]
|
||||
>>> list(range(10, 10, -1)) # start equal to stop with negative step.
|
||||
[]
|
||||
>>> list(range(0, 10, -1)) # start less than stop with negative step.
|
||||
[]
|
||||
```
|
||||
|
||||
`ranges` مع وسيطات الخطوة:
|
||||
|
||||
`>>> list(range(0, 10, 2)) # next value would be 10, stops at 8.
|
||||
[0, 2, 4, 6, 8]
|
||||
>>> list(range(0, 10, 3)) # next value would be 12, stops at 9.
|
||||
[0, 3, 6, 9]
|
||||
>>> list(range(0, 10, 4)) # next value would be 12, stops at 8.
|
||||
[0, 4, 8]
|
||||
>>> list(range(10, 0, -1)) # negative step makes decreasing ranges.
|
||||
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
||||
>>> list(range(-5, -30, -3)) # negative integers are valid arguments.
|
||||
[-5, -8, -11, -14, -17, -20, -23, -26, -29]
|
||||
`
|
||||
```python
|
||||
>>> list(range(0, 10, 2)) # next value would be 10, stops at 8.
|
||||
[0, 2, 4, 6, 8]
|
||||
>>> list(range(0, 10, 3)) # next value would be 12, stops at 9.
|
||||
[0, 3, 6, 9]
|
||||
>>> list(range(0, 10, 4)) # next value would be 12, stops at 8.
|
||||
[0, 4, 8]
|
||||
>>> list(range(10, 0, -1)) # negative step makes decreasing ranges.
|
||||
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
||||
>>> list(range(-5, -30, -3)) # negative integers are valid arguments.
|
||||
[-5, -8, -11, -14, -17, -20, -23, -26, -29]
|
||||
```
|
||||
|
||||
**فوائد:**
|
||||
|
||||
إن الفائدة من استخدام `range` هي أنه بغض النظر عن مدى نطاق معين ، فإن هناك حاجة إلى كمية صغيرة من الذاكرة لتخزين `range` ، وقيم البدء ، والتوقف ، والخطوة. يتم حساب القيم الفردية `ranges` عند التكرار.
|
||||
|
||||
`>>> import sys
|
||||
>>> a_range = range(1000000)
|
||||
>>> a_list = list(a_range)
|
||||
>>> a_tuple = tuple(a_range)
|
||||
>>> sys.getsizeof(a_range)
|
||||
48
|
||||
>>> sys.getsizeof(a_list)
|
||||
9000112
|
||||
>>> sys.getsizeof(a_tuple)
|
||||
8000048
|
||||
`
|
||||
```python
|
||||
>>> import sys
|
||||
>>> a_range = range(1000000)
|
||||
>>> a_list = list(a_range)
|
||||
>>> a_tuple = tuple(a_range)
|
||||
>>> sys.getsizeof(a_range)
|
||||
48
|
||||
>>> sys.getsizeof(a_list)
|
||||
9000112
|
||||
>>> sys.getsizeof(a_tuple)
|
||||
8000048
|
||||
```
|
||||
|
||||
### مزيد من المعلومات:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user