<div>Thank you all for your help. </div>
<div>1) I need to list words with uppercase first, then those with lower case; I used istitle() and isupper (don't know the method for mixed case yet)</div>
<div>2) Steve, it's a compliment that you though I'd undersand your code, but I only know conditional statements, started on lists, not functions yet. nand is still Greek to me right now. <br>3) If someone input "Thank you my FOLKS, i want the output to print words with upper case first:</div>

<div> </div>
<div>Thank</div>
<div>FOLKS</div>
<div>you</div>
<div>my</div>
<div> </div>
<div>3) Can someone help me make my code work in a very simple way. I am still learning, but watch this space colleagues; I may be helping you guys in a few months ;)</div>
<div> </div>
<div>Thanks to all who took their time to help.</div>
<div>Future Python Expert,</div>
<div>Cathy.</div>
<div> </div>
<div>My initial code:<br> <br>s=input("Write a sentence: ")<br>list=s.strip().split()<br>for word in list:<br>    list2 = (word.isupper() or word.istitle())<br>    print (word)<br>else print (word)</div>
<div> </div>
<div>On Wed, Jan 5, 2011 at 7:35 PM, <span dir="ltr"><<a href="mailto:python-list-request@python.org">python-list-request@python.org</a>></span> wrote:<br></div>
<div class="gmail_quote">
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Send Python-list mailing list submissions to<br>       <a href="mailto:python-list@python.org">python-list@python.org</a><br>
<br>To subscribe or unsubscribe via the World Wide Web, visit<br>       <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>or, via email, send a message with subject or body 'help' to<br>
       <a href="mailto:python-list-request@python.org">python-list-request@python.org</a><br><br>You can reach the person managing the list at<br>       <a href="mailto:python-list-owner@python.org">python-list-owner@python.org</a><br>
<br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Python-list digest..."<br><br>Today's Topics:<br><br>  1. Re: Help with code-lists and strings (GrayShark)<br>
  2. Help with a Python coding question (<a href="mailto:kanthony@woh.rr.com">kanthony@woh.rr.com</a>)<br>  3. Re: Help with a Python coding question (Emile van Sebille)<br>  4. Re: Help with a Python coding question (Justin Peel)<br>
  5. Importing modules from miscellaneous folders (Jshgwave)<br>  6. Searching Python-list (Slie)<br>  7. Re: Interrput a thread (Adam Skutt)<br><br><br>---------- Forwarded message ----------<br>From: GrayShark <<a href="mailto:howe.steven@gmail.com">howe.steven@gmail.com</a>><br>
To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 05 Jan 2011 16:56:40 -0600<br>Subject: Re: Help with code-lists and strings<br>On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote:<br>
<br>> On 1/5/2011 12:57 PM, Cathy James wrote:<br>><br>>> I am learning python and came across an excercise where i need to use<br>>> lists to strip words from a sentence; starting with those containing<br>
>> one or more uppercase letters, followed by words with lower case<br>>> letters.<br>><br>> When writing code, it is good to start with one or more input-output<br>> pairs that constitute a test. For example, what, exactly, do you want to<br>
> result from<br>>     "Some special words are ALLCAPS, TitleCase, and MIXed."<br>><br>> It is also good to think about all relevant cases. Note the following:<br>>  >>> 'MIXed'.isupper() or 'MIXed'.istitle()<br>
> False<br>><br>> Do you want punctuation stripped off words? You might skip that at<br>> first.<br><br>In python it's best to build up you functional needs. So two steps. First<br>a nand (negative 'and' operation). Then wrap that with a function to create<br>
two strings of your list element, you''re calling 'word'. By the way,<br>list is reserved word, like string. Don't get in the bad habit of using it.<br><br>def nand( a, b ):<br>       """nand has to vars. Both must be strings """<br>
       return( ( not eval( a ) ) and ( not eval( b ) ) )<br><br>Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both<br>results, 'and' values, return.<br><br>Now wrap 'nand' in packaging an you're cooking with grease.<br>
def mixed_case( str ):<br>       return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str )<br><br>or if that's too advanced/compact, try ...<br>def mixed_case( str ):<br>       # nand() needs strings<br>
       a = "'%s'.isupper()" % str<br>       b = "'%s'.islower()" % str<br>       res = nand( a, b )<br>       return res<br><br>>>> mixed_case('Abcd' )<br>True<br>>>> mixed_case('ABCD' )<br>
False<br>>>> mixed_case('abcd' )<br>False<br><br>Good luck<br>Steven Howe<br><br><br><br>---------- Forwarded message ----------<br>From: <a href="mailto:kanthony@woh.rr.com">kanthony@woh.rr.com</a><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>
Date: Wed, 05 Jan 2011 17:12:13 -0600<br>Subject: Help with a Python coding question<br>I want to use Python to find all "\n" terminated<br>strings in a PDF file, ideally returning string<br>starting addresses.   Anyone willing to help?<br>
<br><br>--<br>--------------------------------- --- -- -<br>Posted with NewsLeecher v4.0 Final<br>Web @ <a href="http://www.newsleecher.com/?usenet" target="_blank">http://www.newsleecher.com/?usenet</a><br>------------------- ----- ---- -- -<br>
<br><br><br><br>---------- Forwarded message ----------<br>From: Emile van Sebille <<a href="mailto:emile@fenx.com">emile@fenx.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 05 Jan 2011 15:45:36 -0800<br>
Subject: Re: Help with a Python coding question<br>On 1/5/2011 3:12 PM <a href="mailto:kanthony@woh.rr.com" target="_blank">kanthony@woh.rr.com</a> said...<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I want to use Python to find all "\n" terminated<br>strings in a PDF file, ideally returning string<br>
starting addresses.   Anyone willing to help?<br></blockquote><br>pdflines = open(r'c:\shared\python_book_01.pdf').readlines()<br>sps = [0]<br>for ii in pdflines: sps.append(sps[-1]+len(ii))<br><br>Emile<br><br><br>
<br><br>---------- Forwarded message ----------<br>From: Justin Peel <<a href="mailto:peelpy@gmail.com">peelpy@gmail.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 5 Jan 2011 18:14:28 -0700<br>
Subject: Re: Help with a Python coding question<br><br><br>
<div class="gmail_quote">On Wed, Jan 5, 2011 at 4:45 PM, Emile van Sebille <span dir="ltr"><<a href="mailto:emile@fenx.com" target="_blank">emile@fenx.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On 1/5/2011 3:12 PM <a href="mailto:kanthony@woh.rr.com" target="_blank">kanthony@woh.rr.com</a> said... 
<div><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I want to use Python to find all "\n" terminated<br>strings in a PDF file, ideally returning string<br>
starting addresses.   Anyone willing to help?<br></blockquote><br></div>pdflines = open(r'c:\shared\python_book_01.pdf').readlines()<br>sps = [0]<br>for ii in pdflines: sps.append(sps[-1]+len(ii))<br><font color="#888888"><br>
Emile</font> 
<div>
<div></div>
<div><br><br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></div></div></blockquote></div>Bear in mind that pdf files often have compressed objects in them. If that is the case, then I would recommend opening the pdf in binary mode and figuring out how to deflate the correct objects before doing any searching. PyPDF is a package that might help with this though it could use some updating. <br>
<br>---------- Forwarded message ----------<br>From: Jshgwave <<a href="mailto:jshgwave@yahoo.com">jshgwave@yahoo.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 5 Jan 2011 17:08:14 -0800 (PST)<br>
Subject: Importing modules from miscellaneous folders<br>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top">On a Windows PC, I would like to be able to store modules in <br>topic-specific foldersinstead of in Python26/Lib/site-packages, <br>and then import into an IPython session those modules and the <br>functions in them.<br>
<br>To test this, I have made a toy module:<br><br>---<br><br>"""<br> toy_module.py <br> <br> This is for testing the importing of modules from folders <br> other than "Lib".<br><br> The first statement below is from Langtangen, Primer, p.143.<br>
 At allows running the module as a program, as well as <br> importing it as a module.<br>"""<br><br><br>if __name__ == '__main__' :<br><br>  def double_it (a) :<br>    b = 2.*a<br>    print 'double_it in toy_module: a = ', a, ', b = ', b<br>
    return b<br><br><br>  def triple_it (a) :<br>    b = 3.*a<br>    print 'triple_it in toy_module: a = ', a, ', b = ', b<br>    return b<br>---<br><br>I have tried many ways of importing this module and its functions, but <br>
all of them have failed.  In the IPython session below, the failures <br>have been flagged for easy identification by "<<<".<br><br>---<br><br>Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]<br>
Type "copyright", "credits" or "license" for more information.<br><br>IPython 0.10.1 -- An enhanced Interactive Python.<br>?         -> Introduction and overview of IPython's features.<br>
%quickref -> Quick reference.<br>help      -> Python's own help system.<br>object?   -> Details about 'object'. ?object also works, ?? prints more.<br><br>In [1]: # Test importing from other than Lib.<br>
<br>In [2]: # 2011-01-05<br><br>In [3]: function_dir = 'G:\\Python_2010-12\\JH_Python_Functions'<br><br>In [4]: # That is for the PC at work.<br><br>In [5]: import os<br><br>In [6]: os.getcwd()<br>Out[6]: 'C:\\Documents and Settings\\Hornstein'<br>
<br>In [7]: os.chdir(function_dir)<br><br>In [8]: os.getcwd()<br>Out[8]: 'G:\\Python_2010-12\\JH_Python_Functions'<br><br>In [9]: import toy_module<br><br>In [10]: result1 = toy_module.double_it(3.)<br>---------------------------------------------------------------------------<br>
AttributeError                            Traceback (most recent call last)<br><br>G:\Python_2010-12\JH_Python_Functions\<ipython console> in <module>()<br><br>AttributeError: 'module' object has no attribute 'double_it'  <<< 1<br>
<br>In [11]: from toy_module import double_it as twox<br>---------------------------------------------------------------------------<br>ImportError                               Traceback (most recent call last)<br><br>G:\Python_2010-12\JH_Python_Functions\<ipython console> in <module>()<br>
<br>ImportError: cannot import name double_it                     <<< 2<br><br>In [12]: IsFileThere = os.isfile('toy_module.py')<br>---------------------------------------------------------------------------<br>
AttributeError                            Traceback (most recent call last)<br><br>G:\Python_2010-12\JH_Python_Functions\<ipython console> in <module>()<br><br>AttributeError: 'module' object has no attribute 'isfile'<br>
<br>In [13]: IsFileThere = os.path.isfile('toy_module.py')<br><br>In [14]: IsFileThere<br>Out[14]: True<br><br>In [15]: filelist = os.listdir(function_dir)<br><br>In [16]: filelist<br>Out[16]:<br>['arc_to_-pitopi.py',<br>
 'arc_to_0to2pi.py',<br> 'ClustersOfGalaxiesUtils.py',<br> 'ClustersOfGalaxiesUtils.py.txt',<br> 'ClustersOfGalaxiesUtils.Test.2010-08-04.1.txt',<br> 'CosmolFns.py.txt',<br> 'CosmolGeom_SmoothedMatter_CL.py.txt',<br>
 'Distances_z.py.txt',<br> 'extract_text_line.py',<br> 'JH.PythonExperimentsOnWindows.2011-01-03.txt',<br> 'LAMBDA_calc.py',<br> '<a href="http://loop_to_sum.example.py/" target="_blank">loop_to_sum.example.py</a>',<br>
 'number_theory.py',<br> 'omega_plasma_radHz.py',<br> 'README.txt',<br> 'Sampletxt.IPython.txt',<br> 'Sampletxt.txt',<br> 'script2_1.py',<br> 'synchRadn.py.txt',<br>
 'toy_module.py',<br> 'toy_module.pyc',<br> '<a href="http://uv2d.feb14-06.py/" target="_blank">uv2D.Feb14-06.py</a>',<br> 'VariablesInFile.py',<br> 'VariablesInFile.pyc',<br> 'VLA_beamwidths.py',<br>
 'z_cosmol.py']<br><br>In [17]: import glob<br><br>In [18]: pyfilelist = glob.glob('*.py')<br><br>In [19]: pyfilelist<br>Out[19]:<br>['arc_to_-pitopi.py',<br> 'arc_to_0to2pi.py',<br> 'ClustersOfGalaxiesUtils.py',<br>
 'extract_text_line.py',<br> 'LAMBDA_calc.py',<br> '<a href="http://loop_to_sum.example.py/" target="_blank">loop_to_sum.example.py</a>',<br> 'number_theory.py',<br> 'omega_plasma_radHz.py',<br>
 'script2_1.py',<br> 'toy_module.py',<br> '<a href="http://uv2d.feb14-06.py/" target="_blank">uv2D.Feb14-06.py</a>',<br> 'VariablesInFile.py',<br> 'VLA_beamwidths.py',<br> 'z_cosmol.py']<br>
<br>In [20]: # Try changing the Python search path.<br><br>In [21]: import sys<br><br>In [22]: sys.path<br>Out[22]:<br>['',<br> 'C:\\Python26\\scripts',<br> 'C:\\WINDOWS\\system32\\python26.zip',<br>
 'C:\\Python26\\DLLs',<br> 'C:\\Python26\\lib',<br> 'C:\\Python26\\lib\\plat-win',<br> 'C:\\Python26\\lib\\lib-tk',<br> 'C:\\Python26',<br> 'C:\\Python26\\lib\\site-packages',<br>
 'C:\\Python26\\lib\\site-packages\\IPython/Extensions',<br> u'C:\\Documents and Settings\\Hornstein\\_ipython']<br><br>In [23]: sys.path.append(function_dir)<br><br>In [24]: sys.path<br>Out[24]:<br>['',<br>
 'C:\\Python26\\scripts',<br> 'C:\\WINDOWS\\system32\\python26.zip',<br> 'C:\\Python26\\DLLs',<br> 'C:\\Python26\\lib',<br> 'C:\\Python26\\lib\\plat-win',<br> 'C:\\Python26\\lib\\lib-tk',<br>
 'C:\\Python26',<br> 'C:\\Python26\\lib\\site-packages',<br> 'C:\\Python26\\lib\\site-packages\\IPython/Extensions',<br> u'C:\\Documents and Settings\\Hornstein\\_ipython',<br> 'G:\\Python_2010-12\\JH_Python_Functions']<br>
<br>In [25]: import toy_module<br><br>In [26]: result1 = toy_module.double_it(3.)<br>---------------------------------------------------------------------------<br>AttributeError                            Traceback (most recent call last)<br>
<br>G:\Python_2010-12\JH_Python_Functions\<ipython console> in <module>()<br><br>AttributeError: 'module' object has no attribute 'double_it'   <<< 3<br><br>In [27]: exit()<br>Do you really want to exit ([y]/n)?<br>
<br><br>Any insight would be appreciated.<br><br>Also, it is unfortunate that no warning is issued when an attempt at importing fails.<br><br>John Hornstein<br><br><br>(By the way, I am stuck with Python2.6 because the binary installer for <br>
NumPy on Windows still refuses to accept any later version of Python.)<br><br></td></tr></tbody></table><br><br>---------- Forwarded message ----------<br>From: Slie <<a href="mailto:stackslip@gmail.com">stackslip@gmail.com</a>><br>
To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 5 Jan 2011 16:31:13 -0900<br>Subject: Searching Python-list<br>I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month.<br>
<br><br><br><br>---------- Forwarded message ----------<br>From: Adam Skutt <<a href="mailto:askutt@gmail.com">askutt@gmail.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Wed, 5 Jan 2011 17:25:49 -0800 (PST)<br>
Subject: Re: Interrput a thread<br>On Jan 4, 10:53 pm, John Nagle <<a href="mailto:na...@animats.com">na...@animats.com</a>> wrote:<br>>      There are systems where there's support designed in for thread<br>
> abort.  LISP/Scheme systems tend to support it.  QNX, the real-time<br>> OS, has well worked out thread-abort semantics at the C level.<br>> (QNX has really good features for "not getting stuck", like the<br>
> ability to put a time limit on any system call.)<br><br>Yes, but "not getting stuck" and ending the thread execution is only<br>one small part of the problem (and arguably the least significant).<br>What we really want is a way to abort without harming other threads of<br>
execution, which is the hard part.  QNX doesn't ipso facto make that<br>easier.  Functionality like time limits on system calls is more about<br>latency guarantees and priority than "getting stuck" in a deadlock<br>
sense.<br><br>>      What you'd really like in Python is the ability for one thread<br>> to be able to force an exception in another thread, plus a<br>> mechanism for locking out such exceptions for critical sections.<br>
> It's not worth having, though, in a system where you can really only<br>> run one thread at a time.<br><br>Exceptions and critical sections are rather fundamentally<br>incompatible, hence the absurd amount of gymnastics .NET goes through<br>
to attempt to make ThreadAbortException functional (and still fails<br>rather miserably).  If you had STM or 'antitry' blocks, then<br>exceptions might be a semi-saneish way to abort a thread.  Without<br>either, I'm not entirely convinced of the utility.<br>
<br>Only allowing the exception to be thrown from defined cancellation<br>points is much better (ala POSIX threads), but diminishes the utility<br>for things that are mostly grinding away in userspace.<br><br>Adam<br><br>
<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br>