SORU
15 Temmuz 2015, ÇARŞAMBA


Neden "not(True) [False] Doğru mu&; return False"?

Eğer bunu yaparsam:

>>> False in [False, True]
True

Bu Doğru döndürür. Sahte listesinde olduğu için sadece.

Ama eğer yaparsam:

>>> not(True) in [False, True]
False

False döndürür. not(True) Yanlış eşit ise:

>>> not(True)
False

Neden?

CEVAP
15 Temmuz 2015, ÇARŞAMBA


Operatör önceliği2.x, 3.x. not önceliği in daha düşük. Eşdeğer:

>>> not (True in [False, True])
False

İstediğin şey bu:

>>> (not True) in [False, True]
True

@Ben belirttiği gibi: asla not(True), yazmak için tavsiye not True tercih ederim. Eski not bir operatör, bir işlevi değil iken, bir işlev çağrısı gibi yapar.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • My name is Festis and I'm free

    My name is F

    2 EKİM 2011
  • REK Roth Productions

    REK Roth Pro

    8 Ocak 2011
  • thegeniuses.tv

    thegeniuses.

    11 Aralık 2006