Re: [Tutor] New to Python - simple question

2012-11-18 Thread ALAN GAULD

>>> And the relevant portion in imtools.py is:
>>> def histeq(im,nbr_bins=256):
>>>      """ Histogram equalization of a grayscale image. """
>>>
>>>      #get image histogram
>>>      imhist,bins = histogram(im.flatten(),nbr_bins,normed=True)
>>
>>
>> This is the call, but where is histogram? If it is in imtools are you sure
>
>The function histogram is supposed to come from the numpy module; at
>least that's the case on my computer (I have numpy 1.6.2 for Python
>2.7):
>
 from numpy import *
 histogram
>
>
>Maybe something is wrong with Unaiza's version of numpy.
>More likely is that there is no import statement for numpy in imtools.py

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


[Tutor] Help with a SQL Statement

2012-11-18 Thread Khalid Al-Ghamdi
Hi All,

The SQL statement below doesn't return anything.. and I don't know why...
I've used the parans but still no luck. Any Suggestions?

cur.execute("""select badge, name, stage, tc, major, package, subject,
course, sb_as from records where
   sb_as = 0 and (subject like 'Workshop&' or subject like
'Basic%' or subject like 'Introduction%') and
   (major not like 'Customer%' or major not like
'Warehouse%') order by tc""")

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


Re: [Tutor] Help with a SQL Statement

2012-11-18 Thread Khalid Al-Ghamdi
Hi, I found one typo in 'Workshop&' which should be 'Workshop%' but it
still gives results containing majors with 'Customer%' and 'Warehouse%' in
them...


On Sun, Nov 18, 2012 at 2:21 PM, Khalid Al-Ghamdi wrote:

> Hi All,
>
> The SQL statement below doesn't return anything.. and I don't know why...
> I've used the parans but still no luck. Any Suggestions?
>
> cur.execute("""select badge, name, stage, tc, major, package, subject,
> course, sb_as from records where
>sb_as = 0 and (subject like 'Workshop&' or subject like
> 'Basic%' or subject like 'Introduction%') and
>(major not like 'Customer%' or major not like
> 'Warehouse%') order by tc""")
>
> Thanks
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with a SQL Statement

2012-11-18 Thread Bod Soutar
On Nov 18, 2012 11:30 AM, "Khalid Al-Ghamdi"  wrote:
>
> Hi, I found one typo in 'Workshop&' which should be 'Workshop%' but it
still gives results containing majors with 'Customer%' and 'Warehouse%' in
them...
>
>
> On Sun, Nov 18, 2012 at 2:21 PM, Khalid Al-Ghamdi 
wrote:
>>
>> Hi All,
>>
>> The SQL statement below doesn't return anything.. and I don't know
why... I've used the parans but still no luck. Any Suggestions?
>>
>> cur.execute("""select badge, name, stage, tc, major, package,
subject, course, sb_as from records where
>>sb_as = 0 and (subject like 'Workshop&' or subject
like 'Basic%' or subject like 'Introduction%') and
>>(major not like 'Customer%' or major not like
'Warehouse%') order by tc""")
>>
>> Thanks
>>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

This is not a python issue, but shouldn't the last part of your where
clause be "major not like 'Customer%' and major not like 'Warehouse%'"

?

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


Re: [Tutor] Help with a SQL Statement

2012-11-18 Thread Alan Gauld

On 18/11/12 11:29, Khalid Al-Ghamdi wrote:


The SQL statement below doesn't return anything.. and I don't know
why... I've used the parans but still no luck. Any Suggestions?


I'll restructure it to how I think you want it...

cur.execute("""
select badge, name, stage, tc, major, package, subject, course, sb_as
from records
where
sb_as = 0 and
(subject like 'Workshop&') or
(subject like 'Basic%') or
(subject like 'Introduction%') and
(major not like 'Customer%') or
(major not like 'Warehouse%')
order by tc""")


See if that helps... I think your parens were grouping the wrong things.


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

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


Re: [Tutor] LCM

2012-11-18 Thread Andrew
On Wed, 14 Nov 2012 19:52:03 +0200, Selby Rowley Cannon  
 wrote:



Hey,

 I've been trying to write a function to find the Lowest Common  
Multiple of two numbers, but it isn't working and I've kinda hit a dead  
end on the thought-process end of things. Anyone mind looking at it, and  
tell me what's wrong? (I hop you don't think it's too long to put in an  
email)


Code:

def lowestCommonMultiple(a, b, amount): #k
 float(amount)
 if a == b:
 print 'You cannot find the LCM of the same number twice.'
 else:
 numbersList = list(range(amount))
 aMultiples = []
 bMultiples = []
 for aNumber in numbersList:
 aMultiples.append(a*aNumber)
 for bNumber in numbersList:
 bMultiples.append(b*bNumber)
 if aMultiples[1] == bMultiples[1]:
 print 'The LCM of ', a, ' and ', b, ' is ', aMultiple[1]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Hello World,

I have script I wonder if it would be suitable:


def LCM(x,y):
for n in range(1, 1):
for n2 in range(1, 1):
x_lcm = x*n
y_lcm = y*n2
if x_lcm == y_lcm:
print"The LCM of",x,"and",y,"is",x_lcm
return x_lcm
else:
pass


dx
--
守破離(shuhari) first learn, then detach, and finally transcend
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame problem with mac

2012-11-18 Thread Jonatán Guadamuz Espinoza
El nov 17, 2012 11:39 a.m., "Ciaran Mooney" 
escribió:
>
> Hi,
>
> Was hoping u could help me.
>
> I can't seem to download a version of pygame that is compatible with
python 3.2 on my Mac powerbook with OS tiger.

You could look at this page

http://packages.debian.org/experimental/python3-pygame

Here you can get source could suited for python 3.

>
> I only seem to he able to get pygame for python 2.7 which i have never
used.
>
> Thanks
> Ciaran
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] LCM

2012-11-18 Thread Dave Angel
On 11/18/2012 12:50 PM, Andrew wrote:
> On Wed, 14 Nov 2012 19:52:03 +0200, Selby Rowley Cannon
>  wrote:
>
>> Hey,
>>
>>  I've been trying to write a function to find the Lowest Common
>> Multiple of two numbers, but it isn't working and I've kinda hit a
>> dead end on the thought-  

>> I have script I wonder if it would be suitable:
>
>
> def LCM(x,y):
> for n in range(1, 1):
> for n2 in range(1, 1):
> x_lcm = x*n
> y_lcm = y*n2
> if x_lcm == y_lcm:
> print"The LCM of",x,"and",y,"is",x_lcm
> return x_lcm
> else:
> pass
>

That won't usually provide the LCM, it'll  just provide some common
multiple.  Occasionally, it'll happen to be right.

Rather than returning the first value that's equal, you'd have to return
the lowest value that's equal.

-- 

DaveA

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


Re: [Tutor] sending email via smtplib

2012-11-18 Thread Alexander
On Sun, Nov 18, 2012 at 12:23 AM, Saad Javed  wrote:

> import smtplib
>
> from_addr = "some_a...@hotmail.com"
> to_addr = "some_a...@gmail.com"
> smtp_srv = "smtp.live.com"
>
> subject = "Test"
> message = "Test"
>
> msg = "To:%s\nFrom:%s\nSubject: %s\n\n%s" % (to_addr, from_addr, subject,
> message)
>
> smtp = smtplib.SMTP(smtp_srv, 587)
> smtp.set_debuglevel(1)
> smtp.ehlo()
> smtp.starttls()
> smtp.ehlo()
> smtp.login(user, passwd)
> smtp.sendmail(from_addr, to_addr, msg)
> smtp.quit()
>
> When I run this code, I get this output:
> send: 'ehlo [127.0.1.1]\r\n'
> reply: '250-BLU0-SMTP190.blu0.hotmail.com Hello [my-ip-address]\r\n'
> reply: '250-TURN\r\n'
> reply: '250-SIZE 41943040\r\n'
> reply: '250-ETRN\r\n'
> reply: '250-PIPELINING\r\n'
> reply: '250-DSN\r\n'
> reply: '250-ENHANCEDSTATUSCODES\r\n'
> reply: '250-8bitmime\r\n'
> reply: '250-BINARYMIME\r\n'
> reply: '250-CHUNKING\r\n'
> reply: '250-VRFY\r\n'
> reply: '250-TLS\r\n'
> reply: '250-STARTTLS\r\n'
> reply: '250 OK\r\n'
> reply: retcode (250); Msg: BLU0-SMTP190.blu0.hotmail.com Hello
> [my-ip-address]
> TURN
> SIZE 41943040
> ETRN
> PIPELINING
> DSN
> ENHANCEDSTATUSCODES
> 8bitmime
> BINARYMIME
> CHUNKING
> VRFY
> TLS
> STARTTLS
> OK
> send: 'STARTTLS\r\n'
> Traceback (most recent call last):
>   File "sendemail.py", line 24, in 
> smtp.starttls()
>   File "/usr/lib/python2.7/smtplib.py", line 636, in starttls
> (resp, reply) = self.docmd("STARTTLS")
>   File "/usr/lib/python2.7/smtplib.py", line 385, in docmd
> return self.getreply()
>   File "/usr/lib/python2.7/smtplib.py", line 358, in getreply
> + str(e))
> smtplib.SMTPServerDisconnected: Connection unexpectedly closed: [Errno
> 104] Connection reset by peer
>
> I can send email via browser. Why is my authentication being blocked by
> hotmail?
>
> P.S: I tried sending from gmail. Same error.
>
> Saad
>
> You start TLS but is the connection to the server secured using SSL?
Usually email providers have particular ports and types of encryption that
must be specified to authenticate before you can DL an entire inbox or send
a message from the address.
Alexander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sending email via smtplib

2012-11-18 Thread Saad Javed
I don't think using SSL works with hotmail. I tried using:

smtplib.*SMTP_SSL*("smtp.live.com", 587)
smtplib.login(user, passwd)
...

That gave this error:

Traceback (most recent call last):
  File "sendemail.py", line 22, in 
smtp = smtplib.SMTP_SSL(smtp_srv, 587)
  File "/usr/lib/python2.7/smtplib.py", line 776, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout)
  File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
(code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 782, in _get_socket
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
  File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 143, in __init__
self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown protocol
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor