Re: [Tutor] List comprehensions

2008-04-10 Thread Alan Gauld
Dinesh B Vadhia [EMAIL PROTECTED] wrote i I'm using a Javascript autocomplete plugin for an online web application/service. Each time a user inputs a character, the character is sent to the backend Python program which searches for the character in a list of 10,000 string items. Eeek!

Re: [Tutor] Doubts about Pylint

2008-04-10 Thread Alan Gauld
Dick Moores [EMAIL PROTECTED] wrote A = 8 az = A It may well be happy since A is a constant and the variable is being assigned the constant rather than the literal. Thanks, Alan, but I tried your A = 8 az = A and got the same complaint about az. OK, In that case its probably the fact

Re: [Tutor] List comprehensions

2008-04-10 Thread linuxian iandsd
also if you need to go for 2 results I propose you use filters interactive menus which will help you tailor the query to the users desires thus limit the query results. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Copy script

2008-04-10 Thread linuxian iandsd
could you do a : dir /b inside this directory just so that we can know the real file names. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List comprehensions

2008-04-10 Thread linuxian iandsd
i think you are using ajax ... which undoubdetly uses an sql database since its based on queries run from whithin the application in the browser whithout the need for refreshing the page ... i would suggest you try serching internet for something like google autocomplete feature i guess the

Re: [Tutor] List comprehensions

2008-04-10 Thread W W
My guess, though I'm not sure, is that google uses hashes... why? Because they're a *ahem* load faster than loops, and the reason is they replace the repetitive nature of a loop by using some type of formula. Exactly /how/ this is implemented, I'm not sure. A simple example of the speed

Re: [Tutor] List comprehensions

2008-04-10 Thread Kent Johnson
Dinesh B Vadhia wrote: Kent I'm using a Javascript autocomplete plugin for an online web application/service. Each time a user inputs a character, the character is sent to the backend Python program which searches for the character in a list of 10,000 string items. Once it finds the

Re: [Tutor] List comprehensions

2008-04-10 Thread Alan Gauld
Kent Johnson [EMAIL PROTECTED] wrote application/service. Each time a user inputs a character, the character is sent to the backend Python program which searches for the character in a list of 10,000 string items. Once it finds the character, the backend will return that string and N

Re: [Tutor] List comprehensions

2008-04-10 Thread Kent Johnson
Alan Gauld wrote: One possibility is that the javascript fetches the list back on the first few characters and caches it on the browser Here is an autocomplete widget I use that can do exactly that: http://www.dyve.net/jquery/?autocomplete Kent ___

Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Dinesh B Vadhia
The 10,000 string items are sorted. The way the autocomplete works is that when a user enters a char eg. 'f', the 'f' is sent to the server and returns strings with the char 'f'. You can limit the number of items sent back to the browser (say, limit to between 15 and 100). The string items

Re: [Tutor] List comprehensions

2008-04-10 Thread bob gailer
Dinesh B Vadhia wrote: Kent I'm using a Javascript autocomplete plugin for an online web application/service. Each time a user inputs a character, the character is sent to the backend Python program which searches for the character in a list of 10,000 string items. Once it finds the

Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Kent Johnson
Dinesh B Vadhia wrote: The 10,000 string items are sorted. The way the autocomplete works is that when a user enters a char eg. 'f', the 'f' is sent to the server and returns strings with the char 'f'. If it is all strings containing 'f' (not all strings starting with 'f') then the

Re: [Tutor] Copy script

2008-04-10 Thread Tony Cappellini
Message: 7 Date: Thu, 10 Apr 2008 01:46:49 +0100 From: Alan Gauld [EMAIL PROTECTED] Subject: Re: [Tutor] Copy script To: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original I don;t see how the input file relates to

[Tutor] Text editing

2008-04-10 Thread Michael Schultz
Hello everyone. I'm looking to build a cross-platform writer's assistant, and I figured my first step would be to re-invent the wheel, er I mean built a simple rich-text editor as a base. I'm trying to figure out the simplest way to do so, and figured I'd ask if anyone knew some good resources

Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Dinesh B Vadhia
Ignore the 'adjacent items' remark. The rest is correct ie. looking for all strings containing a substring x. - Original Message - From: Kent Johnson To: Dinesh B Vadhia Cc: tutor@python.org Sent: Thursday, April 10, 2008 6:32 AM Subject: Re: [Tutor] Searching through large number

Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Greg Graham
One idea has to do with the fact that there are only 26 (assuming Latin alphabet) possible first letters, so I would try splitting up the list of 10,000 into 26 lists in a dictionary indexed by the first letter. Just doing that is a big reduction of your search space. That way you won't be doing

Re: [Tutor] Text editing

2008-04-10 Thread Kent Johnson
Michael Schultz wrote: Hello everyone. I'm looking to build a cross-platform writer's assistant, and I figured my first step would be to re-invent the wheel, er I mean built a simple rich-text editor as a base. I'm trying to figure out the simplest way to do so, and figured I'd ask if

Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Kent Johnson
Dinesh B Vadhia wrote: Ignore the 'adjacent items' remark. The rest is correct ie. looking for all strings containing a substring x. Perhaps this would help: http://hkn.eecs.berkeley.edu/~dyoo/python/suffix_trees/ A SubstringDict that maps each string to itself would do exactly what you

[Tutor] queries from the web random number

2008-04-10 Thread linuxian iandsd
I have been used to making queries to websites automatically analizing the results. a few minutes ago ... i can no longer do that now a website is protected by a ramdom number that i have to enter before i can login. its a picture with numbers on it that i have to type in in the authentication

Re: [Tutor] Copy script

2008-04-10 Thread Alan Gauld
Tony Cappellini [EMAIL PROTECTED] wrote I don;t see how the input file relates to the pdf files? Which part of the pdf file does the input numbers refer to? Kent, I believe the text file contains the name Actually that was me :-) The problem with the Windows console commands is I don't

Re: [Tutor] Text editing

2008-04-10 Thread Alan Gauld
Michael Schultz [EMAIL PROTECTED] wrote Hello everyone. I'm looking to build a cross-platform writer's assistant, and I figured my first step would be to re-invent the wheel, er I mean built a simple rich-text editor as a base. I'm trying to figure out the simplest way to do so, and

Re: [Tutor] queries from the web random number

2008-04-10 Thread Alan Gauld
linuxian iandsd [EMAIL PROTECTED] wrote now a website is protected by a ramdom number that i have to enter before i can login.its a picture with numbers on it that i have to type in in the authentication form before login in. This is added to web sites to specifically stop people screen

Re: [Tutor] queries from the web random number

2008-04-10 Thread Marc Tompkins
On Thu, Apr 10, 2008 at 9:14 AM, linuxian iandsd [EMAIL PROTECTED] wrote: I have been used to making queries to websites automatically analizing the results. a few minutes ago ... i can no longer do that now a website is protected by a ramdom number that i have to enter before i can login.

[Tutor] Graphs in Python

2008-04-10 Thread Sanhita Mallick
Hi. I am a newbie to Python. I am trying to implement a Python code for graph manipulation. My graphs are about 200-500 nodes big. Excepting for the short basic graph implementation info on Python.org, where can I find more in depth info about how to express graphs in python, and how to use them

Re: [Tutor] Graphs in Python

2008-04-10 Thread Kent Johnson
Sanhita Mallick wrote: Hi. I am a newbie to Python. I am trying to implement a Python code for graph manipulation. My graphs are about 200-500 nodes big. Excepting for the short basic graph implementation info on Python.org, where can I find more in depth info about how to express graphs

Re: [Tutor] Copy script

2008-04-10 Thread Tony Cappellini
Of course they do - they can use input redirection just like Unix. Oh,-I have forgotten about that. But why use clunky batch language when you can use Python? After all, he did post this to the python list. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] queries from the web random number

2008-04-10 Thread linuxian iandsd
i was wondering if there was there any means of sending this number to the script thru the web. I mean have the script run from cron i can remotely access the image read the code enter the code in a form to be submitted to my script or another script i don't mind as long as it gets to final

[Tutor] Python, CGI and CSS

2008-04-10 Thread Alex Krycek
Hi, I've looked all over the internet but have not found an answer to my question. How do I apply an external stylesheet to the XHTML in a Python script? I tried to include the standard link rel='stylesheet' type='text/css' href='style1.css' / in with the rest of the printed XHTML. But that

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Steve Willoughby
On Thu, Apr 10, 2008 at 02:22:47PM -0600, Alex Krycek wrote: Hi, I've looked all over the internet but have not found an answer to my question. How do I apply an external stylesheet to the XHTML in a Python script? I tried to include the standard link rel='stylesheet' type='text/css'

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Eric Walstad
Hi Alex, On Thu, Apr 10, 2008 at 1:22 PM, Alex Krycek [EMAIL PROTECTED] wrote: Hi, I've looked all over the internet but have not found an answer to my question. How do I apply an external stylesheet to the XHTML in a Python script? I tried to include the standard link rel='stylesheet'

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Alex Krycek
Eric, I'm sorry, I never actually managed to get any stylesheets to work with my cgi scripts. The scripts that did work are just simple HTML. I'm using Apache 2.2.8 on a Mac OS X 10.4.11 system. When I get home I'll definitely look up the log file and paste it here. I'll also have to fool around

[Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Robert Kirkpatrick
Hi All, Just wondering if there are any basic conventions for including code snippets that are for testing / debugging only? For example, you could set a boolean variable called DEBUG, then have snippets of code like: if DEBUG: do stuff else: do otherstuff The use case I'm dealing with

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Eric Walstad
Hey Alex, On Thu, Apr 10, 2008 at 1:43 PM, Alex Krycek [EMAIL PROTECTED] wrote: Eric, I'm sorry, I never actually managed to get any stylesheets to work with my cgi scripts. The scripts that did work are just simple HTML. I'm using Apache 2.2.8 on a Mac OS X 10.4.11 system. If I understand

Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Eric Walstad
Hi Robert On Thu, Apr 10, 2008 at 1:34 PM, Robert Kirkpatrick [EMAIL PROTECTED] wrote: Hi All, Just wondering if there are any basic conventions for including code snippets that are for testing / debugging only? For example, you could set a boolean variable called DEBUG, then have

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Kent Johnson
Alex Krycek wrote: Eric, I'm sorry, I never actually managed to get any stylesheets to work with my cgi scripts. The scripts that did work are just simple HTML. Where are the css files that work located? What URL is used to fetch them? If you put the css for your cgi into the same

Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Kent Johnson
Robert Kirkpatrick wrote: Hi All, Just wondering if there are any basic conventions for including code snippets that are for testing / debugging only? For example, you could set a boolean variable called DEBUG, That is pretty common, with a boolean or an integer (for levels of debug

Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Kent Johnson
Eric Walstad wrote: I'd do something like this: from settings import DEBUG def my_user_list() # assumes long_list is already populated (db, file, etc) if DEBUG: return long_list[:5] else: return long_list def process(user): # do the work on the user

[Tutor] SQLite LIKE question

2008-04-10 Thread Dinesh B Vadhia
I'm reading a text file into an in-memory pysqlite table. When I do a SELECT on the table, I get a 'u' in front of each returned row eg. (u'QB VII',) (u'Quackser Fortune Has a Cousin in the Bronx',) I've checked the data being INSERT'ed into the table and it has no 'u'. The second problem

Re: [Tutor] python access of usb for winxp

2008-04-10 Thread Alan Gauld
govind goyal [EMAIL PROTECTED] wrote I want to retreive data to and fro USB device attached/connected to my WinXP PC. It depends what kind of device it is. If it is a drive or flash card you can use the normal file access functions. If it is a printer or scanner then the usual APIs for

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Alan Gauld
Alex Krycek [EMAIL PROTECTED] wrote How do I apply an external stylesheet to the XHTML in a Python script? Python doesn't really do anything with CSS that is handled by the browser. All Python can do is insert the correct HTML into the server response to the browser. I tried to include the

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Alan Gauld
Alex Krycek [EMAIL PROTECTED] wrote I did look into CGI tutorials, but they didn't use Python code. They used something like: start_html(-title = $title, -head = style({type = 'text/css'} ) That looks like Perl. Try the CGI tutorial on the Python web site. That would be a good start.

Re: [Tutor] SQLite LIKE question

2008-04-10 Thread Alan Gauld
Dinesh B Vadhia [EMAIL PROTECTED] wrote I'm reading a text file into an in-memory pysqlite table. When I do a SELECT on the table, I get a 'u' in front of each returned row eg. (u'QB VII',) The u is not part of the data its Python telling you that the string is Unicode. The second

Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Alan Gauld
Robert Kirkpatrick [EMAIL PROTECTED] wrote The use case I'm dealing with right now is to query the SVN commits for a weekly period and report on each user for that time period. If I'm testing though, I only want to cycle through a few users, not all of them. You could pass the values in

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Curtis Adkins
It seems that your link to the stylesheet is just pointing to the wrong place. Like the others said, check to make sure you are pointing to the right place of the CSS file by typing it into the web browser. If you use the link you gave : http://localhost/cgi-bin/style1.css; what shows up?

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Alex Krycek
Thank you all for your help. I've finally figured it out. I took people's suggestions and typed in the path for the CSS file into my browser. Well, I received an internal service error. When I checked the error log, I had received the following: [Thu Apr 10 20:38:47 2008] [error] [client ::1]