Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4d336d

Browse files
Merge branch 'wilfredinni:master' into master
2 parents97bbc30 +6df25c6 commitc4d336d

36 files changed

+5777
-4763
lines changed

‎.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

‎.vscode/extensions.json‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎.vscode/settings.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"getsize",
6969
"getstate",
7070
"groupby",
71+
"gspagare",
7172
"gtag",
7273
"hasattr",
7374
"hashable",
@@ -108,6 +109,7 @@
108109
"mkdir",
109110
"mkvirtualenv",
110111
"Mozar",
112+
"msohaib",
111113
"mydata",
112114
"mypy",
113115
"namelist",
@@ -162,6 +164,7 @@
162164
"shirinapr",
163165
"shutil",
164166
"sitebuiltins",
167+
"skyunna",
165168
"starmap",
166169
"staticmethod",
167170
"strformat",
@@ -174,6 +177,7 @@
174177
"thacer13",
175178
"timedelta",
176179
"timeit",
180+
"tomfun",
177181
"Traceback",
178182
"udiskie",
179183
"unhashable",

‎contributors/contributors.json‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
"rawatdev",
77
"gsemet",
88
"vaibhavb02",
9-
"flymemoryRPA",
10-
"szTheory",
11-
"Acumane",
129
"LairdStreak",
13-
"omii2k01",
14-
"lukaszwojcik89",
15-
"noraa-july-stoke",
16-
"matteodem",
10+
"Acumane",
11+
"szTheory",
12+
"flymemoryRPA",
13+
"fPkX6F1nGTX",
14+
"gspagare",
15+
"skyunna",
1716
"ckartchner",
17+
"matteodem",
18+
"noraa-july-stoke",
19+
"lukaszwojcik89",
20+
"omii2k01",
1821
"danielpclin",
1922
"nugel",
2023
"michaelbaluja",
@@ -25,10 +28,10 @@
2528
"HasnatHridoy",
2629
"azanbinzahid",
2730
"abdussalam02",
28-
"alvyynm",
2931
"Yaya9256",
3032
"Vishesh-dd4723",
3133
"thoughtworks-tcaceres",
34+
"techboy-coder",
3235
"shirinapr",
3336
"senlog",
3437
"SeaSide53",
@@ -38,12 +41,13 @@
3841
"RichardScottOZ",
3942
"richjohnsonxyz",
4043
"AdamRosas27",
44+
"alvyynm",
4145
"comrade5",
4246
"damiankrolik",
4347
"ehmsu",
4448
"firdousmurtaza1",
45-
"gulu42",
4649
"kakasahebKK",
50+
"msohaib9",
4751
"omerts",
4852
"paulwongx",
4953
"qudongfang",
@@ -59,13 +63,14 @@
5963
"evanrrees",
6064
"Gaura",
6165
"gaurav-jo1",
66+
"tomfun",
6267
"ImgBotApp",
6368
"unixorn",
6469
"kavin5kumar",
6570
"asenov",
6671
"Matthew-Nicholson",
6772
"mohammedalrawi98",
68-
"madeelchaudhary",
73+
"adeelmc",
6974
"mu-us61",
7075
"wn9237",
7176
"hacktron95",

‎docs/builtin/breakpoint.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Python breakpoint() built-in function
2525
>>>for iinrange(5):
2626
...# Stream i to stdout
2727
...print(i)
28-
...# Create breakpoint at # 3
29-
...if i==3:
30-
...breakpoint()
28+
...# Create breakpoint at # 3
29+
...if i==3:
30+
...breakpoint()
3131
...
3232
# 0
3333
# 1

‎docs/builtin/next.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Python next() built-in function
2222
>>> i=iter([1,2,3])
2323
>>> i
2424
# <list_iterator object at 0x7f93158badc0>
25-
>>>i.__next__()
25+
>>>next(i)
2626
# 1
27-
>>>i.__next__()
27+
>>>next(i)
2828
# 2
29-
>>>i.__next__()
29+
>>>next(i)
3030
# 3
3131
```
3232

‎docs/builtin/pow.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title:Python pow() built-in function - Python Cheatsheet
3-
description:Given a string representing one Unicode character, return an integer representingtheUnicode code pointofthat character.
3+
description:The pow() function returnsthepowerofa number.
44
---
55

66
<base-title:title="frontmatter.title":description="frontmatter.description">
@@ -12,16 +12,27 @@ Python pow() built-in function
1212
From the <a target="_blank" href="https://docs.python.org/3/library/functions.html#pow">Python 3 documentation</a>
1313
</base-disclaimer-title>
1414
<base-disclaimer-content>
15-
Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.
15+
The pow() function returns the power of a number.It takes two or three arguments:
16+
pow(base, exp): Returns base raised to the power of exp (base ** exp).
17+
pow(base, exp, mod): Returns (base ** exp) % mod (for modular arithmetic).
18+
Result is computed more efficiently than base ** exp % mod, if mod arg is present.
1619
</base-disclaimer-content>
1720
</base-disclaimer>
1821

1922
##Example
2023

2124
```python
22-
>>> result=pow(2,3)
23-
>>>print(result)
25+
# Basic exponentiation
26+
>>>pow(2,3)
2427
# 8
28+
29+
# Using three arguments (modular exponentiation)
30+
>>>pow(2,3,5)
31+
# 3 (since 2^3 = 8, and 8 % 5 = 3)
32+
33+
# Works with negative exponents (returns float)
34+
>>>pow(2,-3)
35+
# 0.125 (since 2^(-3) = 1/8)
2536
```
2637

2738

‎docs/cheatsheet/comprehensions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ List Comprehensions are a special kind of syntax that let us create lists out of
1818
</base-disclaimer-content>
1919
</base-disclaimer>
2020

21-
Read <router-linkto="/blog/python-comprehensions-step-by-step">Python Comprehensions: A step by step Introduction</router-link> for a more in-deep or introduction.
21+
Read <router-linkto="/blog/python-comprehensions-step-by-step">Python Comprehensions: A step by step Introduction</router-link> for a more in-depth introduction.
2222

2323
##List comprehension
2424

‎docs/cheatsheet/decorators.md‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ description: A Python Decorator is a syntax that provide a concise and reusable
77
Python Decorators
88
</base-title>
99

10-
A Python Decorator provides a concise and reusable way for extending a function or a class.
10+
A Python Decorator provides a concise and reusable way for extending
11+
a function or a class.
1112

1213
##Bare bone decorator
1314

14-
A decorator in its simplest form is a function that takes another function as an argument and returns a wrapper. The following example shows the creation of a decorator and its usage.
15+
A decorator in its simplest form is a function that takes another
16+
function as an argument and returns a wrapper. The following example
17+
shows the creation of a decorator and its usage.
1518

1619
```python
1720
defyour_decorator(func):
@@ -58,7 +61,8 @@ foo("Jack")
5861

5962
##Template for a basic decorator
6063

61-
This template is useful for most decorator use-cases. It is valid for functions with or without parameters, and with or without a return value.
64+
This template is useful for most decorator use-cases. It is valid for functions
65+
with or without parameters, and with or without a return value.
6266

6367
```python
6468
import functools
@@ -102,7 +106,46 @@ def foo(bar):
102106

103107
##Class based decorators
104108

105-
A decorator can also be defined as a class instead of a method. This is useful for maintaining and updating a state, such as in the following example, where we count the number of calls made to a method:
109+
To decorate a class method, you must define the decorator within the class. When
110+
only the implicit argument`self` is passed to the method, without any explicit
111+
additional arguments, you must make a separate decorator for only those methods
112+
without any additional arguments. An example of this, shown below, is when you
113+
want to catch and print exceptions in a certain way.
114+
115+
```python
116+
classDecorateMyMethod:
117+
118+
defdecorator_for_class_method_with_no_args(method):
119+
defwrapper_for_class_method(self)
120+
try:
121+
return method(self)
122+
exceptExceptionas e:
123+
print("\nWARNING: Please make note of the following:\n")
124+
print(e)
125+
return wrapper_for_class_method
126+
127+
def__init__(self,succeed:bool):
128+
self.succeed= succeed
129+
130+
@decorator_for_class_method_with_no_args
131+
defclass_action(self):
132+
ifself.succeed:
133+
print("You succeeded by choice.")
134+
else:
135+
raiseException("Epic fail of your own creation.")
136+
137+
test_succeed= DecorateMyMethods(True)
138+
test_succeed.class_action()
139+
# You succeeded by choice.
140+
141+
test_fail= DecorateMyMethod(False)
142+
test_fail.class_action()
143+
# Exception: Epic fail of your own creation.
144+
```
145+
146+
A decorator can also be defined as a class instead of a method. This is useful
147+
for maintaining and updating a state, such as in the following example, where we
148+
count the number of calls made to a method:
106149

107150
```python
108151
classCountCallNumber:

‎docs/cheatsheet/exception-handling.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can't divide by zero, that is a mathematical true, and if you try to do it i
2727
...print(dividend/ divisor)
2828
...
2929
>>> divide(dividend=10,divisor=5)
30-
#5
30+
#2
3131

3232
>>> divide(dividend=10,divisor=0)
3333
# Traceback (most recent call last):
@@ -45,7 +45,7 @@ Let's say we don't want our program to stop its execution or show the user an ou
4545
...print('You can not divide by 0')
4646
...
4747
>>> divide(dividend=10,divisor=5)
48-
#5
48+
#2
4949

5050
>>> divide(dividend=10,divisor=0)
5151
# You can not divide by 0
@@ -58,17 +58,22 @@ You can also handle multiple exceptions in one line like the following without t
5858
```python
5959
>>>defdivide(dividend ,divisor):
6060
...try:
61-
... var='str'+1
62-
...print(dividend/ divisor)
61+
...if (dividend==10):
62+
... var='str'+1
63+
...else:
64+
...print(dividend/ divisor)
6365
...except (ZeroDivisionError,TypeError)as error:
6466
...print(error)
6567
...
68+
69+
>>> divide(dividend=20,divisor=5)
70+
# 4
71+
6672
>>> divide(dividend=10,divisor=5)
67-
#5
73+
#`can only concatenate str (not "int") to str` Error message
6874

6975
>>> divide(dividend=10,divisor=0)
7076
# `division by zero` Error message
71-
# `can only concatenate str (not "int") to str` Error message
7277
```
7378

7479
##Finally code in exception handling

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp