Re: [Tutor] Request for help with code

2018-11-06 Thread Steven D'Aprano
On Tue, Nov 06, 2018 at 06:32:25PM -0500, Joel Goldstick wrote: [snip nearly seven screens of quoted text] > still not indented.. sorry.. figure that out Hey Joel, is the Backspace key on your keyboard broken? :-) This sort of mass (and unnecessary) quoting is why Bottom-Posting gets a bad rep

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Sarfraaz Ahmed
Hello, There are specific operating system, path related modules in Python for handling these scenarios. You could try looking at os.path module. On Tue, Nov 6, 2018 at 11:16 PM Asad wrote: > Hi all , > > Can you provide some advice and code for the following problem : > > I have a log

Re: [Tutor] Request for help with code

2018-11-06 Thread Cameron Simpson
On 06Nov2018 15:50, Joseph Gulizia ", count) You should see that the expected code is actually reached and run, and if it isn't, the corresponding print()s do not happen. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe o

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-06 Thread Alan Gauld via Tutor
On 06/11/2018 18:07, srinivasan wrote: > bash command in python using subprocess module, I ma seeing the below > *        cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)* In general you should try to do as little as possible using bash and subprocess. Especially try to avoid long

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Alan Gauld via Tutor
On 06/11/2018 19:47, Cameron Simpson wrote: > It is better to just construct the required path. Chdir there requires a > chdir back, and chdir affects all the relative paths your programme may > be using. > > I'd use os.path.dirname to get '/a/b/c/d/test' and then just append to > it with os.p

Re: [Tutor] Request for help with code

2018-11-06 Thread David Rock
* Mats Wichmann [2018-11-06 16:54]: > > there must be some solution... guys, do you know of any alternate way to > send a message to the list if a mail client isn't cooperating? or do we > have instructions for beating gmail into submission? Obviously gmail is > a key part of the modern infrastr

Re: [Tutor] Request for help with code

2018-11-06 Thread Mats Wichmann
On 11/6/18 4:36 PM, Joseph Gulizia wrote: > Funny using a text editorand showed indented in my browser. Won't > bother the list again. We don't want you to "not bother" us, just hoping to get things in a state where we can actually help... here's what we end up seeing: https://www.mail

Re: [Tutor] Request for help with code

2018-11-06 Thread Cameron Simpson
On 06Nov2018 15:50, Joseph Gulizia I'm using the bookazine "The Python Book" First Edition on pages 13-14 it gives the code (listed further below). It asks for user to state a given number of integers (for example 4)...then user enters integers. It doesn't stop seeking input after the number r

Re: [Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
Funny using a text editorand showed indented in my browser. Won't bother the list again. On Tue, Nov 6, 2018, 17:32 Joel Goldstick On Tue, Nov 6, 2018 at 6:17 PM Joseph Gulizia > wrote: > > > > Apologies for earlier errors when asking for help -- I am hopeful that > this > > shortened

Re: [Tutor] Request for help with code

2018-11-06 Thread Joel Goldstick
On Tue, Nov 6, 2018 at 6:17 PM Joseph Gulizia wrote: > > Apologies for earlier errors when asking for help -- I am hopeful that this > shortened post displays properly: > The code is Python 2... trying to solve why loop doesn't stop at given > number of integersif I input request for 3 intege

Re: [Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
Apologies for earlier errors when asking for help -- I am hopeful that this shortened post displays properly: The code is Python 2... trying to solve why loop doesn't stop at given number of integersif I input request for 3 integersit keeps asking for integer1...and keeps asking for input,

Re: [Tutor] Request for help with code

2018-11-06 Thread Steven D'Aprano
On Tue, Nov 06, 2018 at 03:50:42PM -0600, Joseph Gulizia wrote: > I'm using the bookazine "The Python Book" First Edition on pages 13-14 it > gives the code (listed further below). > > It asks for user to state a given number of integers (for example 4)...then > user enters integers. It doesn't

Re: [Tutor] Request for help with code

2018-11-06 Thread Bob Gailer
On Nov 6, 2018 4:51 PM, "Joseph Gulizia" wrote: > > I'm using the bookazine "The Python Book" First Edition on pages 13-14 it > gives the code (listed further below). > > It asks for user to state a given number of integers (for example 4)...then > user enters integers. It doesn't stop seeking i

[Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
I'm using the bookazine "The Python Book" First Edition on pages 13-14 it gives the code (listed further below). It asks for user to state a given number of integers (for example 4)...then user enters integers. It doesn't stop seeking input after the number requested thereby creating an infinite

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Cameron Simpson
On 06Nov2018 18:10, Alan Gauld wrote: >On 06/11/2018 13:13, Asad wrote: > >> Can you provide some advice and code for the following problem : > >The first thing is to go read the documentation for the os.path module. >It is designed for reliable path manipulation. > >> /a/b/c/d/test/test_2

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Mats Wichmann
>>4) look for the latest file in the directory /a/b/c/d/test/123456/789 > > Slightly more complex, you need the creation timestamp. > You can find that with os.path.getctime() (or several > other options, eg os.stat) here's a trick you might be able to make use of: somelist = generate-lis

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-06 Thread David Rock
> > *def get_fstype_of_mounted_partition(self, fs):* >""" >Get the filesystem type of the mounted partition. > >:partition_name : Partition path as string (e.g. /dev/mmcblk0p1) >:return: filesystem type as string or None if not found >""" > > *

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Alan Gauld via Tutor
On 06/11/2018 13:13, Asad wrote: > Can you provide some advice and code for the following problem : The first thing is to go read the documentation for the os.path module. It is designed for reliable path manipulation. > /a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log > > f3 = ope

[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-06 Thread srinivasan
Dear Python Experts Team, 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" *CODE:* ** im

[Tutor] Regex for Filesystem path

2018-11-06 Thread Asad
Hi all , Can you provide some advice and code for the following problem : I have a logfile to check for errors : /a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) st1 = f3.readlines () from the above log I