[Python-Dev] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

Chris Angelico rosuav at gmail.com
Tue Nov 6 13:15:21 EST 2018


On Wed, Nov 7, 2018 at 5:11 AM srinivasan <srinivasan.rns at gmail.com> wrote:
> As am newbie to python development, I am trying to use the below function to get verify the filesystem type of the SD card parition using bash command in python using subprocess module, I ma seeing the below Error "SyntaxError: can't assign to literal"
>

This is more appropriate for python-list than for python-dev, which is
about the development OF Python. But your problem here is quite
simple:

>         cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)

You're trying to use the same quotation mark inside the string and
outside it. That's not going to work. Try removing your inner quotes.

You may also want to consider using Python to do your searching and
cutting, rather than a shell pipeline. For more information on that,
ask on python-list; people will be very happy to help out.

ChrisA


More information about the Python-Dev mailing list