Re: [Tutor] Ptyhon GUI doubt

2009-08-25 Thread Rich Lovely
2009/8/24 Reddy Etikela, Rajasekhar :
> Hi,
>
> I am new to the Python. I have installed Python 2.6.2 version in windows XP.
>
> When I try to open the IDLE(Python GUI), getting the below message. Any
> configuration settings required for this?
>
>
> Please let me know the details.
>
> Thanks,
> Raj
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>

This is usually a firewall issue.  What firewall software are you
using, and do you have access to modify its settings?

-- 
Rich "Roadie Rich" Lovely
There are 10 types of people in the world: those who know binary,
those who do not, and those who are off by one.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Sun, Aug 23, 2009 at 6:06 PM, kreglet wrote:
>
> Hello,
>
>  The problem that I am having is writing an algorithm for finding all the
> possible words from a given word. For example: python
>
> from "python" you can make the words pot, top, hop, not etc. There are few
> examples for making anagrams for a word, but only the whole word. I have
> tried unsuccessfully to modify some of these to suit my purpose. Also on the
> web there are numerous sites where you can type in a word and it will give
> you a list of all the words that could be made from it. How would I go about
> this in python?

Another way to do this:
- sort the letters in the target word; for example 'python' becomes 'hnopty'
- sort the letters in the word you want to test, for example 'pot' becomes 'opt'
- walk through test letters looking for them in the target list. For
each test letter,
  - if it matches the current target letter, go to the next letter in each list
  - if it is less than the current target letter, go to the next target letter
  - if the test letter is greater than the target letter, or you run
out of target letters, there is no match
  - if you get to the end of the test letters, you have a match

The code for this is pretty simple and doesn't require much in the way
of data, just the two lists of letters. If you like I can share my
implementation.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Ptyhon GUI doubt

2009-08-25 Thread Reddy Etikela, Rajasekhar

Hi Rich,

I am using my organization machine. I am not aware of the firewall which we are 
using and don't have the access to it.

Thanks,
Raj
 

-Original Message-
From: Rich Lovely [mailto:roadier...@googlemail.com] 
Sent: Tuesday, August 25, 2009 4:15 PM
To: Reddy Etikela, Rajasekhar
Cc: tutor@python.org
Subject: Re: [Tutor] Ptyhon GUI doubt

2009/8/24 Reddy Etikela, Rajasekhar :
> Hi,
>
> I am new to the Python. I have installed Python 2.6.2 version in windows XP.
>
> When I try to open the IDLE(Python GUI), getting the below message. 
> Any configuration settings required for this?
>
>
> Please let me know the details.
>
> Thanks,
> Raj
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>

This is usually a firewall issue.  What firewall software are you using, and do 
you have access to modify its settings?

--
Rich "Roadie Rich" Lovely
There are 10 types of people in the world: those who know binary, those who do 
not, and those who are off by one.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Mon, Aug 24, 2009 at 8:58 PM, kreglet  wrote:

>
> Wayne,
>
> > def myfunc(cmpword, mainword):
> >   for letter in cmpword:
> > if mainword.gets(letter):
> > if cmpword[letter] >mainword[letter]:
> >  return False
> > else:
> > return False
>
>  I tried your function and couldn't get it to work. It threw an error in
> the
> line "if mainword.gets(letter):" saying that "gets" was not an attribute of
> dictionary. I tried it with "if mainword.get(letter):" -- no s but that
> would't work either.


sorry, 'get' is what I meant. You also need to add "return True" on the same
level as the else.

In [5]: word1 = {'d':1, 'o':1, 'g':1}

In [6]: word2 = {'g':1, 'o':1}

In [7]: in_word(word2, word1)
Out[7]: True

In [24]: word2 = {'b':1, 'a':1, 'r':1}

In [25]: in_word(word2, word1)
Out[25]: False

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Trouble with a Recipe ...

2009-08-25 Thread Garry Bettle
Hi,

Hope this email finds everyone well - roll on the weekend.

I'm trying to run http://code.activestate.com/recipes/576824/

I'm in IDLE and I try:

>>> email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject": "Testing", 
>>> "From": "garry.bet...@gmail.com"}, text="Testing")

but I get the following error:

Traceback (most recent call last):
  File "", line 1, in 
email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject":
"Testing", "From": "garry.bet...@gmail.com"}, text="Testing")
  File "C:\Documents and Settings\Garry\Desktop\recipe-576824-1.py",
line 50, in email_it_via_gmail
+ headers.get("Bcc", [])
TypeError: cannot concatenate 'str' and 'list' objects

Sorry, but I according to the recipe I don't need a Bcc.

Sorry, again, for such a simple question!

Cheers,

Garry
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble with a Recipe ...

2009-08-25 Thread Vern Ceder
At the top in the docstring it says, '"To", "Cc" and "Bcc" values must 
be *lists*'.


That means instead of "To":  "garry.bet...@gmail.com", you need "To": 
["garry.bet...@gmail.com"] i.e. a list containing the destination 
address. That's so that you could send to, cc and bcc more than one address.


HTH,

Vern


Garry Bettle wrote:

Hi,

Hope this email finds everyone well - roll on the weekend.

I'm trying to run http://code.activestate.com/recipes/576824/

I'm in IDLE and I try:


email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject": "Testing", "From": 
"garry.bet...@gmail.com"}, text="Testing")


but I get the following error:

Traceback (most recent call last):
  File "", line 1, in 
email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject":
"Testing", "From": "garry.bet...@gmail.com"}, text="Testing")
  File "C:\Documents and Settings\Garry\Desktop\recipe-576824-1.py",
line 50, in email_it_via_gmail
+ headers.get("Bcc", [])
TypeError: cannot concatenate 'str' and 'list' objects

Sorry, but I according to the recipe I don't need a Bcc.

Sorry, again, for such a simple question!

Cheers,

Garry
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


--
This time for sure!
   -Bullwinkle J. Moose
-
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble with a Recipe ...

2009-08-25 Thread Garry Bettle
Many, many thanks Vern.

For the life of me, I couldn't remember [] are for lists:  I was trying with ().

Guess I picked a bad day to stop sniffing glue!

Cheers,

Garry

On Tue, Aug 25, 2009 at 15:55, Vern Ceder wrote:
> At the top in the docstring it says, '"To", "Cc" and "Bcc" values must be
> *lists*'.
>
> That means instead of "To":  "garry.bet...@gmail.com", you need "To":
> ["garry.bet...@gmail.com"] i.e. a list containing the destination address.
> That's so that you could send to, cc and bcc more than one address.
>
> HTH,
>
> Vern
>
>
> Garry Bettle wrote:
>>
>> Hi,
>>
>> Hope this email finds everyone well - roll on the weekend.
>>
>> I'm trying to run http://code.activestate.com/recipes/576824/
>>
>> I'm in IDLE and I try:
>>
> email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject":
> "Testing", "From": "garry.bet...@gmail.com"}, text="Testing")
>>
>> but I get the following error:
>>
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>    email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject":
>> "Testing", "From": "garry.bet...@gmail.com"}, text="Testing")
>>  File "C:\Documents and Settings\Garry\Desktop\recipe-576824-1.py",
>> line 50, in email_it_via_gmail
>>    + headers.get("Bcc", [])
>> TypeError: cannot concatenate 'str' and 'list' objects
>>
>> Sorry, but I according to the recipe I don't need a Bcc.
>>
>> Sorry, again, for such a simple question!
>>
>> Cheers,
>>
>> Garry
>> ___
>> Tutor maillist  -  tu...@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
> --
> This time for sure!
>   -Bullwinkle J. Moose
> -
> Vern Ceder, Director of Technology
> Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
> vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor Mailing List

2009-08-25 Thread John Jenkinson
For the time being, I would like to be removed from the Tutor Mailing List
for Python Users.
Thanks,
- John Jenkinson
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Mailing List

2009-08-25 Thread Kent Johnson
On Tue, Aug 25, 2009 at 10:28 AM, John
Jenkinson wrote:
> For the time being, I would like to be removed from the Tutor Mailing List
> for Python Users.

Click on the link below and follow the directions...
Kent

> Thanks,
> - John Jenkinson
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread kreglet

Wayne,
 I appreciate your patience with me. I still can't get this to work:


from operator import itemgetter
class testwords:
def __init__(self):
self.lettercount={}
self.inword=False
self.mainword=""
self.cmpword=""

def countletters(word):
lc.lettercount = {}
for letter in word:
lc.lettercount[letter] =lc.lettercount.get(letter,0) + 1
print sorted(lc.lettercount.iteritems(), key=itemgetter(1))

def comparewords(cmpword, mainword):
for letter in cmpword:
if mainword.get(letter):
print letter, cmpword[letter], mainword[letter]
if cmpword[letter] >mainword[letter]:
lc.inword=False

else:
if cmpword[letter] <=mainword[letter]:
lc.inword=True


lc=testwords()

lc.mainword="batty"
lc.cmpword="bat"

countletters(lc.mainword)
mainword = lc.lettercount

countletters(lc.cmpword)
cmpword = lc.lettercount

comparewords(cmpword, mainword)

if lc.inword==True:
print lc.cmpword + " IS in: " + lc.mainword
if lc.inword==False:
print lc.cmpword + " IS NOT in: " + lc.mainword


This is confusing me:

lc.mainword="batty"
lc.cmpword="bat"


[('a', 1), ('y', 1), ('b', 1), ('t', 2)]
[('a', 1), ('b', 1), ('t', 1)]
a 1 1
b 1 1
t 1 2
bat IS in: batty

lc.mainword="batty"
lc.cmpword="byyt"

[('a', 1), ('y', 1), ('b', 1), ('t', 2)]
[('b', 1), ('t', 1), ('y', 2)]
y 2 1
b 1 1
t 1 2
byyt IS in: batty

if I put :  if cmpword[letter] <=mainword[letter]:
lc.inword=True


on the same level as the else statement:
lc.mainword="batty"
lc.cmpword="bat"


[('a', 1), ('y', 1), ('b', 1), ('t', 2)]
[('a', 1), ('b', 1), ('t', 1)]
a 1 1
b 1 1
t 1 2
bat IS Not in: batty

Neither is: byyt

Isn't what comes after the else statment to catch if a letter is in the
cmpword that is not in the mainword?

lc.mainword="batty"
lc.cmpword="bst"

KeyError: 's'




Wayne-68 wrote:
> 
> On Mon, Aug 24, 2009 at 8:58 PM, kreglet  wrote:
> 
>>
>> Wayne,
>>
>> > def myfunc(cmpword, mainword):
>> >   for letter in cmpword:
>> > if mainword.gets(letter):
>> > if cmpword[letter] >mainword[letter]:
>> >  return False
>> > else:
>> > return False
>>
>>  I tried your function and couldn't get it to work. It threw an error in
>> the
>> line "if mainword.gets(letter):" saying that "gets" was not an attribute
>> of
>> dictionary. I tried it with "if mainword.get(letter):" -- no s but that
>> would't work either.
> 
> 
> sorry, 'get' is what I meant. You also need to add "return True" on the
> same
> level as the else.
> 
> In [5]: word1 = {'d':1, 'o':1, 'g':1}
> 
> In [6]: word2 = {'g':1, 'o':1}
> 
> In [7]: in_word(word2, word1)
> Out[7]: True
> 
> In [24]: word2 = {'b':1, 'a':1, 'r':1}
> 
> In [25]: in_word(word2, word1)
> Out[25]: False
> 
> HTH,
> Wayne
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Algorithm-tp25107922p25140474.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread kreglet

Hello Kent,

Yes I would like to see your implementation. It seems to work but I get
error at the end.

concat=''.join

mainword="python"
cmpword="pot"
 # sort the letters in the target word; for example 'python' becomes
'hnopty'
tmplst=[]
for letters in mainword:
tmplst.append(letters)

tmplst.sort()
mainword=concat(tmplst)
# sort the letters in the word you want to test, for example 'pot' becomes
'opt'
tmplst=[]
for letters in cmpword:
tmplst.append(letters)

tmplst.sort()
cmpword=concat(tmplst)

inword=False
# walk through test letters looking for them in the target list. 
print cmpword, mainword
for letter in range(len(cmpword)): #Test
for let in range(len(mainword)):#Target
print cmpword[letter], mainword[let],
# if it matches the current target letter, go to the next 
letter in each
list
if cmpword[letter]==mainword[let]:
print "Match: "
let +=1
letter +=1
# if it is less than the current target letter, go to the next 
target
letter
if cmpword[letter]mainword[let]:   
print "No Match:"
inword=False
inword=True


if inword==True:
print cmpword + " is IN: " + mainword
else:
print cmpword + " is NOT in: " + mainrowd


opt hnopty
o h No Match:
o n No Match:
o o Match: 
p p Match: 
t t Match: 
Traceback (most recent call last):
  File "/home/kreglet/bin/knt.py", line 45, in 
if cmpword[letter] 
> 
> Another way to do this:
> - sort the letters in the target word; for example 'python' becomes
> 'hnopty'
> - sort the letters in the word you want to test, for example 'pot' becomes
> 'opt'
> - walk through test letters looking for them in the target list. For
> each test letter,
>   - if it matches the current target letter, go to the next letter in each
> list
>   - if it is less than the current target letter, go to the next target
> letter
>   - if the test letter is greater than the target letter, or you run
> out of target letters, there is no match
>   - if you get to the end of the test letters, you have a match
> 
> The code for this is pretty simple and doesn't require much in the way
> of data, just the two lists of letters. If you like I can share my
> implementation.
> 
> Kent
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Algorithm-tp25107922p25142030.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Tue, Aug 25, 2009 at 5:03 PM, kreglet wrote:
>
> Hello Kent,
>
> Yes I would like to see your implementation. It seems to work but I get
> error at the end.
>
> concat=''.join
>
> mainword="python"
> cmpword="pot"
>  # sort the letters in the target word; for example 'python' becomes
> 'hnopty'
> tmplst=[]
> for letters in mainword:
>        tmplst.append(letters)

This can be written as
tmplst = list(mainword)

> tmplst.sort()

The above could be greatly simplified to
tmplst = sorted(mainword)

> mainword=concat(tmplst)

You don't really need to convert back to a string, the list would work fine.

> # sort the letters in the word you want to test, for example 'pot' becomes
> 'opt'
> tmplst=[]
> for letters in cmpword:
>        tmplst.append(letters)
>
> tmplst.sort()
> cmpword=concat(tmplst)

Same as above

> inword=False
> # walk through test letters looking for them in the target list.
> print cmpword, mainword
> for letter in range(len(cmpword)): #Test
>        for let in range(len(mainword)):#Target

You want to walk the two lists together. Nested loops is not the right
structure. Here is my version:

""" Find all words that can be made with the letters of a given word """

def contains(word, letters):
''' Test whether all letters of word are in letters.
Letters must be a sorted list.'''
letterIndex = 0;
for letter in sorted(word):
if letterIndex >= len(letters):
# Ran out of letters
return False

while letter > letters[letterIndex] and letterIndex < len(letters) -1:
# Skip letters that are too small
letterIndex += 1

if letter == letters[letterIndex]:
# A match, keep checking
letterIndex += 1
continue

# No match for current letter
return False

return True


def findWordsIn(targetWord, minLen=3):
letters = sorted(targetWord)

for word in open('/usr/share/dict/words'):
word = word.strip()

if len(word) < minLen:
continue

if contains(word, letters):
print word

findWordsIn('python', 3)

Prints:
hop
hot
hoy
hyp
hypo
not
noy
nth
opt
pho
phon
phony
phot
phyton
poh
pon
pont
pony
pot
poy
python
tho
thon
thy
ton
tony
top
toph
toy
typo
yon
yont
yot

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how to remove first '/'

2009-08-25 Thread davidwilson
Hello,
I want to strip the first '/' from the following:

'/path/to/file'

How can I do this?

Dave
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to remove first '/'

2009-08-25 Thread vince spicer
On Tue, Aug 25, 2009 at 3:55 PM,  wrote:

> Hello,
> I want to strip the first '/' from the following:
>
> '/path/to/file'
>
> How can I do this?
>
> Dave
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

there are many ways to do this, heres a few:

x = "/path/to/file"

print x.partition("/")[-1]
print x[1:]
print "/".join(x.split("/")[1:])
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to remove first '/'

2009-08-25 Thread عماد نوفل
On Tue, Aug 25, 2009 at 5:55 PM,  wrote:

> Hello,
> I want to strip the first '/' from the following:
>
> '/path/to/file'
>
> How can I do this?
>
> Dave
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

If I understand correctly
>>> m = '/path/to/file'
>>> m[1:]
'path/to/file'
>>>


-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to remove first '/'

2009-08-25 Thread davidwilson

Thank you for the replies.


 Original Message 
From: Emad Nawfal (عماد نوفل)
To: davidwil...@safe-mail.net
Cc: tutor@python.org
Subject: Re: [Tutor] how to remove first '/'
Date: Tue, 25 Aug 2009 18:01:26 -0400


>
>
> On Tue, Aug 25, 2009 at 5:55 PM,   wrote:
> >
> >  Hello,
> > I want to strip the first '/' from the following:
> >
> > '/path/to/file'
> >
> > How can I do this?
> >
> > Dave
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>
>
> If I understand correctly
> >>> m = '/path/to/file'
> >>> m[1:]
> 'path/to/file'
> >>>
>
>
> --
> لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد 
> الغزالي
> "No victim has ever been more repressed and alienated than the truth"
>
> Emad Soliman Nawfal
> Indiana University, Bloomington
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Tue, Aug 25, 2009 at 2:14 PM, kreglet  wrote:

>
> Wayne,
>  I appreciate your patience with me. I still can't get this to work:
>
>
> from operator import itemgetter
> class testwords:
> def __init__(self):
>self.lettercount={}
> self.inword=False
>self.mainword=""
>self.cmpword=""
>
> def countletters(word):
>lc.lettercount = {}
>for letter in word:
>lc.lettercount[letter] =lc.lettercount.get(letter,0) + 1
>print sorted(lc.lettercount.iteritems(), key=itemgetter(1))
>
> def comparewords(cmpword, mainword):
>for letter in cmpword:
>if mainword.get(letter):
>print letter, cmpword[letter], mainword[letter]
> if cmpword[letter] >mainword[letter]:
> lc.inword=False
>
>else:
> if cmpword[letter] <=mainword[letter]:
> lc.inword=True
>
>
> lc=testwords()
>
> lc.mainword="batty"
> lc.cmpword="bat"
>
> countletters(lc.mainword)
> mainword = lc.lettercount
>
> countletters(lc.cmpword)
> cmpword = lc.lettercount
>
> comparewords(cmpword, mainword)
>
> if lc.inword==True:
>print lc.cmpword + " IS in: " + lc.mainword
> if lc.inword==False:
>print lc.cmpword + " IS NOT in: " + lc.mainword


This is a bit redundant -  since lc.inword returns True or False you can
simply test:

if lc.inword:
  #do stuff
else:
  #do other stuff

That's really the proper way to do it. Also, AFAIK two "if" statements take
longer than an if/else statement. Of course we're talking about ms or less,
but it still reads better to have an if/else.

It appears that I've not been coding enough lately - and my explanation has
been a bit of a failure.

I just did a quick test and this code seems to work correctly:
def countletters(word):
lettercount = {}
for letter in word:
lettercount[letter] = lettercount.get(letter, 0) + 1

return lettercount

def comparewords(cmpword, mainword):
for letter in cmpword:
if mainword.get(letter):
if cmpword[letter] > mainword[letter]:
return False
else:
return False
return True

word1 = countletters('python')
word2 = countletters('pyz')

print comparewords(word2, word1)


at least "py" was in "python", so was "pyn", but 'pyz' was not.

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread Kent Johnson
On Tue, Aug 25, 2009 at 9:55 PM, Wayne wrote:
> I just did a quick test and this code seems to work correctly:
> def countletters(word):
>     lettercount = {}
>     for letter in word:
>         lettercount[letter] = lettercount.get(letter, 0) + 1
>     return lettercount
> def comparewords(cmpword, mainword):
>     for letter in cmpword:
>         if mainword.get(letter):
>             if cmpword[letter] > mainword[letter]:
>                 return False

This could be
  if cmpword[letter] > mainword.get(letter, 0):

The whole loop could be simplified a bit using dict.items():
for letter, count in cmpword.items():
  if count > mainword.get(letter, 0):
return False

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Algorithm

2009-08-25 Thread kreglet

Wayne, Kent, Alan, and Mac

Thank you for all the help and suggestions . 

Wayne and Kent,

Both your solutions work great. The extra comments you gave on the code that
I tried will help reduce the line count and make the code more readable in
the rest of the project. Apparently, I still have a lot to learn. I really
appreciate the time you took to help and teach me.

Thanx,
kreglet


-- 
View this message in context: 
http://www.nabble.com/Algorithm-tp25107922p25145813.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Ptyhon GUI doubt

2009-08-25 Thread Lie Ryan

Reddy Etikela, Rajasekhar wrote:

Hi Rich,

I am using my organization machine. I am not aware of the firewall which we are 
using and don't have the access to it.



You can just ignore the message if you cannot the administrator to 
adjust the firewall's setting. Just be aware that when IDLE is running 
without subprocess, the execution environment between IDLE itself and 
your own program is shared (although IDLE does its best to clean things 
up). This means your program can mess up IDLE and a previous runs of the 
program may affect the later runs. It may also be problematic to work 
with a windowing toolkit or threading as they may compete with IDLE's 
own GUI thread. To work around this, test your program directly from the 
real python interpreter (i.e. from the command line/terminal, instead of 
via IDLE).


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor