1
0

040_line_continue.py 899 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. a = 1 + 2 \
  2. + 3
  3. assert a == 6
  4. assert 1 + 2 \
  5. + 3 == 6
  6. assert 1 + 2 + \
  7. 3 + \
  8. 4 == 10
  9. assert 1 + 2 + \
  10. 3 + \
  11. 4 + 5 + 6 \
  12. == 21
  13. if 1 and 2 \
  14. and 3 \
  15. and 4 \
  16. and 5:
  17. assert True
  18. else:
  19. assert False
  20. 1 and 2 \
  21. and 3 \
  22. and 4
  23. a = 1
  24. assert a == 1
  25. # https://github.com/pocketpy/pocketpy/issues/408
  26. x = (
  27. 1
  28. +
  29. 2
  30. )
  31. # https://peps.python.org/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
  32. compile('''
  33. income = (gross_wages
  34. + taxable_interest
  35. + (dividends - qualified_dividends)
  36. - ira_deduction
  37. - student_loan_interest)
  38. '''.strip(), 'main.py', 'exec')
  39. res = []
  40. class Thing:
  41. def do_a(self):
  42. res.append("A")
  43. return self
  44. def do_b(self):
  45. res.append("B")
  46. return self
  47. def do_c(self):
  48. res.append("C")
  49. return self
  50. (Thing()
  51. .do_a()
  52. .do_b()
  53. .do_c())
  54. assert res == ["A", "B", "C"]