Re: [Tutor] using the loop function while another

2012-10-10 Thread Alan Gauld
On 10/10/12 02:14, eryksun wrote: another=input('Do you have another book to order for this student?', '\nEnter y for yes: ') Remove the comma, and this will parse correctly. Oops, yes good catch, don't know where that came from. another=input(''' Do you have

[Tutor] ctypes question

2012-10-10 Thread Albert-Jan Roskam
Hi,   I have a program that reads and writes files using ctypes. When I want it to read AND write (e.g. read a file, select some stuff and write that), the library returns a 'read-open' error. I think that the pointer to the file handle for read and write point to the same address. To test that

Re: [Tutor] ctypes question

2012-10-10 Thread Peter Otten
Albert-Jan Roskam wrote: > I have a program that reads and writes files using ctypes. When I want it > to read AND write (e.g. read a file, select some stuff and write that), > the library returns a 'read-open' error. I think that the pointer to the > file handle for read and write point to the sa

Re: [Tutor] ctypes question

2012-10-10 Thread Alan Gauld
On 10/10/12 11:02, Albert-Jan Roskam wrote: I have a program that reads and writes files using ctypes. Any particular reason why? That's not normally something I'd expect you to need ctypes for. Unless you just want to play with ctypes... When I want it to read AND write (e.g. read a file,

Re: [Tutor] ctypes question

2012-10-10 Thread eryksun
On Wed, Oct 10, 2012 at 6:02 AM, Albert-Jan Roskam wrote: > > elif pf.startswith("lin"): > libc = ctypes.CDLL("libc.so.6") > fopen = libc.fdopen > fh = fopen(ctypes.c_char_p(fn), "rb") > fhPtr = ctypes.byref(ctypes.c_int(fh)) > buff = ctypes.create_string_buffer(lines) > ret = libc.fread(

Re: [Tutor] ctypes question

2012-10-10 Thread Albert-Jan Roskam
- Original Message - > From: eryksun > To: Albert-Jan Roskam > Cc: Python Mailing List > Sent: Wednesday, October 10, 2012 1:40 PM > Subject: Re: [Tutor] ctypes question > > On Wed, Oct 10, 2012 at 6:02 AM, Albert-Jan Roskam > wrote: >> >> elif pf.startswith("lin"): >>     libc = cty

[Tutor] iterating over a changing list

2012-10-10 Thread Ed Owens
I'm trying to iterate over a list of elements, and make changes to the list in front of the element I'm currently working with. I can update the list, but the 'for' doesn't see the new element. Here's the code: import string def add_element(items, point): items = items[:point+1][:] + [['n

[Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread Benjamin Fishbein
I've been scraping info from a website with a url program I wrote. But now I can't open their webpage, no matter which web browser I use. I think they've somehow blocked me. How can I get back in? Is it a temporary block? And can I get in with the same computer from a different wifi? __

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread James Reynolds
On Wed, Oct 10, 2012 at 4:35 PM, Benjamin Fishbein wrote: > I've been scraping info from a website with a url program I wrote. But now > I can't open their webpage, no matter which web browser I use. I think > they've somehow blocked me. How can I get back in? Is it a temporary block? > And can I

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread c smith
how could someone know enough to write their own web-scraping program and NOT know that this is not about python or how to get around this problem? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.o

Re: [Tutor] iterating over a changing list

2012-10-10 Thread Mark Lawrence
On 10/10/2012 20:52, Ed Owens wrote: I'm trying to iterate over a list of elements, and make changes to the list in front of the element I'm currently working with. I can update the list, but the 'for' doesn't see the new element. Here's the code: import string def add_element(items, point)

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread Mark Lawrence
On 10/10/2012 21:35, Benjamin Fishbein wrote: I've been scraping info from a website with a url program I wrote. But now I can't open their webpage, no matter which web browser I use. I think they've somehow blocked me. How can I get back in? Is it a temporary block? And can I get in with the

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread Walter Prins
Hi On 10 October 2012 21:35, Benjamin Fishbein wrote: > I've been scraping info from a website with a url program I wrote. But now I > can't open their webpage, no matter which web browser I use. I think they've > somehow blocked me. How can I get back in? Is it a temporary block? And can I >

Re: [Tutor] iterating over a changing list

2012-10-10 Thread Dave Angel
On 10/10/2012 03:52 PM, Ed Owens wrote: > I'm trying to iterate over a list of elements, and make changes to the list > in front of the element I'm currently working with. I can update the list, > but the 'for' doesn't see the new element. Here's the code: > > import string > > def add_element(

Re: [Tutor] iterating over a changing list

2012-10-10 Thread eryksun
On Wed, Oct 10, 2012 at 3:52 PM, Ed Owens wrote: > > import string Why are you importing "string"? Most string functions one would need are methods of str/unicode. Sometimes "string" is still required, however. > def add_element(items, point): > items = items[:point+1][:] + [['new']] + items

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread Steven D'Aprano
On 11/10/12 07:35, Benjamin Fishbein wrote: I've been scraping info from a website with a url program I wrote. But now I can't open their webpage, no matter which web browser I use. I think they've somehow blocked me. How can I get back in? Is it a temporary block? How the hell would we know??

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-10 Thread boB Stepp
On Tue, Oct 9, 2012 at 4:29 AM, eryksun wrote: > Python 3 lets you use any Unicode letter as an identifier, including > letter modifiers ("Lm") and number letters ("Nl"). For example: > > >>> aꘌꘌb = True > >>> aꘌꘌb > True > > >>> Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ = range(1, 6) > >>> Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-10 Thread Steven D'Aprano
On 11/10/12 12:23, boB Stepp wrote: On Tue, Oct 9, 2012 at 4:29 AM, eryksun wrote: Python 3 lets you use any Unicode letter as an identifier, including letter modifiers ("Lm") and number letters ("Nl"). For example: >>> aꘌꘌb = True >>> aꘌꘌb True >>> Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ = ran

Re: [Tutor] iterating over a changing list

2012-10-10 Thread Steven D'Aprano
On 11/10/12 08:49, eryksun wrote: Also, generally avoid mutating a list while iterating over it. listiterator is just incrementing an index, so modifying the size of the list can produce nonsense (e.g. if you remove the current item, the next item will be skipped). Instead, create an empty list