Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System

216 views

Published on

Выступление на PYCON RUSSIA 2017

Published in: Internet
  • Be the first to comment

«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System

  1. 1. PYWAT АЛЕКСАНДР ШВЕЦ
  2. 2. >>> [1,2,3] == sorted([1,2,3])
  3. 3. >>> [1,2,3] == sorted([1,2,3]) True
  4. 4. >>> [1,2,3] == sorted([1,2,3]) True >>> (1,2,3) == sorted((1,2,3))
  5. 5. >>> [1,2,3] == sorted([1,2,3]) True >>> (1,2,3) == sorted((1,2,3)) False
  6. 6. >>> [1,2,3] == sorted([1,2,3]) True >>> (1,2,3) == sorted((1,2,3)) False
  7. 7. >>> a = 2, 1, 3
  8. 8. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a)
  9. 9. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True
  10. 10. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True >>> reversed(a) == reversed(a)
  11. 11. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True >>> reversed(a) == reversed(a) False
  12. 12. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True >>> reversed(a) == reversed(a) False >>> b = reversed(a) >>> sorted(b) == sorted(b)
  13. 13. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True >>> reversed(a) == reversed(a) False >>> b = reversed(a) >>> sorted(b) == sorted(b) False
  14. 14. >>> a = 2, 1, 3 >>> sorted(a) == sorted(a) True >>> reversed(a) == reversed(a) False >>> b = reversed(a) >>> sorted(b) == sorted(b) False
  15. 15. >>> a = ([],)
  16. 16. >>> a = ([],) >>> a[0].extend([1])
  17. 17. >>> a = ([],) >>> a[0].extend([1]) >>> a[0]
  18. 18. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1]
  19. 19. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1] >>> a[0] += [2]
  20. 20. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1] >>> a[0] += [2] TypeError: 'tuple' object does not support item assignment
  21. 21. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1] >>> a[0] += [2] TypeError: 'tuple' object does not support item assignment >>> a[0]
  22. 22. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1] >>> a[0] += [2] TypeError: 'tuple' object does not support item assignment >>> a[0] [1, 2]
  23. 23. >>> a = ([],) >>> a[0].extend([1]) >>> a[0] [1] >>> a[0] += [2] TypeError: 'tuple' object does not support item assignment >>> a[0] [1, 2]
  24. 24. >>> isinstance(type, object)
  25. 25. >>> isinstance(type, object) True
  26. 26. >>> isinstance(type, object) True >>> isinstance(object, type)
  27. 27. >>> isinstance(type, object) True >>> isinstance(object, type) True
  28. 28. >>> isinstance(type, object) True >>> isinstance(object, type) True
  29. 29. >>> all([])
  30. 30. >>> all([]) True
  31. 31. >>> all([]) True >>> all([[]])
  32. 32. >>> all([]) True >>> all([[]]) False
  33. 33. >>> all([]) True >>> all([[]]) False >>> all([[[]]])
  34. 34. >>> all([]) True >>> all([[]]) False >>> all([[[]]]) True
  35. 35. >>> all([]) True >>> all([[]]) False >>> all([[[]]]) True
  36. 36. >>> sum("")
  37. 37. >>> sum("") 0
  38. 38. >>> sum("") 0 >>> sum("", ())
  39. 39. >>> sum("") 0 >>> sum("", ()) ()
  40. 40. >>> sum("") 0 >>> sum("", ()) () >>> sum("", [])
  41. 41. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) []
  42. 42. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) [] >>> sum("", {})
  43. 43. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) [] >>> sum("", {}) {}
  44. 44. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) [] >>> sum("", {}) {} >>> sum("", "")
  45. 45. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) [] >>> sum("", {}) {} >>> sum("", "") TypeError: sum() can't sum strings
  46. 46. >>> sum("") 0 >>> sum("", ()) () >>> sum("", []) [] >>> sum("", {}) {} >>> sum("", "") TypeError: sum() can't sum strings
  47. 47. >>> a = 1
  48. 48. >>> a = 1 >>> def foo(): >>> return a >>> foo()
  49. 49. >>> a = 1 >>> def foo(): >>> return a >>> foo() 1
  50. 50. >>> a = 1 >>> def foo(): >>> return a >>> foo() 1 >>> def bar(): >>> a += 1 >>> return a >>> bar()
  51. 51. >>> a = 1 >>> def foo(): >>> return a >>> foo() 1 >>> def bar(): >>> a += 1 >>> return a >>> bar() UnboundLocalError: local variable 'a' referenced before assignment
  52. 52. >>> a = 1 >>> def foo(): >>> return a >>> foo() 1 >>> def bar(): >>> a += 1 >>> return a >>> bar() UnboundLocalError: local variable 'a' referenced before assignment
  53. 53. >>> x = float("nan") >>> y = float("nan")
  54. 54. >>> x = float("nan") >>> y = float("nan") >>> x == x
  55. 55. >>> x = float("nan") >>> y = float("nan") >>> x == x False
  56. 56. >>> x = float("nan") >>> y = float("nan") >>> x == x False >>> [x] == [x]
  57. 57. >>> x = float("nan") >>> y = float("nan") >>> x == x False >>> [x] == [x] True
  58. 58. >>> x = float("nan") >>> y = float("nan") >>> x == x False >>> [x] == [x] True >>> [x] == [y]
  59. 59. >>> x = float("nan") >>> y = float("nan") >>> x == x False >>> [x] == [x] True >>> [x] == [y] False
  60. 60. >>> x = float("nan") >>> y = float("nan") >>> x == x False >>> [x] == [x] True >>> [x] == [y] False
  61. 61. >>> a = 100 >>> b = 100
  62. 62. >>> a = 100 >>> b = 100 >>> a is b
  63. 63. >>> a = 100 >>> b = 100 >>> a is b True
  64. 64. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300
  65. 65. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300 >>> a is b
  66. 66. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300 >>> a is b False
  67. 67. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300 >>> a is b False >>> a, b = 300, 300 >>> a is b
  68. 68. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300 >>> a is b False >>> a, b = 300, 300 >>> a is b True
  69. 69. >>> a = 100 >>> b = 100 >>> a is b True >>> a = 300 >>> b = 300 >>> a is b False >>> a, b = 300, 300 >>> a is b True
  70. 70. >>> x, y = ??? >>> x + y == y + x False
  71. 71. [0], [1]
  72. 72. >>> x, y = ??? >>> min(x, y) == min(y, x) False
  73. 73. {0}, {1}
  74. 74. >>> x = ??? >>> x < x True
  75. 75. https://github.com/cosmologicon/pywat
  76. 76. СПАСИБО fb.com/ashwets ashvets@mymary.ru Александр Швец технический директор системы Marilyn

×