{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/8571","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/8571/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/8571/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/8571/events","html_url":"https://github.com/sympy/sympy/issues/8571","id":51109174,"number":8571,"title":"printing: Add containing a Boolean fails","user":{"login":"cbm755","id":818622,"avatar_url":"https://avatars.githubusercontent.com/u/818622?v=3","gravatar_id":"","url":"https://api.github.com/users/cbm755","html_url":"https://github.com/cbm755","followers_url":"https://api.github.com/users/cbm755/followers","following_url":"https://api.github.com/users/cbm755/following{/other_user}","gists_url":"https://api.github.com/users/cbm755/gists{/gist_id}","starred_url":"https://api.github.com/users/cbm755/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbm755/subscriptions","organizations_url":"https://api.github.com/users/cbm755/orgs","repos_url":"https://api.github.com/users/cbm755/repos","events_url":"https://api.github.com/users/cbm755/events{/privacy}","received_events_url":"https://api.github.com/users/cbm755/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/printing","name":"printing","color":"0000FF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-05T15:14:33Z","updated_at":"2016-02-11T07:35:38Z","closed_at":null,"body":"I offer no particular opinion on whether they make sense but neither of these operations seem to be forbidden:\r\n````\r\na = x*S.true\r\nb = x + S.true\r\n````\r\nBut only `a` can be printed (and gives `x*True`) whereas `print(b)` and `pprint(b)` give:\r\n\r\n````\r\nAttributeError: 'BooleanTrue' object has no attribute 'as_coeff_Mul'\r\n````\r\n"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/182748972","html_url":"https://github.com/sympy/sympy/issues/8571#issuecomment-182748972","issue_url":"https://api.github.com/repos/sympy/sympy/issues/8571","id":182748972,"user":{"login":"cbm755","id":818622,"avatar_url":"https://avatars.githubusercontent.com/u/818622?v=3","gravatar_id":"","url":"https://api.github.com/users/cbm755","html_url":"https://github.com/cbm755","followers_url":"https://api.github.com/users/cbm755/followers","following_url":"https://api.github.com/users/cbm755/following{/other_user}","gists_url":"https://api.github.com/users/cbm755/gists{/gist_id}","starred_url":"https://api.github.com/users/cbm755/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbm755/subscriptions","organizations_url":"https://api.github.com/users/cbm755/orgs","repos_url":"https://api.github.com/users/cbm755/repos","events_url":"https://api.github.com/users/cbm755/events{/privacy}","received_events_url":"https://api.github.com/users/cbm755/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T07:35:38Z","updated_at":"2016-02-11T07:35:38Z","body":"Well for me I get:\r\n````\r\nIn [5]: x = S('x')\r\n\r\nIn [6]: sympy.__version__\r\nOut[6]: '0.7.7.dev'\r\n\r\nIn [7]: a = x*S.true\r\n\r\nIn [8]: b = x + S.true\r\n\r\nIn [9]: a\r\nOut[9]: x*True\r\n\r\nIn [10]: b\r\nOut[10]: ---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n/usr/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)\r\n    688                 type_pprinters=self.type_printers,\r\n    689                 deferred_pprinters=self.deferred_printers)\r\n--> 690             printer.pretty(obj)\r\n    691             printer.flush()\r\n    692             return stream.getvalue()\r\n\r\n------- 8< ---------\r\n\r\n/home/cbm/src/sympy.git/sympy/core/basic.pyc in __repr__(self)\r\n    390     def __repr__(self):\r\n    391         from sympy.printing import sstr\r\n--> 392         return sstr(self, order=None)\r\n    393 \r\n    394     def __str__(self):\r\n\r\n------- 8< ---------\r\n\r\n/home/cbm/src/sympy.git/sympy/core/expr.pyc in as_terms(self)\r\n    916 \r\n    917         for term in Add.make_args(self):\r\n--> 918             coeff, _term = term.as_coeff_Mul()\r\n    919 \r\n    920             coeff = complex(coeff)\r\n\r\nAttributeError: 'BooleanTrue' object has no attribute 'as_coeff_Mul'\r\n````\r\nSo either:\r\n\r\n1. its ok to make such a thing, so then it should be ok to print it.\r\n\r\n2. or creating such a thing should raise a TypeError.  Similar to:\r\n````\r\nIn [22]: S.true + S.true\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-22-dd610d9ad10a> in <module>()\r\n----> 1 S.true + S.true\r\n\r\nTypeError: unsupported operand type(s) for +: 'BooleanTrue' and 'BooleanTrue'\r\n````\r\n\r\nPerhaps I feel 2 is better, but as I said originally, I have not thought about it carefully.  If you try to fix this you will need to think about this carefully ;-)\r\n\r\nOther examples of strange things: `S(1)*S.false` is just `S.false` but `S(2)*S.false` raises the `no attribute 'as_coeff_Mul'` error."}}