Complex evaluation bug
a = 1+3j complex(str(a)) Why does this not work ? It should -- http://mail.python.org/mailman/listinfo/python-list
Re: Complex evaluation bug
Heiko Wundram wrote: > Am Freitag 19 Mai 2006 18:03 schrieb Paul McGuire: > >>An eval-less approach - the problem is the enclosing parens. >> > > > I've just submitted two patches to the Python bugtracker at: > > http://sourceforge.net/tracker/index.php?func=detail&aid=1491866&group_id=5470&atid=305470 > > which either change the repr() format (removing the parentheses), which I > find > doubtful, because it's not backwards-compatible, or alter the constructor to > accept the repr() format for complex numbers (a bracketed number). > > Feel free to comment. > > --- Heiko. thanks -- http://mail.python.org/mailman/listinfo/python-list
If Statement Error (Tic Tac Toe)
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has won. At first it looked like it was working, but now it sometimes assigns a win when you enter an X or O (doesn't matter) on certain tiles (row 1, column 1 won't be an error, but row 2, column 3 will be...). If you can find the problem, I'd be very thankful! Here's the code: # TIC TAC TOE # Started: 10/31/05 # Ended: still in progress loop = 1 while loop == 1: print "TIC TAC TOE" print "1 - Play Multiplayer" print "2 - Quit" option = input("> ") if option == 2: # QUIT loop = 0 if option == 1: # MAIN GAME LOOP print "Rules: You will alternate turns." print "On your turn, you can place your letter (O = Player 1 or X = Player 2)", print "in any unoccupied square." print "The first to get 3 in a row wins. Good luck!" gameboard = [' ',' ',' ',' ',' ',' ',' ',' ',' '] win = 0 turnnumber = 0 while win != 1: if turnnumber % 2 == 0: print " " print "Player 1" print " " print "[",gameboard[0],"]","[",gameboard[1],"]","[",gameboard[2],"]" print "[",gameboard[3],"]","[",gameboard[4],"]","[",gameboard[5],"]" print "[",gameboard[6],"]","[",gameboard[7],"]","[",gameboard[8],"]" print "What row?" row = input("> ") print "What column?" column = input("> ") if (row > 3 or row < 1) or (column > 3 or column < 1): print "Exceeeded limits." turnnumber = turnnumber - 1 if row == 1 and column == 1: if gameboard[0] != ('O' or 'X'): gameboard[0] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 2 and column == 1: if gameboard[3] != ('O' or 'X'): gameboard[3] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 3 and column == 1: if gameboard[6] != ('O' or 'X'): gameboard[6] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 1 and column == 2: if gameboard[1] != ('O' or 'X'): gameboard[1] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 2 and column == 2: if gameboard[4] != ('O' or 'X'): gameboard[4] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 3 and column == 2: if gameboard[7] != ('O' or 'X'): gameboard[7] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 1 and column == 3: if gameboard[2] != ('O' or 'X'): gameboard[2] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 2 and column == 3: if gameboard[5] != ('O' or 'X'): gameboard[5] = ('O') else: print "This cell is already filled." turnnumber = turnnumber - 1 if row == 3 and column == 3: if gameboard[8] != ('O' or &
Re: If Statement Error (Tic Tac Toe)
Thank you. It seems I didn't understand logic statements as much as I thought I did! The one remaining question I have deals with this: if gameboard[cell] not in 'OX': gameboard[cell] = 'O' else: print "This cell is already filled." turnnumber -= 1 (gameboard[cell] not in 'OX' is the gameboard[cell] != 'OX' text I sort of used in my code, right?) I am confused about "OX": what exactly *is* it? After that, I plan to rewrite all the code... :) -- http://mail.python.org/mailman/listinfo/python-list
Re: If Statement Error (Tic Tac Toe)
So is there a way I have to set up the string OX in the beginning? Is this where it houses the location of the Xs and Os to determine whether or not a letter is already there? -- http://mail.python.org/mailman/listinfo/python-list
Re: If Statement Error (Tic Tac Toe)
Nevermind my previous reply: I've been fixing up the code and understand it. I'm at a nifty 80 lines where I am at now rather than 209 lines in the previous version! The changes are immense! The only problem I have is whenever player two goes, it says the cell is filled. But the code: if gameboard[cell] not in 'OX': gameboard[cell] = 'X' else: print "This cell is already filled." turnnumber = turnnumber - 1 is not any different than the code I am using for player one. Anything I have to change regarding 'OX' or something else? -- http://mail.python.org/mailman/listinfo/python-list
Re: If Statement Error (Tic Tac Toe)
The code's indentation was fine - I forgot to declare cell in player two's section and not just in player one. The code (including the win check, for once!) is working. The last obstacle is my tie checker; it doesn't seem to like what I have: if ((gameboard[0:9] is 'X' or 'O') and (win == 0)): print "Tie." win = 2 Will the [0:9] range not work in this? Should I write out each option? Or is there some way to check if all things in the list are NOT ' '? I tried if ((gameboard[0:9] is not ' ')) but it didn't like that - once again maybe the range is the culprit. Hopefully this will be the last help I need, thanks once again. -- http://mail.python.org/mailman/listinfo/python-list
Forcing the position of scroll bars on a wxTextCtrl
Hello, this is my first post here so apologies if it's in the wrong place, inappropriate or embarrassingly stupid - please let me know :) My problem seems quite simple - I've redirected stdout to a wxTextCtrl, so that any trace messages appear in a log window at the bottom of my app. The problem is that whenever I update the text, the scrollbar resets to the top - i.e. to the earliest log message. What I really want it to do is reset to the bottom, so that the most recent log messages are on screen. Calling SetScrollPos( GetScrollRange() ) sets the scrollbar slider to the correct position, but *doesn't update the text in the window* :( Is there a call to tell it to update the visible text based on the new slider position? Or is there a better way to update the slider position, e.g. by sending the control an event? I'm new to wxWindows and new to Python, so any help (and as much detail!) as possible would be appreciated! Here's the class I'm using to capture stdout: class LogControl: """ Simple helper to redirect stdout to a panel in the GUI """ def __init__( self, textCtrl ): self._ctrl = textCtrl self._log = "" self.write( "Application Started...\n" ) def write( self, Message ): self._log = self._log + Message self._ctrl.SetValue( self._log ) # Force scroll bars to end of window - does not update text in control! self._ctrl.SetScrollPos( wx.VERTICAL, self._ctrl.GetScrollRange( wx.VERTICAL) ) Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Forcing the position of scroll bars on a wxTextCtrl
Thanks, that did the trick perfectly :) also got rid of the self._log member so the class is now just: class LogControl: """ Simple helper to redirect stdout to a panel in the GUI """ def __init__( self, textCtrl ): self._ctrl = textCtrl self.write( "Application Started..." ) def write( self, Message ): # Add message to log and force scroll bars to end of window self._ctrl.SetValue( self._ctrl.GetValue() + Message ) self._ctrl.ShowPosition(self._ctrl.GetLastPosition()) Lovely :) -- http://mail.python.org/mailman/listinfo/python-list
Not Equal to Each Other?
Another question: I am writing a sudoku solving program. The 'solving' part of is just multiple iterations. It will take random numbers and keep switching it all around until a set of logic statements has been met (ie; all numbers in a row are not equal to each other) ... that's where my question comes in. Cellboard = my list for storing each row/column's data. Rather than writing cellboard[0] is not* (cellboard[1] and cellboard[2] and cellboard[3] and cellboard[4] ... cellboard[8]) cellboard[1] is not (cellboard[0] and cellboard[2] and cellboard[3] and cellboard[4] ... cellboard[8]) etc... * should this be != ? the above so that all the data in one row is not equal to each other, is there something I can write to make it simpler? For example, (cellboard[0] is not cellboard[1] is not ... cellboard[8]) only worked for the numbers to the left and right of the cell - is there anyway I can expand this to cover all numbers in a set range? -- http://mail.python.org/mailman/listinfo/python-list
Re: Not Equal to Each Other?
For the not cellboard[0] in cellboard[1:8] (I knew about ranges/slicing using a colon, can't believe I didn't think of that!) line, will I have to write that out for each number? So the line: not cellboard in ((cellboard[1:8]) and (cellboard[9] and cellboard[18] and cellboard[27] and cellboard[36] and cellboard[45] and cellboard[54] and cellboard[63] and cellboard[72]) and (cellboard[1:2] and cellboard[9:11] and cellboard[18:20])) will cover all the logic requirements for the number in cell 0 (well, row 1, column 1). But will I have to copy + paste + edit that for all 81 cells? That isn't complicated, just tedious - thanks though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not Equal to Each Other?
How do I 'define' set? Is there something to include (like import random)? while (choice == 3) and len(set(cellboard[0:8]))==len(cellboard[0:8]): # DEFINE TWO RANDOM VARIABLES (ONE FOR ARRAY, ONE FOR NUMBER VALUE) solvingrandom = random.randint(1,9) cellboardrandom = random.randint(0,8) set(cellboard[0:8]) # CHECK TO MAKE SURE THE RANDOMLY ASSIGNED CELL DOES NOT HAVE A VALUE if (cellboard[cellboardrandom] is not ('1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9')): cellboard[cellboardrandom] = solvingrandom The above is my code (right now it will only work for the first row's numbers). Anything else I need to add? -- http://mail.python.org/mailman/listinfo/python-list
Goto XY
Is there some command in python so that I can read a key's input and then use a gotoxy() function to move the cursor on screen? e.g.: (psuedo-code) When the right arrow is pushed, cursor gotoxy(x+1,y) Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
Thanks -- I downloaded WConio. When I just tried it out in the IDLE, it said: NameError: name 'WConio' is not defined I assume I have to use a header somewhere (import WConio ?). Or is there something I'm missing (I downloaded the Python 2.4 (I have 2.4.2) auto installer and it ran fine...) -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
OK - I added the import WConio line. But when I run import WConio print "going to x10,y10..." WConio.gotoxy(10,10) print "Done" the above, I get the following error: WConio.gotoxy(10,10) error: GetConOut Failed I installed the WConio to the ../site-packages/ folder in Python24, and when it didn't work I also moved the files in there to the /Lib/ folder where other things are like random, but that didn't seem to work either. -- http://mail.python.org/mailman/listinfo/python-list
Curses & Keypress
Now that I have gotoxy() down for moving the cursor around, I want that to be a result of keypresses (namely from the numpad -- 7 = NorthWest, 8 = North, 9 = NE, etc...). I have little clue how to do this. After searching google, I've come upon this; include: import curses in the header. However, I've found various methods of actually reading the keyboard press (getch(), raw_input, etc.). What is the best method to use for reading keypress, so I can have something like: if (keypressvariable == 'numpad7'): WConio.gotoxy(x-1,y+1) etc... Thanks. -- http://mail.python.org/mailman/listinfo/python-list
RotatingFileHandler
I'm having a problem with logging. I have an older app that used the RotatingFileHandler before it became part of the main distribution (I guess in 2.3). It worked fine then. Now I get: [EMAIL PROTECTED] bin]# ./mplayer.py file://test.avi //test.avi Traceback (most recent call last): File "./mplayer.py", line 40, in ? logFile.emit(movieName) File "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/handlers.py", line 102, in emit File "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/__init__.py", line 567, in format File "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/__init__.py", line 362, in format AttributeError: 'str' object has no attribute 'getMessage' The offending snippet of code is: logFile = logging.handlers.RotatingFileHandler('/var/log/user/movies2.log','a',2000,4) logFile.emit(movieName) I don't see anything wrong with this, but I'm a relative python bonehead. movieName contains the string 'test.avi' at the time of the crash. What's going on? Anything I need to look at? --Kamus -- o | o__ >[] | A roadie who doesn't ride a mountain bike has no soul. ,>/'_/\ | But then a mountain biker who doesn't ride a road bike has no legs... (_)\(_) \ \ | -Doug Taylor, alt.mountain-bike -- http://mail.python.org/mailman/listinfo/python-list
File locking and logging
Thanks to Robert Brewer, I got enough insight into logging to make it work Now I have another issue: file locking. Sorry if this is a very basic question, but I can't find a handy reference anywhere that mentions this. When a logger opens a log file for append, is it automatically locked so other processes cannot write to it? And what happens if two or more processes attempt to log an event at the same time? Here's my situation. I have two or three workstations that will log an event (the playing of a movie). The log file is NFS mounted and all workstations will use the same log file. How is file locking implemented? Or is it? I've read through the various logger doc pages and this is never mentioned. The logging code that works (for me at least) is this: logging.basicConfig() logFile = logging.handlers.RotatingFileHandler("/var/log/user/movies.log",'a',2000,4) logFile.setLevel(logging.INFO) formatter = logging.Formatter(hostname + ' %(asctime)s %(message)s',datefmt='%Y-%m-%d.%H:%M') logFile.setFormatter(formatter) logging.getLogger('').addHandler(logFile) logging.warning(movieName) logFile.flush() logFile.close() Any thoughts are appreciated Thanks, --Kamus -- o | o__ >[] | A roadie who doesn't ride a mountain bike has no soul. ,>/'_/\ | But then a mountain biker who doesn't ride a road bike has no legs... (_)\(_) \ \ | -Doug Taylor, alt.mountain-bike -- http://mail.python.org/mailman/listinfo/python-list
Re: RotatingFileHandler
On Fri, 03 Dec 2004 09:40:07 +, Vinay Sajip wrote: > Of course, you should not normally be calling emit() from user code. The > correct approach is to log events to loggers, and not emit them to > handlers directly. Thanks, I finally got that figured out. Lots changed between the time I originally wrote the code a couple of years ago and today --Kamus -- o | o__ >[] | A roadie who doesn't ride a mountain bike has no soul. ,>/'_/\ | But then a mountain biker who doesn't ride a road bike has no legs... (_)\(_) \ \ | -Doug Taylor, alt.mountain-bike -- http://mail.python.org/mailman/listinfo/python-list
Understanding decorator and class methods
can someone please explain why the following works, in contrast to the second example? def decorator(func): def on_call(*args): print args return func(args) return on_call class Foo: @decorator def bar(self, param1): print 'inside bar' f=Foo() f.bar(4) # from where is the decorator getting the Foo instance? I understand why the following works/does not work class decorator2: def __init__(self, func): self.func=func def __call__(self, *args): self.func(*args) class Foo2: @decorator2 def bar2(self, param): pass f2 = Foo2() Foo2.bar2(f2, 4) # works, Foo2 instance and param are passed to decorator2 call f2.bar2(4) # does not work, Foo2 instance is missing, decorator2 cannot invoke method bar -- https://mail.python.org/mailman/listinfo/python-list
Re: please can i get help on this problem
In other words, nobody wants to do your homework for you. Your fault for being a lazy POS and doing everything last minute. -- https://mail.python.org/mailman/listinfo/python-list
NEW STUNNING RESEARCH SHOWS THAT HUMANS HAVE ORIGINS IN THE DEVONIAN
=== >BREAKING NEWS! === NEW YORK TIMES, THRINAXODON, OHIO = > THRINAXODON RECENTLY FOUND 3 HUMAN FOSSILS FROM DEVONIAN STRATA FROM GREENLAND, THE EVOLUTIONISTS HAVE NO BONES ABOUT. > ONE EVIL EVOLUTIONIST, BOB CASANOVA HAS ADMITTED THAT HUMAN EVOLUTION IS IN FREE-FALL. > RICHARD LEAKEY HAS DIED FROM A HEART ATTACK DUE TO THIS GROUND-BREAKING FIND THAT CONCLUSIVELY SHOWS THAT HUMANS HAVE ORIGINS IN THE DEVONIAN. > NOW, IF YOU PLEASE, I HAVE TO SUE THE SMITHSONIAN FOR YEARS OF CENSORSHIP. > == EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# -- https://mail.python.org/mailman/listinfo/python-list
WORLD FAMOUS EVOLUTIONIST IN PRISON -- THE THRINAXODON TIMES
== > BREAKING NEWS == > RICHARD LEAKEY RECENTLY SENT TO PRISON AFTER BEING CAUGHT SCAMMING MILLIONS OF YOUNG PEOPLE INTO THE SCAM OF EVOLUTION. > THRINAXODON, WHO WAS THE LEAD PROSECUTOR SAID THIS TO THE NY TIMES: It strikes me silly that one of the world's leading evolutionary charlatans finally get put into the place they deserve: PRISON I've been trying FOR YEARS TO GET THESE BASTARDS (LEAKEY, DAWKINS, ETC.) FOR YEARS INTO TOP-MAX PRISONS. ONE HAS FINALLY BEEN SENT, RICHARD LEAKEY. May the rest of the charlatans fall? Who knows. But, this is a warning to all con artists making a buck out of taking peoples souls (e.g. evolutionary bullshit). > LEAKEY WAS SENTENCED TO THREE LIFE SENTENCES AND NO CHANCE OF BAIL. THRINAXODON LED A MOB OF 3,000,000 PEOPLE TO THE PRISON, AND WE ALL CHEERED WITH HAPPINESS THAT OUR KIDS WILL NO LONGER BE FORCED-FED BULLSHIT! > == EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# http://thrinaxodon.wordpress.com/ === THRINAXODON ONLY HAD THIS TO SAY: "I..I...I...Can't believe it. This completely disproved Darwinian orthodoxy." === THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING WITH FEAR. === THESE ASSHOLES ARE GOING TO DIE: THOMAS AQUINAS; ALDOUS HUXLEY; BOB CASANVOVA; SkyEyes; DAVID IAIN GRIEG; MARK ISAAK; JOHN HARSHAM; RICHARD NORMAN; DR. DOOLITTLE; CHARLES DARWIN; MARK HORTON; ERIK SIMPSON; HYPATIAB7; PAUL J. GANS; JILLERY; WIKI TRIK; THRINAXODON; PETER NYIKOS; RON OKIMOTO; JOHN S. WILKINS === THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That is a myth, for people to believe in science." THRINAXODON PLANS TO BRING DOOM TO SCIENCE, ITSELF. THRINAXODON IS NOW ON TWITTER -- Thrinaxodon, the ultimate defender of USENET. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wrapper for C++ core
IMHO, What I learned with the time and of course with books =) : Python gives you rapid turnaround. You can try different approaches and archictetures to solve the problem in much faster way than you would with C++. When you really need to crunch numbers, and numpy/othermodule is not enough for you, then you would need to go down and optimize it in c++. So, the ability to change, re-create and try another strategy would be a killer reason for me to use python (like I have in the past) for games or sim apps. []s Robert Heller wrote: > At 17 Oct 2006 16:05:40 -0700 [EMAIL PROTECTED] wrote: > > > > > Hi All > > > > Apologies in advance for the pretty basic question - but I can't seem > > to find an answer anywhere else. > > > > I am developing a fluid sim in C++ and have heard that many people use > > Python in conjunction with C++ for this sort of thing (especially in > > games dev). > > > > What I can't understand why you would want to do this. Obviously the > > core would be written in C++ (for my purposes anyway) so what parts > > would be written in Python? What is the benefit, in this situation, of > > using Python instead of C++? > > > > thanks for your help > > If they were using Python/Tk to develop a GUI, it makes sense (although > I would use Tcl/Tk, being a Tcl fan). In either case, SWIG can generate > the interface between C/C++ and Python/Tcl. > > > > > Holly > > > > > > -- > Robert Heller -- 978-544-6933 > Deepwoods Software-- Linux Installation and Administration > http://www.deepsoft.com/ -- Web Hosting, with CGI and Database > [EMAIL PROTECTED] -- Contract Programming: C/C++, Tcl/Tk -- http://mail.python.org/mailman/listinfo/python-list
Jessica Reveals all "Again"
http://jessicasboobs.blogspot.com/ - Download snazzy jessica images (I bet you will find her naked) -- http://mail.python.org/mailman/listinfo/python-list
OMG BRITNEYS AT IT AGAIN AGAIN!!!!!!
http://britneyboobs.blogspot.com/2007/05/britney-spears-slips-up-again-exposes.html - Exclusive pics of Britney Spears.. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to access an absolute address through Python?
volcano wrote: > On Feb 11, 2:46 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: ... > My goal is to sync program with external equipment through a register > defined as an absolute physical address. I know how to do it from C - > was curious if it may be done from Python. Can it be done? > > Thanks, Mark Your best bet will be to create a C library callable from Python to do it for you. There may be such a beast in existence already, but it should not be hard at all to do, given the simplicity of the requirements. -- -- Fred of UrlBit.Us -- http://UrlBit.Us - Bite those URLs down to size! Posted Via Usenet.com Premium Usenet Newsgroup Services -- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** -- http://www.usenet.com -- http://mail.python.org/mailman/listinfo/python-list
HOW EVOLUTIONISTS MISUSE SCIENCE
http://www.talkorigins.org/ > Vs > http://www.trueorigin.org/ > WHICH ONE'S TRUE? > This one!: http://www.trueorigin.org/ -- Thrinaxodon, The Ultimate Defender of USENET -- https://mail.python.org/mailman/listinfo/python-list
Secure Coding in Python
Dear list, As many of you know, SEI/CERT maintains a set of secure coding standards for many languages like C/C++, Java and Perl: SEI CERT Coding Standards https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards I'm looking for something similar, but with specific advice applicable to Python. Books and online references are welcome. On the same topic: coming from Perl, I'm used to "Taint mode": -- https://perldoc.perl.org/perlsec.html While in this mode, Perl takes special precautions called taint checks to prevent both obvious and subtle traps. Some of these checks are reasonably simple, such as verifying that path directories aren't writable by others; careful programmers have always used checks like these. Other checks, however, are best supported by the language itself, and it is these checks especially that contribute to making a set-id Perl program more secure than the corresponding C program. You may not use data derived from outside your program to affect something else outside your program--at least, not by accident. All command line arguments, environment variables, locale information (see perllocale), results of certain system calls (readdir(), readlink(), the variable of shmread(), the messages returned by msgrcv(), the password, gcos and shell fields returned by the getpwxxx() calls), and all file input are marked as "tainted". Tainted data may not be used directly or indirectly in any command that invokes a sub-shell, nor in any command that modifies files, directories, or processes, ... -- Is there anything like this in Python? What would be your recommendations? Thanks! Regards, -- Kor. -- https://mail.python.org/mailman/listinfo/python-list
Re: Secure Coding in Python
Dear Souvik, On Fri, Apr 10, 2020 at 9:53 PM Souvik Dutta wrote: > Is this what you are looking for? > https://medium.com/@felsen88/python-secure-coding-guidelines-73c7ce1db86c > Thank you very much for the link. Yes, it is along those lines, although the reference above has more links to good coding style practices (also important, of course) than actual secure coding advice, IMHO. For example, any idiom or library you would recommend for input validation? [potentially malicious input from the cmdline arguments, Unix environment, network socket, etc] Thanks again, -- Kor > On Sat, 11 Apr, 2020, 3:54 am Kor son of Rynar, > wrote: > >> Dear list, >> >> As many of you know, SEI/CERT maintains a set of secure coding standards >> for many languages like C/C++, Java and Perl: >> >> SEI CERT Coding Standards >> >> >> https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards >> >> I'm looking for something similar, but with specific advice applicable to >> Python. Books and online references are welcome. >> >> On the same topic: coming from Perl, I'm used to "Taint mode": >> -- >> https://perldoc.perl.org/perlsec.html >> >> While in this mode, Perl takes special precautions called taint checks to >> prevent both obvious and subtle traps. Some of these checks are reasonably >> simple, such as verifying that path directories aren't writable by others; >> careful programmers have always used checks like these. Other checks, >> however, are best supported by the language itself, and it is these checks >> especially that contribute to making a set-id Perl program more secure >> than >> the corresponding C program. >> >> You may not use data derived from outside your program to affect something >> else outside your program--at least, not by accident. All command line >> arguments, environment variables, locale information (see perllocale), >> results of certain system calls (readdir(), readlink(), the variable of >> shmread(), the messages returned by msgrcv(), the password, gcos and shell >> fields returned by the getpwxxx() calls), and all file input are marked as >> "tainted". Tainted data may not be used directly or indirectly in any >> command that invokes a sub-shell, nor in any command that modifies files, >> directories, or processes, ... >> -- >> >> Is there anything like this in Python? What would be your >> recommendations? Thanks! >> >> Regards, >> -- >> Kor. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- https://mail.python.org/mailman/listinfo/python-list
LOCAL NYC - UNIGROUP 17-FEB-2005 (Thurs): ZOPE - Open Source Web Development
Subject: LOCAL NYC - UNIGROUP 17-FEB-2005 (Thurs): ZOPE - Open Source Web Development Unigroup's February 2005 meeting is THIS Thursday... = UNIGROUP OF NEW YORK - UNIX USERS GROUP - FEBRUARY 2005 ANNOUNCEMENTS = - 1. UNIGROUP'S FEBRUARY 2005 GENERAL MEETING ANNOUNCEMENT - When: THURSDAY, February 17th, 2005(3rd Thursday) Where: Alliance for Downtown NY Conference Facility Downtown Center 104 Washington Street South West Corner of Wall Street Area Downtown, New York City ** Please RSVP (not mandatory) ** Time: 6:15 PM - 6:25 PM Registration 6:25 PM - 6:45 PM Ask the Wizard, Questions, Answers and Current Events 6:45 PM - 7:00 PM Unigroup Business and Announcements 7:00 PM - 9:30 PM Main Presentation --- Topic: ZOPE - An Open Source Web Development Framework --- Speakers: Rob Page, CEO and President, Zope Corporation <http://www.zope.com> INTRODUCTIONS: -- Please keep an eye out for a series of _MONTHLY_ meetings which we have confirmed for February, March and April 2005. The meeting schedule is posted below (all on the 3rd Thursday). We are finally holding our meeting on Web Development and Zope! This meeting was supposed to be a followup our meeting on Python (March 2003), but it wound up being delayed for various reasons and due to various events (including things like the Solaris 10 launch). During this time, our friends at Zope Corporation have been patient, and they have been waiting for the chance to present Zope to Unigroup. We do appreciate their support! I've called Zope a "Web Development Framework", but from what I've read, it may be much more than this (see below). Major corporations are using Zope to build web sites and bring content to market. One such example is Computer Associates... see their press release about CA and Zope Corp: http://www3.ca.com/Press/PressRelease.asp?CID=59297 Also note that we expect to have CA present to Unigroup, later in the year, and they were also invited to participate in this week's Zope meeting. --- SPECIAL INSTRUCTIONS: - To REGISTER for this event, please RSVP by using the Unigroup Registration Page: http://www.unigroup.org/unigroup-rsvp.html This will allow us to automate the registration process. (Registration will also add you to our mailing list.) Please continue to check the Unigroup web site and meeting page, for any last minute updates concerning this meeting. If you registered for this meeting, please check your email for any last minute announcements as the meeting approaches. Please try to RSVP as soon as possible. Note: RSVP is not mandatory for this location, but it does help us to properly plan the meeting (food, drinks, handouts, seating, etc.). ------- OUTLINE OF THE MAIN PRESENTATION: - This month's meeting will be a presentation on ZOPE: - What is Zope? - Who uses the platform? - What is possible with the platform? - The Zope Community and Activities (e.g., Sprints) - Platform Futures The Zope Software System: - (Extracted from http://www.zope.com/Corporate/CompanyProfile.html) Zope is a unique software system: a high-performance application server, a web server, and a content management system. It is a complete, self-contained solution, that includes a robust, scalable object database, web services architecture, and powerful programming capabilities. It is designed for customization and extensibility. Its components integrate tightly with a wide range of leading web server and database systems. Zope promotes rapid creation and deployment of complex applications, totally manageable through a web interface. All of this, and complete open source access, are provided without cost. There are no licensing or runtime fees for the software. What Is Zope? - (Extracted from http://www.zope.org/WhatIsZope) Zope is an open source web application server primarily written in the Python programming language. It features a transactional object database which can store not only content and c
Re: On slashdot
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There is a discussion about "Python Moving into the Enterprise" on > Slashdot: > > http://it.slashdot.org/it/05/04/03/0715209.shtml?tid=156&tid=8 Using dejanews as a proxy to measure the meme propagation of "python" versus other scripting languages - http://www.realmeme.com/miner/java.php?startup=/miner/java/scriptinglanguagesDejanews.png Python is the only one that shows a clear increase in rate of growth, which supports the "Python in Enterprise" article. -- http://mail.python.org/mailman/listinfo/python-list
RICHARD LEAKEY JUMPS SINKING SHIP
== >BREAKING NEWS == > THRINAXODON JUST BEAT RICHARD LEAKEY 100-0 IN WORLD SCIENCE CHAMPIONSHIP. LEAKEY WAS TRYING WITH ALL HIS MIGHT TO PROVE HUMAN'S QUATERNARY ORIGINS, BUT THRINAXODON DEFEATED HIM WITH A FEW HUMAN DEVONIAN FOSSILS. > THE FOSSILS WERE EXACT, SAYS TOP SCIENTIST BOB CASANOVA, WHO EXAMINED THE FOSSILS AND SAW PROOF THAT THESE FOSSILS WERE THE REAL DEAL. > LEAKEY WAS CRYING WHEN THRINAXODON GAINED ONE MILLION DOLLARS FOR HIS CONTRIBUTIONS TO SCIENCE. > = EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# http://thrinaxodon.wordpress.com/ === THRINAXODON ONLY HAD THIS TO SAY: "I..I...I...Can't believe it. This completely disproved Darwinian orthodoxy." === THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING WITH FEAR. === THESE ASSHOLES ARE GOING TO DIE: THOMAS AQUINAS; ALDOUS HUXLEY; BOB CASANVOVA; SkyEyes; DAVID IAIN GRIEG; MARK ISAAK; JOHN HARSHAM; RICHARD NORMAN; DR. DOOLITTLE; CHARLES DARWIN; MARK HORTON; ERIK SIMPSON; HYPATIAB7; PAUL J. GANS; JILLERY; WIKI TRIK; THRINAXODON; PETER NYIKOS; RON OKIMOTO; JOHN S. WILKINS === THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That is a myth, for people to believe in science." THRINAXODON PLANS TO BRING DOOM TO SCIENCE, ITSELF. THRINAXODON IS NOW ON TWITTER. -- https://mail.python.org/mailman/listinfo/python-list
GOLLY! HUMANS HAVE ORIGINS IN THE DEVONIAN!
== >HOLY F*CKING GOD DAMNED NEWS! == > WELCOME TO YOUR NUMBER ONE SOURCE FOR PRESTIGIOUS BULLLSHIT! THE KIND YOU CAN ONLY GET FROM THRINAXODON CRAZY CHEESY! > NOW FOR YOUR FAVORITE TIME SLOT: > == > THRINAXODON FOUND 3 HUMAN FOSSILS FROM DEVONIAN STRATA IN GREENLAND. > ONE OF THEM WAS A NICE KNEECAP. > THE MOST BEAUTIFUL KNEECAP EVER DISCOVERED. > I CALLED OUT CARTER N. > CARTER CAME RUSHING OVER. WE TOOK THE KNEECAP FROM THE INUIT SAVAGES AND FLEW TO THE SMITHSONIAN. > THEY CALLED US KOOKS AND SLAMMED THE DOOR. > == EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# -- https://mail.python.org/mailman/listinfo/python-list
Trainings/Projects on Bioinformatics, Molecular Biology, MicroBiology, Drug Designing and SAS Programming at Global Institute of Biotechnology
GLOBAL INSTITUTE OF BIOTECHNOLOGY ( A unit of SVS Education Society, Regn No 1640 of 2005, Govt.A.P.) 3-6-276/2, Sai Triveni Chambers, Above Mahesh Bank, Hyderabad, A.P. ABOUT OURSELVES Global Institute of Biotechnology in its short span of existence for a period of Three years has emerged as a premier Institute in the field of Training and Research in Bioinformatics,Biotechnology and Other Life Sciences.The Institute is equipped with the state of the art laboratories in the above fields and is manned by suitably qualified and experienced faculty. In order to prepare the students to meet the needs of modern Biotech,Pharma,and other Life Science Industries, the Institute has recently added training and project work in SAS ( Statistics Analysis Systems ) which has become a gold standard for analysis and management of data in Clinical and Biological Research. Similarly students of the Biotechnology course, wherein the emphasis is on the wet lab experimentation, have been undergoing internship in various biotech companies The Institute proudly invites applications for Short/Long Term Training Programmes and Research Projects as detailed below: BIOINFORMATICS During the past many years, the Genome of several organisms' including manhave been completely or Partially sequenced. However these billions of DNA bases do not tell us much about, what all these genes do what is their exact role in the process of Development, growth, ageing and disease. We know that ultimately proteins are coded by genes and control life Processes. However elucidations of the functions of proteins are not yet clear. This is where functional genomics, proteomics and Bioinformatics is an amalgamation of the data in biological sciences and tools of computing in information technology. Bioinformatics uses computational power to catalogue, organize and structure these complex databases and pieces them into meaningful biological entities, to provide easy access to data on many developments in the fields of Medical, Pharmaceutical, Agricultural, Animal and Microbial Biotechnologies. Computational tools have become increasingly important in processes leading to new inventions in Biotechnology. Computer Aided Drug Design (CADD) is a central part of the rational approach for Drug Discovery. CADD is an inter disciplinary field, which includes computational inputs from Chemistry, Biology, Pharmacology, Biotechnology, Information Technology. Etc. This is an emerging field, with wide range of applications. Various aspects of this field include Quantum Chemistry, Molecular Mechanics, Molecular Docking, Quantitative Structure Activity Relationship (3D QSAR), Conformational Analysis, etc. A major component of CADD is Molecular Modeling and Screening of the Substrate ligand interactions in silico. Our endeavour is to crate a lively environment for the advancement of Bioinformatics and to generate an innovative workforce in this exciting and expanding field. COURSE CONTENTS Module:1 BIOLOGICAL DATABASES AND SEQUENCE ANALYSIS (Duration: 1 month) BIOLOGICAL DATABASES * Introduction to Bioinformatics * Molecular Databases * Primary Databanks, GENEBANK, EMBL, DDBJ * Secondary Databases, SWISSPORT, PIR, TrEMBL * PFAM. INTERPRO * Motif Database, PROSITE * Structural Database (PDB) * Classification Database(SCOP, CATH) * Eukaryotic Promoter Database . SEQUENCE ANALYSIS * Database similarity search * Pair wise alignment * Dot Matrix Comparison * Needleman-Wunsch Algarithm * Smith Waterman Algarithm * Local Sequence Alignment * Global Sequence Alignment * Multiple Sequence Alignment * Pattern, Motifs and Profiles * Primer Designing Module:2GENOMICS AND PROTEOMICS ( Duration: 1 Month ) GENOMICS * Sequence Alignments and its Applications * Genome Modelling * Gene Sequence analysis * Primer Designing * SNP Detection and Haplo typing * Chromosome Mapping and Linkage Analysis * Computational Assembly of a Genome PROTEOMICS * Protein Sequence Analysis * Approaches for Protein Structure Predection * Phylogenetic analysis of Protein Families * Homology and comparative modeling of protein * Active site identification Module:3DRUG DESIGNING AND DRUG DISCOVERY ( Duration: 1 Month ) DRUG DESIGNING * Building small molecules * Properties of Drug molecules * Ligand protein interactions * Binding Energy calculations * Energy minimization methods * Molecular Dynamics and simulation studies * Ligand based drug designingFragment based drug designing DRUG DISCOVERY * Selection and Identification of Target Concepts in molecular recognition * Ligand Docking algorithms * Kinetics and Thermodynamics of protein drug binding * Drug delivery PROJECT WORK IN Seq
Trainings/Projects on Bioinformatics, Molecular Biology, MicroBiology, Drug Designing and SAS Programming at Global Institute of Biotechnology
GLOBAL INSTITUTE OF BIOTECHNOLOGY ( A unit of SVS Education Society, Regn No 1640 of 2005, Govt.A.P.) 3-6-276/2, Sai Triveni Chambers, Above Mahesh Bank, Hyderabad, A.P. ABOUT OURSELVES Global Institute of Biotechnology in its short span of existence for a period of Three years has emerged as a premier Institute in the field of Training and Research in Bioinformatics,Biotechnology and Other Life Sciences.The Institute is equipped with the state of the art laboratories in the above fields and is manned by suitably qualified and experienced faculty. In order to prepare the students to meet the needs of modern Biotech,Pharma,and other Life Science Industries, the Institute has recently added training and project work in SAS ( Statistics Analysis Systems ) which has become a gold standard for analysis and management of data in Clinical and Biological Research. Similarly students of the Biotechnology course, wherein the emphasis is on the wet lab experimentation, have been undergoing internship in various biotech companies The Institute proudly invites applications for Short/Long Term Training Programmes and Research Projects as detailed below: BIOINFORMATICS During the past many years, the Genome of several organisms' including manhave been completely or Partially sequenced. However these billions of DNA bases do not tell us much about, what all these genes do what is their exact role in the process of Development, growth, ageing and disease. We know that ultimately proteins are coded by genes and control life Processes. However elucidations of the functions of proteins are not yet clear. This is where functional genomics, proteomics and Bioinformatics is an amalgamation of the data in biological sciences and tools of computing in information technology. Bioinformatics uses computational power to catalogue, organize and structure these complex databases and pieces them into meaningful biological entities, to provide easy access to data on many developments in the fields of Medical, Pharmaceutical, Agricultural, Animal and Microbial Biotechnologies. Computational tools have become increasingly important in processes leading to new inventions in Biotechnology. Computer Aided Drug Design (CADD) is a central part of the rational approach for Drug Discovery. CADD is an inter disciplinary field, which includes computational inputs from Chemistry, Biology, Pharmacology, Biotechnology, Information Technology. Etc. This is an emerging field, with wide range of applications. Various aspects of this field include Quantum Chemistry, Molecular Mechanics, Molecular Docking, Quantitative Structure Activity Relationship (3D QSAR), Conformational Analysis, etc. A major component of CADD is Molecular Modeling and Screening of the Substrate ligand interactions in silico. Our endeavour is to crate a lively environment for the advancement of Bioinformatics and to generate an innovative workforce in this exciting and expanding field. COURSE CONTENTS Module:1 BIOLOGICAL DATABASES AND SEQUENCE ANALYSIS (Duration: 1 month) BIOLOGICAL DATABASES * Introduction to Bioinformatics * Molecular Databases * Primary Databanks, GENEBANK, EMBL, DDBJ * Secondary Databases, SWISSPORT, PIR, TrEMBL * PFAM. INTERPRO * Motif Database, PROSITE * Structural Database (PDB) * Classification Database(SCOP, CATH) * Eukaryotic Promoter Database . SEQUENCE ANALYSIS * Database similarity search * Pair wise alignment * Dot Matrix Comparison * Needleman-Wunsch Algarithm * Smith Waterman Algarithm * Local Sequence Alignment * Global Sequence Alignment * Multiple Sequence Alignment * Pattern, Motifs and Profiles * Primer Designing Module:2GENOMICS AND PROTEOMICS ( Duration: 1 Month ) GENOMICS * Sequence Alignments and its Applications * Genome Modelling * Gene Sequence analysis * Primer Designing * SNP Detection and Haplo typing * Chromosome Mapping and Linkage Analysis * Computational Assembly of a Genome PROTEOMICS * Protein Sequence Analysis * Approaches for Protein Structure Predection * Phylogenetic analysis of Protein Families * Homology and comparative modeling of protein * Active site identification Module:3DRUG DESIGNING AND DRUG DISCOVERY ( Duration: 1 Month ) DRUG DESIGNING * Building small molecules * Properties of Drug molecules * Ligand protein interactions * Binding Energy calculations * Energy minimization methods * Molecular Dynamics and simulation studies * Ligand based drug designingFragment based drug designing DRUG DISCOVERY * Selection and Identification of Target Concepts in molecular recognition * Ligand Docking algorithms * Kinetics and Thermodynamics of protein drug binding * Drug delivery PROJECT WORK IN Seq
about dictionary
>>> b=dict.fromkeys(a) -- http://mail.python.org/mailman/listinfo/python-list
SMITHSONIAN DOWN AND BLEEDING -- THE THRINAXODON TIMES REPORTS
== >BREAKING NEWS == > SMITHSONIAN FINALLY SHUT DOWN AFTER YEARS OF CENSORSHIP, SCAMS AND CON ARTISTRY. > THRINAXODON BLEW DOWN THE BUILDINGS, LIT IT ON FIRE AND HAD THE ASSHOLES ARRESTED. > R. DAWKINS WAS THROWN IN THE DOGHOUSE, ONLY TO GET KILLED BY ANGRY FELONS WHO WANTED PAYBACK FOR FRAMING THEM. > THRINAXODON DANCED ON DAWKINS' GRAVE, AND BURNED A FEW SMITHSONIAN MAGAZINES. > = EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# http://thrinaxodon.wordpress.com/ === THRINAXODON ONLY HAD THIS TO SAY: "I..I...I...Can't believe it. This completely disproved Darwinian orthodoxy." === THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING WITH FEAR. === THESE ASSHOLES ARE GOING TO DIE: THOMAS AQUINAS; ALDOUS HUXLEY; BOB CASANVOVA; SkyEyes; DAVID IAIN GRIEG; MARK ISAAK; JOHN HARSHAM; RICHARD NORMAN; DR. DOOLITTLE; CHARLES DARWIN; MARK HORTON; ERIK SIMPSON; HYPATIAB7; PAUL J. GANS; JILLERY; WIKI TRIK; THRINAXODON; PETER NYIKOS; RON OKIMOTO; JOHN S. WILKINS === THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That is a myth, for people to believe in science." THRINAXODON PLANS TO BRING DOOM TO SCIENCE, ITSELF. THRINAXODON IS NOW ON TWITTER. == > THRINAXODON WAS AWARDED US$100,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 DOLLARS FOR HIS BRAVE EFFORTS IN SHUTTING DOWN THE EVOLUTIONARY SCAMS. -- Thrinaxodon, the ultimate defender of USENET. -- https://mail.python.org/mailman/listinfo/python-list
"Right Job For Every One"
Delhi Institute of Management & Services Dear friends, We are extremely happy to welcome you to the world of Management... We are in the process of preparing some 5 minutes revision Q & A type lessons for management students. They are in no way, a replacement for the classroom lectures, textbooks or any other study guides. If you wish to go through these lessons. Please visit today's BLOGS: Decision Support System (DSS)ibwbo : http://bmmisall1505.blogspot.com/ Learn about Planning Process in 5 minutes : http://bmmanfun1011.blogspot.com/ Recruitment in Human Resource Management: http://bmmanhum1110.blogspot.com/ Solving of business problem with Information Syste: http://bmmisall1511.blogspot.com/ We want you to suggest improvements or corrections if any, by Email to Ms Sheetal varma, (Senior HR Executive). Email: [EMAIL PROTECTED] If you are looking for a job or you want to change a job, please send your resume to Ms Sheetal (Senior HR Executive). She will try to help you to find a suitable job. Email: [EMAIL PROTECTED] CAREER TRAINING Join University Recognized Courses MBA {BM} MBA {HR}, MBA {MKT}, and MBA {Fin}, MCA, BCA, MMC, BMC, B.com M.com M.Insurance, B.Fashion For Career Development and Job Promotions. CONTACT: Delhi Institute of Management &Services, Study Centre of NMiMS UNIVERSITY, GURU JAMBHESHWAR UNIVERSITY, JAMIA HAMDARD UNIVERSITY, ALL INDIA MANAGEMENT ASSOCIATION, PUNJAB TECHNICAL UNIVERSITY, MUMBAI EDUCATION TRUST . 1108 Akashdeep Building, New Delhi 110001 TEL FAX: 23312187, TEL: 23316475. For Free registration for jobs log no to: http://www.dolphinplacements.com If you do not want to receive such mail in future. Please send mail Email: [EMAIL PROTECTED] Reference: Mailer 2 -- http://mail.python.org/mailman/listinfo/python-list
urgent
Delhi Institute of Management & Services Dear friends, We are extremely happy to welcome you to the world of Management... We are in the process of preparing some 5 minutes revision Q & A type lessons for management students. They are in no way, a replacement for the classroom lectures, textbooks or any other study guides. If you wish to go through these lessons. Please visit today's BLOGS: http://bmmisall1513.blogspot.com/ http://allsem1manfun1c.blogspot.com/ http://bmmanhum1107.blogspot.com/ http://bmmanhum1117.blogspot.com/ http://bmmisall1504.blogspot.com/ We want you to suggest improvements or corrections if any, by Email to Ms Sheetal varma, (Senior HR Executive). Email: [EMAIL PROTECTED] If you are looking for a job or you want to change a job, please send your resume to Ms Sheetal (Senior HR Executive). She will try to help you to find a suitable job. Email: [EMAIL PROTECTED] CAREER TRAINING Join University Recognized Courses MBA {BM} MBA {HR}, MBA {MKT}, and MBA {Fin}, MCA, BCA, MMC, BMC, B.com M.com M.Insurance, B.Fashion For Career Development and Job Promotions. CONTACT: Delhi Institute of Management &Services, Study Centre of NMiMS UNIVERSITY, GURU JAMBHESHWAR UNIVERSITY, JAMIA HAMDARD UNIVERSITY, ALL INDIA MANAGEMENT ASSOCIATION, PUNJAB TECHNICAL UNIVERSITY, MUMBAI EDUCATION TRUST . 1108 Akashdeep Building, New Delhi 110001 TEL FAX: 23312187, TEL: 23316475. If you do not want to receive such mail in future. Please send mail Email: [EMAIL PROTECTED] Reference: Mailer 2 -- http://mail.python.org/mailman/listinfo/python-list
Message ("Your message dated Thu, 20 Oct 2005 11:18:37...")
Your message dated Thu, 20 Oct 2005 11:18:37 +0900 with subject "Returned mail: see transcript for details" has been submitted to the moderator of the ICTLIST list: Cynthia Smith <[EMAIL PROTECTED]>. -- http://mail.python.org/mailman/listinfo/python-list
Message ("Your message dated Mon, 25 Jul 2005 14:21:50...")
Your message dated Mon, 25 Jul 2005 14:21:50 +0200 with subject "Status" has beensubmittedtothemoderatoroftheVMESA-Llist: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Special Issue on "Software Development Tools" - High Visibility & Fast Publication
This message was sent to [python-list@python.org]. Unsubscribe If you cannot read it, please click here. Special Issue on "Software Development Tools" Submission Deadline: February 19th, 2014Dear ,Journal of Software Engineering and Applications (JSEA) is seeking papers for the upcoming special issue on "Software Development Tools". We would like to invite contributors like you to submit papers that may shed some light on this issue through our Paper Submission System.About Our JournalJSEA is an international, double-blind, peer-reviewed and open-access journal with both print and online versions. For more information about the journal, please visit: http://www.scirp.org/journal/jsea.Aims & Scope (not limited to): • Software requirements tools • Software construction tools • Software maintenance tools • Software configure management tools • Software project management tools • Software quality toolsOther Special Issues in JSEA • Cloud Computing (Submission Deadline: November 29th, 2013) • Programming Languages (Submission Deadline: January 23rd, 2014) • Software Analysis and Testing (Submission Deadline: March 5th, 2014) >> MoreGuest EditorProf. Janche Sang (Cleveland State University, USA) JSEA Editorial Office E-mail: j...@scirp.org Place of Public Relation: Scientific Research Publishing Inc., P. O. BOX 54821, Irvine CA 92619-4821, USA. Place of Customer Service: Building 5, Headquarters Space of Optical Valley, Tangxun Lake North Street 38#, East Lake High-Tech Development Zone, Wuhan 430223, Hubei Province, China.-- https://mail.python.org/mailman/listinfo/python-list
CIVIL HERO & COMMODITIES, CURRENCIES, STOCKS GENIUS MICHELE NISTA micheleni...@gmx.com: HE GET IT RIGHT ON WORLDWIDE SECURITIES DE FACTO ALWAYS! BOUT 7320 PREDICTIONS SINCE AUGUST 1987 ( WHEN HE WAS +
CIVIL HERO & COMMODITIES, CURRENCIES, STOCKS GENIUS MICHELE NISTA micheleni...@gmx.com: HE GET IT RIGHT ON WORLDWIDE SECURITIES DE FACTO ALWAYS! BOUT 7320 PREDICTIONS SINCE AUGUST 1987 ( WHEN HE WAS +/- 20): 7320 SUCCESS! 100% SHOCKING WINNING SCORE! GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA micheleni...@gmx.com! HE GET IT RIGHT ON WORLDWIDE STOCKS, CURRENCIES & COMMODITIES ALWAYS! ABOUT 7320 PREDICTIONS ON INTERNET SINCE 8.1987 (WHEN WAS MORE OR LESS 20 YEARS OLD): 7320 SUCCESS! 100% SHOCKING WINNING SCORE!!! GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA (micheleni...@gmx.com) ADVANCED IN EXTREMELY PERFECT WAY THE CONTINUOUS WALL STREET CRASH OF 1987 ( AS SAID.. AT THAT TIME HE WAS, MORE OR LESS, JUST 20 YEARS OLD)! AS THE ONE OF 2007, 2008 AND BEGINNING OF 2009 WITH "JUST" 1 AND HALF YEAR OF INCREDIBLY WINNING FORETASTE! GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA micheleni...@gmx.com AVDANCED IN EXTREMELY PERFECT WAY, THEN, THE MORE OF DOUBLING OF WALL STREET, SINCE 3.2009! HE PROPHESIED ALL THIS ON INTERNET, AGAIN, WITH MONTHS AND MONTHS IN ADVANCE! ALL AT FANTASTIC LIGHT OF SUNSHINE!!! ALL PROVABLE AND VISIBLE STILL NOW!!! GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA (micheleni...@gmx.com) WAS "ONE OF THE NUMBER ONES" OF ITALIAN STOCK EXCHANGE, IN THE 90S, PRODUCING OVER 10 MILIONS OF EUROS OF COMMISSIONS OF THE 90S ( SO, 15 MILIONS OF NOW), FROM BELOW ZERO: WAS THE ABSOLUTE IDOL OF GOLDMAN SACHS, MERRILL LYNCH, AND NEARLY ANY "FOR GOOD" INVESTMENT BANK IN THE WORLD! THAT'S WHY EVERYONE WAS GIVING HIM AND STILL GIVE HIM THE NICK OF KING MIDAS! INGENIOUS HERO MICHELE NISTA HAS A GREAT HEART TOO, "NOT JUST" A SORT OF INVINCIBLE INTUITION! HE DEDICATES, SINCE HE WAS 17, ALL HIS GIFTS OF HEAVEN HE HAS TO POOREST PEOPLE IN THE WORLD, VOLUNTEERING AND NOT ONLY, FOR MANY ORGANIZATIONS SAVING OR IMPROVING SUFFERING LIVES IN LATIN AMERICA AND AFRICA. HE IS CERTAINLY A CIVIL INCORRUPTIBLE HERO TOO! IN THE LAST 21 YEARS, IN MILAN, WAS THE MOST TENACIOUS MAN HUNTING TO DESTROY THE ASSASSIN DICTATORSHIP OF MAFIOSO, MEGA MAFIA MONEY LAUNDERER, EXTREME NAZIFASCIST, LIAR, MEGA THIEF, CORRUPTING PIG, PRINCIPAL OF HUNDREDS OF MURDERS AND SLAUGHTERS, VERY ASCERTAINED PEDOPHILE SILVIO BERLUSCONI! FOR ALL THIS, THERE W ERE FOUR ATTEMPTS OF KILLING HIM, ORDERED BY BASTARD SANGUINARY, AS WELL AS METASTASES OF THE ENTIRE WORLD: SILVIO BERLUSCONI!!! AND HIS FATHER LOST LIFE ON ORDER OF NAZIFASCIST AND COSA NOSTRA'S BRUTAL, VICIOUS, CRUEL, FEROCIOUS PRINCIPAL OF KILLING SILVIO BERLUSCONI (MAKING SHREWDLY TO PASS, VIA HIS PRIVATE OR PUBLIC NEW "OVRA, GESTAPO AND DINA" AL HIS ABSOLUTE REPELLENT HINDREDS OF HOMICIDES FOR FALSE ACCIDENTS, FALSE SUICIDES, FALSE ILLNESS, ALL THE TIMES)! AS A MATTER OF FACT, GENIUS, KING MIDAS, DEMOCRAT HERO MICHELE NISTA micheleni...@gmx.com "DECIDED TO EMIGRATE" TO LONDON, ON 2003, TO REMAIN ALIVE!! BUT GOD, IF HE'LL CONTINUE TO DESERVE SO, WILL MAKE HIM WIN!!! GROUP OF FRIENDS AND CLIENTS, EXTREMELY GRATEFUL TO THIS KING MIDAS, TO THIS INGENIOUS AND CIVIL HERO OF OUR TIMES: MICHELE NISTA (micheleni...@gmx.com)!!! RUDI STUEZLI. SENIOR CONSULTANT GOLDMAN SACHS. -- https://mail.python.org/mailman/listinfo/python-list
Looking for a decent HTML parser for Python...
I'm trying to parse HTML in a very generic way. So far, I'm using SGMLParser in the sgmllib module. The problem is that it forces you to parse very specific tags through object methods like start_a(), start_p() and the like, forcing you to know exactly which tags you want to handle. I want to be able to handle the start tags of any and all tags, like how one would do in the Xerces C++ XML parser. In other words, I would like a simple start() method that is called whenever any tag is encountered. How may I do this? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a decent HTML parser for Python...
"Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I'm trying to parse HTML in a very generic way. >So far, I'm using SGMLParser in the sgmllib module. The problem is > that it forces you to parse very specific tags through object methods like > start_a(), start_p() and the like, forcing you to know exactly which tags > you want to handle. I want to be able to handle the start tags of any and > all tags, like how one would do in the Xerces C++ XML parser. In other > words, I would like a simple start() method that is called whenever any > tag is encountered. How may I do this? >Thank you... Okay, I think I found what I'm looking for in HTMLParser in the HTMLParser module. Thanks... -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a decent HTML parser for Python...
"Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >Okay, I think I found what I'm looking for in HTMLParser in the > HTMLParser module. Except it appears to be buggy or, at least, not very robust. There are websites for which it falsely terminates early in the parsing. I have a sneaking feeling the sgml parser will be more robust, if only it had that one feature I am looking for. Can someone help me out here? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
I'm looking for a pythonic red-black tree...
I need a red-black tree in Python and I was wondering if there was one built in or if there's a good implementation out there. Something that, lets face it, does whatever the C++ std::map<> allows you to do... Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Getting VideoCapture to work with Python 2.5
I can't seem to get VideoCapture (http://videocapture.sourceforge.net/) to work with my version of Python (2.5). Why is that? I've followed the instructions which made it look easy but, as it happens all too often, it simply doesn't work. The error I get is that the .py interface file can't find an expected module (using the "import" keyword) but that module exists as a DLL in the correct directory. Why doesn't it recognize it? Has anyone else used this library with Python 2.5 successfully? Any theories as to what might be going wrong? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Unexpected behaviour with HTMLParser...
HTMLParser is behaving in, what I find to be, strange ways and I would like to better understand what it is doing and why. First, it doesn't appear to translate HTML escape characters. I don't know the actual terminology but things like & don't get translated into & as one would like. Furthermore, not only does HTMLParser not translate it properly, it seems to omit it altogether! This prevents me from even doing the translation myself, so I can't even working around the issue. Why is it doing this? Is there some mode I need to set? Can anyone else duplicate this behaviour? Is it a bug? Secondly, HTMLParser often calls handle_data() consecutively, without any calls to handle_starttag() in between. I did not expect this. In HTML, you either have text or you have tags. Why split up my text into successive handle_data() calls? This makes no sense to me. At the very least, it does this in response to text with & like escape sequences (or whatever they're called), so that it may successively avoid those translations. Again, why is it doing this? Is there some mode I need to set? Can anyone else duplicate this behaviour? Is it a bug? These are serious problems for me and I would greatly appreciate a deeper understanding of these issues. Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected behaviour with HTMLParser...
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Just Another Victim of the Ambient Morality schrieb: >> HTMLParser is behaving in, what I find to be, strange ways and I >> would like to better understand what it is doing and why. >> >> First, it doesn't appear to translate HTML escape characters. I >> don't know the actual terminology but things like & don't get >> translated into & as one would like. Furthermore, not only does >> HTMLParser not translate it properly, it seems to omit it altogether! >> This prevents me from even doing the translation myself, so I can't even >> working around the issue. >> Why is it doing this? Is there some mode I need to set? Can anyone >> else duplicate this behaviour? Is it a bug? > > Without code, that's hard to determine. But you are aware of e.g. > > handle_entityref(name) > handle_charref(ref) > > ? Actually, I am not aware of these methods but I will certainly look into them! I was hoping that the issue would be known or simple before I commited to posting code, something that is, to my chagrin, not easily done with my news client... >> Secondly, HTMLParser often calls handle_data() consecutively, without >> any calls to handle_starttag() in between. I did not expect this. In >> HTML, you either have text or you have tags. Why split up my text into >> successive handle_data() calls? This makes no sense to me. At the very >> least, it does this in response to text with & like escape sequences >> (or whatever they're called), so that it may successively avoid those >> translations. > > That's the way XML/HTML is defined - there is no guarantee that you get > text as whole. If you must, you can collect the snippets yourself, and on > the next end-tag deliver them as whole. I think there's some miscommunication, here. You can't mean "That's the way XML/HTML is defined" because those format specifications say nothing about how the format must be parsed. As far as I can tell, you either meant to say that that's the way HTMLParser is specified or you're referring to how text in XML/HTML can be broken up by tags, in which case I've already addressed that in my post. I expected to see handle_starttag() calls in between calls to handle_data(). Unless I'm missing something, it simply makes no sense to break up contiguous text into multiple handle_data() calls... >> Again, why is it doing this? Is there some mode I need to set? Can >> anyone else duplicate this behaviour? Is it a bug? > > No. It's the way it is, because it would require buffering with unlimited > capacity to ensure this property. It depends on what you mean by "unlimited capacity." Is it so bad to buffer with as much memory as you have? ...or, at least, have a setting for such operation? Moreover, you know that you'll never have to buffer more than there is HTML, so you hardly need "unlimited capacity..." For instance, I believe Xerces does this translation for you 'cause, really, why wouldn't you want it to? >> These are serious problems for me and I would greatly appreciate a >> deeper understanding of these issues. > > HTH, and read the docs. This does help, thank you. I have obviously read the docs, since I can use HTMLParser enough to find this behaviour. I don't find the docs to be very explanatory (perhaps I'm reading the wrong docs) and I think they assume you already know a lot about HTML and parsing, which may be necessary assumptions but are not necessarily true... -- http://mail.python.org/mailman/listinfo/python-list
Need help parsing with pyparsing...
I'm trying to parse with pyparsing but the grammar I'm using is somewhat unorthodox. I need to be able to parse something like the following: UPPER CASE WORDS And Title Like Words ...into two sentences: UPPER CASE WORDS And Title Like Words I'm finding this surprisingly hard to do. The problem is that pyparsing implicitly assumes whitespace are ignorable characters and is (perhaps necessarily) greedy with its term matching. All attempts to do the described parsing either fails to parse or incorrectly parses so: UPPER CASE WORDS A nd Title Like Words Frankly, I'm stuck. I don't know how to parse this grammar with pyparsing. Does anyone know how to accomplish what I'm trying to do? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help parsing with pyparsing...
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Oct 22, 4:18 am, "Just Another Victim of the Ambient Morality" > <[EMAIL PROTECTED]> wrote: >> I'm trying to parse with pyparsing but the grammar I'm using is >> somewhat >> unorthodox. I need to be able to parse something like the following: >> >> UPPER CASE WORDS And Title Like Words >> >> ...into two sentences: >> >> UPPER CASE WORDS >> And Title Like Words >> >> I'm finding this surprisingly hard to do. The problem is that >> pyparsing >> implicitly assumes whitespace are ignorable characters and is (perhaps >> necessarily) greedy with its term matching. All attempts to do the >> described parsing either fails to parse or incorrectly parses so: >> >> UPPER CASE WORDS A >> nd Title Like Words >> >> Frankly, I'm stuck. I don't know how to parse this grammar with >> pyparsing. >> Does anyone know how to accomplish what I'm trying to do? >> Thank you... > > By the way, are these possible data lines?: > > A Line With No Upper Case Words > A LINE WITH NO TITLE CASE WORDS > SOME UPPER CASE WORDS A Title That Begins With A One Letter Word Thank you for your kind help! Unfortunately, there are some ambiguities but, hopefully and surely, they'll be very rare. There will always be an uppercase section followed by a non-uppercase section. So, your examples will parse like so: A Line With No Upper Case Words ...the second example will result in a parse error... SOME UPPER CASE WORDS A Title That Begins With A One Letter Word Occasional errors can be tolerated. My problem was that my posted problem happened all the time which, of course, is not tolerable. The ambiguities you bring up, especially the last one, are interesting and I'm not sure how to deal with them without an English grammatical analysis, which is too much, especially if I'm to integrate it with pyparsing. Another problem involves the ambiguity of numbers. Some more examples, if you're interested: FAHRENHEIT 451 2000 Copies Sold 1984 Book Of The Year The last example is actually okay but the first one is honestly ambiguous. Thanks again... -- http://mail.python.org/mailman/listinfo/python-list
Is there a usenet library for Python?
Is there a Python library to communicate with a usenet server? I did a bit of googling and found some sites that suggest that you can roll your own fairly easily but, mostly, I got a lot of false positives with talk of Python libraries on usenet and I am really hoping this work has already done. Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Is pyparsing really a recursive descent parser?
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: from pyparsing import * grammar = OneOrMore(Word(alphas)) + Literal('end') grammar.parseString('First Second Third end') Amazingly enough, this will fail to parse! Now, maybe I have no idea what I'm talking about but shouldn't a recursive descent parser recursively descend through all possible rule combinations to discover one that works? Why does pyparsing fail to parse this? Is there a way to get pyparsing to parse a grammar like this? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a usenet library for Python?
"Grant Edwards" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-10-30, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: > >> Is there a Python library to communicate with a usenet server? > > Which protocol are you interested in, NNTP (for reading/posting > from a client) or the other one that hosts use to transfer news > feeds amongst themselves (C-NEWS)? If you google for Python > and the protocl name, I bet you'll find something like this: I'm interested in the former, an NNTP client. Thank you Grant and Jean-Paul (who answered this question in another post). I should have guessed at searching for "NNTP" instead of "usenet..." -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 2, 5:47 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> >> Pyparsing is no recursive descent parser. It doesn't go back in the >> input >> stream. The ``OneOrMore(Word(alphas))`` part "eats" the 'end' and when >> it >> can't get more, the parser moves to the ``Literal('end')`` part which >> fails because the 'end' is already gone. >> >> > Is there a way to get pyparsing to parse a grammar like this? >> >> Negative lookahead maybe: >> >> grammar = (OneOrMore(NotAny(Literal('end')) + Word(alphas)) >>+ Literal('end')) >> >> Ciao, >> Marc 'BlackJack' Rintsch- Hide quoted text - >> >> - Show quoted text - > > Well I'll be darned! All this time, I thought "recursive descent" > described the recursive behavior of the parser, which pyparsing > definitely has. I never knew that backing up in the face of parse > mismatches was a required part of the picture. It has recursion in it but that's not sufficient to call it a recursive descent parser any more than having a recursive implementation of the factorial function. The important part is what it recurses through... > In pyparsing, each construction gets composed from more fine-grained > constructions, and they are called recursively to match or not match > against the input string. > > For example, taking your working parser example: > > grammar = (OneOrMore(NotAny(Literal('end')) + Word(alphas)) > + Literal('end')) > > This creates the following data structure: > > - And > - OneOrMore >- And > - NotAny >- Literal('end') > - Word(alphas) > - Literal('end') > > Every instance in this structure derives from the base class > ParserElement, which defines a method parse(). parse() in turn calls > preParse(), parseImpl(), and postParse(). If parseImpl succeeds, it > returns a ParseResults object and the next location within the input > string to continue parsing. > > The parseImpl methods are most often overridden in the subclasses (a > few override postParse as well), such as: > - And.parseImpl invokes parse() (note the recursion) on each of the > expressions in its list. All must succeed or And.parseImpl throws an > exception. > - OneOrMore.parseImpl invokes parse() on its contained expression, > which must succeed at least once; if not, the exception is rethrown. > If the contained expression succeeds once, then its parse() method is > called again and again until it fails, but no exceptions are rethrown, > since only one match was actually required. > - NotAny inverts the success/failure of its contained expression. If > the expression's parse() method succeeds, NotAny.parseImpl throws an > exception. If the contained expression's parse() method throws an > exception, NotAny returns successfully. (NotAny does not advance the > parse location, nor does it return any tokens.) > - Literal and Word are terminals, in that they do not invoke any other > expression's parse() method. Literal.parseImpl tests whether its > string exists at the current parse location, and throws an exception > if it doesn't. Word.parseImpl tests whether the current parse > location contains a letter in the Word instance's set of valid initial > characters - if so success; if not, throws an exception. It then > advances through the input string, matching characters in the Word > instance's set of valid body characters. The entire matched string is > then returned, along with an updated string index at which to continue > parsing. Thank you for the detailed description of pyparsing's implementation. > In my concept of "recursive descent" parsing, I was under the > impression that pyparsing's use of this data structure, and > *recursive* calls of parse() as it *descends* through the data > structure, constituted a recursive descent parser. What the OP > requested was a more regular expression-ish matcher, with backup (or > backtracking). In my concept of "recursive descent" parsing, I was under the impression that one should recurse through all rule combinations to ensure that the grammar is fully applied. As I have mentioned before, merely having recursion in your algorithm is insufficient. What you recurse through is key. pyparsing recurses through rules but what's important is to recurse through rule combinations. Otherwise, the parser won't be correct. That is
Re: Is pyparsing really a recursive descent parser?
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 3, 12:33 am, "Just Another Victim of the Ambient Morality" > <[EMAIL PROTECTED]> wrote: >> It has recursion in it but that's not sufficient to call it a >> recursive >> descent parser any more than having a recursive implementation of the >> factorial function. The important part is what it recurses through... > > > >> In my opinion, the rule set I mentioned in my original post: >> >> grammar = OneOrMore(Word(alphas)) + Literal('end') >> >> ...should be translated (internally) to something like this: >> >> word = Word(alphas) >> grammar = Forward() >> grammar << ((word + grammar) | (word + Literal(end))) >> >> This allows a recursive search to find the string correct without any >> need for "backtracking," if I understand what you mean by that. Couldn't >> pyparsing have done something like this? >> > > Dear JAVotAM - > > This was a great post! (Although I'm not sure the comment in the > first paragraph was entirely fair - I know the difference between > recursive string parsing and recursive multiplication.) I often use hyperbole to emphasize a point. I honestly mean no offense. That comment wasn't even meant to be fair, I was hoping to be provocative... > You really got me thinking more about how this recursion actually > behaves, especially with respect to elements such as OneOrMore. Your > original question is really quite common, and up until now, my stock > answer has been to use negative lookahead. The expression you posted > is the first time I've seen this solution, and it *does* work. I'm glad I got you thinking! I'd hate to be another newbie with another of a thousand questions answered in the FAQ Hey, are you the author of pyparsing? > I was all set to write a cocky response on why your expression > wouldn't work. I've seen it many times before, where people (usually > coming from EBNF experience) implement listOfXs = OneOrMore(x) as: > > listOfXs = Forward() > listOfXs << ( x + listOfXs | x ) > > Actually, what they usually write is: > > listOfXs << ( listOfXs + x ) > > but this sends pyparsing into a recursive tailspin. > > So I fired up SciTE and copy/pasted your code into the editor and ran > it, and it worked just fine - this was a shock! I studied this for a > few minutes, and then realized what was happening. First of all, I > misread what you posted. You posted this: > > grammar << ((word + grammar) | (word + Literal(end))) > > which works. I *thought* you posted this: > > grammar << ((word + grammar) | word) + Literal(end) > > which doesn't work. In fact this behaves the same as your original > post, except it iterates over the input string's words recursively, > vs. repetition ins a for-loop, as is done by OneOrMore. I'm grateful that you actually tested my code before posting your cocky response! > So going back to your working version, I had to see why it works. > Initially, the first term in the MatchFirst (the '|' operator creates > MatchFirst instances) is just the same, and by grammar referencing > itself, it just goes word by word through the input trying to find a > match. I'll try to visualize the steps: > > level"First Second Third end" > 1 word grammar > 2 word grammar > 3 word grammar > 4word grammar <- fails! > 4word end <- fails! > (therefore level 3 grammar fails!) > 3 word end<-- success!!! > > grammar has 2 options: to match a word followed by a grammar, or to > match a word followed by 'end'. At 4 levels deep into the Forward's > recursion, the first option fails, because after parsing "end" as the > initial word, there is no more text to try to match against grammar. > Level 4's Forward then also tries to match a word followed by 'end', > but this fails for the same reason. So at this point, the 4th level > Forward fails to match either of its options, so it throws its > exception back up to level 3, indicating that the first alternative, > word followed by grammar, failed. Level 3 then moves on to see if > word followed by the literal 'end' matches, and it does - success! This is, literally, what it's doing. I'm not exactly a programming whiz so I think of it a little more abstractly. In pyparsing's implem
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-03, Paul McGuire <[EMAIL PROTECTED]> wrote: >> On Nov 3, 12:33 am, "Just Another Victim of the Ambient Morality" >><[EMAIL PROTECTED]> wrote: >>> It has recursion in it but that's not sufficient to call it a >>> recursive >>> descent parser any more than having a recursive implementation of the >>> factorial function. The important part is what it recurses through... >> >> >> >>> In my opinion, the rule set I mentioned in my original post: >>> >>> grammar = OneOrMore(Word(alphas)) + Literal('end') >>> >>> ...should be translated (internally) to something like this: >>> >>> word = Word(alphas) >>> grammar = Forward() >>> grammar << ((word + grammar) | (word + Literal(end))) >>> >>> This allows a recursive search to find the string correct without >>> any >>> need for "backtracking," if I understand what you mean by that. >>> Couldn't >>> pyparsing have done something like this? >>> >> >> Dear JAVotAM - >> >> This was a great post! (Although I'm not sure the comment in the >> first paragraph was entirely fair - I know the difference between >> recursive string parsing and recursive multiplication.) >> >> You really got me thinking more about how this recursion actually >> behaves, especially with respect to elements such as OneOrMore. Your >> original question is really quite common, and up until now, my stock >> answer has been to use negative lookahead. The expression you posted >> is the first time I've seen this solution, and it *does* work. > > Is there not an ambiguity in the grammar? > > In EBNF: > > goal --> WORD { WORD } END > > WORD is '[a-zA-Z]+' > END is 'end' > > I think it is fine that PyParsing can't guess what the composer > of that grammar meant. First, I don't know if that constitutes an ambiguity in the grammar. 'end' is a word but it's unambiguous that this grammar must end in a literal 'end'. You could interpret the input as just a sequence of words or you could interpret it as a sequence of words terminated by the word 'end'. One interpretation conforms to the grammar while the other doesn't. You would assume that the interpretation that agrees with the grammar would be the preferable choice and so should the program... Secondly, even if it is an ambiguity... so what? pyparsing's current behaviour is to return a parse error, pretending that the string can't be parsed. Ideally, perhaps it should alert you to the ambiguity but, surely, it's better to return _a_ valid parsing than to pretend that the string can't be parsed at all... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-04, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> >> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> >>> Is there not an ambiguity in the grammar? >>> >>> In EBNF: >>> >>> goal --> WORD { WORD } END >>> >>> WORD is '[a-zA-Z]+' >>> END is 'end' >>> >>> I think it is fine that PyParsing can't guess what the composer >>> of that grammar meant. >> >> One interpretation conforms to the grammar while the other >> doesn't. You would assume that the interpretation that agrees >> with the grammar would be the preferable choice and so should >> the program. Secondly, even if it is an ambiguity... so what? >> pyparsing's current behaviour is to return a parse error, >> pretending that the string can't be parsed. Ideally, perhaps >> it should alert you to the ambiguity but, surely, it's better >> to return _a_ valid parsing than to pretend that the string >> can't be parsed at all... > > I wouldn't characterize it as pretending. How would you parse: > > hello end hello end > > "WORD END WORD END" and "WORD WORD WORD END" are both valid > interpretations, according to the grammar. ...and it would be nice if the parser were to parse one of them since they are both right. Having more than one right answer is not the same as having no answer, which is what pyparsing claims... > As soon as you remove the ambiguity from the grammar, PyParsing > starts to work correctly. This is simply not true. Try this: grammar = OneOrMore(Word(alphas)) + Literal('end') + Literal('.') grammar.parseString('First Second Third end.') ...again, this will fail to parse. Where's the ambiguity? Besides, parsing ambiguous grammars is a useful feature. Not all grammars being parsed are designed by those doing the parsing... > Consider writing a recursive decent parser by hand to parse the > language '[ab]+b'. > > goal --> ab_list 'b' > ab_list --> 'a' list_tail > ab_list --> 'b' list_tail > list_tail --> 'a' list_tail > list_tail --> 'b' list_tail > list_tail --> null > > > The above has the exact same bug (and probably some others--I'm > sorry unable to test it just now) as the PyParsing solution. > > The error is in the grammar. It might be fixed by specifying that > 'b' must be followed by EOF, and then it could be coded by using > more than one character of lookahead. I don't exactly understand the syntax you used to describe the productions of your recursive descent parser so not only did I not follow it but I couldn't make out the rest of your post. Could you explain in a little more detail? The last part that points to 'null' is especially confusing... As demonstrated earlier, it's not just the grammar. There are situations that are unambiguous that pyparsing can't parse simply and there's no reason for it. Besides, ambiguous grammars are a fact of life and some of us need to parse them. It's usually okay, too. Consider a previous example: grammar = OneOrMore(Word(alphas)) + Literal('end') While you may consider this inherently ambiguous, it's usually not. That is to say, as long as it is rare that 'end' is used not at the end of the string, this will simply parse and, yet, pyparsing will consistently fail to parse it... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-04, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >>> Consider writing a recursive decent parser by hand to parse >>> the language '[ab]+b'. >>> >>> goal --> ab_list 'b' >>> ab_list --> 'a' list_tail >>> ab_list --> 'b' list_tail >>> list_tail --> 'a' list_tail >>> list_tail --> 'b' list_tail >>> list_tail --> null >>> >>> >>> The above has the exact same bug (and probably some others--I'm >>> sorry unable to test it just now) as the PyParsing solution. >>> >>> The error is in the grammar. It might be fixed by specifying that >>> 'b' must be followed by EOF, and then it could be coded by using >>> more than one character of lookahead. >> >> I don't exactly understand the syntax you used to describe the >> productions of your recursive descent parser so not only did I not follow >> it >> but I couldn't make out the rest of your post. Could you explain in a >> little more detail? The last part that points to 'null' is especially >> confusing... > > It's the BNF spelling of > > goal --> ab_list 'b' > ab_list --> ab { ab } > ab --> 'a' | 'b' > > The null is to say that list_tail can match nothing, i.e, an > empty string. > > Then, in the Parser class, every method (except for match, which > is used as a central place to consume characters) corresponds to > one of the productions in the BNF. Breaking things down into > BNF-based productions often makes implementation, debugging and > code generation easier. > > PyParsing saves me that stop, since I can often directly > implement the EBNF using PyParsing. Okay, I see that now, thank you. Your statement from the previous post: >> Consider writing a recursive decent parser by hand to parse >> the language '[ab]+b'. >> >> goal --> ab_list 'b' >> ab_list --> 'a' list_tail >> ab_list --> 'b' list_tail >> list_tail --> 'a' list_tail >> list_tail --> 'b' list_tail >> list_tail --> null >> >> >> The above has the exact same bug (and probably some others--I'm >> sorry unable to test it just now) as the PyParsing solution. ...merely demonstrates that this grammar is similarly ambiguous. There are many ways to parse this correctly and pyparsing chooses none of these! Instead, it returns the same error it does when the string has no solutions... >> As demonstrated earlier, it's not just the grammar. There are >> situations that are unambiguous that pyparsing can't parse >> simply and there's no reason for it. > > Yes, many parser generators have many more limitations than just > the requirement of an unambiguous grammar. Yes, but a recursive descent parser? I expect such things from LALR and others, but not only do I expect a recursive descent parser to correctly parse grammars but I expect it to even parse ambiguous ones, in that it is the only technique prepared to find more than one solution... >> Besides, ambiguous grammars are a fact of life and some of us >> need to parse them. It's usually okay, too. Consider a >> previous example: >> >> grammar = OneOrMore(Word(alphas)) + Literal('end') >> >> While you may consider this inherently ambiguous, it's usually >> not. That is to say, as long as it is rare that 'end' is used >> not at the end of the string, this will simply parse and, yet, >> pyparsing will consistently fail to parse it... > > I believe there's no cure for the confusion you're having except > for implementing a parser for your proposed grammar. > Alternatively, try implementing your grammar in one of your other > favorite parser generators. I believe there is a cure and it's called recursive descent parsing. It's slow, obviously, but it's correct and, sometimes (arguably, often), that's more important the execution speed. I spent this morning whipping up a proof of concept parser whose interface greatly resembles pyparsing but, baring unknown bugs, works and works as I'd expect a recursive descent parser to work. I don't know Python very well so the parser is pretty simple. It only lexes single characters as tokens. It only supports And, Or, Optional, OneOrMore and ZeroOrMore rules but I already think this is a rich set of rules. I'm sure others can be added. Finally, I'm not sure it's safely copying all its parameter input the same way pyparsing does but surely those bugs can be worked out. It's merely a proof of concept to demonstrate a point. Everyone, please look it over and tell me what you think. Unfortunately, my news client is kind of poor, so I can't simply cut and paste the code into here. All the tabs get turned into single spacing, so I will post this link, instead: http://theorem.ca/~dlkong/new_pyparsing.zip I hope you can all deal with .zip files. Let me know if this is a problem. Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-04, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> I believe there's no cure for the confusion you're having except >>> for implementing a parser for your proposed grammar. >>> Alternatively, try implementing your grammar in one of your other >>> favorite parser generators. >> >> I believe there is a cure and it's called recursive descent >> parsing. It's slow, obviously, but it's correct and, sometimes >> (arguably, often), that's more important the execution speed. >> >> I spent this morning whipping up a proof of concept parser >> whose interface greatly resembles pyparsing but, baring unknown >> bugs, works and works as I'd expect a recursive descent parser >> to work. I don't know Python very well so the parser is pretty >> simple. It only lexes single characters as tokens. It only >> supports And, Or, Optional, OneOrMore and ZeroOrMore rules but >> I already think this is a rich set of rules. I'm sure others >> can be added. Finally, I'm not sure it's safely copying all >> its parameter input the same way pyparsing does but surely >> those bugs can be worked out. It's merely a proof of concept >> to demonstrate a point. >> Everyone, please look it over and tell me what you think. >> Unfortunately, my news client is kind of poor, so I can't >> simply cut and paste the code into here. All the tabs get >> turned into single spacing, so I will post this link, instead: >> >> http://theorem.ca/~dlkong/new_pyparsing.zip > > Your program doesn't necessarily address the ambiguity in the > grammar in question, since right now it is only a recognizer. > Will it be hard to get it to return a parse tree? Hey, it's only a proof of concept. If you can parse the tree, surely you can record what you parsed, right? Did you notice that the parse() functions have the rather serious bug of not returning how much of the string they could parse? It just so happens that the contstructions that I made only ever had to increment the matches by one, so they just happen to work. That's an easy bug to fix but a pretty major one to have overlooked. Hence, my enthusiasm for input... > The grammar in your implementation is: > >>>> goal = OneOrMore(RuleAnd('a') | RuleAnd('b')) + RuleAnd('b') >>>> goal.parse(0, 'ab') > True >>>> goal.parse(0, 'ba') > False >>>> goal.parse(0, 'b') > False >>>> goal.parse(0, 'aaab') > True >>>> goal.parse(0, 'abc') > True > > So far so good. :) Good! Keep hammering at it! More importantly, study it to understand the idea I'm trying to convey. This is what I thought a recursive descent parser would do... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Kay Schluehr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 4, 10:44 pm, "Just Another Victim of the Ambient Morality" > <[EMAIL PROTECTED]> > >> I believe there is a cure and it's called recursive descent parsing. >> It's slow, obviously, but it's correct and, sometimes (arguably, often), >> that's more important the execution speed. > > Recursive decendent parsing is not necessarily slow but from your > remarks above I infer you want a general RD parser with backtracking: > when one rule doesn't match, try another one to derive the current > symbol in the input stream. I think I've just discovered a major hurdle in my understand of the problem. You keep saying "with backtracking." Why? Isn't "backtracking" inherent in recursion? So, why can't these alleged "recursive descent parsers" find valid parsings? How are they not already backtracking? What was the point of being recursive if not to take advantage of the inherent backtracking in it? Obviously, these parsers aren't recursing through what I think they should be recursing. The question is "why not?" Correct me if I'm wrong but I'm beginning to think that pyparsing doesn't typically use recursion, at all. It only employs it if you create one, using the Forward class. Otherwise, it does everything iteratively, hence the lack of "backtracking." > I'm not sure one needs to start again with a naive approach just to > avoid any parser theory. For a user of a parser it is quite important > whether she has to wait 50 seconds for a parse to run or 50 > milliseconds. I don't like to compromise speed for implementation > simplicity here. This attitude is all too prevalent among computer professionals... Of course it's a useful thing to shield users from the intricacies of parser theory! Just as much as it is useful to shield drivers from needing automotive engineering or software users from programing. How many people have come to this newsgroup asking about anomalous pyparsing behaviour, despite their grammars being mathematically correct. Think of it this way. You can force all the clients of pyparsing to duplicate work on figuring out how to massage pyparsing to their grammars, or you can do the work of getting pyparsing to solve people's problems, once. That's what a library is supposed to do... Finally, I can't believe you complain about potential speed problems. First, depending on the size of the string, it's likely to be the difference between 2ms and 200ms. Secondly, if speed were an issue, you wouldn't go with a recursive descent parser. You'd go with LALR or the many other parsing techniques available. Recursive descent parsing is for those situations where you need correctness, regardless of execution time. These situations happen... I've said this before, albeit for a different language, but it applies to Python just as well. I don't use Python to write fast code, I use it to write code fast. If _you_ "don't like to compromise speed for implementation simplicity" then you have a plethora choices available to you. What about the guy who needs to parse correctly and is unconcerned about speed? -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-05, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> >> "Kay Schluehr" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> On Nov 4, 10:44 pm, "Just Another Victim of the Ambient Morality" >>> <[EMAIL PROTECTED]> >>> >>>> I believe there is a cure and it's called recursive descent parsing. >>>> It's slow, obviously, but it's correct and, sometimes (arguably, >>>> often), >>>> that's more important the execution speed. >>> >>> Recursive decendent parsing is not necessarily slow but from your >>> remarks above I infer you want a general RD parser with backtracking: >>> when one rule doesn't match, try another one to derive the current >>> symbol in the input stream. >> >> I think I've just discovered a major hurdle in my understand of the >> problem. >> You keep saying "with backtracking." Why? Isn't "backtracking" >> inherent in recursion? So, why can't these alleged "recursive descent >> parsers" find valid parsings? How are they not already backtracking? >> What >> was the point of being recursive if not to take advantage of the inherent >> backtracking in it? >> Obviously, these parsers aren't recursing through what I think they >> should be recursing. The question is "why not?" > > There are different kinds of recursion. Compare: > > def fac1(x, y=1): >""" Compute factorials with a recursive function (it calls >itself), but the stack is not actually used for storing >anything important, i.e., it is tail-recursive. """ >if x < 0: > raise ValueError('non-negative integer') >elif x == 0: > return y >else: > return fac1(x-1, y*x) > > to > > def fac2(x): >""" Computes factorials with a recursive process, keeping >the state of the calculation on the stack. """ >if x < 0: > raise ValueError('non-negative integer') >if x == 0: > return 1 >else: > return fac2(x-1) * x > > to > > def Ack(x, y): >""" The Ackermann function. Creates a humongous mess even >with quite tiny numbers. """ >if x < 0 or y < 0: > raise ValueError('non-negative integer') >elif x == 0: > return y + 1 >elif y == 0: > return foo3(x-1, 1) >else: > return foo3(x-1, foo3(x, y-1)) > > There's probably a word for the type of recursive process built > by fac2; the RDP's I'm most familiar with create a fac2 sort of > process, which stores valuable info on the stack. > > And even though fac1 defines an iterative process, the code > itself is recursive, and you can call it a recursive function if > you wish (and in Python you might as well). While interesting, none of this actually addresses the point I was making. I wasn't saying that there was no recursion (at least, not in this paragraph), I was saying that it wasn't recursing through what I thought it should be recursing through. It recurses through a set of rules without any regard to how these rules interact with each other. That's why it fails to parse valid strings. In my opinion, it should recurse through appropriate combinations of rules to determine validity, rather than by arbitrary categorization... >> Correct me if I'm wrong but I'm beginning to think that >> pyparsing doesn't typically use recursion, at all. It only >> employs it if you create one, using the Forward class. >> Otherwise, it does everything iteratively, hence the lack of >> "backtracking." > > It's recursive because each production rule calls other > production rules to define itself. A rule regularly ends up > calling itself. Consider the Parser class I built earlier. > list_tail keeps calling itself to continue consuming characters > in an ab_list. The stack is used to keep track of where we are in > the grammar; at any time you can look up the stack and see how > you got where you are--you 'descend' down from the topmost > productions to the most primitive productions, and then back up > once everything has been sorted out. Take another look > at the exception raised in my Parsing class example for an > illustrative traceback. I guess that all the And and Or class in pyparsing ca
How do I change elements in a list?
How do you change certain elements in a list? I'm looking to do the Python equivalent of this Ruby code: -> first = [1, 2] => [1, 2] -> second = first => [1, 2] -> first.map! {|i| i + 1} => [2, 3] -> first => [2, 3] -> second => [2, 3] I need to change a list, in place, so other variables referencing that list also see the change. Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-05, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> "Kay Schluehr" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> I'm not sure one needs to start again with a naive approach >>> just to avoid any parser theory. For a user of a parser it is >>> quite important whether she has to wait 50 seconds for a parse >>> to run or 50 milliseconds. I don't like to compromise speed >>> for implementation simplicity here. >> >> This attitude is all too prevalent among computer >> professionals... Of course it's a useful thing to shield users >> from the intricacies of parser theory! Just as much as it is >> useful to shield drivers from needing automotive engineering or >> software users from programing. How many people have come to >> this newsgroup asking about anomalous pyparsing behaviour, >> despite their grammars being mathematically correct. > > You might be interested in the Early parsing algorithm. It is > more efficient than the naive approach used in your prototype, > and still handles ambiguous grammars. I think I might be interested in this algorithm, thank you! > There is a Python module SPARK that provides generic classes for > building small language compilers using an Early parser, and I > was able to get it to parse your ambiguous grammar without > trouble. It is not as convenient or as well documented as > PyParsing, but the parsing algorithm provides the power you're > looking for. It might serve as a backend for the library you're > currently working on. > > http://www.cpsc.ucalgary.ca/~aycock/spark/ You know, I tried this thing but, for the life of me, I can't figure out how to use it and the few tutorials out there are less than illuminating... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-11-07, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> You might be interested in the Early parsing algorithm. It is >>> more efficient than the naive approach used in your prototype, >>> and still handles ambiguous grammars. >> > > I'll take this opportunity to correct my misspelling. It's > "Earley". > >> I think I might be interested in this algorithm, thank you! >> >>> http://www.cpsc.ucalgary.ca/~aycock/spark/ >> >> You know, I tried this thing but, for the life of me, I >> can't figure out how to use it and the few tutorials out there >> are less than illuminating... > > I'll send you the code I composed. > > The tricky part of Spark is the Token and AST classes you have to > use. A type used as a token class is required to provide a > __cmp__ function that behaves in the following confounding > manner: > > class Token(object): >def __cmp__(self, o): > return cmp(self.type, o) > > If you attempt to use a list, string or a tuple as token, it just > barfs. AST's are required to provide an even weirder interface. > > In effect, you have to write badly designed wrappers around > tuples and lists, respectively to take advantage of the generic > classes. > > Go to the examples directory of the distribution to find working > versions of these stupid classes. > > Once you get over that hurdle it becomes easier. Be sure to > provide your Parser and Scanner classes with an error method to > prevent the library from raising SystemExit(!) on errors. Scanner > classes are also required to override the t_default method to > prevent this mishap. > > In short, it hasn't really evovled into a user-friendly package > yet. Thank you. How is it that I seem to be the only one in the market for a correct parser? Earley has a runtine of O(n^3) in the worst case and O(n^2) typically. I have trouble believing that everyone else in the world has such intense run-time requirements that they're willing to forego correctness. Why can't I find a pyparsing-esque library with this implementation? I'm tempted to roll my own except that it's a fairly complicated algorithm and I don't really understand how it's any more efficient than the naive approach... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Chris Mellon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: > >> > In short, it hasn't really evovled into a user-friendly package >> > yet. >> >> Thank you. >> How is it that I seem to be the only one in the market for a correct >> parser? Earley has a runtine of O(n^3) in the worst case and O(n^2) >> typically. I have trouble believing that everyone else in the world has >> such intense run-time requirements that they're willing to forego >> correctness. Why can't I find a pyparsing-esque library with this >> implementation? I'm tempted to roll my own except that it's a fairly >> complicated algorithm and I don't really understand how it's any more >> efficient than the naive approach... > > You have an unusual definition of correctness. Many people would say > that an ambiguous grammar is a bug, not something to support. I don't think I do. Besides, you assume too much... First off, we've already established that there are unambiguous grammars for which pyparsing will fail to parse. One might consider that a bug in pyparsing... Secondly, I get the impression you want to consider ambiguous grammars, in some sense, "wrong." They are not. Even if they were, if you are parsing something for which you are not the creator and that something employs an ambiguous grammar, what choice do you have? Furthermore, given a set of possible parsings, you might be able to decide which one you favour given the context of what was parsed! There's a plethora of applications for parsing ambiguous grammars yet there are no tools for doing so? > In fact, I often use pyparsing precisely in order to disambiguate > (according to specific rules, which are embodied by the parser) > ambiguous input, like bizarre hand-entered datetime value. What do you mean? How do you use pyparsing to disambiguate: 01-01-08 ...? -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 07 Nov 2007 21:15:50 +0000, Just Another Victim of the Ambient > Morality wrote: > >> Why can't I find a pyparsing-esque library with this implementation? >> I'm tempted to roll my own except that it's a fairly complicated >> algorithm and I don't really understand how it's any more efficient than >> the naive approach... > > I think you may have just answered your own question :) Yes, but my own answer lacks detail that I was hoping you could provide... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pyparsing really a recursive descent parser?
"Chris Mellon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 7, 2007 5:15 PM, Just Another Victim of the Ambient Morality > <[EMAIL PROTECTED]> wrote: >> >> "Chris Mellon" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality >> > <[EMAIL PROTECTED]> wrote: >> > >> >> > In short, it hasn't really evovled into a user-friendly package >> >> > yet. >> >> >> >> Thank you. >> >> How is it that I seem to be the only one in the market for a >> >> correct >> >> parser? Earley has a runtine of O(n^3) in the worst case and O(n^2) >> >> typically. I have trouble believing that everyone else in the world >> >> has >> >> such intense run-time requirements that they're willing to forego >> >> correctness. Why can't I find a pyparsing-esque library with this >> >> implementation? I'm tempted to roll my own except that it's a fairly >> >> complicated algorithm and I don't really understand how it's any more >> >> efficient than the naive approach... >> > >> > You have an unusual definition of correctness. Many people would say >> > that an ambiguous grammar is a bug, not something to support. >> >> I don't think I do. > > There are an enormous variety of parsing tools, and it's the subject > of much research. And in all those tools, not one meets your > definition of correctness? You don't think that might make it unusual? It doesn't appear to be common, I'll grant you that! However, there is some research. For instance, the Earley parser appears to be what I want (in conjunction with a parse tree builder). A CYK parser would probably do, too. The algorithms are out there yet no one has chosen to use any of them. At the same time, there are several LALR parsers. Why did anyone need to write the second one after the first one was written?! In fact, in a sense, my problem is solved. There exists a solution to my problem. It's just that no one has implemented that solution. I guess you're right in that it really does appear to be an unusual problem but I don't understand how... >> Besides, you assume too much... >> First off, we've already established that there are unambiguous >> grammars >> for which pyparsing will fail to parse. One might consider that a bug in >> pyparsing... > > You might. Or you might not, since it's well known that there are lots > of types of parsers that can't parse all possible grammars, but that > doesn't make those parsers useless. No one said they were useless. I only said that a correct parser is useful. Many people in this thread seem to disagree and I find this incredible... >> Secondly, I get the impression you want to consider ambiguous >> grammars, >> in some sense, "wrong." They are not. > > Sure they are, at least in many contexts. I understand that you want > support for them, but it's by far more common to want one and only one > set of results from parsing a particular document. Okay, in some contexts, an ambiguous grammar may be considered erroneous. However, in many other contexts, it's merely a fact of life. How is it that there are no tools to address this? If nothing else, pyparsing throws the same error it does when there is no valid parsing of the string. Having no solution and having several solutions are not the same thing... >>Even if they were, if you are >> parsing something for which you are not the creator and that something >> employs an ambiguous grammar, what choice do you have? > > You either disambiguate, or you don't accept ambiguous input. The > third option seems to be what you want, which is to find all possible > solutions and return all of them (and wouldn't this be NP-hard in the > general case?) but that's not a satisfactory result in most > applications. What do you mean by "disambiguate?" Do you mean disambiguate the grammar? One of the conditions of the problem is that you have no control over the grammar, so that's really not an option. Also, an implicit condition of solving a problem is that the problem be... solved, so not accepting the input is not an option, either. While there are many applications that can't deal with multiple solutions, surely there are some? Again, perhaps you can pick one solution over the other through the context of the parse results? That's k
How do I convert escaped HTML into a string?
I've done a google search on this but, amazingly, I'm the first guy to ever need this! Everyone else seems to need the reverse of this. Actually, I did find some people who complained about this and rolled their own solution but I refuse to believe that Python doesn't have a built-in solution to what must be a very common problem. So, how do I convert HTML to plaintext? Something like this: This is a string. ...into: This is a string. Actually, the ideal would be a function that takes an HTML string and convert it into a string that the HTML would correspond to. For instance, converting: This &that or the other thing. ...into: This & that or the other thing. ...since HTML seems to convert any amount and type of whitespace into a single space (a bizarre design choice if I've ever seen one). Surely, Python can already do this, right? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
A bug in Python's regular expression engine?
This won't compile for me: regex = re.compile('(.*\\).*') I get the error: sre_constants.error: unbalanced parenthesis I'm running Python 2.5 on WinXP. I've tried this expression with another RE engine in another language and it works just fine which leads me to believe the problem is Python. Can anyone confirm or deny this bug? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: A bug in Python's regular expression engine?
"Paul Hankin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 27, 3:48 pm, "Just Another Victim of the Ambient Morality" > <[EMAIL PROTECTED]> wrote: >> This won't compile for me: >> >> regex = re.compile('(.*\\).*') >> >> I get the error: >> >> sre_constants.error: unbalanced parenthesis >> >> I'm running Python 2.5 on WinXP. I've tried this expression with >> another RE engine in another language and it works just fine which leads >> me >> to believe the problem is Python. Can anyone confirm or deny this bug? > > Your code is equivalent to: > regex = re.compile(r'(.*\).*') > > Written like this, it's easier to see that you've started a regular > expression group with '(', but it's never closed since your closed > parenthesis is escaped (which causes it to match a literal ')' when > used). Hence the reported error (which isn't a bug). > > Perhaps you meant this? > regex = re.compile(r'(.*\\).*') > > This matches any number of characters followed by a backslash (group > 1), and then any number of characters. If you're using this for path > splitting filenames under Windows, you should look at os.path.split > instead of writing your own. Indeed, I did end up using os.path functions, instead. I think I see what's going on. Backslash has special meaning in both the regular expression and Python string declarations. So, my version should have been something like this: regex = re.compile('(.*).*') That is funny. Thank you for your help... Just for clarification, what does the "r" in your code do? -- http://mail.python.org/mailman/listinfo/python-list
How do I not make a list?
It may sound like a strange question but that's probably only because I don't know the proper terminology. I have an iterable object, like a list, and I want to perform a transform on it (do an operation on each of the elements) and then pass it onto something else that expects and iterable. I'm pretty sure this something else doesn't need a list, either, and just wants to iterate over elements. Now, I could just make a list, using a list comprehension, performing my operation on each element, and then pass that list on, knowing that it is iterable. However, I was wondering if there was a way I can do virtually this without having to actually allocate the memory for a list. Creating a stock iterator or generator or whatever it's called, with a passed in operation? I hope I've described this adequately. Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Are Python deques linked lists?
I'm looking for a linked list implementation. Something iterable with constant time insertion anywhere in the list. I was wondering if deque() is the class to use or if there's something else. Is there? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Bad hack fix around a bizarre problem...
I'm trying to write a Python program that manipulates a MySQL database and have chosen to use MySQLdb. So, I used by system's package manager, YUM, and it appeared to install correctly. So, I tried it out and got this error: Traceback (most recent call last): File "", line 1, in ? File "MySQLdb/__init__.py", line 22, in ? raise ImportError, "this is MySQLdb version %s, but _mysql is version %r" %\ ImportError: this is MySQLdb version (1, 2, 2, 'final', 0), but _mysql is version (1, 2, 1, 'final', 1) It looks like the MySQLdb version doesn't match the _mysql version. If these were two different libraries, I might understand how this error happened. However, they're part of the same library. _mysql is just a Python binding to the MySQL C API and MySQLdb is just a Python wrapper around _mysql to be compliant with the Python DB specification. They were both part of the same library so how did their versions fall out of sync? That's like getting a Windows application with incompatible DLLs! So, my bad hack of a fix is to copy the MySQLdb python code to a local directory (where my python program will eventually reside) and, on this local copy, comment out the version check. The idea is that MySQLdb is pure Python, so it's unlikely that there is any incompatibility between it and the very thin layer that is _mysql. The local copy is so I don't forget that I'm using a modified version of this library. Python seems to import this over the global one. I've done a bit of testing and, so far, it appears to work! What is my problem? A google search reveals that I'm not the only person with this problem but it also reveals that absolutely no one knows how to fix this. What are the chances that my fix will backfire? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Why doesn't this RE match?
I'm confused by this behaviour: import re regex = re.compile('foo') match = regex.match('whatfooever') In my experience with regular expressions, regex should have found a match. However, in this case regex.match() returns None. Why is that? What am I missing? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Any news on when some libraries will be ported to Python 3.0?
I'm excited to use Python 3.0 (foolishly, it's the only Python interpreter I have on my system) but there are no libraries for it beyond the kitchen sink. Personally, a good start would be Beautiful Soup and Mechanize. I could also use DB. Has there been any word on Beautiful Soup? Has there been any word on Mechanize? What about DB? PIL would be nice, too, now that I think about it. Anyway, I'd love to hear some news about any of these things in particular or even anything in general. Am I the only one who's psyched for this version of Python? Thank you... -- http://mail.python.org/mailman/listinfo/python-list
Re: Confessions of a Python fanboy
"Steven D'Aprano" wrote in message news:pan.2009.08.04.09.28...@remove.this.cybersource.com.au... > On Tue, 04 Aug 2009 10:03:53 +0200, Bruno Desthuilliers wrote: > >>> Disadvantages: your code is filled with line noise. It's an arbitrary >>> choice between @@ meaning instance attribute and @@ meaning class >>> attribute -- there's no logical reason for choosing one over the other, >>> so you have to memorise which is which. It's easy to get it wrong. >> >> So far that's something I have no difficulty living with. > > I don't like arbitrary symbols. Most people don't -- that's why "line > noise" is unpopular. It's hard to read, hard to write, hard to maintain, > and hard to talk about. The more line-noise, the worse the language. It's not "line noise" if it conveys information... > Of course, *ultimately* every symbol is arbitrary. There's no reason why > "2" should mean the integer two, or "list" should mean a sequence type, > but some symbols have such a long history, or have some other connection > (say, with human languages), that the arbitrariness is lost. For > instance, "+" is the obvious, non-arbitrary choice for the addition > operator in any programming language using Latin symbols, and probably > any programming language on Earth. (Not the *only* choice, but the > obvious one.) > > I have a similar dislike for decorator syntax, because "@" ("at" in > English) has nothing to do with decorations. It's an arbitrary symbol. > One might argue that "$" would have been a more logical choice, because > we turn numerals into currency by decorating it with a $ sign. (At least > in the US, Canada, Australia, and a few other countries.) I use > decorators all the time, and they are a fantastic invention, but the > arbitrariness of the @ syntax is a negative. Oh well, one negative out of > a whole lot of positives isn't too bad. You can think of "@" as describing something being "at" the instance or the class. "$" is totally arbitrary to me 'cause I don't thnk of my code as currency... > At least I only have to deal with *one* such arbitrary symbol that needs > memorizing. There's no need to distinguish between @@function_decorator > and @class_decorator (or should it be the other way around?). Similarly, > Python's choice of syntax for attributes is consistent: object.attribute > works for everything, whether object is a class, an instance, a module, > and whether attribute is callable or not. You can even use it on ints, > provided you are clever about it: You can think of "@" as being at an instance or "@@" to be more emphatically (as the Japanese do in their language) integrated with a class, being available to all instances... or you can simply understand that instance vairables are more common than class variables so the shorter notation is used for the more common case... You want to talk about arbitrariness? Why is len() a function you pass objects into while objects can have methods that describe themselves to you? At least Ruby defines operators using the actual name of the operator instead of you having to remember an arbitrary magic incantation that corresponds to the operator... class Test attr_reader :data def initialize(data) @data = data end # This is the operator part... def + right Test.new @data + right.data end end >>>>> Somebody who knows more Ruby than me should try writing the Zen of >>>>> Ruby. Something like: >>>> (snip childish parody of Python Zen) >>>> >>>> Steven, is that any useful ? >>> >>> It made me feel good. >> >> Why ??? >> >> You don't like Ruby ? Fine, don't use it. Period. I can't see the point >> of all these pissing contests. > > Criticism of a language is a pissing contest? > > Yeah, okay, I was a tad dismissive. I un-apologetically jump to strong > impressions about languages based on minimal use -- but I'm also willing > to change my mind. Ruby certainly looks to me like it has some nice > features. Syntax that looks like Perl isn't one of them though. Yeah, that would be the "pissing contest" part. You could simply have gone to the Ruby newsgroup and posted some criticisms to see what was behind those decisions. However, that would have avoided the pissing contest and perhaps you wanted one... >>> Just because Smalltalk had a particular (mis?)feature >> >> You can drop the 'mis' part IMHO. The point of code blo
Adjacency lists with sqlalchemy...
I'm desperately trying to declare an adjacency list table with declarative_base() but I can't figure it out. Strangely, all the documentation avoids declarative_base() like the plague and does everything the hard way. What the hell is this thing for if we're not supposed to use it? If anyone can show me how to declaratively create ORM adjacency list or explain to me why this can't be done, I'd be very grateful. Thank you! -- http://mail.python.org/mailman/listinfo/python-list