동일합니다, 당신은 당신이 upvoted 때문에, RemcoGerlich의 의견에 충분한주의를 가지고하지 않았다 무의미한 대답을 받아 들였다.
내가 이것을 쓸 때, 4 명의 다른 사람들이 똑같은 무의미한 대답을 upvoted.
정말 대단합니다.
더 잘 보입니까? :
def OP(a,b,c):
return not isinstance(a, int)\
or not isinstance(b, int)\
or not isinstance(c, int)\
or not isinstance(a, float)\
or not isinstance(b, float)\
or not isinstance(c, float)
def AZ(a,b,c):
return all(isinstance(var, (int, float))
for var in [a, b, c])
gen = ((a,b,c) for a in (1, 1.1 ,'a')
for b in (2, 2.2, 'b') for c in (3, 3.3, 'c'))
print ' OPv | AZv OPv is AZv\n'\
' -----|----- -----------'
OPV_list = []
for a,b,c in gen:
OPv = OP(a,b,c)
OPV_list.append(OPv)
AZv = AZ(a,b,c)
print '%3r %3r %3r %s | %s %s'\
% (a,b,c,OPv,AZv,OPv is AZv if OPv is not AZv else '')
print '------------- ----'
print 'all(OPV_list) : ',all(OPV_list)
결과
OPV = 네
AZV I에 한정 = 무의미한 않음
, B는 C가 확인에 짧은
OPv | AZv OPv is AZv
-----|----- -----------
1 2 3 True | True
1 2 3.3 True | True
1 2 'c' True | False False
1 2.2 3 True | True
1 2.2 3.3 True | True
1 2.2 'c' True | False False
1 'b' 3 True | False False
1 'b' 3.3 True | False False
1 'b' 'c' True | False False
1.1 2 3 True | True
1.1 2 3.3 True | True
1.1 2 'c' True | False False
1.1 2.2 3 True | True
1.1 2.2 3.3 True | True
1.1 2.2 'c' True | False False
1.1 'b' 3 True | False False
1.1 'b' 3.3 True | False False
1.1 'b' 'c' True | False False
'a' 2 3 True | False False
'a' 2 3.3 True | False False
'a' 2 'c' True | False False
'a' 2.2 3 True | False False
'a' 2.2 3.3 True | False False
'a' 2.2 'c' True | False False
'a' 'b' 3 True | False False
'a' 'b' 3.3 True | False False
'a' 'b' 'c' True | False False
------------- ----
all(OPV_list) : True
중 'isinstance (a, INT) 이후' 또는 isinstance (a, float)가 False가 될 것입니다. smartass 응답은 if가 항상 true이고 완전히 생략 될 수 있다는 것입니다. – RemcoGerlich
다음 코드에서 검사를 생략하고 결과 오류를 catch합니다. – Matthias
내 대답 좀 봐, 제발, 문제를 볼 수 .... – eyquem