Re: Regular expression use
On 24 Aug 2007 10:58:46 GMT, [EMAIL PROTECTED] (Nick Maclaren) wrote: > >For reasons that I won't explain, as they are too complicated >and not terribly relevant, I am interested in discovering what >people actually use regular expressions for. Not the subject >domain, but the construction of the regular expressions. > >I know about computer scientists and parsing, and I know about >the use of relatively simple ones for things like extracting >HTML links from Web pages. But I don't have much feel for the >(probably rare but difficult) uses of more complex ones for >other purposes. I have heard of several such uses, but don't >have an overall idea of what is going on. > >Any pointers appreciated, to more-or-less anything. > In the linked project, regular expression are used to parse communication protocol responses, file contents, and interporocess communcation (at least). They may not be pretty elegant solutions, but this is the first project I made in python (and also with regex)!! NOTE: I am the author, and I swear the application is free of viruses, it has been fully developed with a python and a WingWare standar installation, and it will only deposit some files on your $python$/Lib/site-packages folder. Any comments welcome. NOTE2: Software in spanish, but it should not be pretty difficult to follow (I hope!) best regards, Zara http://www.albalaing.com/Firmware.aspx?id_firmware=2359 -- http://mail.python.org/mailman/listinfo/python-list
Re: Enum class with ToString functionality
On Mon, 10 Sep 2007 02:28:57 -0700, [EMAIL PROTECTED] wrote: >Hi, > >I have the following class - > >class TestOutcomes: >PASSED = 0 >FAILED = 1 >ABORTED = 2 > >plus the following code - > >testResult = TestOutcomes.PASSED > >testResultAsString >if testResult == TestOutcomes.PASSED: >testResultAsString = "Passed" >elif testResult == TestOutcomes.FAILED : >testResultAsString = "Failed" >else: >testResultAsString = "Aborted" > >But it would be much nicer if I had a function to covert to string as >part of the TestOutcomes class. How would I implement this? > You should implement __str__ (or __repr__) method in your class, class TestOutcomes: PASSED = 0 FAILED = 1 ABORTED = 2 def __str__(self): textResultAsString="Unknown" if testResult == TestOutcomes.PASSED: testResultAsString = "Passed" elif testResult == TestOutcomes.FAILED : testResultAsString = "Failed" else: testResultAsString = "Aborted" return testResultAsString Regards, Zara -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Feature Request: Allow changing base of member indices to 1
On Mon, 16 Apr 2007 10:15:19 +0200, "Javier Bezos" <[EMAIL PROTECTED]> wrote: >Paddy, > >>> Dijkstra's argument is obsolete, as it is based on >>> how array length was computed many years ago -- if >>> we have an array a = b..e, then the lenght of a >>> is e-b (half open range). Good at low level >>> programming. >>> >>> But a quarter of a century after we know concepts >>> are much better than low level programming and >>> explicit computations -- if we have an array >>> a = b..e, then the length of a should be a.length() >>> (or a.length(b,e)), and it is independent of > >> Hi Javier, >> You seem to have missed out array *indexing* >> in your argument, or is array indexing obsolete? > >Of course, it isn't, but it has evolved over the >past 25 years. When Djikstra wrote that, many >people (including me) was using a Spectrum--- >Now we have OO programming to deal with concepts >and a more generic programming. So, to me it's >clear his _argument_ is very outdated and cannot >be applied directly and withot reservations to >modern languages like Python. > One language created by and for mathematicians: Haskell. It uses zero based list indexing (the most similar to array indexing they have), so that list!!0 is the first element and list!!3 the fourth element. And they tend to reason in Dijkstra's style. They love natural numbers beginning with zer: zara -- http://mail.python.org/mailman/listinfo/python-list
Re: PY Zip
On 30 Jan 2007 21:18:52 -0800, "GISDude" <[EMAIL PROTECTED]> wrote: >Hi all. > >I am trying to find a module that has a Zip utility that I can use in >Python. I would like to be able to call the module and ZIP up a >directory. I thought there was such a module, but I have not been able >to find it. > >I need this to be able to be used in Python Win. Is there a ZIP utilty >already stored with a basic PYTHON download? > >Thanks all. It is included with basic Python installation. Look at Pyton Manulas, Library Reference, 12. Data Compression and Archiving. Best regards, Zara -- http://mail.python.org/mailman/listinfo/python-list
Re: why it is invalid syntax?
On Thu, 22 Nov 2007 00:00:16 -0600, alf <[EMAIL PROTECTED]> wrote: >Hi, > >I wonder why it is an invalid syntax: > > > >>> if 1: if 1: if 1: print 1 > File "", line 1 > if 1: if 1: if 1: print 1 > > >or > > >>> if 1: for i in range(10): print i > File "", line 1 > if 1: for i in range(10): print i > >I would expect one could nest : > You may take a look at python documentation, Language reference, 7. Compound statement. It clearly states that what follows the : of if,while,for... if it is not a new line, it should be a list of simple statements. Son no there is no : nesting. >compound_stmt ::= if_stmt > | while_stmt > | for_stmt > | try_stmt > | with_stmt > | funcdef > | classdef >suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT >statement ::= stmt_list NEWLINE | compound_stmt >stmt_list ::= simple_stmt (";" simple_stmt)* [";"] > Regards, Zara -- http://mail.python.org/mailman/listinfo/python-list
Re: "Python" is not a good name, should rename to "Athon"
On Sat, 1 Dec 2007 16:51:35 +0200, "Dotan Cohen" <[EMAIL PROTECTED]> wrote: >On 30/11/2007, Gerardo Herzig <[EMAIL PROTECTED]> wrote: >> You will be eaten by the Snake-Ra god tonight! > >Wasn't Ra the Sun god? > He meant quetzatcoatl. We could rename the language. Now try qith Quetzatcoatl and its derivatives: - QuetzatcoatlGTK - QuetzatcoatlTest - Quetzatcoatl_argfs_ughs_IlostMybreath And some equally funny and easy to pronounce others... Regards, Zara -- http://mail.python.org/mailman/listinfo/python-list
Re: "Python" is not a good name, should rename to "Athon"
On Sat, 1 Dec 2007 13:40:10 -0800 (PST), "Russ P." <[EMAIL PROTECTED]> wrote: >On Dec 1, 12:47 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> On Sat, 2007-12-01 at 12:10 -0800, Russ P. wrote: >> > On Dec 1, 2:10 am, Bjoern Schliessmann > > [EMAIL PROTECTED]> wrote: >> > > Russ P. wrote: >> > > > I agree that Python is not a good name for a programming language, >> >> > > Why not? >> >> > Think about proposing its use to someone who has never heard of it >> > (which I did not too long ago). As the OP pointed out, a Python is a >> > snake. Why should a programming language be named after a snake? >> >> That's not a persuasive argument. >> >> First of all, Python is named for a comedy troupe from England. For >> comparison, Perl is named for a knitting technique, Lisp is named for a >> speech impediment, Ruby is named for a rock, Smalltalk is named for a >> not-so-useful form of communication, and Java is named after a beverage >> or an island. >> >> Which of those is a good name for a programming language by your >> criterion? > >None. None of them are good names by my criteria. But then, a name is >only a name. One of the few names I like is Pascal, because he was a >great mathematician and scientist. > >After thinking about it a bit, here are examples of what I would >consider a good name for a programming language: > >Newton# >Newton* >Newton+ > >Newton was a great scientist, and his name is easy to spell and >pronounce. The trailing character serves to disambiguate it from >Newton in online searches. For shorthand in online discussions, N#, >N*, or N+ could be used as aliases. > >Names of other great scientists, mathematicians, or computer >scientists could also be used, of course. Take your pick. > >How about renaming Python3000? I would never use the name of a mathematician for a procedural language. Mathemathician names should be for funtional languages (such as Haskell). Procedural languages are flexible, they keep on tangling and getting out of it, they like publicity: Houdini or, as suggested in other messages: Houdini3 Best regards, Zara -- http://mail.python.org/mailman/listinfo/python-list
Re: Error on Python
On Sat, 9 Feb 2008 10:26:26 -0800 (PST), maehhheeyy <[EMAIL PROTECTED]> wrote: >Hi, right now I'm using Python and Multicast. I have the code for >Multicast receiver on Python but I keep getting this error; > >File "", line 1, in bind >error: (10049, "Can't assign requested address") > >The error is coming from this line; >sock.bind ((MCAST_ADDR, MCAST_PORT)) > >Can anyone please help me solve this problem? This error typically arises when the address is neither the IP address of a network connection or 0.0.0.0. If you are trying to connect an IGMP socket under Windows, it may not be treated as a normal socket. You must use the corresponding setsockopt() options, and I am not sure if they are available throguh Python! Search MSDN for IGMP, or lok directly at: http://msdn2.microsoft.com/en-us/library/ms739172(VS.85).aspx If you are trying on *NIX SO, I don't know if this is applicable best regrads, Zara -- http://mail.python.org/mailman/listinfo/python-list