You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having directed string input into the standard input of a LocalCommand (via <<i.e.__lshift__), I am unable to cast the resulting StdinDataRedirection object to string. Attempting to do so raises an uncaught exception.
$ ipython
Python 3.6.3 (default, Dec 20 2017, 11:51:43)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import plumbum
In [2]: plumbum.__version__
Out[2]: (1, 6, 4)
In [3]: cat = plumbum.local['cat']
In [4]: stdin_bound_cat = cat << 'hello world'
In [5]: str(stdin_bound_cat)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-37-15af60a0e450> in <module>()
----> 1 str(stdin_bound_cat)
~/.pyenv/versions/3.6.3/envs/test/lib/python3.6/site-packages/plumbum/commands/base.py in __str__(self)
49
50 def __str__(self):
---> 51 return " ".join(self.formulate())
52
53 def __or__(self, other):
TypeError: sequence item 2: expected str instance, list found
Underlying this issue is that the formulate() method for this object returns a list which itself contains both strings and lists:
In [6]: stdin_bound_cat.formulate()
Out[6]: ["echo 'hello world'", '|', ['/bin/cat']]
which result cannot simply be joined by a string, as its __str__ attempts to do.
Needless to say, this issue prevents passing such objects to print(), and minorly complicates introspection.
The text was updated successfully, but these errors were encountered:
Having directed string input into the standard input of a
LocalCommand
(via<<
i.e.__lshift__
), I am unable to cast the resultingStdinDataRedirection
object to string. Attempting to do so raises an uncaught exception.Underlying this issue is that the
formulate()
method for this object returns a list which itself contains both strings and lists:which result cannot simply be joined by a string, as its
__str__
attempts to do.Needless to say, this issue prevents passing such objects to
print()
, and minorly complicates introspection.The text was updated successfully, but these errors were encountered: