質問するログイン新規登録

質問編集履歴

6

書式の改善

2016/07/19 10:43

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -3,6 +3,7 @@
3
3
  いま、例えばあるクラスFooを作ろうとしているときに、2パターンのコードを考えています。
4
4
 
5
5
 
6
+ ```Python
6
7
  class Foo(object):
7
8
  def __init__(self, n):
8
9
  self.x = n
@@ -14,7 +15,10 @@
14
15
  y = do_something(x)
15
16
  return y
16
17
 
18
+ ```
19
+
17
20
 
21
+ ```Python
18
22
  class Foo(object):
19
23
  def __init__(self, n):
20
24
  self.x = n
@@ -23,7 +27,9 @@
23
27
 
24
28
  def set_y(self):
25
29
  self.y = do_something(self.x)
30
+ ```
26
31
 
32
+
27
33
  ①は、calc_yで使用する変数を明示しているので、クラス変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
28
34
 
29
35
  しかし調べた限りでは@staticmethodは可能なら使わないほうが良いという記事が多く、その点では②にすべきであるように思えます。

5

2016/07/19 10:43

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -24,7 +24,7 @@
24
24
  def set_y(self):
25
25
  self.y = do_something(self.x)
26
26
 
27
- ①は、calc_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
27
+ ①は、calc_yで使用する変数を明示しているので、クラス変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
28
28
 
29
29
  しかし調べた限りでは@staticmethodは可能なら使わないほうが良いという記事が多く、その点では②にすべきであるように思えます。
30
30
 

4

2016/05/30 05:02

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
  class Foo(object):
7
- def ¥__init¥__(self, n):
7
+ def __init__(self, n):
8
8
  self.x = n
9
9
  self.z = 3
10
10
  self.y = self.calc_y(x)
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  class Foo(object):
19
- def \__init¥__(self, n):
19
+ def __init__(self, n):
20
20
  self.x = n
21
21
  self.z = 3
22
22
  self.set_y()

3

2016/05/30 04:51

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -4,27 +4,27 @@
4
4
 
5
5
 
6
6
  class Foo(object):
7
- def ¥_¥_init¥_¥_(self, n):
7
+ def ¥__init¥__(self, n):
8
8
  self.x = n
9
9
  self.z = 3
10
- self.y = self.calc¥_y(x)
10
+ self.y = self.calc_y(x)
11
11
 
12
12
  @staticmethod
13
- def calc¥_y(x):
13
+ def calc_y(x):
14
- y = do¥_something(x)
14
+ y = do_something(x)
15
15
  return y
16
16
 
17
17
 
18
18
  class Foo(object):
19
- def ¥_¥_init¥_¥_(self, n):
19
+ def \__init¥__(self, n):
20
20
  self.x = n
21
21
  self.z = 3
22
- self.set¥_y()
22
+ self.set_y()
23
23
 
24
- def set¥_y(self):
24
+ def set_y(self):
25
- self.y = do¥_something(self.x)
25
+ self.y = do_something(self.x)
26
26
 
27
- ①は、calc¥_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
27
+ ①は、calc_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
28
28
 
29
29
  しかし調べた限りでは@staticmethodは可能なら使わないほうが良いという記事が多く、その点では②にすべきであるように思えます。
30
30
 

2

2016/05/30 04:49

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -4,27 +4,27 @@
4
4
 
5
5
 
6
6
  class Foo(object):
7
- def \_\_init\_\_(self, n):
7
+ def ¥_¥_init¥_¥_(self, n):
8
8
  self.x = n
9
9
  self.z = 3
10
- self.y = self.calc\_y(x)
10
+ self.y = self.calc¥_y(x)
11
11
 
12
12
  @staticmethod
13
- def calc\_y(x):
13
+ def calc¥_y(x):
14
- y = do\_something(x)
14
+ y = do¥_something(x)
15
15
  return y
16
16
 
17
17
 
18
18
  class Foo(object):
19
- def \_\_init\_\_(self, n):
19
+ def ¥_¥_init¥_¥_(self, n):
20
20
  self.x = n
21
21
  self.z = 3
22
- self.set\_y()
22
+ self.set¥_y()
23
23
 
24
- def set\_y(self):
24
+ def set¥_y(self):
25
- self.y = do\_something(self.x)
25
+ self.y = do¥_something(self.x)
26
26
 
27
- ①は、calc\_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
27
+ ①は、calc¥_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
28
28
 
29
29
  しかし調べた限りでは@staticmethodは可能なら使わないほうが良いという記事が多く、その点では②にすべきであるように思えます。
30
30
 

1

2016/05/30 04:48

投稿

MasatakaMiyoshi
MasatakaMiyoshi

スコア109

title CHANGED
File without changes
body CHANGED
@@ -4,27 +4,27 @@
4
4
 
5
5
 
6
6
  class Foo(object):
7
- def __init__(self, n):
7
+ def \_\_init\_\_(self, n):
8
8
  self.x = n
9
9
  self.z = 3
10
- self.y = self.calc_y(x)
10
+ self.y = self.calc\_y(x)
11
11
 
12
12
  @staticmethod
13
- def calc_y(x):
13
+ def calc\_y(x):
14
- y = do_something(x)
14
+ y = do\_something(x)
15
15
  return y
16
16
 
17
17
 
18
18
  class Foo(object):
19
- def __init__(self, n):
19
+ def \_\_init\_\_(self, n):
20
20
  self.x = n
21
21
  self.z = 3
22
- self.set_y()
22
+ self.set\_y()
23
23
 
24
- def set_y(self):
24
+ def set\_y(self):
25
- self.y = do_something(self.x)
25
+ self.y = do\_something(self.x)
26
26
 
27
- ①は、calc_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
27
+ ①は、calc\_yで使用する明示しているので、クラス変数変数xの変更がこれに影響すること、変数zの変更はこれに全く影響しないことが明示されます。
28
28
 
29
29
  しかし調べた限りでは@staticmethodは可能なら使わないほうが良いという記事が多く、その点では②にすべきであるように思えます。
30
30