Learning Python

2006-08-11 Thread Dr. Pastor
Attempting to learn Python; I constructed the module
listed below. I would like to make it shorter, faster,
more "Python like". (Windows XP, Pro.)
Many thanks for any advice!
...
 
#---
  # Name:SendMoreMoney.py
  # Purpose: A solution to the SEND+MORE=MONEY puzzle.
  #
  # Author:  Dr. Pastor
  #
  # Copyright:   (c) Dr. Pastor 2006
 
#---
  #!/usr/bin/env python

#
# The solution for the puzzle of
#SEND
#   +MORE
#   -
#   MONEY
#

def perm(items, n=None):
 if n is None:
 n = len(items)
 for i in range(len(items)):
 v = items[i:i+1]
 if n == 1:
 yield v
 else:
 rest = items[:i] + items[i+1:]
 for p in perm(rest, n-1):
 yield v + p

def comb(items, n=None):
 if n is None:
 n = len(items)
 for i in range(len(items)):
 v = items[i:i+1]
 if n == 1:
 yield v
 else:
 rest = items[i+1:]
 for c in comb(rest, n-1):
 yield v + c
#
#   S   E   N   D   M   O   R   Y
# ['0','1','2','3','4','5','6','7','8','9']
#
print
print "Selections of 8 items from 10 then the permutation of them."
print
b=0
for s in comb([0,1,2,3,4,5,6,7,8,9],8):
 for a in perm(s,None):
 if (a[4]*1000+a[5]*100+a[2]*10+a[1])*10+a[7] == \
  (a[0]+a[4])*1000+(a[1]+a[5])*100+(a[2]+a[6])*10+(a[3]+a[1]):
 b += 1
 print ' SEND', '  ',a[0],a[1],a[2],a[3]
 print ' MORE', '  ',a[4],a[5],a[6],a[1]
 print ' ', ' -'
 print 'MONEY', '',a[4],a[5],a[2],a[1],a[7]
 print
print "There are ", b, " solutions."
print
...
















== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python

2006-08-12 Thread Dr. Pastor
What a bright replies! It is a
pleasure to study them.
Thanks to you all.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Motions.

2006-10-10 Thread Dr. Pastor
Hi:
I would like to track the motions of
small birds in short (20-30sec) .avi films.
What tool-set/programs would be wise to use?
Thanks for any guidance.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Motions.

2006-10-14 Thread Dr. Pastor
Thank you Sir!

Gerrit Holl wrote:
> On 2006-10-11 00:26:38 +0200, Dr. Pastor wrote:

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Array? Please help.

2006-05-28 Thread Dr. Pastor
No it is not home work.
(I have not did any home work for more than 50 years.)
I am a beginner, and just do not see a really proper
way to program the question.
Thanks anyhow.

Scott David Daniels wrote:

> Dr. Pastor wrote:
> 
>> I need a row of 127 bytes that I will use as a
>> circular buffer. Into the bytes (at unspecified times)
>> a mark (0> After some time the "buffer" will contain the last 127 marks.
> 
> 
> Sounds a lot like homework.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Array? Please help.

2006-05-28 Thread Dr. Pastor
Many thanks to you all. (Extra thanks to Mr. Daniels.)

Dr. Pastor wrote:
> I need a row of 127 bytes that I will use as a
> circular buffer. Into the bytes (at unspecified times)
> a mark (0 After some time the "buffer" will contain the last 127 marks.
> (A pointer will point to the next byte to write to.)
> What would be the Pythonic way to do the above?
> Thanks for any guidance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE for Python

2006-08-28 Thread Dr. Pastor
Please could you tell me how to uninstal SPE?
Regards.

jelle wrote:
> I think SPE is a terrible complete and efficient IDE!
> 

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE for Python

2006-08-28 Thread Dr. Pastor
Please advise how to uninstal SPE.
Regards,
Dr. Pastor.


jelle wrote:
> I think SPE is a terrible complete and efficient IDE!
> 

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE for Python

2006-08-28 Thread Dr. Pastor
Thank you Sir.
I downloaded SPE from the main site.
Installed on Windows XP.
Regards.


Sybren Stuvel wrote:
> Dr. Pastor enlightened us with:
>> Please advise how to uninstal SPE.
> 
> First you'll have to tell us how you installed it in the first place.
> Without that, we can only guess.
> 
> Sybren

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Exception EOFError.

2006-09-03 Thread Dr. Pastor
Python 2.5b3 on Windows XP.

(exception EOFError
Raised when one of the built-in functions (input() or
raw_input()) hits an end-of-file condition (EOF) without reading any data.)

For me, raw_input (hit enter) returns an empty string!
(>>> x=raw_input()

 >>> x
''
 >>> )

Any confirmation?
Regards.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception EOFError.

2006-09-03 Thread Dr. Pastor
Thank you Sir.

Dr. Pastor wrote:
> Python 2.5b3 on Windows XP.
> 
> (exception EOFError
> Raised when one of the built-in functions (input() or
> raw_input()) hits an end-of-file condition (EOF) without reading any data.)
> 
> For me, raw_input (hit enter) returns an empty string!
> (>>> x=raw_input()
> 
>  >>> x
> ''
>  >>> )
> 
> Any confirmation?
> Regards.
> 
> == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
> News==
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
> Newsgroups
> = East and West-Coast Server Farms - Total Privacy via Encryption =

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Test for number?

2006-09-04 Thread Dr. Pastor
In the following code I would like to ascertain
that x has/is a number. What the simplest TEST should be?
(Could not find good example yet.)
---
x=raw_input('\nType a number from 1 to 20')
if TEST :
Do_A
else:
Do_B
---
Thanks for any guidance.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Path?

2006-09-06 Thread Dr. Pastor
I installed Python 2.5 on Windows XP.
I got the following system that works well.
---
Python 2.5b3 (r25b3:51041, Aug  3 2006, 09:35:06) [MSC v.1310 32 bit 
(Intel)] on
win32 Type "copyright", "credits" or "license()" for more information.

IDLE 1.2b3
 >>> import sys
 >>> sys.path
['C:\\Python25\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python25.zip',
'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win',
'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 
'C:\\Python25\\lib\\site-packages',
'C:\\Python25\\lib\\site-packages\\wx-2.6-msw-ansi']
 >>>
---
Question: How did I end up with the second item in path?
Is that a zip file?
There is no such a file in system32.
What would be the correct way to set path to assist the search?
Thanks for any advice.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Path?

2006-09-06 Thread Dr. Pastor
Many thanks, Sir.

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Video.

2006-02-21 Thread Dr. Pastor
Dear All:
(I am a 100% beginner in Python.)
What environment,library,product should I
import or study to manipulate cameras, video,
fire-wire, avi files?
Thanks you for any guidance.

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


Re: Video.

2006-02-21 Thread Dr. Pastor
Thank you Sybren.
Where is it?
Regards.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Video.

2006-02-21 Thread Dr. Pastor
Many thanks to you All.
-- 
http://mail.python.org/mailman/listinfo/python-list


PYTHONPATH?

2006-02-23 Thread Dr. Pastor
Several Documents about Python
refer to PYTHONPATH.
I could not find such variable.
(Python 2.4.2, IDLE 1.1.2, Windows XP)
How should/could I nominate a Directory to be
the local Directory?
Thanks for any guidance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Cretins.

2007-06-13 Thread Dr. Pastor
Please do not do business with
those cretins who without authorization
attaching the following text to my postings:

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Array?

2006-05-25 Thread Dr. Pastor
I need a row of 127 bytes that I will use as a
circular buffer. Into the bytes (at unspecified times)
a mark (0http://mail.python.org/mailman/listinfo/python-list


Array? Please help.

2006-05-27 Thread Dr. Pastor
I need a row of 127 bytes that I will use as a
circular buffer. Into the bytes (at unspecified times)
a mark (0http://mail.python.org/mailman/listinfo/python-list


About IDLE?

2006-03-09 Thread Dr. Pastor
Installed Python 2.4.2 on Windows XP.
Activated IDLE.
Loaded the following into the Edit window:
---
# dates are easily constructed and formatted (Tutorial 10.8)

from datetime import date
now = date.today()
now

now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")

# dates support calendar arithmetic

birthday = date(1985, 12, 1)
age = now - birthday
age.days
---
When I select Run Module in the Edit window, I got only
two >>> after the RESTART line.
I expected to see the output of several commands!
Typing in age.days do produce the number of days.

Why I do not get any output?
Thanks for any guidance.


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


About printing in IDLE?

2006-03-09 Thread Dr. Pastor
Installed Python 2.4.2 on Windows XP.
Activated IDLE.
Loaded the following to the Edit window:
---
print "hello world"
for i in range(10):
 print i,

print "Done"
---
It prints as: 0 1 2 3 4 5 6 7 8 9 Done
Should not Done be printed on a new line alone?
Thanks for any guidance.

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


Re: About IDLE?

2006-03-09 Thread Dr. Pastor
Any reply?

Dr. Pastor wrote:
> Installed Python 2.4.2 on Windows XP.
> Activated IDLE.
> Loaded the following into the Edit window:
> ---
> # dates are easily constructed and formatted (Tutorial 10.8)
> 
> from datetime import date
> now = date.today()
> now
> 
> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
> 
> # dates support calendar arithmetic
> 
> birthday = date(1985, 12, 1)
> age = now - birthday
> age.days
> ---
> When I select Run Module in the Edit window, I got only
> two >>> after the RESTART line.
> I expected to see the output of several commands!
> Typing in age.days do produce the number of days.
> 
> Why I do not get any output?
> Thanks for any guidance.
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About printing in IDLE?

2006-03-09 Thread Dr. Pastor
Many thanks to you all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About IDLE?

2006-03-09 Thread Dr. Pastor
Thank you! I can see only your reply.
But indeed google prints three.
The mind boggles.


Nick Smallbone wrote:

> Dr. Pastor wrote:
> 
>>Any reply?
>>
> 
> 
> ahem. three replies, when i counted:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/ab0c8455251e616c/
> 
-- 
http://mail.python.org/mailman/listinfo/python-list