Re: [Tutor] getting binary file from website with custom header

2011-01-28 Thread Steven D'Aprano
Alex Hall wrote: Sorry. http://api.bookshare.org. Hmmm, I get: 403 Developer Inactive so that's no help to me. However, I did find this: http://developer.bookshare.org/docs/Home/ [quote] For user authenticated services, the user's username will be passed in via the for parameter in the en

Re: [Tutor] getting binary file from website with custom header

2011-01-28 Thread Alex Hall
On 1/29/11, Steven D'Aprano wrote: > A few more comments... > > Alex Hall wrote: >> Hello, >> I am continuing to work on that api wrapper... I never realized how >> little I know about urllib/urllib2! The idea of downloading from the >> api is pretty easy: give it a url and a password and it gives

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Steven D'Aprano
David Hutto wrote: You should read this: http://www.voidspace.org.uk/python/articles/authentication.shtml Void Space...You mean like the one between your ears...badumpchee. Apologies I couldn't resist. I'm sure you really could have, if you tried *wink* Michael Foord of Voidspace is a hig

Re: [Tutor] getting binary file from website with custom header

2011-01-28 Thread Steven D'Aprano
A few more comments... Alex Hall wrote: Hello, I am continuing to work on that api wrapper... I never realized how little I know about urllib/urllib2! The idea of downloading from the api is pretty easy: give it a url and a password and it gives you the book. Here is a quote from the api documen

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread David Hutto
On Fri, Jan 28, 2011 at 11:30 PM, Steven D'Aprano wrote: > Karim wrote: >> >> Hello, >> >> I want to create a client to access a webpage. But when I access it >> interactively  there is a dialog box >> which ask for login and password. > > You should read this: > > http://www.voidspace.org.uk/pyth

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Steven D'Aprano
Karim wrote: Hello, I want to create a client to access a webpage. But when I access it interactively there is a dialog box which ask for login and password. You should read this: http://www.voidspace.org.uk/python/articles/authentication.shtml or this French translation: http://www.void

Re: [Tutor] getting binary file from website with custom header

2011-01-28 Thread Steven D'Aprano
Alex Hall wrote: I keep getting an error 403, which the api defines as a bad login attempt. This could mean anything. Perhaps your password is wrong. Perhaps your username is wrong. Perhaps the website is sniffing the user-agent and refusing to allow Python to connect. Try setting the user-

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Alex Hall, 28.01.2011 14:25: >> On 1/28/11, Stefan Behnel wrote: >>> Alex Hall, 28.01.2011 14:09: On 1/28/11, Stefan Behnel wrote: > Alex Hall, 27.01.2011 23:23: >> self.id=root.find("id").text >> self.name=root.find("name).text > > T

[Tutor] getting binary file from website with custom header

2011-01-28 Thread Alex Hall
Hello, I am continuing to work on that api wrapper... I never realized how little I know about urllib/urllib2! The idea of downloading from the api is pretty easy: give it a url and a password and it gives you the book. Here is a quote from the api documentation: In addition the MD5 hash of the end

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
Thanks Ian! This is a simple one! I found this other way said more flexible, I must check it too: *import urllib class myURLOpener(urllib.FancyURLopener): def setpasswd(self, user, passwd): self.__user = user self.__passwd = passwd def prompt_user_passwd(self, host, r

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
Vince I saw your answer on the related subject fron October 2010 : *Re: [Tutor] Requesting restricted URL (further authentication requested)*. Thanks Karim On 01/28/2011 11:05 PM, Vince Spicer wrote: You may want to look at httplib2 http://code.google.com/p/httplib2/ This great module make

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread ian douglas
If it's HTTP basic_auth, you could try this method too: http://username:passw...@domain.com/page.html On 01/28/2011 01:54 PM, Karim wrote: Hello, I want to create a client to access a webpage. But when I access it interactively there is a dialog box which ask for login and password. I wan

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Vince Spicer
You may want to look at httplib2 http://code.google.com/p/httplib2/ This great module makes auth very simple Vince On Fri, Jan 28, 2011 at 3:54 PM, Karim wrote: > > Hello, > > I want to create a client to access a webpage. But when I access it > interactively there is a dialog box > which as

[Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
Hello, I want to create a client to access a webpage. But when I access it interactively there is a dialog box which ask for login and password. I want to access it in batch via python but I could only found a basic example: ||#||!/bin/env|| ||python| |#|| ||-*-|| ||coding:|| ||utf-8||

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/28/2011 08:02 AM, Alex Hall wrote: >> On 1/28/11, Dave Angel wrote: >>> On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread bob gailer
On 1/28/2011 10:22 AM, Nevins Duret wrote: Hello Python collective, I am trying to wrap my head around what exactly is causing me not to get any output or error message in the following code: There are so many problems with this program it is hard to know where to begin. Have you suc

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Nevins Duret wrote: Hello Python collective, I am trying to wrap my head around what exactly is causing me not to get any output or error message in the following code: #!/usr/bin/env python3.1 import random def main(): def chosen_letter(): chosen_letter = Conson

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/28/2011 08:02 AM, Alex Hall wrote: On 1/28/11, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I fi

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread Elwin Estle
I don't consider myself qualified to answer your question...but just in looking at your program and the description of what it is supposed to do, I'm a bit confused. So let me get this straight...the user is supposed to choose a letter, and the program is supposed to tell them if it is a vowel

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread Peter Otten
Nevins Duret wrote: > Hello Python collective, > > I am trying to wrap my head around what exactly is causing me > not to get any output or error message in the following code: > >> #!/usr/bin/env python3.1 >> >> import random >> >> def main(): >> >> def chosen_letter(): >> >>

[Tutor] Wrapping my head around global variables!!

2011-01-28 Thread Nevins Duret
Hello Python collective, I am trying to wrap my head around what exactly is causing me not to get any output or error message in the following code: #!/usr/bin/env python3.1 import random def main(): def chosen_letter(): chosen_letter = Consonant() chosen_lette

Re: [Tutor] What does ^ and | mean?

2011-01-28 Thread tee chwee liong
thanks for showing the path.. :) From: waynejwer...@gmail.com Date: Fri, 28 Jan 2011 09:17:36 -0600 Subject: Re: [Tutor] What does ^ and | mean? To: tc...@hotmail.com CC: tutor@python.org On Fri, Jan 28, 2011 at 9:09 AM, tee chwee liong wrote: hi, i'm confuse on how does ^ and | mean.

Re: [Tutor] What does ^ and | mean?

2011-01-28 Thread Wayne Werner
On Fri, Jan 28, 2011 at 9:09 AM, tee chwee liong wrote: > hi, > > i'm confuse on how does ^ and | mean. When i tried |, i thought it is > addition but 4|4 also give 4? > They're called bitwise operators: http://wiki.python.org/moin/BitwiseOperators + is the addition operator: 4 + 2 == 6 4 + 4

Re: [Tutor] What does ^ and | mean?

2011-01-28 Thread Alex Hall
Not sure about caret (^), but I believe | is binary or. 4|2 is 100 | 010 = 110, and 110 in decimal is 6. 4|4= 100|100 is 100 or 4. The caret might be binary and, but I am not sure. On 1/28/11, tee chwee liong wrote: > > hi, > > i'm confuse on how does ^ and | mean. When i tried |, i thought it i

[Tutor] What does ^ and | mean?

2011-01-28 Thread tee chwee liong
hi, i'm confuse on how does ^ and | mean. When i tried |, i thought it is addition but 4|4 also give 4? >>> 4|2 6 >>> 4|1 5 >>> 4|3 7 >>> 4|4 4 When i tried ^, looks like subtraction but 2^4 gives 6? >>> 2^3 1 >>> 2^2 0 >>> 2^4 6 Pls help to clear my confusion. thanks.

Re: [Tutor] Project Idea

2011-01-28 Thread Wayne Werner
On Thu, Jan 27, 2011 at 8:03 PM, Ben Ganzfried wrote: > Hey guys, > > Would it be feasible for a beginner to write a script that could connect > with: > https://chrome.google.com/extensions/detail/laankejkbhbdhmipfmgcngdelahlfoji > ? More specifically, I am interested in writing a script such tha

Re: [Tutor] Is it possible to make a circle of 1 hour

2011-01-28 Thread bob gailer
In future please start a new thread instead of hijacking an existing one. We track things by thread, and I almost missed your question! -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscrip

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Stefan Behnel
Alex Hall, 28.01.2011 14:25: On 1/28/11, Stefan Behnel wrote: Alex Hall, 28.01.2011 14:09: On 1/28/11, Stefan Behnel wrote: Alex Hall, 27.01.2011 23:23: self.id=root.find("id").text self.name=root.find("name).text There's a findtext() method on Elements for this purpose. I thought tha

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Alex Hall, 28.01.2011 14:09: >> On 1/28/11, Stefan Behnel wrote: >>> Alex Hall, 27.01.2011 23:23: self.id=root.find("id").text self.name=root.find("name).text >>> >>> There's a findtext() method on Elements for this purpose. >>> >> I thought that was

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Stefan Behnel
Alex Hall, 28.01.2011 14:09: On 1/28/11, Stefan Behnel wrote: Alex Hall, 27.01.2011 23:23: self.id=root.find("id").text self.name=root.find("name).text There's a findtext() method on Elements for this purpose. I thought that was used to search for the text of an element? I want to get th

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Hi, > > since you said that you have it working already, here are just a few > comments on your code. > > Alex Hall, 27.01.2011 23:23: >> all=root.findall("list/result") >> for i in all: >> self.mylist.append(Obj().parse(i)) > > It's uncommon to use "i" for any

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Alex Hall wrote: >> >> I tried both of those and got a different error. I have since fixed it >> so I no longer have the exact text, but it was something about not >> supporting convertion from unicode. I finally ended up doing this: >> s

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I finally ended up doing this: self.title�ta.find("title").text.encode("utf-8"

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Peter Otten
Alex Hall wrote: > Hello again: > I have never seen this message before. I am pulling xml from a site's > api and printing it, testing the wrapper I am writing for the api. I > have never seen this error until just now, in the twelfth result of my > search: > UnicodeEncodeError: 'ASCII' codec can'

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'A

[Tutor] Project Idea

2011-01-28 Thread Ben Ganzfried
Hey guys, Would it be feasible for a beginner to write a script that could connect with: https://chrome.google.com/extensions/detail/laankejkbhbdhmipfmgcngdelahlfoji ? More specifically, I am interested in writing a script such that the user would have to enter a short password (say 6 random lett