Can local function access local variables in main program?

2007-11-03 Thread Sullivan WxPyQtKinter
I am confused by the following program: def f(): print x x=12345 f() result is: 12345 however: def f(): print x x=0 x=12345 f() result is: Traceback (most recent call last): File ...\test.py, line 5, in ? f() File ...\test.py, line 2, in f print x UnboundLocalError:

Re: Can local function access local variables in main program?

2007-11-03 Thread Sullivan WxPyQtKinter
Actually I am quite satisfied with and error, which is my expectation. But the implicit global variable access seems quite uncomfortable to me. Why is that necessary? On Nov 3, 3:39 am, Stargaming [EMAIL PROTECTED] wrote: On Sat, 03 Nov 2007 07:18:17 +, Sullivan WxPyQtKinter wrote: I am

Seek the one billionth line in a file containing 3 billion lines.

2007-08-08 Thread Sullivan WxPyQtKinter
I have a huge log file which contains 3,453,299,000 lines with different lengths. It is not possible to calculate the absolute position of the beginning of the one billionth line. Are there efficient way to seek to the beginning of that line in python? This program: for i in range(10):

Re: Seek the one billionth line in a file containing 3 billion lines.

2007-08-08 Thread Sullivan WxPyQtKinter
On Aug 8, 2:35 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Sullivan WxPyQtKinter [EMAIL PROTECTED] writes: This program: for i in range(10): f.readline() is absolutely every slow There are two problems: 1) range(10) builds a list of a billion elements

Python CGI problem: correct result, but incorrect browser response.

2006-04-06 Thread Sullivan WxPyQtKinter
title:Python CGI problem: correct result, but incorrect browser response. In one of my CGI program,named 'login.py', the script return a HEADER to web browser: Set-Cookie: sessionID=LAABUQLUCZIQJTZDWTFE; Set-Cookie: username=testuser; Status:302 Location:edit.py (blank line) but the IE prompted

debug CGI with complex forms

2006-04-06 Thread Sullivan WxPyQtKinter
When the form in one HTML is very complex with a lot of fields(input, button,radio,checkbox etc.), setting the environment is quite burdernsome, so I usually change the stdout and stderr of the submit processing script to a file object to see the output directly from that file. This just can do,

Does anyone know where is the Berkeley XML Database documentation for its Python API?

2006-04-04 Thread Sullivan WxPyQtKinter
I have been looking for python API documentation of BDBXML for quite a few days but I could not find it. Anyone has any idea where it is? Or if there is not such a thing at all, how could I get started? In addition, in the previous posts I have seen some grumble about python API's lack of

Re: DOM and HTML

2006-04-02 Thread Sullivan WxPyQtKinter
I do not know much about the HTML DOMBut I think if you just mean treating HTML like XML and build it into a DOM tree and (Very important) the HTML file is not a 1 lines or even longer one, then go ahead to xml.dom.minidom module for help. It has a basic (and great) implementation for

Berkeley DB XML vs 4suite for fast searching in XML DB?

2006-04-01 Thread Sullivan WxPyQtKinter
Storing XML in relational database with indexing feature is exactly what I need. But 4suite is mentioned from time to time and seemingly holding better support for python. I have no idea if 4 suite has provide strong support for random access or relatively random access for XML database and with

How to search HUGE XML with DOM?

2006-03-31 Thread Sullivan WxPyQtKinter
a relation database has admiring search efficiency when the database is very big (several thousands or tens of thousands of records). But my current project is based on XML, for its tree-like data structure has much more flexibility; and DOM, which could be manipulated just like a tree. However,

Re: How to search HUGE XML with DOM?

2006-03-31 Thread Sullivan WxPyQtKinter
Perhaps what you have said is correct. But XML is more direct for programmers and readers in my view point. bayerj 写道: Mind, that XML documents are not more flexible than RDBMS. You can represent any XML document in a RDBMS. You cannot represent any RDBMS in an XML document. RDBMS are

Very stupid question.

2006-03-30 Thread Sullivan WxPyQtKinter
How to get the length of a file via build-in file object support? In Visual Basic there is len(file) of something like that. But in python, where is this property? Sorry for this stupid question, if it is. Thank you for help. -- http://mail.python.org/mailman/listinfo/python-list

Re: Very stupid question.

2006-03-30 Thread Sullivan WxPyQtKinter
In addition, f=file('filename','r');len(f.read()) is quite expensive in my point of view, If the file is serveral MB or larger. -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI redirection: let us discuss it further

2006-03-29 Thread Sullivan WxPyQtKinter
Well, in that case, the internal direction is just what I need. Thank you so much for help. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do clients(web browser) close a python CGI program that is not responding?

2006-03-28 Thread Sullivan WxPyQtKinter
Actually my project is converting certain specially costomized XML file to HTML to display and edit. Sometimes the XML file is too big, or the client upload a very huge file for the server to process, which exceeds the processing ability of my server.(after all, it is a small server on my poor

Re: How to inplement Session in CGI

2006-03-28 Thread Sullivan WxPyQtKinter
bruno at modulix 写道: Sullivan WxPyQtKinter wrote: Python disappointly failed to provide a convinient cgi session management module. Probably because there are much better options for web programming in Python ? Really? Then what is it? -- http://mail.python.org/mailman/listinfo

No Cookie: how to implement session?

2006-03-28 Thread Sullivan WxPyQtKinter
I do not want to use Cookies in my site since not all web browser support it well and sometimes people close cookie functioning for security reasons. I tried to add hidden field with a sessionID in every python CGI script generated web pages, so everytime my client POST a request, the server

Re: CGI redirection: let us discuss it further

2006-03-28 Thread Sullivan WxPyQtKinter
Just read the name of the server (os.environ['SERVER_NAME']) to work out what absolute URL to redirect to, whist still being portable. Here's some code I dug up that should also cope with non-default ports and SSL, if that's of any use: ssl= os.environ.get('HTTPS', 'off') not in ('',

Re: No Cookie: how to implement session?

2006-03-28 Thread Sullivan WxPyQtKinter
As you said, There is no solution? I mean, tracing a real session without using tricks like hidden field and cookies in CGI script? Dennis Lee Bieber 写道: On 28 Mar 2006 09:40:24 -0800, Sullivan WxPyQtKinter [EMAIL PROTECTED] declaimed the following in comp.lang.python: I do not want

CGI redirection: let us discuss it further

2006-03-27 Thread Sullivan WxPyQtKinter
I am now programming python scripts for CGI environment. The redirection has been discussed in this forum for over one hundred times. I have seen most of them, but still have some questions: 1. Are there any method (in python of course) to redirect to a web page without causing a Back button

To my clients force to terminate a python CGI program?

2006-03-27 Thread Sullivan WxPyQtKinter
Hi,there. Sometimes a python CGI script tries to output great quantities of HTML responce or in other cases, it just falls into a dead loop. How could my client close that CGI script running on the server? I tried to use the STOP button in the web browser button, but it does not work. In

How do clients(web browser) close a python CGI program that is not responding?

2006-03-27 Thread Sullivan WxPyQtKinter
Hi,there. Sometimes a python CGI script tries to output great quantities of HTML responce or in other cases, it just falls into a dead loop. How could my client close that CGI script running on the server? I tried to use the STOP button in the web browser button, but it does not work. In

How to inplement Session in CGI

2006-03-27 Thread Sullivan WxPyQtKinter
Python disappointly failed to provide a convinient cgi session management module. Not willing to use external modules, I would like to implement a simplest Session object on my own. The basic problem is: how could a python CGI program understand several requests are in the same session?

How to search XML? Are there special libs?

2006-03-16 Thread Sullivan WxPyQtKinter
I am now using XML to record my lab records in quite a complex way, in which about 80 tags are used to identify different types of data. I think it is a good idea to search for a popular and mature XML search engine before I started to program it myself: I need the following functions: Search

Is xml.dom.minidom.Element.cloneNode(deep=True) really fixed already?

2006-03-13 Thread Sullivan WxPyQtKinter
Hi, I am now using minidom for my current development. I use cloneNode method in Element object, but it just does not work. The test code is very simple as follows: =CODE== from xml.dom.minidom import * a=Element('see') print a.toprettyxml() b=a.cloneNode(True) print

Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I use python in Windows XP platform. I find that if I write a .py file in a directory, such as windows desktop, in which a file named 'ticket.txt' is located: f=open(\ticket.txt) print f.read() In IDLE, this py file work all right. But if I launch python interpretor in the command shell like

Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I use python on Windows XP platform. I find that if I write a .py file in a directory, such as windows desktop, in which a file named 'ticket.txt' is located: f=open(ticket.txt) print f.read() In IDLE, this py file work all right. But if I launch python interpretor in the command shell like

Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
Sorry, I mistyped the line. In the program it IS: f=open(ticket.txt), no '\' included. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I see. I once was a VB programmer. In VB, the current directory is always set to where the module locates before it runs. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I see. I once was a VB programmer. In VB, the current directory is always set to where the module locates before it runs. -- http://mail.python.org/mailman/listinfo/python-list

How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
When debugging using 'print' statement, I usually want to print some important values together with the function name as the context of the values printed out. So my hope is that I could get the name of the function. Since every function object actually has a private __name__ attribute that gives

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
I have Google the whole thing and find another way for alternative implementation of getting the function's name. But all they returns are just strings. If I would like to refer to the function object in order to call it recursively, what shall I do then? --

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
the name of a function. Kay Schluehr 写道: Sullivan WxPyQtKinter wrote: So how could I refer to the function object per se, in the body of the function itself? Just use the name. def f(): print f.__name__ f() f -- http://mail.python.org/mailman/listinfo/python-list

Python IDE: great headache....

2006-03-11 Thread Sullivan WxPyQtKinter
IDLE is no longer satisfactory for me. Other IDEs make me very confused. Really do not know which one to use. I use WinXP sp2 for current development. So far as I know, Eclipse + PyDev + PyDev Extension is perfect for source code editing. Since I am really not sure how to use the debugger

Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
Hi, everyone. Simply put, what I need most now is a python lib to generate simple HTML. I am now using XML to store my lab report records. I found python really convinient to manipulate XML, so I want to make a small on-line CGI program to help my colleagues to build their lab report records

Re: Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
Sorry I am completely a green-hand in HTML. What is HTMLTemplate and ElementTree? Would you please post some source code as an example? Of course I would Google them to find out more. Thank you so much. -- http://mail.python.org/mailman/listinfo/python-list

Re: Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
That lib can help. But still, I have to code a lot using that lib. Maybe my program is quite strange, far from common. Thank you, after all~! -- http://mail.python.org/mailman/listinfo/python-list

Confused by Method(function) of a module and method of a class/instance

2006-03-06 Thread Sullivan WxPyQtKinter
In python, these expression seems yields the same result: inputstring='ABC' print inputstring.lower() print lower(inputstring) print string.lower(inputstring) result: abc abc abc Question: Is the method lower() just a method for the inputstring instance( an instrance object of a string class

Re: Confused by Method(function) of a module and method of aclass/instance

2006-03-06 Thread Sullivan WxPyQtKinter
Yes, I checked out that I have already run from string import *. So the lower() means string.lower() function. However, something else came out just now: instr='a' instr.join('b') 'b' instr.lower() 'A' instr 'a' Both as the method of the type str, join never use the instr instance object as

It is fun.the result of str.lower(str())

2006-03-06 Thread Sullivan WxPyQtKinter
Guess what would be the result of these functions: str.lower('ASFA') str.join(str(),['1','1','1']) str.join('a','b') If you guess them correctly, please explain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a tiny script language using python: I need a string processing lib

2006-03-04 Thread Sullivan WxPyQtKinter
I have gone over the shlex and cmd and so, but none of them are satisfactory. However, I tried to program this this function on my own and found it pretty easy. Thank you so much for the suggestion, after all. -- http://mail.python.org/mailman/listinfo/python-list

Making a tiny script language using python: I need a string processing lib

2006-03-02 Thread Sullivan WxPyQtKinter
I do not know if there is any lib specially designed to process the strings in scipt language. for example: I hope to process the stringprint a,b,c,d,e in the formcommand argumentlist and return: {'command'='print', 'argumentlist'=['a','b','c','d','e']} Are there any lib to implement this?

Re: Any Tkinker based rich text widget?

2006-02-20 Thread Sullivan WxPyQtKinter
yes, I have tried Text Widget for quite some time. However, its speed is far from satisfying. When it holds more than 20,000 characters, it starts to response quite slow. When you drag your mouse over some text to select, the selection is usually done after 0.5second or so. My intent to use this

Re: Any Tkinker based rich text widget?

2006-02-20 Thread Sullivan WxPyQtKinter
Thank you so much for help. It is my honor to get a reply from a prestigious figure like you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Any Tkinker based rich text widget?

2006-02-18 Thread Sullivan WxPyQtKinter
In addiiton, I hope it directly support basic HTML grammar. [EMAIL PROTECTED] 写道: Hi all I am using the standard python GUI Tkinter as my program's main interface. Although I know wxPython has some widget to support rich text widget, but I do not have time to shift to wx series. Does