Re: [Tutor] eval func with floating...

2011-08-23 Thread Steven D'Aprano
Christopher King wrote: If the user ever sees an AssertionError, your code is buggy. Well you saw that I caught the AssertionError, so the user wouldn't technically see it. For the other stuff, I didn't know the etiquette for assertion It's not etiquette, it is the actual way assert works.

Re: [Tutor] Python Speech

2011-08-23 Thread Alex Hall
Sorry, the link is: http://hg.qwitter-client.net then select "accessible output". On 8/23/11, Christopher King wrote: > Sorry, forgot to hit reply all. > -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _

Re: [Tutor] eval func with floating...

2011-08-23 Thread Christopher King
> > If the user ever sees an AssertionError, your code is buggy. > Well you saw that I caught the AssertionError, so the user wouldn't technically see it. For the other stuff, I didn't know the etiquette for assertion ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Python Speech

2011-08-23 Thread Christopher King
Sorry, forgot to hit reply all. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] eval func with floating...

2011-08-23 Thread Steven D'Aprano
Christopher King wrote: if c: print *eval("float(%s)"%a)* else: print "error! please use -defined operators-!" I would use a assert statement for more readability, like so. *try: assert c* *except AssertionError: print "error! please use -defined operators-!"* else: *pri

Re: [Tutor] Python Speech

2011-08-23 Thread Alex Hall
Depending on what you want, you could try accessible_output. This uses the first available screen reader to speak, or sapi5 speech if no screen reader is loaded. I believe the link is: http://hg.qwitter-client.net/dependencies HTH. On 8/23/11, Steven D'Aprano wrote: > Christopher King wrote: >> H

Re: [Tutor] eval func with floating...

2011-08-23 Thread Christopher King
> if c: > print *eval("float(%s)"%a)* > else: > print "error! please use -defined operators-!" > I would use a assert statement for more readability, like so. *try: assert c* *except AssertionError: print "error! please use -defined operators-!"* else: *print *eval("float(%s

Re: [Tutor] Python Speech

2011-08-23 Thread Steven D'Aprano
Christopher King wrote: Hello Tutors, I need help with text to speech and or speech to text. I know of two packages, but they require win32, which I can't get to work. The Win32 package was filled with pyd's and no py's..Could some one tell me how to get win32 to work or a package that doesn'

[Tutor] Python Speech

2011-08-23 Thread Christopher King
Hello Tutors, I need help with text to speech and or speech to text. I know of two packages, but they require win32, which I can't get to work. The Win32 package was filled with pyd's and no py's..Could some one tell me how to get win32 to work or a package that doesn't use it.

[Tutor] Fw: Zip - password protect

2011-08-23 Thread ALAN GAULD
Forwarding to group. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Forwarded Message From: James Reynolds To: Alan Gauld Sent: Tuesday, 23 August, 2011 20:11:57 Subject: Re: [Tutor] Zip - password protect On Tue, Aug 23, 2011 at 2:57 PM, Alan Gaul

Re: [Tutor] issues with urllib and loading a webpage

2011-08-23 Thread Robert Sjoblom
>> Are you using Python 3 and urllib, and not using httplib2? Because I >> honestly can't get urllib.request.urlopen to work with >> http://www.boursorama.com/ -- I only get b'' from there. > > Yes, Python 3.2 which version one are you using? I tried both with > debug and without. Python 3.2.1 64

Re: [Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Sander Sweers
On 23 August 2011 22:59, Robert Sjoblom wrote: > Are you using Python 3 and urllib, and not using httplib2? Because I > honestly can't get urllib.request.urlopen to work with > http://www.boursorama.com/ -- I only get b'' from there. Yes, Python 3.2 which version one are you using? I tried both w

Re: [Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Robert Sjoblom
>Don't know, works fine for me.. > >Greets >Sander Are you using Python 3 and urllib, and not using httplib2? Because I honestly can't get urllib.request.urlopen to work with http://www.boursorama.com/ -- I only get b'' from there. best regards, Robert S. _

Re: [Tutor] Zip - password protect

2011-08-23 Thread James Reynolds
On Tue, Aug 23, 2011 at 4:11 PM, James Reynolds wrote: > > > On Tue, Aug 23, 2011 at 3:49 PM, Emile van Sebille wrote: > >> On 8/23/2011 12:31 PM James Reynolds said... >> >> I'm trying the 7-zip solution, but I can't get past this >>> error: WindowsError: [Error 2] The system cannot find the f

Re: [Tutor] Zip - password protect

2011-08-23 Thread James Reynolds
On Tue, Aug 23, 2011 at 3:49 PM, Emile van Sebille wrote: > On 8/23/2011 12:31 PM James Reynolds said... > > I'm trying the 7-zip solution, but I can't get past this >> error: WindowsError: [Error 2] The system cannot find the file specified >> >> The line it fails at is here: z = subprocess.cal

Re: [Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Sander Sweers
On 23/08/11 21:27, Robert Sjoblom wrote: Here's the code I'm working with: from http.client import HTTPConnection HTTPConnection.debuglevel = 1 from urllib.request import urlopen url = "http://www.boursorama.com/includes/cours/last_transactions.phtml?symbole=1xEURUS"; response = urlopen(url) pr

Re: [Tutor] Zip - password protect

2011-08-23 Thread Emile van Sebille
On 8/23/2011 12:31 PM James Reynolds said... I'm trying the 7-zip solution, but I can't get past this error: WindowsError: [Error 2] The system cannot find the file specified The line it fails at is here: z = subprocess.call(['7z', 'a', '1234', '-y', name + '.zip'] + self.file_locs) (from now)

Re: [Tutor] Zip - password protect

2011-08-23 Thread James Reynolds
On Tue, Aug 23, 2011 at 2:57 PM, Alan Gauld wrote: > On 23/08/11 19:23, James Reynolds wrote: > >> I tried that already. >> >> that's only to set the default password to read the zip, not to set a >> pasword (wording is misleading I think) >> >> > I'm confused. > > Which password are you thinking

[Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Robert Sjoblom
So, an issue regarding urllib (python 3) came up earlier. I solved it by using httplib2 instead, but I'm rather curious as to why urllib wouldn't work. Here's the code I'm working with: from http.client import HTTPConnection HTTPConnection.debuglevel = 1 from urllib.request import urlopen url =

Re: [Tutor] Zip - password protect

2011-08-23 Thread Alan Gauld
On 23/08/11 19:23, James Reynolds wrote: I tried that already. that's only to set the default password to read the zip, not to set a pasword (wording is misleading I think) I'm confused. Which password are you thinking of? Is it at the OS level to prevent access to the file - in which case

Re: [Tutor] Zip - password protect

2011-08-23 Thread Emile van Sebille
On 8/23/2011 11:23 AM James Reynolds said... I tried that already. that's only to set the default password to read the zip, not to set a pasword (wording is misleading I think) Did you see http://stackoverflow.com/questions/2195747/python-code-to-create-a-password-encrypted-zip-file ? Chec

Re: [Tutor] Zip - password protect

2011-08-23 Thread James Reynolds
I tried that already. that's only to set the default password to read the zip, not to set a pasword (wording is misleading I think) On Tue, Aug 23, 2011 at 1:42 PM, Emile van Sebille wrote: > On 8/23/2011 10:19 AM James Reynolds said... > > Does anyone know if a way to password protect a zip f

Re: [Tutor] Zip - password protect

2011-08-23 Thread Emile van Sebille
On 8/23/2011 10:19 AM James Reynolds said... Does anyone know if a way to password protect a zip file? I have no issues creating the zip file, but I would like to password protect as well. I'm aware of a commercial solution, but I would like something open source. The standard zipfile library

[Tutor] Zip - password protect

2011-08-23 Thread James Reynolds
Does anyone know if a way to password protect a zip file? I have no issues creating the zip file, but I would like to password protect as well. I'm aware of a commercial solution, but I would like something open source. ___ Tutor maillist - Tutor@python

Re: [Tutor] eval func with floating...

2011-08-23 Thread Peter Otten
Chanakya Mitra wrote: [simulacrx] > c=set(a).intersection(set(check)) [Chanakya Mitra] > shouldn’t this be: > c=set(a).issubset(set(check)) > ? > set(a).intersection(set(check)) will be true as long as only one element > appears in both. ie. 15/a8 kill the process and spit out an error instead >

Re: [Tutor] eval func with floating...

2011-08-23 Thread Chanakya Mitra
c=set(a).intersection(set(check)) shouldn’t this be: c=set(a).issubset(set(check)) ? set(a).intersection(set(check)) will be true as long as only one element appears in both. ie. 15/a8 kill the process and spit out an error instead of asking "error! please use -defined operators-!

Re: [Tutor] eval func with floating...

2011-08-23 Thread Joel Goldstick
On Tue, Aug 23, 2011 at 6:52 AM, Peter Otten <__pete...@web.de> wrote: > simulacrx wrote: > > > check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]") > > You have to quote the digits: 1 is an integer while "1" is a string of > length one: > > >>> "1" == 1 > False > > Also, you forgot the "0".

Re: [Tutor] eval func with floating...

2011-08-23 Thread Peter Otten
simulacrx wrote: > check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]") You have to quote the digits: 1 is an integer while "1" is a string of length one: >>> "1" == 1 False Also, you forgot the "0". Note that there's no need to use a tuple as set() will happily accept a string: check

Re: [Tutor] eval func with floating...

2011-08-23 Thread Troels Emtekær Linnet
Thats because you do integer division. Do either: float(15)/8 15/float(8) 15.0/8 15/8.0 Just be sure, that either 15 or 8 is a float, and not both an integer. Best Troels 2011/8/16 simulacrx > hi; > --- > check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]") > > whi

[Tutor] eval func with floating...

2011-08-23 Thread simulacrx
hi; --- check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]") while True: a=raw_input("type your query : \n") c=set(a).intersection(set(check)) if c: print *eval("float(%s)"%a)* else: print "error! please use -defined operators-!" -