Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Michael Torrie
On 11/07/2018 01:31 PM, MRAB wrote: > On 2018-11-07 09:20, Thomas Jollans wrote: >> I'll just take this opportunity to point out (for those that don't know) >> that Visual Studio Code (an open source cross-platform programmer's text >> editor of the same calibre as Sublime or Atom, not an IDE) has

Re: Does this behavior have a better design pattern?

2018-11-07 Thread lampahome
> > > The rest is just cruft ;) > > > > *Is there better design pattern for me?* > > If A does B to C, is that a crime? > No > Your problem description suffers from overgeneralisation. > > Generally speaking you get better solutions when you ask yourself > "How can I solve this problem effici

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Thomas Jollans
On 07/11/2018 21:31, MRAB wrote: > On 2018-11-07 09:20, Thomas Jollans wrote: >> On 06/11/2018 22:51, Lie Ryan wrote: I like to step through my code line by line, it's impossible to do it with object-oriented programming language. >>> >>> I suggest pudb, it's a curses based debugger,

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread MRAB
On 2018-11-07 09:20, Thomas Jollans wrote: On 06/11/2018 22:51, Lie Ryan wrote: I like to step through my code line by line, it's impossible to do it with object-oriented programming language. I suggest pudb, it's a curses based debugger, which is nicer than pdb, but doesn't require tedious I

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

2018-11-07 Thread srinivasan
Many Thanks a lot , I can use for reliably "lsblk %s -n -o FSTYPE" in the reused code of mine as below cmd = "lsblk %s -n -o FSTYPE" % partition_path return self._helper.execute_cmd_output_string(cmd) I really appreciate for all your support w.r.t this.. I feel I have kick start

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

2018-11-07 Thread Ben Bacarisse
srinivasan writes: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="108

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

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:42 PM srinivasan wrote: > > Some I managed to fix temporarily as below, might be useful for others. Also > please correct me if anything wrong or for any improvements in the below > > cmd = "blkid -o export %s" % partition_path > out = self._helper.execut

Re: Unable to remove python from my computer.

2018-11-07 Thread Rhodri James
I assume "on a PC" actually means "on Windows". Redirected back to the list since I neither know nor care about wrangling Python on Windows. On 07/11/2018 12:27, Jack Gilbert wrote: on a PC: click start, (click on the window, lower left hand corner)[ in 8.1] Control Panel Programs and Feature

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

2018-11-07 Thread srinivasan
Some I managed to fix temporarily as below, might be useful for others. Also please correct me if anything wrong or for any improvements in the below cmd = "blkid -o export %s" % partition_path out = self._helper.execute_cmd_output_string(cmd) var = out.split("TYPE=", 1)[1]

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

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:36 PM Qian Cai wrote: > > srinivasan wrote: > > Even after changing as per the below > > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > > or: > > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > > or: > > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" >

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

2018-11-07 Thread Qian Cai
srinivasan wrote: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="1084

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

2018-11-07 Thread srinivasan
Even after changing as per the below "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" or: 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' or: "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" Still my output is: */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* My expected outp

Re: Does this behavior have a better design pattern?

2018-11-07 Thread Peter Otten
lampahome wrote: > Above is I thought to make code clear, and this pattern is called simple > factory? This is a factory function: > def get_class(obj): > if obj == 'A1' or obj == 'A2': > return A(obj) > else: > return B(obj) The rest is just cruft ;) > > *Is there bet

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

2018-11-07 Thread Brian J. Oney via Python-list
On Wed, 2018-11-07 at 10:22 +0100, srinivasan wrote: > blkid -o export %s | grep \'TYPE\' | cut -d\"=\" -f3 You don't need to escape the single quotes. Try either: "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" or: 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' or: "blkid -o export %s | g

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Thomas Jollans
On 06/11/2018 22:51, Lie Ryan wrote: >> I like to step through my code line by line, >> it's impossible to do it with >> object-oriented programming language. > > I suggest pudb, it's a curses based debugger, which is nicer than pdb, but > doesn't require tedious IDE setup. I'll just take this o

Does this behavior have a better design pattern?

2018-11-07 Thread lampahome
I have two categories A,B, and A has 2 items A1,A2 B have 2 items B1, B2. I have two class A and B, and A will handle A1,A2, B handle B1,B2. I want to parse one of A1,A2,B1,B2 to script and generate the corresponding class(object). Ex: Both in class A and B, all have func1(), func2(). What I tho

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

2018-11-07 Thread srinivasan
After changing the line to *"cmd = "blkid -o export %s | grep \'TYPE\' | cut -d\"=\" -f3" % fs"*, Now I dont see the error "SyntaxError: can't assign to literal" This is not returning exactly "*vfat*" instead of this, it is returning as "* /dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* "

Re: int.to_bytes() for a single byte

2018-11-07 Thread Thomas Jollans
On 07/11/2018 05:22, jlada...@itu.edu wrote: > On Tuesday, November 6, 2018 at 7:19:09 PM UTC-8, Terry Reedy wrote: >> On 11/6/2018 9:30 PM, j...y@it.u wrote: >> >>> b = i.to_bytes(1, "big") >>> >>> Is there another function which provides a more logical interface to this >>> straightforward task?