Replace "dash" values in a field with new line- VB equivalent of Python

2013-03-19 Thread Cathy James
Dear All,
I need some assistance with Python so that values in the "Name" field e.g.
Murray - James - Leo can be labeled as:

Murray
James
Leo

with a new line replacing every dash.

Basically I need the equivalent of this VB in Python:
replace ( [Name]  , "-", vbNewLine)

I tried this but no luck:

str.[Name].replace("-", "\n")
str.[Name].replace("-", \n)
[Name].replace("-", \n")

Your help is appreciated
-- 
http://mail.python.org/mailman/listinfo/python-list


Need Help Using list items as output table names in MsACCESS

2012-03-28 Thread Cathy James
Dear Python folks,
I need your help on using list items as output table names in
MsACCESS-new to Python- simple would be better:

import arcpy, os
outSpace = "c:\\data\\Info_Database.mdb\\"
arcpy.overwriteOutput = True
SQL = "Database Connections\\SDE_ReadOnly.sde\\"

inFcList = [(SDE + "sde.GIS.Parcel"),
(SDE + "sde.GIS.Residence"),
(SDE + "sde.GIS.Park"),
(SDE + "sde.GIS.Field"),
(SDE + "sde.GIS.Business"),
(SDE + "sde.GIS.Facility"),
(SDE + "sde.GIS.Tertiary"),
(SDE + "sde.GIS.KiddieClub")]

#I'd like to crete output tables in the MDB whose names correspond to
input names such that
#"sde.GIS.Parcel" becomes "sde.GIS.Parcel_Buffer_500"
for fc in inFcList:
arcpy.overwriteOutput = True
arcpy.Buffer_analysis(fc,(outSpace+fc+"_Buffer_500"), "500 Feet",
"FULL", "ROUND", "ALL", "")
print Finished
#Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Please Help with vertical histogram

2011-07-11 Thread Cathy James
Please kindly help- i have a project where I need to plot dict results
as a histogram. I just can't get the y- axis to print right.  May
someone please help?  I have pulled my hair for the past two weeks, I
am a few steps ahead, but stuck for now.


def histo(his_dict = {1:16, 2:267, 3:267, 4:169, 5:140, 6:112, 7:99,
8:68, 9:61, 10:56, 11:35, 12:13, 13:9, 14: 7, 15:2}):

x_max = 17 #get maximum value of x
y_max = 400 #get minimum value of y
# print each line
print ('^')
for j in range(y_max, 0, -100):# draw

s = '|'
for i in range(1, x_max):
if i in his_dict.keys() and his_dict[i] >= j:
s += '***'
else:
s += '   '
print (s)
print (j)
# print x axis
s = '+'
for i in range(1, x_max):
s += '-+-'
s += '>'
print (s)

# print indexes
s = ' '
for i in range(1, x_max):
s += ' %d ' % i
print (s)

histo()

# I need it to look like this:
400 -|
   |
   |
   |
   |
300 -|
   |
   |   **
   |   **
   |   **
200 -|   **
   |   **
   |   *
   |   
   |   
100 -|   ***
   |   **
   |   
   |   ***
   |*
0 -+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
   | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
-- 
http://mail.python.org/mailman/listinfo/python-list


Struggling with sorted dict of word lengths and count

2011-06-27 Thread Cathy James
Dear Python Programmers,

I am a Python newby and I need help with my code: I have done parts of it
but I can't get what I need: I need to manipulate text to come up with word
lengths and their frequency:ie

how many 1-letter words in a text
how many 2-letter words in a text, etc

I believe I am on the right path, but I can't get it right, I hope someone
can shed some light: Code below.

import string
import sys
def word_length(word):
for p in string.punctuation:
word = word.replace(p, "")  # replace any punctuation symbol with
empty string
return len(word)

def fileProcess(filename = open('input_text.txt', 'r')):
#Need to show word count(ascending order) for each of the word lengths
that has been encountered.

#
print ("Length \t" + "Count")#print header for all numbers
freq = {} #empty dict to accumulate word count and word length
for line in filename:
for word in line.lower().split( ):#split lines into words and make
lower case
wordlen = word_length(word)#run function to return length of
each word
freq[wordlen] = freq.get(wordlen, 0) + 1#increment the stored
value if there is one, or initialize
print(word, wordlen, freq[wordlen])

fileProcess()
-- 
http://mail.python.org/mailman/listinfo/python-list


search through this list's email archives

2011-06-23 Thread Cathy James
Dear All,

I looked through this forum's archives, but I can't find a way to
search for a topic through the archive. Am I missing something?

Thanks as always.
CJ.
-- 
http://mail.python.org/mailman/listinfo/python-list


print header for output

2011-06-18 Thread Cathy James
I managed to get output for my function, thanks much  for your
direction. I really appreciate the hints. Now I have tried to place
the statement "print ("Length \t" + "Count\n")" in different places in
my code so that the function can print the headers only one time in
this manner:

Count  Length
4 7
8 1
12 2


Code so far:
def fileProcess(filename = open('declaration.txt', 'r')):

"""Call the program with an argument,
it should treat the argument as a filename,
splitting it up into words, and computes the length of each word.
print a table showing the word count for each of the word lengths
that has been encountered."""

freq = {} #empty dict to accumulate word count and word length
print ("Length \t" + "Count\n")
for line in filename:
punc = string.punctuation + string.whitespace#use Python's
built-in punctuation and whiitespace
for word in (line.replace (punc, "").lower().split()):
if word in freq:
freq[word] +=1 #increment current count if word already in dict

else:
freq[word] = 1 #if punctuation encountered,
frequency=0 word length = 0
#print ("Length \t" + "Count\n")#print header for all numbers.
for word, count in freq.items():
print(len(word), count)

fileProcess()

On Sat, Jun 18, 2011 at 7:09 PM,   wrote:
> Send Python-list mailing list submissions to
>        python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>        python-list-requ...@python.org
>
> You can reach the person managing the list at
>        python-list-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Re: How do you copy files from one location to another?
>      (Terry Reedy)
>   2. Re: Strategy to Verify Python Program is POST'ing to a web
>      server. (Paul Rubin)
>   3. Re: Strategy to Verify Python Program is POST'ing to a web
>      server. (Terry Reedy)
>   4. Re: debugging https connections with urllib2? (Roy Smith)
>   5. Re: Improper creating of logger instances or a Memory Leak?
>      (Chris Torek)
>   6. Re: Strategy to Verify Python Program is POST'ing to a web
>      server. (Chris Angelico)
>   7. NEED HELP-process words in a text file (Cathy James)
>   8. Re: NEED HELP-process words in a text file (Chris Rebert)
>   9. Re: NEED HELP-process words in a text file (Tim Chase)
>
>
> -- Forwarded message --
> From: Terry Reedy 
> To: python-list@python.org
> Date: Sat, 18 Jun 2011 16:52:26 -0400
> Subject: Re: How do you copy files from one location to another?
> On 6/18/2011 1:13 PM, Michael Hrivnak wrote:
>>
>> Python is great for automating sysadmin tasks, but perhaps you should
>> just use rsync for this.  It comes with the benefit of only copying
>> the changes instead of every file every time.
>>
>> "rsync -a C:\source E:\destination" and you're done.
>
> Perhaps 'synctree' would be a candidate for addition to shutil.
>
> If copytree did not prohibit an existing directory as destination, it could 
> be used for synching with an 'ignore' function.
>
> --
> Terry Jan Reedy
>
>
>
>
> -- Forwarded message --
> From: Paul Rubin 
> To: python-list@python.org
> Date: Sat, 18 Jun 2011 14:03:19 -0700
> Subject: Re: Strategy to Verify Python Program is POST'ing to a web server.
> "mzagu...@gmail.com"  writes:
>> For example, if I create a website that tracks some sort of
>> statistical information and don't ensure that my program is the one
>> that is uploading it, the statistics can be thrown off by people
>> entering false POST data onto the data upload page.  Any remedy?
>
> If you're concerned about unauthorized users posting random crap, the
> obvious solution is configure your web server to put password protection
> on the page.
>
> If you're saying AUTHORIZED users (those allowed to use the program to
> post stuff) aren't trusted to not bypass the program, you've basically
> got a DRM problem, especially if you think the users might
> reverse-engineer the program to figure out the protocol.  The most
> effective approaches generally involve delivering the program in the
> form of a hardware product that's difficult to tamper with.  That's what
> cable TV boxes amount

NEED HELP-process words in a text file

2011-06-18 Thread Cathy James
Dear Python Experts,

First, I'd like to convey my appreciation to you all for your support
and contributions.  I am a Python newborn and need help with my
function. I commented on my program as to what it should do, but
nothing is printing. I know I am off, but not sure where. Please
help:(

import string
def fileProcess(filename):
"""Call the program with an argument,
it should treat the argument as a filename,
splitting it up into words, and computes the length of each word.
print a table showing the word count for each of the word lengths
that has been encountered.
Example:
Length Count
1 16
2 267
3 267
4 169
>>>"&"
LengthCount
00
>>>
>>>"right."
LengthCount
510
"""
freq = [] #empty dict to accumulate words and word length
filename=open('declaration.txt, r')
for line in filename:
punc = string.punctuation + string.whitespace#use Python's
built-in punctuation and whiitespace
for i, word in enumerate (line.replace (punc, "").lower().split()):
if word in freq:
freq[word] +=1 #increment current count if word already in dict

else:
freq[word] = 0 #if punctuation encountered,
frequency=0 word length = 0
for word in freq.items():
print("Length /t"+"Count/n"+ freq[word],+'/t' +
len(word))#print word count and length of word separated by a tab




#Thanks in advance,
CJ.
-- 
http://mail.python.org/mailman/listinfo/python-list


Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread Cathy James
I am almost there, but I need a little help:

I would like to

a) print my dogs in the format  index. name: breed as follows:

0. Mimi:Poodle
1.Sunny: Beagle
2. Bunny: German Shepard
I am getting

(0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong?

b) I would like to append to my list, but my line dogs.dogAppend() is
giving a TypeError:

for i in enumerate (self.dogAppend()):
TypeError: 'list' object is not callable

Any help?

#MY CODE BELOW:

import sys
class Dog():
def __init__(self, name, breed):
self.name = name
self.breed = breed

def dogAppend(self):
self.dogAppend = []
self.dogAppend.append((self.name,self.breed))
return self.dogAppend


def display (self):
for i in enumerate (self.dogAppend()):
print (i,".",  self.name, ": " + self.breed)

if __name__ == "__main__":
dogs = Dog(name=input (" Enter Dog Name: "), breed=input ("Enter
Dog Breed: "))
while not dogs:
print("Goodbye!!")
sys.exit()
else:
#dogs.dogAppend()
dogs.display()
-- 
http://mail.python.org/mailman/listinfo/python-list


Newby Python help needed with functions

2011-06-03 Thread Cathy James
I need a jolt here with my python excercise, please somebody!! How can I
make my functions work correctly? I tried below but I get the following
error:

if f_dict[capitalize]:

KeyError: 

Code below:



def capitalize (s):
"""capitalize accepts a string parameter and applies the capitalize()
method"""
s.capitalize()
def title(s):
"""accepts a string parameter and applies the title() method"""
s.title()
def upper(s):
"""accepts a string parameter and applies the upper() method"""
s.upper()
def lower(s):
"""accepts a string parameter and applies the lower() method"""
s.lower()
def exit():
"""ends the program"""
import sys
sys.exit()
if __name__ == "__main__":
f_dict = {'capitalize': 'capitalize(s)',
  'title': 'title(s)',
  'upper': 'upper(s)',
  'lower': 'lower(s)',
  'exit': 'exit(s)'}
options = f_dict.keys()
prompt = 'Enter a function name from the list (%s): ' % ',
'.join(options)
while True:
inp = input(prompt)
option =f_dict.get(inp, None)#either finds the function in question or
returns a None object
s = input ("Enter a string: ").strip()
if not (option):
print ("Please enter a valid selection")
else:
if f_dict[capitalize]:
capitalize(s)
elif f_dict [title]:
title(s)
elif f_dict[upper]:
upper(s)
elif f_dict [lower]:
lower(s)
elif f_dict[exit]:
print ("Goodbye!! ")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user

2011-05-24 Thread Cathy James
TJG- that solved the printing issue!! Many thanks:)

Thanks to Chris and Jean Michel for your hints.

On Tue, May 24, 2011 at 4:07 AM,  wrote:

> Send Python-list mailing list submissions to
>python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>python-list-requ...@python.org
>
> You can reach the person managing the list at
>python-list-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Re: Why did Quora choose Python for its development?
>  (Stefan Behnel)
>   2. Re: Why did Quora choose Python for its development?
>  (Octavian Rasnita)
>   3. Re: Why did Quora choose Python for its development?
>  (Chris Angelico)
>   4. NEED HELP- read file contents, while loop to accept user
>  input, andenter to exit (Cathy James)
>   5. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Tim Golden)
>   6. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Chris Angelico)
>   7. Re: I installed Python 3 on Fedora 14 By Downloading
>  python3.2 bziped  source tarball and install it according to the
>  README,   Now How shall I uninstalled python 3.2? (harrismh777)
>   8. Re: Why did Quora choose Python for its development?
>  (Daniel Kluev)
>   9. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Chris Rebert)
>  10. Re: [Savoynet] More 'vast heavin' (Chris Angelico)
>
>
> -- Forwarded message --
> From: Stefan Behnel 
> To: python-list@python.org
> Date: Tue, 24 May 2011 08:23:55 +0200
> Subject: Re: Why did Quora choose Python for its development?
> Beliavsky, 20.05.2011 18:39:
>
>> I thought this essay on why one startup chose Python was interesting.
>>
>
> Since everyone seems to be hot flaming at their pet languages in this
> thread, let me quickly say this:
>
> Thanks for sharing the link.
>
> Stefan
>
>
>
>
> -- Forwarded message --
> From: "Octavian Rasnita" 
> To: 
> Date: Tue, 24 May 2011 11:10:36 +0300
> Subject: Re: Why did Quora choose Python for its development?
> From: "Stefan Behnel" 
>
>> Beliavsky, 20.05.2011 18:39:
>>
>>> I thought this essay on why one startup chose Python was interesting.
>>>
>>
>> Since everyone seems to be hot flaming at their pet languages in this
>> thread, let me quickly say this:
>>
>> Thanks for sharing the link.
>>
>
>
> Maybe I have missed a message, but if I didn't, please provide that link.
> I am always interested to find the best solutions.
>
> Thanks.
>
> Octavian
>
>
>
>
> -- Forwarded message --
> From: Chris Angelico 
> To: python-list@python.org
> Date: Tue, 24 May 2011 18:20:44 +1000
> Subject: Re: Why did Quora choose Python for its development?
> On Tue, May 24, 2011 at 6:10 PM, Octavian Rasnita 
> wrote:
> > From: "Stefan Behnel" 
> >>
> >> Beliavsky, 20.05.2011 18:39:
> >>>
> >>> I thought this essay on why one startup chose Python was interesting.
> >>
> >> Since everyone seems to be hot flaming at their pet languages in this
> >> thread, let me quickly say this:
> >>
> >> Thanks for sharing the link.
> >
> >
> > Maybe I have missed a message, but if I didn't, please provide that link.
> > I am always interested to find the best solutions.
>
> At the beginning of the thread, three days and forty-odd messages ago,
> this was posted:
>
> http://www.quora.com/Why-did-Quora-choose-Python-for-its-development
>
> It's the reason for the thread title, regardless of the current thread
> content :)
>
> Chris Angelico
>
>
>
> -- Forwarded message --
> From: Cathy James 
> To: python-list@python.org
> Date: Tue, 24 May 2011 03:31:37 -0500
> Subject: NEED HELP- read file contents, while loop to accept user input,
> and enter to exit
> dear mentor,
>
> I need help with my code:
> 1) my program won't display file contents upon opening
> 2) my program is not writing to file
> 3) my program is not closing when user presses enter- gow do I do this with
> a while loop?
>
> please see my attempt below and help:
>
> #1) open file and display

NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Cathy James
dear mentor,

I need help with my code:
1) my program won't display file contents upon opening
2) my program is not writing to file
3) my program is not closing when user presses enter- gow do I do this with
a while loop?

please see my attempt below and help:

#1) open file and display current file contents:
f = open ('c:/testing.txt'', 'r')
f.readlines()
#2)  and 3) use while loop  to write user input to file, save to file, close
when press enter:
while True:
s = input ('enter name: ').strip()
f = open ('c:/testing.txt', 'a')
if f.writable():
f.write(s)
break
else:
f = open ('c:/testing.txt', 'r')
f.readlines()
for line in f:
print (line)
-- 
http://mail.python.org/mailman/listinfo/python-list


MS Access table values as input into a formula in another table-need help!!

2011-01-30 Thread Cathy James
Dear Python Community,

Table1:
Prop_codeR_Value
GC 0.8
CI 0.6
LDR 0.4
HDR 0.6
TR 0.65
CR 0.35

Table 2:
O_ID PROP_CODE AI  TArea  R_Value Pre_R_Value IR
MER02006 LDR 38.19235 132.3178 0.4 0.115456 0.555143
MER02006 TR 20.78983 132.3178 0.65 0.102128 0.555143
MER02006 UO 1.850129 132.3178 0.25 0.003496 0.555143
MER03001 GC 16.565  137.592  0.8 0.096314 0.45027
Initially, I manually entered R_Value from table 1 into table 2 in order to
later compute subsequent fields using Python. Now I’d like to make the
process a bit more automatic. I would like to get R_Values  for each
Prop_Code  from table 1 into table 2 so that I can use them in a Table2
computation later on. I was thinking maybe a putting table 1 into a dict
then use those values in table 2, but I need help getting started. Just
learning Python and dicts are still tricky for me. Please help me modify the
code below so that i don't have to repeat the lines of code below for all
values of Prop_Code:
import arcpy,sys
arcpy.env.workspace = "C:\\test\\DRAINAGE.mdb"
Table1= "basins"
Table2="CV_Table"
cur = arcpy.UpdateCursor(table2, "[PROP_CODE] = 'LDR'")
row = cur.next()
# Perform the update and move to the next row as long as there are
#  rows left
while row:
row.R_Value  = 0 #initialize field from nulls to zero values
row.R_Value = 0.4 #INstead, I need to get this from Table 2
cur.updateRow(row)
row = cur.next()
# Delete the cursors to remove any data locks
del row, cur

THANKS!!
-- 
http://mail.python.org/mailman/listinfo/python-list


newby qn about functions

2011-01-18 Thread Cathy James
 #This has to be very simple, but I don't get it-please help

def *lower_case*(s):

#return s

print(s)

#return s.lower()

print(s.lower())

s=*"Testing Functions-lower case: "
*

lower_case(s)
*"""how can i use a return statement  to write a function that returns the
string "Testing Functions-lower case: "and the lowercase representation of
its string parameter""" If I uncomment the above, nothing outputs to
console:(*
**
*Much appreciation as always.*
-- 
http://mail.python.org/mailman/listinfo/python-list


Functions Not Fun (yet)-please help!

2011-01-16 Thread Cathy James
Dear all,

I can't thank you enough for taking time from your busy schedules to assist
me (and others) in my baby steps with Python. Learning about functions now
and wondering about some things commented in my code below. Maybe someone
can break it down for me and show me why i cant print the function i
created. I am using IDLE, saved it as .py

def my_func(a, b="b is a default" ,c="c is another default"):
print (a)
print (b)
print (c)


#printing the function itself:

#1. assign value to a only, b and c as default:
a= "testing"
print (my_func(a,b,c)) #why does program say c is not defined, tho default
in function above?
#2. assign a and b only, c is default
print my_func(a="testing a", b="testing b")
-- 
http://mail.python.org/mailman/listinfo/python-list


cipher encoding

2011-01-12 Thread Cathy James
Dear all,

I hope someone out there can help me.

 The output string of my code is close to what i need, but i need it
1)printed on one line and
2) reversed

#mycode:
s= input("Enter message: ")
key=1
for letter in s:
num=(chr(ord(letter)+1))
print(num)
#or is there a better way to rewrite it with elementary level Python, which
happens 2b my current ranking.
#Your insight is always appreciated:)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with code-lists and strings

2011-01-05 Thread Cathy James
Thank you all for your help.
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)
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.
3) If someone input "Thank you my FOLKS, i want the output to print words
with upper case first:

Thank
FOLKS
you
my

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 ;)

Thanks to all who took their time to help.
Future Python Expert,
Cathy.

My initial code:

s=input("Write a sentence: ")
list=s.strip().split()
for word in list:
list2 = (word.isupper() or word.istitle())
print (word)
else print (word)

On Wed, Jan 5, 2011 at 7:35 PM,  wrote:

> Send Python-list mailing list submissions to
>python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>python-list-requ...@python.org
>
> You can reach the person managing the list at
>python-list-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Re: Help with code-lists and strings (GrayShark)
>   2. Help with a Python coding question (kanth...@woh.rr.com)
>   3. Re: Help with a Python coding question (Emile van Sebille)
>   4. Re: Help with a Python coding question (Justin Peel)
>   5. Importing modules from miscellaneous folders (Jshgwave)
>   6. Searching Python-list (Slie)
>   7. Re: Interrput a thread (Adam Skutt)
>
>
> -- Forwarded message --
> From: GrayShark 
> To: python-list@python.org
> Date: Wed, 05 Jan 2011 16:56:40 -0600
> Subject: Re: Help with code-lists and strings
> On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote:
>
> > On 1/5/2011 12:57 PM, Cathy James wrote:
> >
> >> I am learning python and came across an excercise where i need to use
> >> lists to strip words from a sentence; starting with those containing
> >> one or more uppercase letters, followed by words with lower case
> >> letters.
> >
> > When writing code, it is good to start with one or more input-output
> > pairs that constitute a test. For example, what, exactly, do you want to
> > result from
> > "Some special words are ALLCAPS, TitleCase, and MIXed."
> >
> > It is also good to think about all relevant cases. Note the following:
> >  >>> 'MIXed'.isupper() or 'MIXed'.istitle()
> > False
> >
> > Do you want punctuation stripped off words? You might skip that at
> > first.
>
> In python it's best to build up you functional needs. So two steps. First
> a nand (negative 'and' operation). Then wrap that with a function to create
> two strings of your list element, you''re calling 'word'. By the way,
> list is reserved word, like string. Don't get in the bad habit of using it.
>
> def nand( a, b ):
>"""nand has to vars. Both must be strings """
>return( ( not eval( a ) ) and ( not eval( b ) ) )
>
> Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both
> results, 'and' values, return.
>
> Now wrap 'nand' in packaging an you're cooking with grease.
> def mixed_case( str ):
>return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str )
>
> or if that's too advanced/compact, try ...
> def mixed_case( str ):
># nand() needs strings
>a = "'%s'.isupper()" % str
>b = "'%s'.islower()" % str
>res = nand( a, b )
>return res
>
> >>> mixed_case('Abcd' )
> True
> >>> mixed_case('ABCD' )
> False
> >>> mixed_case('abcd' )
> False
>
> Good luck
> Steven Howe
>
>
>
> -- Forwarded message --
> From: kanth...@woh.rr.com
> To: python-list@python.org
> Date: Wed, 05 Jan 2011 17:12:13 -0600
> Subject: Help with a Python coding question
> I want to use Python to find all "\n" terminated
> strings in a PDF file, ideally returning string
> starting addresses.   Anyone willing to help?
>
>
> --
> ---

Help with code-lists and strings

2011-01-05 Thread Cathy James
Dear all,

You folks will probably hear from me more often in the next few months. I
hope some of you have time help me on occassion. Actually, a volunteer
mentor would be greatly appreciated:)

I am learning python and came across an excercise where i need to use lists
to strip words from a sentence; starting with those containing one or more
uppercase letters, followed by words with lower case letters.  When I try, i
get words in the order they were written:(*  *I tried if statements, but
unsuccessful. This has to be very easy to you experts, but I am clueless (
still rocket science to me) :(

#Below is my shot at it:

s=input("Write a sentence: ")
list=s.strip().split()
for word in list:
list2 = (word.isupper() or word.istitle())
print (word)
else print (word)
-- 
http://mail.python.org/mailman/listinfo/python-list