Re: Ordering Products
Ron Adam wrote: Kay Schluehr wrote: Here might be an interesting puzzle for people who like sorting algorithms ( and no I'm not a student anymore and the problem is not a students 'homework' but a particular question associated with a computer algebra system in Python I'm currently developing in my sparetime ). For motivation lets define some expression class first: This works for (simple) expressions with mixed multiplication and addition. class F(list): def __init__(self,*x): #print '\nF:',x list.__init__(self,x) def __add__(self, other): return A(self,other) def __radd__(self, other): return A(other,self) def __mul__(self, other): return M(self,other) def __rmul__(self, other): return M(other,self) def __repr__(self): return str(self[0]) def __order__(self): for i in self: if isinstance(i,A) \ or isinstance(i,M): i.__order__() self.sort() class A(F): def __init__(self, *x): #print '\nA:',x list.__init__(self, x) def __repr__(self): self.__order__() return +.join([str(x) for x in self]) class M(F): def __init__(self,*x): #print '\nM:',x list.__init__(self,x) def __repr__(self): self.__order__() return *.join([str(x) for x in self]) a = F('a') b = F('b') c = F('c') d = F('d') print '\n a =', a print '\n b+a+2 =', b+a+2 print '\n c*b+d*a+2 =', c*b+d*a+2 print '\n 7*a*8*9+b =', 7*a*8*9+b a = a b+a+2 = 2+a+b c*b+d*a+2 = 2+a*d+b*c 7*a*8*9+b = 9*8*7*a+b -- reverse sorted digits? The digits sort in reverse for some strange reason I haven't figured out yet, but they are grouped together. And expressions of the type a*(c+b) don't work in this example. It probably needs some better logic to merge adjacent like groups. I think the reverse sorting my be a side effect of the nesting that takes place when the expressions are built. Having the digits first might be an advantage as you can use a for loop to add or multiply them until you get to a not digit. Anyway, interesting stuff. ;-) Cheers, Ron Hi Ron, I really don't want to discourage you in doing your own CAS but the stuff I'm working on is already a bit more advanced than my mono-operational multiplicative algebra ;) Mixing operators is not really a problem, but one has to make initial decisions ( e.g about associativity i.e. flattening the parse-tree ) and sub-algebra generation by means of inheritance: a,b = seq(2,Expr) type(a+b) class '__main__.Expr' class X(Expr):pass x,y = seq(2,X) type(x+y) class '__main__.X' This is not particular hard. It is harder to determine correspondence rules between operations on different levels. On subalgebras the operations of the parent algebra are induced. But what happens if one mixes objects of different algebras that interoperate with each other? It would be wise to find a unified approach to make distinctive operations visually distinctive too. Infix operators may be re-introduced just for convenience ( e.g. if we can assume that all algebras supporting __mul__ that are relevant in some computation have certain properties e.g. being associative ). ## After thinking about M ( or Expr ;) a little more I come up with a solution of the problem of central elements of an algebra ( at least the identity element e is always central ) that commute with all other elements. Here is my approach: # Define a subclass of list, that provides the same interface as list and # a customized sorting algorithm import sets class Factors(list): def __init__(self,li): list.__init__(self,li) self.elems = sets.Set(li) # raw set of factors used in the __mul__ self._center = () # storing central elements commuting with # with all others def _get_center(self): return self._center def _set_center(self,center): Center = sets.Set(center) if not Center=self.elems: raise ValueError,Subset required else: self._center = Center center = property(_get_center, _set_center) def __add__(self,li): return Factors(list.__add__(self,li)) def sort(self): center = list(self.center) def commutator(x,y): if isinstance(x,(int,float,long)): # numeral literals should return -1 # always commute if isinstance(y,(int,float,long)): return 1 if x == y: return 0 if x in center: if y in center: if center.index(x)center.index(y): # induce an aritrary return -1
WG: creating new process with pipes under win xp -troubles
hello! I wrote a python parent script which starts a separate script in a new process (under Windows XP Pro SP2, Python 2.4.1). Through anonymous pipes I have a bidirectional communication to the child. Now I embedded the parent script in a CPP program, but when I start the cpp dummy application it seems as the application is producing copies of itself (like a recursive function - in the windows task manager the number of the same process is increasing) and the child process is not working! But when i start the parent script directly, it works well. Maybe you can tell me the reason why it does not work in CPP. Below you can find the the part of the code which is starting the client process. I hope you can help me. Thank you! Michael Lieschnegg I took following code from a closed forum to create the child process: class Process: def __init__(self, command, args, environment, path): # security attributes for pipes sAttrs = win32security.SECURITY_ATTRIBUTES() sAttrs.bInheritHandle = 1 # create pipes hStdin_r, self.hStdin_w = win32pipe.CreatePipe(sAttrs, 0) self.hStdout_r, hStdout_w = win32pipe.CreatePipe(sAttrs, 0) # set the info structure for the new process. StartupInfo = win32process.STARTUPINFO() StartupInfo.hStdInput = hStdin_r StartupInfo.hStdOutput = hStdout_w StartupInfo.dwFlags = win32process.STARTF_USESTDHANDLES # Create new output read handles and the input write handle. Set # the inheritance properties to FALSE. Otherwise, the child inherits # the these handles; resulting in non-closeable handles to the pipes # being created. pid = win32api.GetCurrentProcess() tmp = win32api.DuplicateHandle( pid, self.hStdin_w, pid, 0, 0, # non-inheritable!! win32con.DUPLICATE_SAME_ACCESS) # Close the inhertible version of the handle win32file.CloseHandle(self.hStdin_w) self.hStdin_w = tmp tmp = win32api.DuplicateHandle( pid, self.hStdout_r, pid, 0, 0, # non-inheritable! win32con.DUPLICATE_SAME_ACCESS) # Close the inhertible version of the handle win32file.CloseHandle(self.hStdout_r) self.hStdout_r = tmp # start the process. print creating process cmdline = %s %s % (command, string.join(args, ' ')) hProcess, hThread, dwPid, dwTid = win32process.CreateProcess( None, # program cmdline,# command line None, # process security attributes None, # thread attributes 1, # inherit handles, or USESTDHANDLES won't work. # creation flags. Don't access the console. 0, # Don't need anything here. # If you're in a GUI app, you should use # CREATE_NEW_CONSOLE here, or any subprocesses # might fall victim to the problem described in: # KB article: Q156755, cmd.exe requires # an NT console in order to perform redirection.. environment, # new environment path, # new directory StartupInfo) # Child is launched. Close the parents copy of those pipe handles # that only the child should have open. win32file.CloseHandle(hStdout_w) win32file.CloseHandle(hStdin_r) self.outQueue = Queue.Queue() self.closed = 0 self.stdoutClosed = 0 threading.Thread(target=self.doWrite).start() def write(self, data): self.outQueue.put(data) def closeStdin(self): self.outQueue.put(None) def connectionLost(self): if not self.closed: print connection lost self.closed = 1 self.closeStdin() win32file.CloseHandle(self.hStdout_r) def doWrite(self): while 1: data = ""> if data == None: break try: win32file.WriteFile(self.hStdin_w, data, None) except win32api.error: print error break win32file.CloseHandle(self.hStdin_w) def doReadOut(self): try: hr, data = "" 8192, None) except win32api.error: self.stdoutClosed = 1 return self.handleData(data) return repr(data) def handleData(self, data): print Got, repr(data) if __name__ == '__main__': exe = win32api.GetModuleFileName(0) print exe p = Process(exe, ['-u', 'dispatcher.py', ''], None, None) print ok, made process object while 1: p.write(hello, world! Who you are?\n) p.doReadOut() When I run this script directly, the client process (dispatcher.py) will be started correctly. But when I create a instance of the class Process in my cpp application, the client does not start and the cpp application is producing and starting copies of itself (it seems so). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Honestly, I'm just using Python's own IDLE to do it all. It works rather well for my tastes :) -- http://mail.python.org/mailman/listinfo/python-list
Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router? I have been getting very variable SNR readings - and I would like to collect some evidence to analyse. What is needed is a program that logs into the router's html page every minute, and then extracts the time and the SNR figure, and writes a line of a text file. I reckon it would be useful to many people. -- Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: on Microsoft hatred
John Bokma [EMAIL PROTECTED] wrote A typical Xah Lee posting... wake me up when he is able to write a single post that makes and sense, and doesn't contain fuck or similar words. Obscene language isn't acceptable on comp.lang.c. It is an international group, and what might be acceptable in America may be considered totally offensive, maybe even illegal, elsewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: retrieving https pages
It might be checking the browser's User-agent. My best bet for you would to be to use something to record the headers your browser sends out, and mimic those in Python. If you look at the source code for urlopener (I think you can press Alt+M and type in urlopener), under the FancyURLopener definition, you should see something like self.add_headers (not on a box to check it right now, but it's in the constructer, I remember that much). Just set all the headers to send out (like your browser would) by setting that value from your script. i.e.: import urlopener urlopener = FancyURLopener() urlopener.add_headers = [('User-agent','blah'),('Header2','val'),('monkey','bone')] # do the other stuff here :P HTH -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: main window in tkinter app
On Mon, 18 Jul 2005 16:57:51 GMT, William Gill [EMAIL PROTECTED] wrote: A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self, master): self.root = master self.master=master self.createWidgets() def createWidgets(): ... root = Tk() app = MyMain(root) app.master.title(Object Editor) root.mainloop() would become: class MyMain(Tk): ... ... app = MyMain() app.title(My App) app.mainloop() When I try converting to this approach I run into a problem with the __init__() method. It appears to go into an infinite loop in tkinter.__getattr__(). [...] I never ran into this problem. Can you please post a short script showing this behavior? Without knowing what you exactly do in your __init__ and createWidgets method, it's quite hard to figure out what happens... -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Out of Office AutoReply: Returned mail: Data format error
Title: Out of Office AutoReply: Returned mail: Data format error I am out-of-office, on a business trip, untill July 23, 2005, and may be able to read your e-mail only after this date. If you need to contact me urgently, please call the mobile phone number +1-917-957-0270. Regards, Dan -- http://mail.python.org/mailman/listinfo/python-list
re:c++ÈçºÎÏòpythonµÄœÅ±ŸŽ«µÝÒ»žöÀà×÷Ϊ²ÎÊý¡£
Hi, you should write in English, otherwise there is nobody understand your question. ` -- http://mail.python.org/mailman/listinfo/python-list
Re: Ordering Products
Diez B.Roggisch wrote: I have to admit that I don't understand what you mean with the 'constant parts' of an expression? From what I percieved of your example it seemed to me that you wanted to evaluate the constants like 7*9 first, so that an expression like a * 7 * 9 * b with variables a,b is evaluated like this: a * 63 * b So my suggestion was simply to make the *-operator more precedent when in between two constants. What I mean with constants here are of course integer/float literals. The concept of a differing operator precedence can be extended to arbitray elements when their types are known - which should be possible when variable values are known at parsing time. O.K. The associativity of __mul__ is trivially fullfilled for the dummy class M if an additional __eq__ method is defined by comparing factor lists because those lists are always flat: I don't care about that, as my approach deosn't use python's built-in parser - it can't, as that wouldn't allow to re-define operator precedence. Diez, I try not to care too much about global operator precedence of builtin infix operators. The hard problems in designing a CAS beyond Mathematica are related to a bunch of interoperating algebras all defining their own operations. Finally only local precedences exist that are characteristic for certain patterns of expressions with a lot of tangled operators ( e.g. 'geometric algebra' with vector products, wedge products, inner products, additions and subtractions ). I don't want a system defining a syntactically extendable language with 10 custom punctuations per module that no one ( at least not me ) can remind and which looks as awkward as regular expressions. What you do is to simply collect the factors as list. But what you need (IMHO) is a parsing tree (AST) that reflects your desired behaviour by introducing a different precedence thus that the expression a * 7 *9 * b is not evaluated like ((a*7)*9)*b (which is a tree, and the standard way of evaluationg due to built-in parsers precedence rules) but as a*(7*9)*b which is also a tree. Yes, but I tend to use __mul__ just for convenience. It is reflecting an associative and non-commutative operator whereas __add__ is a convenient way to fix an associative and commutative operator. In an idealized mathematical interpretation they represent nothing specific but as language elements they shall be fixed somehow. For more general operations one may define functional operators e.g. r_assoc and l_assoc where following (in)equations hold: l_assoc(a,b,c) == l_assoc(l_assoc(a,b),c) l_assoc(a,b,c) != l_assoc(a, l_assoc(b,c)) r_assoc(a,b,c) == r_assoc(a,r_assoc(b,c)) r_assoc(a,b,c) != r_assoc(r_assoc(a,b),c) This kind of pattern can be used to define rules about l_assoc and r_assoc. Nevertheless, there is no loss of generality. The system lacks prevention from deriving some class providing __mul__ and overwrite the implementation of __mul__ using l_assoc. People may do this on their own risk. Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
Hi Chris Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router? many people could, I'm sure, if not quite _anyone_ I have been getting very variable SNR readings - and I would like to collect some evidence to analyse. I see. What is needed is a program that logs into the router's html page every minute, and then extracts the time and the SNR figure, and writes a line of a text file. Good, you've got the 'top level' of what you need. How would you break that down into smaller steps? I reckon it would be useful to many people. great - thanks! Jon N -- http://mail.python.org/mailman/listinfo/python-list
How to write at a sppecific location
Hi All I have one csv file which has some data related to test results. It has following information TestId,Expectedres,Actualres 101,12,13 102,13 103,14 If I want to write ActualRes value in the file , How to do that. I tried using seek but its not working. I am not able to write at a specific location. Please tell me what is the rght way. I have chked all the docs but was not able to find any good solution. -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
I'm sure that nobody here is willing to write it for you. However, I believe that jkn was right in trying to get you to solve the problem. ;) You know what you need to do, but how are you going to do it? Create a flow chart ;) -- http://mail.python.org/mailman/listinfo/python-list
RE: How to write at a sppecific location
Hi Pooja, Check the fileinput module's input function. ~Vishnu -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pooja Sent: Tuesday, July 19, 2005 12:29 PM To: python-list@python.org Subject: How to write at a sppecific location Hi All I have one csv file which has some data related to test results. It has following information TestId,Expectedres,Actualres 101,12,13 102,13 103,14 If I want to write ActualRes value in the file , How to do that. I tried using seek but its not working. I am not able to write at a specific location. Please tell me what is the rght way. I have chked all the docs but was not able to find any good solution. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
rbt enlightened us with: Many of the world's most profitable software companies (MS for example) have thousands of goto statements in their code... oh the horror of it all. Why aren't these enlightened-by-the-gods know-it-alls as profitable as these obviously ignorant companies? They write software with huge security holes. Direct3D still isn't as stable as OpenGL. It takes ages for them to create security patches. The things I mention are *not* caused by their nice and clean way of coding. As a matter of fact, they use goto to jump from one function to another! And to make sure a 'return' doesn't return to the last call, but to some other, they combine this awful use of goto with manual stack manipulation. And they do all of this in C (or some derivative) so if one function changes it's parameters, all the manual stack modifications and gotos need to be checked for correctness. I'd rather use an exception, or better even - write small functions so I can call 'return' instead of doing 'goto EXIT'. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows command line problem
I'm using getopt. I doubt getopt recognises \x96 as a command line parameter prefix. I suppose I could iterate over sys.argv doing a replace but that seems messy. I'd rather understand the problem. That said, and me not understanding code pages that much, I chcp'd the machines it works on both coming back with 850, chcp'd the machine it wasn't working on which also came back with 850, but then again the machine where it wasn't working now works. So now it's an intermittent bug. Great. I'll try messing with code pages later and report back if I get anywhere. I need more coffee before I can do anything remotely clever. Damn you windows and your lack of a need for coffee -- http://mail.python.org/mailman/listinfo/python-list
BOUNCE [EMAIL PROTECTED]: Non-member submission from [EMAIL PROTECTED]
From [EMAIL PROTECTED] Tue Jul 19 04:14:47 2005 Received: from mtl-smtpgw2.global.avidww.com (mtl-smtpgw2.global.avidww.com [172.24.33.104]) by paperboy.global.avidww.com (8.12.9/8.12.6) with ESMTP id j6J8ElvQ003608 for [EMAIL PROTECTED]; Tue, 19 Jul 2005 04:14:47 -0400 Received: from softgate1.softimage.com ([172.24.33.30]) by mtl-smtpgw2.global.avidww.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 19 Jul 2005 04:14:31 -0400 Received: from python.org (IDENT:[EMAIL PROTECTED] [127.0.0.1]) by softgate1.softimage.com (8.12.11/8.12.1) with SMTP id j6J79xHO019613 for [EMAIL PROTECTED]; Tue, 19 Jul 2005 03:10:00 -0400 Message-Id: [EMAIL PROTECTED] From: python-list@python.org To: [EMAIL PROTECTED] Subject: MAIL SYSTEM ERROR - RETURNED MAIL Date: Tue, 19 Jul 2005 09:14:21 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000_0013_B2929ED7.98D0B0AF X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600. X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600. X-OriginalArrivalTime: 19 Jul 2005 08:14:31.0648 (UTC) FILETIME=[E404EE00:01C58C39] This is a multi-part message in MIME format. --=_NextPart_000_0013_B2929ED7.98D0B0AF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message was not delivered due to the following reason(s): Your message could not be delivered because the destination server was not reachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most likely there is a network problem that prevented delivery, but it is also possible that the computer is turned off, or does not have a mail system running right now. Your message could not be delivered within 3 days: Server 54.158.252.173 is not responding. The following recipients could not receive this message: [EMAIL PROTECTED] Please reply to [EMAIL PROTECTED] if you feel this message to be in error. --=_NextPart_000_0013_B2929ED7.98D0B0AF Content-Type: text/plain Content-Transfer-Encoding: 7bit [Filename: [EMAIL PROTECTED], Content-Type: application/octet-stream] The attachment file in the message has been removed by eManager. --=_NextPart_000_0013_B2929ED7.98D0B0AF-- -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary, keys and alias
Steven D'Aprano wrote: On Mon, 18 Jul 2005 12:17:37 +0200, Glauco wrote: I want to insert a concept of alias in a dict_based class. The idea is to have a facoltative name in the same dict that correspond at the same value. With this alias i can change original value. example: mydict['a'] = 1 I must define an alias example: myFunctAlias( mydict, 'a', 'b') print mydict {'a':1, 'b':1} mydict['b'] = 2 print mydict {'a':2, 'b':2} The only idea i have is to implement two dictionary one for convert name, alias in two keys with the same value (eg.numeric) in the first dict. The second for store only one time the k, v . You need some sort of redirection, something like this (untested): class Doubledict: def __init__(self, **kargs): self.data = {} self.aliases = {} for key in kargs: # Point the key to a hash. self.aliases[key] = hash(key) # And point the hash at the value. self.data[hash(key)] = kargs[key] def setalias(self, key, alias): # Point the alias to the same hash as the real key. self.aliases[alias] = hash(key) def __getitem__(self, key): return self.data[self.aliases[key]] def __setitem__(self, key, value): self.data[self.aliases[key]] = value The only niggly worry I have is I'm not sure when hash can be used, when it is unique, or even if is it guaranteed to be unique. Thank Steve, the idea was the same... but yours using hash is much elegant. Thank you Glauco -- \\\|/// \\ - - // ( @ @ ) +-oOOo-( )-oOOo--+ || | I have a dream that one day this nation will rise up and | | live out the true meaning of its creed: We hold these | | truths to be self-evident:that all men are created equal.| | I have a dream that one day on the red hills of Georgia| | the sons of former slaves and the sons of former | | slaveowners will be able to sit down together at a table | | of brotherhood. | | I have a dream that one day even the state of Mississippi, | | a desert state, sweltering with the heat of injustice| | and oppression, will be transformed into an oasis of | | freedom and justice. | | I have a dream that my four children will one day live in | | a nation where they will not be judged by the color of | | their skin but by the content of their character.| | I have a dream today. | || |Martin Luther King, Jr 28 Ago 1963 | ++ |glauco(at)uriland.it| | www.uriland.it .oooOICQ: 115323690 | +- ( )-- Oooo.-+ \ (( ) \_)) / (_/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Filtering out non-readable characters
On 15 Jul 2005 17:33:39 -0700, MKoool [EMAIL PROTECTED] wrote: I have a file with binary and ascii characters in it. I massage the data and convert it to a more readable format, however it still comes up with some binary characters mixed in. I'd like to write something to just replace all non-printable characters with '' (I want to delete non-printable characters). I am having trouble figuring out an easy python way to do this... is the easiest way to just write some regular expression that does something like replace [^\p] with ''? Or is it better to go through every character and do ord(character), check the ascii values? What's the easiest way to do something like this? thanks Easiest way is open the file with EdXor (freeware editor), select all, Format Wipe Non-Ascii. Ok it's not python, but it's the easiest. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows command line problem
This was discovered after consultation with a colleague who shall remain nameless but, well, nailed it basically. The answer appears to be: An example command line for running the script was written in a word document. The Autocorrect (sic) feature in word replaces a normal dash at least as I know it with the character Jeff Epler showed above, u'\N{en dash}' which is a nice big long dash in the Arial font. If you cut and paste that onto the command line, bad things can happen although when I do this on my machine I actually get a u with an ^ on top. For whatever reason it must have looked ok on my colleagues machine (or possibly this isn't the answer but I seriously doubt that) and when he ran the Python script things went awry. Thanks Jeff (and nameless colleague). And beware Word autocorrection. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Contest
ThanhNam Nguyen wrote: Since my NNTP server doesnt allow posting, I'll ask you directly instead. Must I start from the first day? No. For example: 1st day: A -- B 100 bucks 2nd day: A -- B 60 bucks 3rd day: A -- B 40 bucks What would the solution be? And for how much in total? There are two correct solutions: [A, B] # spend one night in A, then fly to B on day two (cost 80) [A, A, B] # spend two nights in A, then fly to B on day two (cost 80) Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Contest
ThanhNam Nguyen wrote: 1st day: A -- B 100 bucks 2nd day: A -- B 60 bucks 3rd day: A -- B 40 bucks What would the solution be? And for how much in total? There are two correct solutions: [A, B] # spend one night in A, then fly to B on day two (cost 80) [A, A, B] # spend two nights in A, then fly to B on day two (cost 80) They all mean I must start from the first day. The best solution would be, I fly from A to B for 40 bucks on day 3, assuming I live in the current city A. Then you should assume that you don't live in city A, because the actual cost in this case is 80. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Documentation bug: Python console behaviour changed
The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. The Python interpreter tells me instead: quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-) Side remark: IDLE closes the console either with Ctrl-D or Ctrl-Q. But IDLEs configure dialog window showing the key combinations is so tight and nothing is recognizable without scrolling back and forth that it is discouring to use it at all ;) IPython closes with 'Ctrl-D'. Thanks to IPython I also determined this as the correct shutdown keys for Python too. Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
My console follows documentation: C:\tmp\GspRegTestAppc:\Python24\python ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. ^Z C:\tmp\GspRegTestAppc:\Python24\python ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. ^D File stdin, line 1 ♦ ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list
OO design
I've been scripting with python for a while now. Basically writing a few functions and running in the ipython shell. That's been very useful. But the more I do this the more I see that I'm doing more or less the same thing over and over again. So its feels like I need to get into class programming with all its attendant benefits. However my biggest problem is a conceptual one. I just can't get my head around defining suitable classes, how they aquire data and communicate with each other. I'm hoping some of you python lamas out there might be able to share some of your wisdom on the subject. What I basically do is a lot of the following:: 1. get arbitrary numerical data (typically large data sets in columnar format or even via COM from other packages. I generally have to deal with one or more sets of X,Y data) 2. manipulate the data (scaling, least squares fitting, means, peaks, add/subtract one XY set from another etc) 3. plot data (original set, results of manipulation, scatterplot, histograms etc - I use matplotlib) 4. export data (print, csv, shelve) I have no problem writing bits of functional code to do any of the above. But for the life of me I can't see how I can hook them altogether in an OO based framework that I can build and extend (with more data formats, manipulations, GUI etc). When I think about what I should do I end up with a class XY that has a method for everything I want to do eg. class XY: def read_file def scale_data def plot_data def shelve_data But somehow that doesn't feel right, especially when I expect the number of methods will grow and grow, which would make the class very unwieldy. Even if that was a legitimate option, I don't understand conceptualy how I would, for example, plot two different XY objects on the same graph or add them together point by point. How do two different XY objects communicate and how do you deal with the thing that they must have in common (the plot screen for example). Clearly I'm having some conceptualisation problems here. Hope someone can shed some light on the subject bwaha. -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
rbt wrote: IMO, most of the people who deride goto do so because they heard or read where someone else did. Or perhaps, like me, they have had to maintain FORTRAN code written by a scientist who apparently hadn't heard of subroutines. Spaghetti doesn't quite describe it. I've settled on Lovecraftian: reading the code, you can't help but get the impression of writhing tentacles and impossible angles. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: OO design
chris == chris [EMAIL PROTECTED] writes: chris I have no problem writing bits of functional code to do any chris of the above. But for the life of me I can't see how I can chris hook them altogether in an OO based framework that I can chris build and extend (with more data formats, manipulations, chris GUI etc). Chris, I echo your sentiment. My little pet project has recently grown to include a bit of an object hierarchy. I've always felt that the Java-esque byzantine pedigree for everything last class a trifle over-done. What I used to trigger factorization was whether or not I needed to branch based on data type: if input_data.type == this: do_this() else: do_that() meant I should factor my code to: class input_data_base() pass class input_data_this(input_data_base) pass class input_data_that(input_data_base) pass With this, my project has a modest number of sensible inheritance hierarchies (two) and the code that wouldn't benefit from such retains its procedural character. OO is a great organizer, but every paradigm runs afoul of Sturgeons Law if over-driven. HTH, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
A lot of people swear by WingIDE and as an IDE I think it's the best one there is. (Personally I prefer jed or xjed but that's because I like to work that way) -- http://mail.python.org/mailman/listinfo/python-list
Re: Building Python with Tcl/Tk on Cygwin_NT-5.1
Dean, On Mon, Jul 18, 2005 at 05:59:20AM -0700, Dean N. Williams wrote: Thanks for fixing this problem. You are quite welcome. Thanks for your patience. Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
linuxfreak wrote: Hi guys, Got going with python...and i must say its a pretty cool language. Been using Xemacs to write me programs. But I want an IDE that would give me auto-completion, online help and the like... Tried SPE and Dr.Pyhton but the former crashes regulary and the latter is quite unweildy and does not have a great many features. I quite like the UML feature found in SPE but the damn thing crashes way too often. What are you guys using and what do you think is the best IDE...or should i stick with Xemacs/emacs??? I use Eclipse with the python plugin. It never crashed. I set it to display tabs as two spaces and Eclipse tells if I type spaces instead of tabs by accident. I like it. I had no luck with the code completion, but do you really need that for writing python programs? Mage -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows command line problem
MarkE wrote: The answer appears to be: An example command line for running the script was written in a word document. The Autocorrect (sic) feature in word replaces a normal dash There is a lesson there I wish more people would learn: Word is not a text editor. :) -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Finding # prefixing numbers
In a text that contains references to numbers like this: #583 I want to find them with a regular expression but I'm having problems with the hash. Hopefully this code explains where I'm stuck: import re re.compile(r'\b(\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') ['123', '234', '456'] re.compile(r'\b(X\d\d\d)\b').findall('X123 x (X234) or:X456 X6789') ['X123', 'X234', 'X456'] re.compile(r'\b(#\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') [] re.compile(r'\b(\#\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') [] As you can guess, I'm trying to find a hash followed by 3 digits word bounded. As in the example above, it wouldn't have been a problem if the prefix was an 'X' but that's not the case here. -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
Kay Schluehr wrote: The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. The Python interpreter tells me instead: quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-) Are you really using the console, started with the Command Prompt icon from the Start Menu (or some equivalent)? And are you sure you haven't installed something else that magically changed the behaviour of Ctrl-Z? (I get the documented behaviour with Python 2.4.1, under Win XP.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
Chris wrote: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router? Sure, though I don't have a Netgear DG834. Maybe you could, uh, enable remote administration and publish the admin password here, and those of us without that equipment could access yours in order to test out the script as we write it. ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
I use Vim. It does code completion and jump to variable/function definition. Emacs does this too. You just need to read the documentation about on how to set this up to your liking. The only feature that Vim does not have that I would like is the function argument pop up, but I want that more for C than Python. It looks like Vim 7 is supposed to have this. If you are afraid of Vim, you might want to try cream: http://cream.sf.net -Chris On Mon, Jul 18, 2005 at 10:32:43PM -0700, linuxfreak wrote: Hi guys, Got going with python...and i must say its a pretty cool language. Been using Xemacs to write me programs. But I want an IDE that would give me auto-completion, online help and the like... Tried SPE and Dr.Pyhton but the former crashes regulary and the latter is quite unweildy and does not have a great many features. I quite like the UML feature found in SPE but the damn thing crashes way too often. What are you guys using and what do you think is the best IDE...or should i stick with Xemacs/emacs??? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Dnia Tue, 19 Jul 2005 13:26:38 +0200, Mage napisał(a): I had no luck with the code completion, It works. Just type sys. and wait a while. But you have to set up pydev first. Check PyDev-Builder-Use Builders and PyDev-CodeCompletion-... -- JZ -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding # prefixing numbers
[EMAIL PROTECTED] wrote: In a text that contains references to numbers like this: #583 I want to find them with a regular expression but I'm having problems with the hash. Hopefully this code explains where I'm stuck: import re re.compile(r'\b(\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') ['123', '234', '456'] re.compile(r'\b(X\d\d\d)\b').findall('X123 x (X234) or:X456 X6789') ['X123', 'X234', 'X456'] re.compile(r'\b(#\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') [] re.compile(r'\b(\#\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') [] As you can guess, I'm trying to find a hash followed by 3 digits word bounded. As in the example above, it wouldn't have been a problem if the prefix was an 'X' but that's not the case here. From the re documentation: \b Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. Note that \b is defined as the boundary between \w and \ W, so the precise set of characters deemed to be alphanumeric depends on the values of the UNICODE and LOCALE flags. Inside a character range, \b represents the backspace character, for compatibility with Python's string literals. # is not a letter or digit, so \b# will match only if the # is directly preceded by a letter or digit which isn't the case in any of your examples. Use \B (which is the opposite of \b) instead: re.compile(r'\B(#\d\d\d)\b').findall('#123 x (#234) or:#456 #6789') ['#123', '#234', '#456'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding # prefixing numbers
Thank you! That solved my problem. -- http://mail.python.org/mailman/listinfo/python-list
How to send a query to the browser from time to time?
I am creating a chat application like Messenger for the web (using the browser) and I'm wondering if there is a way to receive new messages from time to time from the server other than refreshing the page each 5 sec. If there were a way to have the server-side application send new messages to the browser this would be awesome because it would save dramatically on bandwidth. The application would consume bandwidth only when there are new messages. There would be no communication client-server until people write a new message. Do you know if it's possible? -- Thanks, Admin. Want to buy me a book? http://tinyurl.com/78xzb :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
Peter Hansen wrote: Kay Schluehr wrote: The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. The Python interpreter tells me instead: quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-) Are you really using the console, started with the Command Prompt icon from the Start Menu (or some equivalent)? And are you sure you haven't installed something else that magically changed the behaviour of Ctrl-Z? (I get the documented behaviour with Python 2.4.1, under Win XP.) -Peter I'm getting the same behavior as Kay. -- -- Lucas Raab lvraab@earthlink.net dotpyFE@gmail.com AIM:Phoenix11890 MSN:dotpyfe @ gmail.com IRC:lvraab ICQ:324767918 Yahoo: Phoenix11890 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
you have an embarassment of riches (i think that's the phrase) http://wiki.python.org/moin/IntegratedDevelopmentEnvironments also try Eric and Komodo (the other $30 IDE with free trial). -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a query to the browser from time to time?
Short answer: Not using HTTP. However, you can use something like AJAX to just load new data from time to time and not the entire page. Or you might be able to keep the connection alive and occationally send stuff to the client using chunked transfer. I'd go for the ajax route if you don't need to support old browsers. -- http://mail.python.org/mailman/listinfo/python-list
RE: Documentation bug: Python console behaviour changed
[Lucas Raab] | Peter Hansen wrote: | Kay Schluehr wrote: | | The documentation of the Python console behaviour is not correct | anymore for Python 2.4.1. At least for the Win2K system | I'm working on | 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. | | The Python interpreter tells me instead: | | | quit | | | 'Use Ctrl-Z plus Return to exit.' | | Nah, 'Ctrl-Z' is now undo :-) | | | Are you really using the console, started with the Command | Prompt icon | from the Start Menu (or some equivalent)? And are you sure | you haven't | installed something else that magically changed the | behaviour of Ctrl-Z? | | (I get the documented behaviour with Python 2.4.1, under Win XP.) | | -Peter | | I'm getting the same behavior as Kay. Usually means you have a readline package installed: I know that this one gives the effect described: http://sourceforge.net/projects/uncpythontools/ Don't know about this one: http://newcenturycomputers.net/projects/readline.html TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a query to the browser from time to time?
not clear if you're asking about XMLHttpRequest http://www.modernmethod.com/sajax/ http://nevow.com/Nevow2004Tutorial.html#livepage or custom browser object: http://wwwsearch.sourceforge.net/mechanize/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
Peter Hansen schrieb: Kay Schluehr wrote: The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. The Python interpreter tells me instead: quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-) Are you really using the console, started with the Command Prompt icon from the Start Menu (or some equivalent)? And are you sure you haven't installed something else that magically changed the behaviour of Ctrl-Z? (I get the documented behaviour with Python 2.4.1, under Win XP.) -Peter Well, Peter, I indeed changed the system magically but yet it was not Windows, but Python! In my description I told You that I installed IPython and IPython requires the readline package. If I rename the readline package ( e.g. _readline ) in the site-packages directory the console behaves as expected. Otherwise it shows the termination behaviour of IPython namely it shuts down with Ctrl-D. It's really sucking... Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
ok, i don't see URL and password here, so try: urllib2 (maybe mechanize), then beautiful soup. maybe another HTML parser ... -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a query to the browser from time to time?
Admin [EMAIL PROTECTED] writes: If there were a way to have the server-side application send new messages to the browser this would be awesome because it would save dramatically on bandwidth. The application would consume bandwidth only when there are new messages. There would be no communication client-server until people write a new message. Do you know if it's possible? Some people have done stuff like that with multipart mime encodings and chunked transfers. I've looked into it but I'm not sure of the exact mechanism any more. It's kind of messy. The other usual way is to open a tcp connection from a java applet. I don't like that since it means you need java in your browser. There's a chat app called arsc that you might look at: http://manuel.kiessling.net/projects/software/arsc/ Warning, last time I looked at it, it had some security bugs. -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
On Tue, 19 Jul 2005 02:33:02 +, Leif K-Brooks wrote: rbt wrote: IMO, most of the people who deride goto do so because they heard or read where someone else did. 1 GOTO 17 2 mean,GOTO 5 3 couldGOTO 6 [snip] That's great, but not a patch on the power of COMEFROM! Or, to put it another way: 1 2 readability COMEFROM 4 3 that'sCOMEFROM 6 4 hurt COMEFROM 7 5 toCOMEFROM 10 6 but COMEFROM 2 7 might COMEFROM 9 8 nothing COMEFROM 3 9 goto COMEFROM 12 10 compared COMEFROM 8 11 comefrom COMEFROM 5 12 usingCOMEFROM 1 -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary, keys and alias
On Tue, 19 Jul 2005 10:20:04 +0200, Glauco wrote: The only niggly worry I have is I'm not sure when hash can be used, when it is unique, or even if is it guaranteed to be unique. Thank Steve, the idea was the same... but yours using hash is much elegant. I'm still worried about hash of two unrelated objects returning the same value. Another implementation is to keep a hidden attribute of the object, and initialise it to the integer 0. Instead of using hash(key), you use the current value of the integer, then increment the integer by one. This is guaranteed to be unique, no matter what. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a query to the browser from time to time?
On Tue, 19 Jul 2005 10:03:48 -0300, Simon Dahlbacka [EMAIL PROTECTED] wrote: I'd go for the ajax route if you don't need to support old browsers. I already use AJAX on several applications, but I don't want to use it in this one because it would poll the server a lot and it may bring the server down if there are many people using the chat application at the same time (too many queries to the database). -- Thanks, Admin. Want to buy me a book? http://tinyurl.com/78xzb :) -- http://mail.python.org/mailman/listinfo/python-list
Re: main window in tkinter app
I never ran into this problem. ... O.K. That, means I probably have something else wrong. I will need to start with a 'clean slate' instead of trying to modify existing code. It's getting to convoluted to follow anyway after all the cobbling I've done. If I get a repeat of the original problem I will post the code and the exact error message, but at least now I know It SHOULD work. Thanks Bill, Eric Brunel wrote: On Mon, 18 Jul 2005 16:57:51 GMT, William Gill [EMAIL PROTECTED] wrote: A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self, master): self.root = master self.master=master self.createWidgets() def createWidgets(): ... root = Tk() app = MyMain(root) app.master.title(Object Editor) root.mainloop() would become: class MyMain(Tk): ... ... app = MyMain() app.title(My App) app.mainloop() When I try converting to this approach I run into a problem with the __init__() method. It appears to go into an infinite loop in tkinter.__getattr__(). [...] I never ran into this problem. Can you please post a short script showing this behavior? Without knowing what you exactly do in your __init__ and createWidgets method, it's quite hard to figure out what happens... -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
Leif K-Brooks wrote: rbt wrote: IMO, most of the people who deride goto do so because they heard or read where someone else did. 1 GOTO 17 2 mean,GOTO 5 3 couldGOTO 6 4 with GOTO 7 5 what GOTO 3 6 possibly GOTO 24 7 you! GOTO 21 8 that GOTO 18 9 really, GOTO 23 10 understandable? 11 neat.GOTO 16 12 and GOTO 25 13 are GOTO 9 14 IGOTO 26 15 wrongGOTO 20 16 IGOTO 2 17 Yes, GOTO 14 18 simple GOTO 12 19 agreeGOTO 4 20 with GOTO 22 21 GotosGOTO 13 22 somethingGOTO 8 23 really GOTO 11 24 be GOTO 15 25 easily GOTO 10 26 totally GOTO 19 I dislike gotos because it is too easy to inadvertently create infinite loops. 10 WINK; 20 GOTO 10 -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
Tim Golden wrote: Usually means you have a readline package installed: Should the readline package be twiddled to change the quit string in builtins to document the correct behavior? -- http://mail.python.org/mailman/listinfo/python-list
Python s60 Contact DB
Hi, i hope the expert can help me! I have a little problem: This piece of code, in python console s60, before compiling will work great: try: ..db = contacts.open() ..names = [] ..numbers = [] The problem is that, if i compile it with py2sis (pyrsc_template.tmp replaced with the original to solve the submenus bug) it doesnt work, when that piece of code is executed, i receive error -50 and nothing happen! hope u can help me! 10ks a lot in advance Regards. -- http://mail.python.org/mailman/listinfo/python-list
Re: Filtering out non-readable characters
On Tue, 19 Jul 2005 20:28:31 +1200, Ross wrote: On 15 Jul 2005 17:33:39 -0700, MKoool [EMAIL PROTECTED] wrote: I have a file with binary and ascii characters in it. I massage the data and convert it to a more readable format, however it still comes up with some binary characters mixed in. I'd like to write something to just replace all non-printable characters with '' (I want to delete non-printable characters). I am having trouble figuring out an easy python way to do this... is the easiest way to just write some regular expression that does something like replace [^\p] with ''? Or is it better to go through every character and do ord(character), check the ascii values? What's the easiest way to do something like this? thanks Easiest way is open the file with EdXor (freeware editor), select all, Format Wipe Non-Ascii. Ok it's not python, but it's the easiest. 1 Open Internet Explorer 2 Go to Google 3 Search for EdXor 4 Browser locks up 5 Force quit with ctrl-alt-del 6 Run anti-virus program 7 Download new virus definitions 8 Remove viruses 9 Run anti-spyware program 10 Download new definitions 11 Remove spyware 12 Open Internet Explorer 13 Download Firefox 14 Install Firefox 15 Open Firefox 16 Go to Google 17 Search for EdXor 18 Download application 19 Run installer 20 Reboot 21 Run EdXor 22 Open file 23 Select all 24 Select FormatWipe Non-ASCII 25 Select Save 26 Quit EdXor Hmmm. Perhaps not *quite* the easiest way :-) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
On Tue, 19 Jul 2005 07:24:19 +0100, Chris wrote: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router? Are you offering to pay somebody to do it, or just suggesting a project for some Python programmer who is bored and looking for a small project to work on out of love? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
rbt [EMAIL PROTECTED] wrote: On Mon, 2005-07-18 at 12:27 -0600, Steven Bethard wrote: Hayri ERDENER wrote: what is the equivalent of C languages' goto statement in python? Download the goto module: http://www.entrian.com/goto/ And you can use goto to your heart's content. And to the horror of all your friends/coworkers. ;) STeVe Shouldn't that be to the horror of all your goto-snob friends. IMO, most of the people who deride goto do so because they heard or read where someone else did. Many of the world's most profitable software companies (MS for example) have thousands of goto statements in their code... oh the horror of it all. Why aren't these enlightened-by-the-gods know-it-alls as profitable as these obviously ignorant companies? It should not really come as a shock that the same fellow who came up with a brilliant efficient way to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto. Coming next from rbt: Pointer arithmetic in python ?. George -- http://mail.python.org/mailman/listinfo/python-list
wxPython - DB Form generator unit
Hi ! Is anyone know about a DB form generator unit under wxPython ? What that's means ? I add information about a Query, or a ListOfDict, I set some other infos (Lookups, others), and it is generate a Form with edit boxes, listboxes, etc. Then I can fill up the form with a record's datas. User can modify them. After I can call Apply method, and every modifications are stored in a result. That is very important thing, when you have many record editor forms. Don't need to create them one-to-one, not need to repeat many codes... Is anyone have an idea ? Thanx: ft -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary, keys and alias
Glauco, Be careful if you decide to use hash. There is possibility of bugs due to that approach, (if hash(x) == hash(y) and x != y). Even if the probability of bug is near 0, your computer will certainly recall you what is the murphy law. If I were you, I would prefer another approach. Cyril On 7/19/05, Glauco [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Mon, 18 Jul 2005 12:17:37 +0200, Glauco wrote:I want to insert a concept of alias in a dict_based class.The ideais to have a facoltative name in the same dict that correspond at the same value. With this alias i can change original value.example:mydict['a'] = 1I must define an aliasexample: myFunctAlias( mydict, 'a', 'b') print mydict{'a':1, 'b':1}mydict['b'] = 2print mydict{'a':2, 'b':2}The only idea i have is to implement two dictionary one for convert name, alias in two keys with the same value (eg.numeric) in the firstdict. The second for store only one time the k, v . You need some sort of redirection, something like this (untested): class Doubledict: def __init__(self, **kargs): self.data = ""> self.aliases = {} for key in kargs: # Point the key to a hash. self.aliases[key] = hash(key) # And point the hash at the value. self.data[hash(key)] = kargs[key] def setalias(self, key, alias): # Point the alias to the same hash as the real key. self.aliases[alias] = hash(key) def __getitem__(self, key): return self.data[self.aliases[key]] def __setitem__(self, key, value): self.data [self.aliases[key]] = value The only niggly worry I have is I'm not sure when hash can be used, when it is unique, or even if is it guaranteed to be unique.Thank Steve, the idea was the same... but yours using hash is much elegant.Thank youGlauco--\\\|///\\- -// (@ @)+-oOOo-( )-oOOo--+||| I have a dream that one day this nation will rise up and || live out the true meaning of its creed: We hold these | | truths to be self-evident:that all men are created equal.|| I have a dream that one day on the red hills of Georgia|| the sons of former slaves and the sons of former || slaveowners will be able to sit down together at a table | | of brotherhood.|| I have a dream that one day even the state of Mississippi, || a desert state, sweltering with the heat of injustice|| and oppression, will be transformed into an oasis of | | freedom and justice. || I have a dream that my four children will one day live in|| a nation where they will not be judged by the color of || their skin but by the content of their character.|| I have a dream today.Martin Luther King, Jr28 Ago 1963 |++|glauco(at)uriland.it||www.uriland.it.oooOICQ: 115323690 |+- ( )-- Oooo.-+ \ (( )\_)) /(_/--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Can I make the Python build use an already-installed version of Expat?
I'm running into problems where Python and VTK both ship with their own distribution of the Expat parser. As long as you never use the Python XML package, everything is fine. But if you try using the Python XML parser after doing an `import vtk', a nice little message saying Segmentation Fault is your reward. For now, the workaround is to save the `import vtk' until after I do all my XML parsing. However, we're starting to build a rather large framework using Python and VTK, and I cannot guarantee that the VTK libraries won't be in memory when some of my XML parsing routines are called. I know that the VTK build has an option for forcing it to use an installation of Expat that's already on the system. But after looking at the Python build scripts, I can't find any such option for Python. Is this at all possible? I know that there is a way to tell Python to link to arbitrary libraries, but I don't know how to turn off the building of the custom Expat that comes with Python. Thanks for any tips, pointers, and insight. -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I send keystrokes to a console window in Windows XP?
Benji, This appears to be exactly what we need. I also see that by changing Command Prompt to Notepad or another application, the key strokes are sent there. With this capability, other possibilities open up. Is there a way to read the output from the from the console window? For example, how can we capture the output of the dir command? Thank you for your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I make the Python build use an already-installed version of Expat?
Steve Juranich [EMAIL PROTECTED] writes: I'm running into problems where Python and VTK both ship with their own distribution of the Expat parser. As long as you never use the Python XML package, everything is fine. But if you try using the Python XML parser after doing an `import vtk', a nice little message saying Segmentation Fault is your reward. This sounds like this bugreport on sourceforge: http://python.org/sf/1075984 Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ -- http://mail.python.org/mailman/listinfo/python-list
Web Framework Reviews
Hello All, I thought it would make sense to write up some of my experiences with python based web frameworks: http://www.personal.psu.edu/staff/i/u/iua1/python_reviews.html best, Istvan. -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
On Tue, 2005-07-19 at 10:02 -0400, George Sakkis wrote: rbt [EMAIL PROTECTED] wrote: On Mon, 2005-07-18 at 12:27 -0600, Steven Bethard wrote: Hayri ERDENER wrote: what is the equivalent of C languages' goto statement in python? Download the goto module: http://www.entrian.com/goto/ And you can use goto to your heart's content. And to the horror of all your friends/coworkers. ;) STeVe Shouldn't that be to the horror of all your goto-snob friends. IMO, most of the people who deride goto do so because they heard or read where someone else did. Many of the world's most profitable software companies (MS for example) have thousands of goto statements in their code... oh the horror of it all. Why aren't these enlightened-by-the-gods know-it-alls as profitable as these obviously ignorant companies? It should not really come as a shock that the same fellow who came up with a brilliant efficient way to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto. Coming next from rbt: Pointer arithmetic in python ?. George I have moments of brilliance and moments of ignorance. You must admit though, that was a unique way of generating permutations... how many other people would have thought of that approach? It did solve my problem ;) -- http://mail.python.org/mailman/listinfo/python-list
print ending with comma
I recently ran into the issue with 'print' were, as it says on the web page called Python Gotchas (http://www.ferg.org/projects/python_gotchas.html): The Python Language Reference Manual says, about the print statement, A \n character is written at the end, unless the print statement ends with a comma. What it doesn't say is that if the print statement does end with a comma, a trailing space is printed. -- But this isn't exactly correct either. If you run this program: import sys print '+', print '-', sys.stdout.write('=') print -- the output is: + -= Note that there is no space after the '-'. (Tested on Win 2000 python 2.3.4, OS X 10.3.9 python 2.3 2.4) I know that this is not a massively important issue, but can someone explain what's going on? -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there any decent python memory profilers available?
[EMAIL PROTECTED] writes: I have a rather large python application (uses around 40MB of memory to start) that gradually chews up memory over many hours. I've done a little googling around, but it looks like I'm faced with prowling through the gc.get_objects() myself. I need a tool to identify where the memory is going. It might even be a leak in a DLL, so maybe a pure python profiler isn't the best, although it would certainly help localize the problem. One is being written as part of Google's Summer Of Code program. Cheers, mwh -- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat -- http://mail.python.org/mailman/listinfo/python-list
Re: print ending with comma
wrote: I recently ran into the issue with 'print' were, as it says on the web page called Python Gotchas (http://www.ferg.org/projects/python_gotchas.html): The Python Language Reference Manual says, about the print statement, A \n character is written at the end, unless the print statement ends with a comma. What it doesn't say is that if the print statement does end with a comma, a trailing space is printed. -- But this isn't exactly correct either. If you run this program: import sys print '+', print '-', sys.stdout.write('=') print -- the output is: + -= Note that there is no space after the '-'. (Tested on Win 2000 python 2.3.4, OS X 10.3.9 python 2.3 2.4) I know that this is not a massively important issue, but can someone explain what's going on? The space isn't appended to the value printed, it is output before the next value is printed. The file object has an attribute softspace (initially 0). If this is 0 then printing a value simply writes the value to the file. If it is 1 then printing a value writes a space followed by the value. After any value which ends with a newline character is printed the softspace attribute is reset to 0 otherwise it is set to 1. Also when a print statement ends without a trailing comma it outputs a newline and resets softspace. Change your print test a little to see this: print +,;print -,;sys.stdout.write(=);print X + -= X Or try this to suppress unwanted spaces in your output: def nospace(s): sys.stdout.softspace = 0 return s print a,nospace(b),c ab c -- http://mail.python.org/mailman/listinfo/python-list
Jython Released
This is an update from Brian Zimmer of the Jython group, new release: There is a new release of Jython available at Sourceforge: http://sourceforge.net/project/showfiles.php?group_id=12867 This release includes many major changes since the last full release: - new-style classes - Java Collections integration - PEP 302 implementation - iterators - generators - __future__ division - support for running on JDK1.5 - new installer - a significant number of features to bring Jython in line with CPython - many, many bugfixes It was compiled a OS X with JDK1.4 but should run on JDK 1.2 +. The full set of changes are too numerous to list in detail. Please consult the sourceforge tracker for all closed issues since the last release. This version of Jython has support for most of Python 2.2 and numerous features from Python 2.3 and beyond. A more comprehensive list will be forthcoming. Please email [EMAIL PROTECTED] with questions. thanks,... The Jython Development Team -- http://mail.python.org/mailman/listinfo/python-list
Re: print ending with comma
[EMAIL PROTECTED] wrote: [snip] A \n character is written at the end, unless the print statement ends with a comma. What it doesn't say is that if the print statement does end with a comma, a trailing space is printed. -- But this isn't exactly correct either. If you run this program: import sys print '+', print '-', sys.stdout.write('=') print -- the output is: + -= [snip] I know that this is not a massively important issue, but can someone explain what's going on? Actually, it is not a trailing space but a leading space that is stored and displayed when print is called next. import sys print 'a', a print 'b', b --- sys.stdout.write() does not include such a leading space. Time to consult python.org about the print statement.: [http://www.python.org/doc/2.0.1/ref/print.html] ...A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line... Yep, another case of RTM :-) André -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I thought it would make sense to write up some of my experiences with python based web frameworks: http://www.personal.psu.edu/staff/i/u/iua1/python_reviews.html You've never used Nevow, have you? Comparing it to Cheetah or ZPT means that you never used it. Nevow is exactly what you define as a web framework, and it would be quite interesting to know why you didn't put it in that section. -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de -- http://mail.python.org/mailman/listinfo/python-list
Re: python certification
I haven't had a change to check it out, but www.guruishcool.com has a python certificate. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I make the Python build use an already-installed version of Expat?
On 7/19/05, Bernhard Herzog [EMAIL PROTECTED] wrote: This sounds like this bugreport on sourceforge: http://python.org/sf/1075984 Thanks! I applied the workaround posted by `bos' and things seem to work now. -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: on Microsoft hatred
J|rgen Exner wrote: Just for the records at Google et.al. in case someone stumbles across Xah's masterpieces in the future: Xah is very well known as the resident troll in many NGs and his 'contributions' are less then useless. Best is to just ignore him. I already had him killfiled. I'm going to add a few of these non-comp.lang.c newsgroups as well, not due to any animosity towards them but because I don't read them and don't plan to, so any message crossed to them is likely a troll. A good newsreader and aggressive use of filtering is the best way to handle such people. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: python certification
[EMAIL PROTECTED] wrote: i want to get a small certificate or diploma in python. it should be online cuz i live in pakistan and wont have teast centers near me. it should be low cost as i am not rich. and hopefully it would be something like a a begginer certification cuz i am new to python. Hmm... I think I can help you. By the way, how much are you willing to spend? You know, getting a high grade is also important...:-) -- http://mail.python.org/mailman/listinfo/python-list
Re: email format in python
On Mon, 18 Jul 2005 06:44:36 -0400, Benji York [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I want to have the python equivalent function of this (that checks email format) ... if (ereg([[:alnum:[EMAIL PROTECTED]:alnum:]]+\.[[:alnum:]]+, ... While it is possible to translate the above code into Python (see http://docs.python.org/lib/module-re.html), you should know that the regex above will not validate all possible email addresses. To be even more explicit about it, the regexp is extremely naive, and gives the wrong results for a lot of common address formats -- not to mention for even more uncommon formats. Do not use it, and do not try to modify it to work! In general it is a fools errand to try to anyway. Agree. In the case of user input validation, it might be ok to politely inform the user that the address looks a bit funny, but refusing to work with it will anger a user sooner or later. /Jorgen -- // Jorgen Grahn jgrahn@ Ph'nglui mglw'nafh Cthulhu \X/algonet.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: on Microsoft hatred
Malcolm [EMAIL PROTECTED] wrote: John Bokma [EMAIL PROTECTED] wrote A typical Xah Lee posting... wake me up when he is able to write a single post that makes and sense, and doesn't contain fuck or similar words. Obscene language isn't acceptable on comp.lang.c. It is an international group, and what might be acceptable in America may be considered totally offensive, maybe even illegal, elsewhere. Then you are going to have a hard time with Xah Lee, since he thinks it makes the message more clear. -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ Happy Customers: http://castleamber.com/testimonials.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: on Microsoft hatred
Default User [EMAIL PROTECTED] wrote: A good newsreader and aggressive use of filtering is the best way to handle such people. The best way is to complain with their ISP/USP and have their account canceled. Kill filing (filtering) is just closing your eyes. -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ Happy Customers: http://castleamber.com/testimonials.html -- http://mail.python.org/mailman/listinfo/python-list
Re: secure uploading
On 16 Jul 2005 18:28:33 -0700, macaronikazoo [EMAIL PROTECTED] wrote: well I want a script to upload something automatically, so i need a python script to do that for me. Well, you need /something/. If you are on a Unix machine, you'd be better off with a cron job. my hoster has ssl enabled on their server and I have generated a key. but now I need to know how to upload something using ssl to the server. how to I ftp something to the server using ssl? Are you sure your hoster doesn't provide ssh access to his machines? If he does, there is a wealth of protocols and tools for secure file transfer: scp, sftp, tar-over-ssh, cpio-over-ssh, rsync-over-ssh, ... With some loss of security, you may even be able to avoid handling passwords. /Jorgen -- // Jorgen Grahn jgrahn@ Ph'nglui mglw'nafh Cthulhu \X/algonet.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
dictionary as property
Hello. (How) can I have a class property d, such that d['foo'] = 'bar' will run a certain function of the class with 'foo' and 'bar' as it's arguments? Thanks in advance. -- Thanos Tsouanas .: My Music: http://www.thanostsouanas.com/ http://thanos.sians.org/ .: Sians Music: http://www.sians.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
I have not used Nevow but I have seen a few examples of how it works and I kept track of it over the years. It used to be very similar to how Cheetah or ZPT does its job. You had a template, and you filled it with data to produce an output. It seems that it has now more features such a form submission and validation. On the other hand I even in its current form I don't see how I would to the simple things that I need every day. Create a session, set a cookie, redirect to another url, perform HTTP autentication, create filter, use another templating language? This is also integral part of the functionality that I expect from an web framework. Web specific things exposed in some python ic way. To avoid any negative feelings I'll remove all remarks to what I think is not a web framework. Istvan. -- http://mail.python.org/mailman/listinfo/python-list
Re: dictionary as property
On Tue, Jul 19, 2005 at 07:56:20PM +0300, Thanos Tsouanas wrote: Hello. (How) can I have a class property d, such that d['foo'] = 'bar' will run a certain function of the class with 'foo' and 'bar' as it's arguments? You could implement a custom container type that will do what you want. See http://docs.python.org/ref/sequence-types.html for __setitem__. Quick hack: class Foo: ... def __init__(self): ... self.d = self ... def __setitem__(self, key, value): ... getattr(self, key)(value) ... def bar(self, param): ... print bar got called with, param ... foo = Foo() foo.d[bar] = 42 bar got called with 42 -- Gerhard -- Gerhard Häring - [EMAIL PROTECTED] - Python, web database development signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
On Tue, 19 Jul 2005 11:29:58 -0400, rbt wrote: It should not really come as a shock that the same fellow who came up with a brilliant efficient way to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto. Coming next from rbt: Pointer arithmetic in python ?. George I have moments of brilliance and moments of ignorance. You must admit though, that was a unique way of generating permutations... how many other people would have thought of that approach? It did solve my problem ;) Sorry rbt, but your algorithm isn't unique, nor was it clever, and in fact your implementation wasn't very good even by the undemanding requirements of the algorithm. It is just a minor modification of bogosort (also known as bozo-sort) algorithm: http://en.wikipedia.org/wiki/Bogosort I quote: ...bogosort is 'the archetypal perversely awful algorithm', one example of which is attempting to sort a deck of cards by repeatedly throwing the deck in the air, picking the cards up at random, and then testing whether the cards are in sorted order. Bogosort is nothing to be proud of, except as a joke. Put it this way: of all the many ways to generate a list of permutations, you managed to find perhaps the least efficient algorithm possible. This is especially ironic when you think back to your first question, which was how to generate the combinations most efficiently. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have not used Nevow but I have seen a few examples of how it works and I kept track of it over the years. It used to be very similar to how Cheetah or ZPT does its job. You had a template, and you filled it with data to produce an output. It seems that it has now more features such a form submission and validation. Formless has been part of nevow since the very beginning. It has also been part of woven (Nevow predecessor), just like liveevil (now enhanced and called livepage). The only part of nevow that you can compare to ZPT or Cheetah is its xmlfile template language. There is no way you can run Nevow on top of any other framework. Also you don't pass data to the templating engine. It's nevow that parses the template and iterates over it to render the page. The template is very stupid in nevow and everything is done in nevow.flat.flattenFactory called by nevow.rend.Page. On the other hand I even in its current form I don't see how I would to the simple things that I need every day. Create a session, set a cookie, redirect to another url, perform HTTP autentication, create filter, use another templating language? This is also integral part of the functionality that I expect from an web framework. Web specific things exposed in some python ic way. Sessions are handled by default with twisted.web: from twisted.application import service, strports from nevow import appserver from nevow import rend, loaders, tags as t, inevow class RootPage(rend.Page): addSlash = True def display_session(self, ctx, data): return inevow.ISession(ctx).uid docFactory = loaders.stan( t.html[t.head[t.title[Session example]], t.body[display_session]] ) application = service.Application('Foobar') site = appserver.NevowSite(RootPage()) server = strports.service('8080', site) server.setServiceParent(application) Save this in a .py or .tac and run it with twistd -noy filename.tac/.py and open http://localhost:8080/ in your browser to see your session uid. If you want autentication: http://nevowexamples.adytum.us/sources/guarded.py http://nevowexamples.adytum.us/sources/guarded2.py There are 2 examples (in the standard nevow distribution) that show how to handle authentication in an application transparent way (you don't have to touch your application by any means to add user authentication, which means you can write everything without taking care of this aspect of the app and then add it later). To redirect to another url just call IRequest(ctx).redirect(newurl) before the rendering begins (like in rend.Page.beforeRender) or in rend.Page.locateChild. HTTPAuthentication is easily handled: http://nevowexamples.adytum.us/sources/http_auth.py just use that class as a base class for your blocked page. (this example is part of the standard nevow distribution). Nevow doesn't have filters because they are handled by twisted.web or twisted.web2 (which is, hopefully soon, going to be one of the required webservers to run nevow, the others are lighttpd, apache, any WSGI application server, nevow was in fact the first framework to support WSGI servers). If you want to use a different templating language you just need to write a custom loader. Somebody did this in the past (I don't recall the url of the project) that used cheetah-like templates. Then for the last point: you can expose directories or files using nevow.static.File exposed objects are: those set as a value in rend.Page.children dict, you can reach them with an url like: http://www.example.com/url/that/returns/a/page/inst/key_in_children_dict Or assign an object to a child_foobar attribute like: p = rend.Page() p.child_foobar = static.File('/etc/') Or return an object from a child_foobar method. Or override rend.Page.childFactory(self, ctx, segment) to return an object in a dynamic way depending on the value of the segment argument. It seems to me that you really never tracked Nevow, your information is very incomplete. I think you should complete it before talking about Nevow :). -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
On 2005-07-19, linuxfreak [EMAIL PROTECTED] wrote: you guys using and what do you think is the best IDE...or should i stick with Xemacs/emacs??? http://pydev.sf.net You get the stability of Eclipse with that, but also the fat. I swear I had code completion working in this, but last time I tried to set it up I got frustrated and gave up, so put aside some time to learn your way around Eclipse if you intend to use this. I still don't feel quite at home there. Personally, I don't find code completion compelling enough a feature to give up my beloved XEmacs and python-mode. Dave Cook -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
On Wed, 2005-07-20 at 03:43 +1000, Steven D'Aprano wrote: On Tue, 19 Jul 2005 11:29:58 -0400, rbt wrote: It should not really come as a shock that the same fellow who came up with a brilliant efficient way to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto. Coming next from rbt: Pointer arithmetic in python ?. George I have moments of brilliance and moments of ignorance. You must admit though, that was a unique way of generating permutations... how many other people would have thought of that approach? It did solve my problem ;) Sorry rbt, but your algorithm isn't unique, nor was it clever, and in fact your implementation wasn't very good even by the undemanding requirements of the algorithm. It is just a minor modification of bogosort (also known as bozo-sort) algorithm: http://en.wikipedia.org/wiki/Bogosort I quote: ...bogosort is 'the archetypal perversely awful algorithm', one example of which is attempting to sort a deck of cards by repeatedly throwing the deck in the air, picking the cards up at random, and then testing whether the cards are in sorted order. Bogosort is nothing to be proud of, except as a joke. It *was* a joke. -- http://mail.python.org/mailman/listinfo/python-list
Re: OO design
fav DP books: http://www.oreilly.com/catalog/hfdesignpat/ http://www.netobjectives.com/dpexplained/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
On 2005-07-19, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On the other hand I even in its current form I don't see how I would to the simple things that I need every day. Create a session, set a cookie, redirect to another url, perform HTTP autentication, create filter, use another templating language? This is also integral part of the functionality that I expect from an web framework. Web specific things exposed in some python ic way. Take a look at the Nevow FAQ and examples. Also, Nevow sits on top of Twisted, so you have all of Twisted's features available. http://divmod.org/users/wiki.twistd/nevow/moin.cgi/FrequentlyAskedQuestions Dave Cook -- http://mail.python.org/mailman/listinfo/python-list
gdb python C API
I have written a c program to interface with a newly installed version of python 2.4.1 on my system. The C program calls a module written in python that goes on to parse an xml file and do other xml specific operations. When I use the module in python, it seems to work alright, but when I try to use my c program to interface, sometimes it works and sometimes it segfaults. I tried using gdb find the segfault, but in the C program, once the python module is called, gdb tells me that some python compiled code has been placed on the stack and is being executed, but i am having trouble finding what part of the python module is being executed (which makes it hard to find the real reason for the segfault). are there any tools / methods that others have used to get what line of the python script is being executed while running in gdb? or if it would actually show me the source python script (instead of the the python c source) that would help. my setup is: self compiled/installed python 2.4.1 my python module calls the xml.dom.minidom module. my problem might be refcounts, i've looked over them many times and they seem to make sense to me but it never hurts to have someone else's opinion. tia, derrick -- http://mail.python.org/mailman/listinfo/python-list
Your message to CMake awaits moderator approval
Your mail to 'CMake' with the subject test will be discarded. The reason it is being discarded is: Post by non-member to a members-only list The mailing lists at Kitware all require membership on the list to post. This is to avoid SPAM. If you are not a member on the list, and you post to the list, your message will be discarded. Do not take it personally, we just do not have enough time to approve every email posted to the list. If you have more than one email account, you can subscribe them all to the list, then set all but one of them to nomail from the mailman web GUI. Also, some mailers tend to add a few extra characters to your return address, if you think you have subscribed, but it is still not accepting your email, try sending yourself an email, and then reply to it. Look at the address that you are replying to, and make sure that is the EXACT same address that you subscribed to on the list. You can join the list here: http://public.kitware.com/mailman/listinfo/CMake If the message is too large, it will also be discarded, try putting the large file on a web server and using a link in your message. Bugs can be reported here: http://public.kitware.com/Bug/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation bug: Python console behaviour changed
Lucas Raab [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Peter Hansen wrote: Kay Schluehr wrote: The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. The Python interpreter tells me instead: quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-) Are you really using the console, started with the Command Prompt icon from the Start Menu (or some equivalent)? And are you sure you haven't installed something else that magically changed the behaviour of Ctrl-Z? (I get the documented behaviour with Python 2.4.1, under Win XP.) -Peter I'm getting the same behavior as Kay. -- -- Lucas Raab I'm getting the same behaviour, too. What is non-standard is, that I am using english international keyboard on German version of Windows 2000 Professional 5.0.2195 SP 4, Build 2195. Claudio -- http://mail.python.org/mailman/listinfo/python-list
Read only files
Hello, I am getting a permission Denied error when i am trying to make changes in some read only files in a directory. How do we check and change the read only attributes of files in python. Please Help, Pranav __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary, keys and alias
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, 19 Jul 2005 10:20:04 +0200, Glauco wrote: The only niggly worry I have is I'm not sure when hash can be used, when it is unique, or even if is it guaranteed to be unique. Thank Steve, the idea was the same... but yours using hash is much elegant. I'm still worried about hash of two unrelated objects returning the same value. Another implementation is to keep a hidden attribute of the object, and initialise it to the integer 0. Instead of using hash(key), you use the current value of the integer, then increment the integer by one. This is guaranteed to be unique, no matter what. id(ob) is already guaranteed to be a unique integer while ob exists. So, if I understand the goal, map possibly-multiple-keys each to id and id to ob. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: main window in tkinter app
O.K. I tried from scratch, and the following snippet produces an infinite loop saying: File C:\Python24\lib\lib-tk\Tkinter.py, line 1647, in __getattr__ return getattr(self.tk, attr) If I comment out the __init__ method, I get the titled window, and print out self.var ('1') import os from Tkinter import * class MyApp(Tk): var=1 def __init__(self): pass def getval(self): return self.var app = MyApp() app.title(An App) print app.getval() app.mainloop() Eric Brunel wrote: On Mon, 18 Jul 2005 16:57:51 GMT, William Gill [EMAIL PROTECTED] wrote: A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self, master): self.root = master self.master=master self.createWidgets() def createWidgets(): ... root = Tk() app = MyMain(root) app.master.title(Object Editor) root.mainloop() would become: class MyMain(Tk): ... ... app = MyMain() app.title(My App) app.mainloop() When I try converting to this approach I run into a problem with the __init__() method. It appears to go into an infinite loop in tkinter.__getattr__(). [...] I never ran into this problem. Can you please post a short script showing this behavior? Without knowing what you exactly do in your __init__ and createWidgets method, it's quite hard to figure out what happens... -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython Released
Ramza Brown wrote: This is an update from Brian Zimmer of the Jython group, new release: Great news! - new installer How do I use it? Thanks, Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython Released
Dave Benjamin wrote: Ramza Brown wrote: This is an update from Brian Zimmer of the Jython group, new release: Great news! - new installer How do I use it? I figured it out. You might want to document this somewhere. ;) java -cp jython_Release_2_2alpha1.jar org.python.util.install.Installation Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
Steven Bethard wrote: Fernando Perez wrote: Steven Bethard wrote: Download the goto module: http://www.entrian.com/goto/ And you can use goto to your heart's content. And to the horror of all your friends/coworkers. ;) That is actually a _really_ cool piece of code, in terms of showing off the kind of things which are possible in python if you're willing to be a little sneaky. Yeah, it's pretty slick. I think most people who see the link don't realize that it's actually *working code* for gotos in Python. For a second I didn't think it was, but the page looked too serious to be just a mockup (regardless of the April's fool warning at the top). So I actually donwloaded the code to see how he did it, because it wasn't quite obvious to me after the standard 3 seconds of thought. It was quite fun the read how he got it to work. Cheers, f -- http://mail.python.org/mailman/listinfo/python-list
Re: main window in tkinter app
It also seems to operate the same with or without app.mainloop(). Is an explicit call to mainloop needed? William Gill wrote: O.K. I tried from scratch, and the following snippet produces an infinite loop saying: File C:\Python24\lib\lib-tk\Tkinter.py, line 1647, in __getattr__ return getattr(self.tk, attr) If I comment out the __init__ method, I get the titled window, and print out self.var ('1') import os from Tkinter import * class MyApp(Tk): var=1 def __init__(self): pass def getval(self): return self.var app = MyApp() app.title(An App) print app.getval() app.mainloop() Eric Brunel wrote: On Mon, 18 Jul 2005 16:57:51 GMT, William Gill [EMAIL PROTECTED] wrote: A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self, master): self.root = master self.master=master self.createWidgets() def createWidgets(): ... root = Tk() app = MyMain(root) app.master.title(Object Editor) root.mainloop() would become: class MyMain(Tk): ... ... app = MyMain() app.title(My App) app.mainloop() When I try converting to this approach I run into a problem with the __init__() method. It appears to go into an infinite loop in tkinter.__getattr__(). [...] I never ran into this problem. Can you please post a short script showing this behavior? Without knowing what you exactly do in your __init__ and createWidgets method, it's quite hard to figure out what happens... -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
It seems to me that you really never tracked Nevow, your information is very incomplete. I think you should complete it before talking about Nevow I think you should take what you posted above and put it up on your main site, because right now there is no way to find any information like this. Your entire intro is about templating and leaves one with no clues as to what else is there. One remark regarding stan. For me it is inconceivable that one would build (and debug) any complicated webpage as stan does it, one element at a time: docFactory = loaders.stan( t.html[t.head[t.title[Session example]], t.body[display_session]] ) The pages that I have to build invariably contain multiple nested html tables etc. I shudder to think that I would ever have to build them like that. I know you have an inverse ZPT like templates those are a lot friendlier on the eyes. For someone who is does not know what Nevow is seeing an example of Stan is very scary because IMO it does not scale at all. This again is just an opinion. Thanks for the explanations. Istvan. -- http://mail.python.org/mailman/listinfo/python-list
Re: dictionary as property
On Tue, Jul 19, 2005 at 07:00:10PM +0200, Gerhard Haering wrote: On Tue, Jul 19, 2005 at 07:56:20PM +0300, Thanos Tsouanas wrote: Hello. (How) can I have a class property d, such that d['foo'] = 'bar' will run a certain function of the class with 'foo' and 'bar' as it's arguments? You could implement a custom container type that will do what you want. See http://docs.python.org/ref/sequence-types.html for __setitem__. Thanks, that doc had all I needed :) -- Thanos Tsouanas .: My Music: http://www.thanostsouanas.com/ http://thanos.sians.org/ .: Sians Music: http://www.sians.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Framework Reviews
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I think you should take what you posted above and put it up on your main site, because right now there is no way to find any information like this. Your entire intro is about templating and leaves one with no clues as to what else is there. Right now there are at least 2 web sites: http://divmod.org/users/exarkun/nevow-api/ + file inevow.py in nevow. http://divmod.org/users/mg/nevow-doc/ And a new one: http://dictator.kieranholland.com/prose/Meet%20Stan.html And the page I linked in my previous post: http://nevowexamples.adytum.us/ this is a living site with the living examples distributed with nevow. at least one example of formless does not work right now because of changes that we are doing in trunk right now (only formless has some problems, all the others work pretty well). There are really a lot of examples, and you can learn a lot of stuff from them. More documentation will be useful for sure, but by just coming in the irc channel #twisted.web on freenode you would have obtained all the answers you wanted to write a better review paper :). One remark regarding stan. For me it is inconceivable that one would build (and debug) any complicated webpage as stan does it, one element at a time: docFactory = loaders.stan( t.html[t.head[t.title[Session example]], t.body[display_session]] ) The pages that I have to build invariably contain multiple nested html tables etc. I shudder to think that I would ever have to build them like that. I know you have an inverse ZPT like templates those are a lot friendlier on the eyes. For someone who is does not know what Nevow is seeing an example of Stan is very scary because IMO it does not scale at all. This again is just an opinion. I have a little project, developed during my little free time that is linked in my signature (weever). It has over 2000 lines of xhtml templates and you can see a living example here: http://vercingetorix.dyndns.org:20080/ I can guarantee you that when templates begin to be a bit too complex stan is what saves the day. I usually use xhtml for everything (and nevow has the best templating engine out there thanks to its flexibility and simplicity, there are only 3 special tags and 3 attributes, and we are working to make it even easier than that) but when xhtml gets complicated stan is incredibly useful. Anyway stan is also incredibly useful to write little examples without requiring a new xhtml file (ok... you may use loaders.xmlstr but...) And it does scale well anyway (Quotient is entirely built using stan and it's very big). Templating engines like ZPT prefer to put some code in the template, Nevow prefers to put code in python and allow you to write some xhtml in python too. python is easier to manage and less likely to be screwed by any designer that doesn't know what python is. Thanks for the explanations. np :) -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de -- http://mail.python.org/mailman/listinfo/python-list