[Tutor] read cell phone's directory?

2014-08-14 Thread = Clayton - Tang =
Hi all,

I am on WIndows and have an Android cell phone running Android 4.4.4.

When I connect the phone to my PC using a micro-USB cable, the phone appears
next to the local hard drive under "This PC" window, then I can browse the
phone's directory like a regular disk. My goal is to find all the photos on the
phone then do something with the files. So I copied the path from the File
Explore navigation bar, which is 'This PC\Nexus 5\Internal storage\DCIM\Camera',
but the follow code doesn't work.

I get an error "W indowsError: [Error 3] The system cannot find the path
specified: 'This PC\\Nexus 5\\Internal storage\\DCIM\\Camera/*.*". Does anyone
know who to make it work?


import os;

## Example pulls filenames from a dir, prints their relative and absolute paths
def printdir(dir):
  filenames = os.listdir(dir)
  for filename in filenames:
print filename ## foo.txt
print os.path.join(dir, filename) ## dir/foo.txt (relative to current dir)
print os.path.abspath(os.path.join(dir, filename)) ## /home/nick/dir/foo.txt
print

if __name__ == '__main__':
  printdir('This PC\Nexus 5\Internal storage\DCIM\Camera')


Clayton___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] read cell phone's directory?

2014-08-14 Thread Chris “Kwpolska” Warrick
On Aug 14, 2014 9:30 AM, "= Clayton - Tang ="  wrote:
>
> Hi all,
>
> I am on WIndows and have an Android cell phone running Android 4.4.4.
>
> When I connect the phone to my PC using a micro-USB cable, the phone
appears next to the local hard drive under "This PC" window, then I can
browse the phone's directory like a regular disk. My goal is to find all
the photos on the phone then do something with the files. So I copied the
path from the File Explore navigation bar, which is 'This PC\Nexus
5\Internal storage\DCIM\Camera', but the follow code doesn't work.
>
> I get an error "W indowsError: [Error 3] The system cannot find the path
specified: 'This PC\\Nexus 5\\Internal storage\\DCIM\\Camera/*.*". Does
anyone know who to make it work?

This was recently discussed on the main list (python-list aka
comp.lang.python). Long story short, modern Android phones are using the
MTP protocol and do not behave like usual USB drives. You must use a module
that implements MTP if you want to access your phone.

> import os;

No need for a semicolon here.

--
Chris “Kwpolska” Warrick 
Sent from my SGS3.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] read cell phone's directory?

2014-08-14 Thread Danny Yoo
On Wed, Aug 13, 2014 at 7:07 PM, = Clayton - Tang =  wrote:
> Hi all,
>
> I am on WIndows and have an Android cell phone running Android 4.4.4.
>
> When I connect the phone to my PC using a micro-USB cable, the phone appears
> next to the local hard drive under "This PC" window, then I can browse the
> phone's directory like a regular disk. My goal is to find all the photos on
> the phone then do something with the files. So I copied the path from the
> File Explore navigation bar, which is 'This PC\Nexus 5\Internal
> storage\DCIM\Camera', but the follow code doesn't work.

Hmmm... there are a few things you may need to resolve.

1.  Backslashes have a meaning in Python string literals.  They mark
the beginning of an escape character sequence, to let programmers
represent strings that contain characters that are hard to otherwise
type.

See:

http://learnpythonthehardway.org/book/ex10.html

2.  "This PC" may be simply a convenient name that Windows 8.1 is
using in its user interface.  It may be mapped to a different location
on your hard drive than a directory called "This PC".  Unfortunately,
I have no experience with Windows 8.1, so hopefully someone else might
be able to investigate.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] re module

2014-08-14 Thread Sunil Tech
Hi,

I have string like
stmt = 'Patient name: Upadhyay Shyam  Date of
birth:   08/08/1988 Issue(s) to be
analyzed:  tesNurse Clinical summary:  test1 Date of
injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3
- 780.50 - 724.4 Brachial neuritis or radiculitis nos - Generalized
anxiety disorder - Acute paranoid reaction - Unspecified sleep disturbance
- Thoracic or lumbosacral neuritis or radiculitis, unspecifiedRequester
name:   Demo SpltycdtesttPhone #:   (213)
480-9000Medical records reviewed __ pages of medical and
administrative records were reviewed including:Criteria
used in analysis  Reviewer comments DeterminationBased on the clinical information submitted for this
review and using the evidence-based, peer-reviewed guidelines referenced
above, this request is Peer Reviewer
Name/Credentials  Solis, Test, PhDInternal Medicine AttestationContact Information Peer to Peer contact attempt 1: 08/13/2014 02:46
PM, Central, Incoming Call, Successful, No Contact Made, Peer Contact Did
Not Change Determination'


i am trying to find the various font sizes and font face from this string.

i tried

print re.search("___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] re module

2014-08-14 Thread Chris “Kwpolska” Warrick
On 14 Aug 2014 15:58 "Sunil Tech"  wrote:
>
> Hi,
>
> I have string like
> stmt = 'Patient name: Upadhyay Shyam  Date of
birth:   08/08/1988 Issue(s) to be
analyzed:  tesNurse Clinical summary:  test1 Date of
injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3
- 780.50 - 724.4 Brachial neuritis or radiculitis nos - Generalized
anxiety disorder - Acute paranoid reaction - Unspecified sleep disturbance
- Thoracic or lumbosacral neuritis or radiculitis, unspecifiedRequester
name:   Demo SpltycdtesttPhone #:   (213)
480-9000Medical records reviewed __ pages of medical and
administrative records were reviewed including:Criteria
used in analysis  Reviewer comments DeterminationBased on the clinical information submitted for this
review and using the evidence-based, peer-reviewed guidelines referenced
above, this request is Peer Reviewer
Name/Credentials  Solis, Test, PhDInternal Medicine AttestationContact Information Peer to Peer contact attempt 1: 08/13/2014 02:46
PM, Central, Incoming Call, Successful, No Contact Made, Peer Contact Did
Not Change Determination'
>
>
> i am trying to find the various font sizes and font face from this string.
>
> i tried
>
> print re.search("
>
> Thank you.
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
Don't use regular expressions for HTML. Use lxml instead.

Also, why would you need that exact thing? It's useless. Also, this code is
very ugly, with too many s and — worse — s which should not be
used at all.

-- 
Chris “Kwpolska” Warrick 
Sent from my SGS3.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] re module

2014-08-14 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I tested it on IDLE. It works.

regards,
Sarma.


On Thu, Aug 14, 2014 at 7:37 PM, Chris “Kwpolska” Warrick <
kwpol...@gmail.com> wrote:

>
> On 14 Aug 2014 15:58 "Sunil Tech"  wrote:
> >
> > Hi,
> >
> > I have string like
> > stmt = 'Patient name: Upadhyay Shyam style="font-family: times new roman,times;">  Date of
> birth:   08/08/1988 Issue(s) to be
> analyzed:  tes style="font-size: 11pt;">Nurse Clinical summary:  test1 style="font-family: times new roman,times;"> Date of
> injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3
> - 780.50 - 724.4 Brachial neuritis or radiculitis nos - Generalized
> anxiety disorder - Acute paranoid reaction - Unspecified sleep disturbance
> - Thoracic or lumbosacral neuritis or radiculitis, unspecified />Requester
> name:   Demo Spltycdtestt style="font-family: times new roman,times;">Phone #:   (213)
> 480-9000Medical records reviewed __ pages of medical and
> administrative records were reviewed including:Criteria
> used in analysis  Reviewer comments  />DeterminationBased on the clinical information submitted for this
> review and using the evidence-based, peer-reviewed guidelines referenced
> above, this request is Peer Reviewer
> Name/Credentials  Solis, Test, PhD style="font-family: times new roman,times;">Internal Medicine />  />Attestation />Contact Information  roman,times\' size=\'3\'>Peer to Peer contact attempt 1: 08/13/2014 02:46
> PM, Central, Incoming Call, Successful, No Contact Made, Peer Contact Did
> Not Change Determination'
> >
> >
> > i am trying to find the various font sizes and font face from this
> string.
> >
> > i tried
> >
> > print re.search(" >
> >
> > Thank you.
> >
> >
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> >
> Don't use regular expressions for HTML. Use lxml instead.
>
> Also, why would you need that exact thing? It's useless. Also, this code
> is very ugly, with too many s and — worse — s which should not
> be used at all.
>
> --
> Chris “Kwpolska” Warrick 
> Sent from my SGS3.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Exercise to work on

2014-08-14 Thread P McCombs
On Aug 12, 2014 3:29 PM, "keith papa"  wrote:
>
> Hi, am a newbie to python and I wondering if you guys can give me some
exercise to work on. I have learned: print function , if function ,
strings, variables, and raw_input. The more the better

Checkio.org is a game made of python coding challenges. They start simple,
demonstrate functional testing, and provide other users' solutions.

http://www.checkio.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] read cell phone's directory?

2014-08-14 Thread = Clayton - Tang =
Chris, thanks for the reply. I don't have newsgroup access, can you point me to
some place where I can learn more? Do you have sample code I can learn from?
Thanks.

Clayton


> On August 14, 2014 at 4:09 AM Chris “Kwpolska” Warrick 
> wrote:
> 
> 
>  On Aug 14, 2014 9:30 AM, "= Clayton - Tang ="   > wrote:
>  >
>  > Hi all,
>  > 
>  > I am on WIndows and have an Android cell phone running Android 4.4.4.
>  > 
>  > When I connect the phone to my PC using a micro-USB cable, the phone
>  > appears next to the local hard drive under "This PC" window, then I can
>  > browse the phone's directory like a regular disk. My goal is to find all
>  > the photos on the phone then do something with the files. So I copied the
>  > path from the File Explore navigation bar, which is 'This PC\Nexus
>  > 5\Internal storage\DCIM\Camera', but the follow code doesn't work.
>  > 
>  > I get an error "W indowsError: [Error 3] The system cannot find the path
>  > specified: 'This PC\\Nexus 5\\Internal storage\\DCIM\\Camera/*.*". Does
>  > anyone know who to make it work?
> 
>  This was recently discussed on the main list (python-list aka
> comp.lang.python). Long story short, modern Android phones are using the MTP
> protocol and do not behave like usual USB drives. You must use a module that
> implements MTP if you want to access your phone.
> 
>  > import os;
> 
>  No need for a semicolon here.
> 
>  --
>  Chris “Kwpolska” Warrick 
>  Sent from my SGS3.
> 



---
Clayton Tang___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] read cell phone's directory?

2014-08-14 Thread Alan Gauld

On 14/08/14 16:48, = Clayton - Tang = wrote:

Chris, thanks for the reply. I don't have newsgroup access, can you
point me to some place where I can learn more? Do you have sample code I
can learn from? Thanks.


The main newsgroup is also available as a mailing list and
can be read, for example, on the Gmane service at:

http://news.gmane.org/gmane.comp.python.general

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] read cell phone's directory?

2014-08-14 Thread Chris “Kwpolska” Warrick
On 14 August 2014 17:48 "= Clayton - Tang ="  wrote:
>
> Chris, thanks for the reply. I don't have newsgroup access,

You don't need it. Use the official mailing list that is mirrored to Usenet.

Main page with subscribe link:
https://mail.python.org/mailman/listinfo/python-list

The thread in question:
https://mail.python.org/pipermail/python-list/2014-August/676375.html

> can you point me to some place where I can learn more? Do you have sample
code I can learn from? Thanks.

The thread does not have any ready answer just yet, it's currently busy
arguing about the protocol. You can Google the term “python MTP”, you may
find some answers there.
-- 
Chris “Kwpolska” Warrick 
Sent from my SGS3.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] re module

2014-08-14 Thread Albert-Jan Roskam

-
On Thu, Aug 14, 2014 4:07 PM CEST Chris “Kwpolska” Warrick wrote:

>On 14 Aug 2014 15:58 "Sunil Tech"  wrote:
>>
>> Hi,
>>
>> I have string like
>> stmt = 'Patient name: Upadhyay Shyamstyle="font-family: times new roman,times;">  Date of
>birth:   08/08/1988 Issue(s) to be
>analyzed:  tesstyle="font-size: 11pt;">Nurse Clinical summary:  test1style="font-family: times new roman,times;"> Date of
>injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3
>- 780.50 - 724.4 Brachial neuritis or radiculitis nos - Generalized
>anxiety disorder - Acute paranoid reaction - Unspecified sleep disturbance
>- Thoracic or lumbosacral neuritis or radiculitis, unspecified/>Requester
>name:   Demo Spltycdtesttstyle="font-family: times new roman,times;">Phone #:   (213)
>480-9000Medical records reviewed __ pages of medical and
>administrative records were reviewed including:Criteria
>used in analysis  Reviewer comments />DeterminationBased on the clinical information submitted for this
>review and using the evidence-based, peer-reviewed guidelines referenced
>above, this request is Peer Reviewer
>Name/Credentials  Solis, Test, PhDstyle="font-family: times new roman,times;">Internal Medicine/> />Attestation/>Contact Information roman,times\' size=\'3\'>Peer to Peer contact attempt 1: 08/13/2014 02:46
>PM, Central, Incoming Call, Successful, No Contact Made, Peer Contact Did
>Not Change Determination'
>>
>>
>> i am trying to find the various font sizes and font face from this string.
>>
>> i tried
>>
>> print re.search(">
>>
>> Thank you.
>>
>>
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
>Don't use regular expressions for HTML. Use lxml instead.
>
>Also, why would you need that exact thing? It's useless. Also, this code is
>very ugly, with too many s and — worse — s which should not be
>used at all.

Why lxml and not bs? I read that bs deals better with malformed html. You said 
the above html is messy, which is not necessarily the same as malformed, but.. 
Anyway, this reference also seems to favor lxml: 
http://stackoverflow.com/questions/4967103/beautifulsoup-and-lxml-html-what-to-prefer
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ
 wrote:
> I tested it on IDLE. It works.


Hi Sarma,


Following up on this one.  I'm pretty sure that:

print re.search("https://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy

for why.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
Hi Sunil,

Don't use regular expressions for this task.  Use something that knows
about HTML structure.  As others have noted, the Beautiful Soup or
lxml libraries are probably a much better choice here.

There are good reasons to avoid regexp for the task you're trying to
do.  For example, your regular expression:

 ">> import re
>>> m = re.match("'(.*)'", "'quoted' text, but note how it's greedy!")
>>> m.group(1)
"quoted' text, but note how it"
##

and note how the match doesn't limited itself to "quoted", but goes as
far as it can.

This shows at least one of the problems that you're going to run into.
Fixing this so it doesn't grab so much is doable, of course.  But
there are other issues, all of which are little headaches upon
headaches.  (e.g. Attribute vlaues may be single or double quoted, may
use HTML entity references, etc.)

So don't try to parse HTML by hand.  Let a library do it for you.  For
example with Beautiful Soup:

http://www.crummy.com/software/BeautifulSoup/bs4/doc/

the code should be as straightforward as:

###
from bs4 import BeautifulSoup
soup = BeautifulSoup(stmt)
for span in soup.find_all('span'):
print span.get('style')
###

where you deal with the _structure_ of your document, rather than at
the low-level individual characters of that document.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor