Re: Python compiler method
"Lady_Valerie" <[EMAIL PROTECTED]> wrote: > >hello guys! i just want to ask favor, coz i want to know how python >compiler method could be done? im really clueless of this programming >language hope anyone coule help me with this topic... im just focusing >only on the compiler of the python.thanks a lot!!! Perhaps you could ask your question in a different way. Python is designed as an interpreted language, like Perl and Javascript. It isn't compiled to machine language. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
temp file name
Hi all, Is there a way to create a unique file name; safely i have used os.tmpnam() with python2.4, i warns that the usage is a potential security risk. tia KM -- http://mail.python.org/mailman/listinfo/python-list
Re: temp file name
Use the tempfile module instead. It is more secure. Check the documentation for tempfile.NamedTemporaryFile. If you are only looking to get a unique name and want to do the file management yourself, you may have to close the file opened by this function and reopen it. On Fri, 17 Dec 2004 17:21:53 +0530, km <[EMAIL PROTECTED]> wrote: > Hi all, > Is there a way to create a unique file name; safely > i have used os.tmpnam() with python2.4, i warns that the usage is a potential > security risk. > tia > KM > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-16, Jeff Shannon schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >>Demanding that users of dictioanaries somehow turn their mutable objects >>into tuples when used as a key and back again when you retrieve the keys >>and need the object [...] >> > > But, you generally don't "retrieve" _keys_ from dicts. You *use* keys > to retrieve *values* from a dict. The only way to get a dict to give > you a key is by using the keys() method (or items() method) to give you > *all* of the keys. > > You say that mutating the keys inside of a dict is bad, and yet you want > keys to be mutable. 1) I don't want them to be mutable. If there was a way to mark individual objects as immutable, I wouldn't mind having all the keys in a dictionary so marked. But I do have objects that turn out to be mutable which are IMO usefull as keys in a dictionary, although I don't want to mutate the keys in dictionaries. > This seems to be an internally inconsistent position, That is because you didn't accurately presented it. > nevermind the fact that I can't think of a case where I'm > likely to "retrieve" a key from a dict, modify it, and then put it > back. (I can think of endless cases where I'd want to do that with > *values*, but not with keys...) Well neither can I, but yet the fact that lists are mutable and tuples are not, is frequently presented as reason why tuples are allowed as keys and tuples are not. > (And if dicts were somehow changed so that keys were copied when added > to a dict, just so that every once in a while someone might be able to > avoid a few conversions to/from tuple, then you're adding the overhead > of an object copy to *every* dict insertion, thus slowing down (possibly > by a significant amount) a large proportion of Python operations. How > is that a gain?) Well will look at two scenario's. In each we will work with mutable objects that we would like to use a keys. In the first we transform them into an immutable object, in the second we just allow mutables to be inserted as keys, but insert a copy of the key instead of the key itself in order to protect the programmer somewhat from mutating dictionary keys. Now in scenario one we will have a lot more copies then in scenario two, because each time we want to use an object as a key we will first have to transform it into an immutable. That means every addition to the dictionary as well as every key access and each such transform means a copy. In scenario two we will only make a copy when a key is added to the dictionary, we don't need to make copies with key accesses. I think scenario two is a performance gain over scenario one. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
python re - a not needed
Hi ! I want to get infos from a html, but I need all chars except <. All chars is: over chr(31), and over (128) - hungarian accents. The .* is very hungry, it is eat < chars too. If I can use not, I simply define an regexp. [not<]* It is get all in the href. I wrote this programme, but it is too complex - I think: import re l=[] for i in range(33,65): if i<>ord('<') and i<>ord('>'): l.append('\\'+chr(i)) s='|'.join(l) all='\w|\s|\%s-\%s|%s'%(chr(128),chr(255),s) sre='([%s]{1,1024})'%all #sre='([?!\\<]{1,1024})' s='xmvccv ÁÁÁ sdfkdsfj eirfie' print sre print s cp=re.compile(sre) m=cp.search(s) print m.groups() Have the python an regexp exception, or not function ? How to I use it ? Thanx for help: kk -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-15, Steve Holden schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >> Op 2004-12-15, Roel Schroeven schreef <[EMAIL PROTECTED]>: >> >>>Antoon Pardon wrote: >>> Op 2004-12-15, Fredrik Lundh schreef <[EMAIL PROTECTED]>: >sorry, but I don't understand your reply at all. are you saying that >dictionaries >could support mutable keys (e.g lists) by making a copy of the key? how >would >such a dictionary pick up changes to the original key object? (I'm >talking about >the key stored in the dictionary, not the key you're using to look things >up). You want to mutate a key that is within a dictionary? >>> >>>No, we don't want to mutate it; as far as I know, that is exactly the >>>reason why dictionaries don't support mutable keys. >> >> >> And I think that is a stupid reason. There are enough other situations >> were people work with mutable objects but don't wish to mutate specific >> objects. Like objects in a sorted sequence you want to keep that way >> or objects in a heapqueue etc. >> >> Demanding that users of dictioanaries somehow turn their mutable objects >> into tuples when used as a key and back again when you retrieve the keys >> and need the object can IMO ibe a bigger support nightmare than the >> possibility that code mutates a key in a dictionary. >> > So provide your objects with a __hash__ method, and you can use them as > dictionary keys. > > Sheesh, learn Python already. What a troll. [Plonk] > Let me get this straight. You first say dictionaries don't support mutable keys for some reason. I say I find it a stupid reason. Then you mark me a troll because I don't know the language while at the same time making a suggestion that implies your original remark about python was wrong. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
On Thu, 16 Dec 2004 07:42:38 GMT, Dimitri Tcaciuc <[EMAIL PROTECTED]> wrote: > Hm, interesting. So I'm hearing lots of different opinions here, but it > seems like there's not too many radical thoughts about not using snake > at all and it can be pretty much summed up to 2 things > 1) use a snake > 2) combine snake with -some- monty python's symbolic +1 on both counts. > I personally totally like the thought of calling the snake Monty, I > couldn't even think of any other alternatives. +1 too. > But before pushing forward any particular design, maybe it will make > sense to make some sort of official logo contest on Python's main > website and post it on /. ? It's a great marketing idea. There was a thread recently on Python-dev that started with a message from Guido, where he talks about a seemingly persistent perception that exists in the specialized press regarding Python as a flexible, nice, but generally slow (or slower than the alternatives) language. The thread ended up as a discussion about Python marketing & advocacy in general. So I think that the timing is good. But on the other hand, making this into a open contest takes more than a simple announcement on Slashdot. Some things need to be arranged first: 1) Our vote may count, but Guido's opinion not only count, it's decisive. So I believe that's better for we to hear his opinion before we even start talking about it seriously. 2) The folks are python-dev are much more involved with Python than most people that gather around comp.lang.python. Their opinion is also important. However, to announce it on the python-dev list out of the blue is not a good idea; the list is highly focused on Python development issues, and is not the place for this discussion. I would prefer that some senior member (Guido himself, or some of the other old-timers) did the announcement on Ptyhon-dev, if only to make people know about it. 3) Finally, if there's a competition, there must be a decision process. It may be democratic voting, it may be a comitee, it may be Guido's opinion, I don't know. But the conditions need to be clear from the start. > That should be a better option, since there obviously are waaay more > great artists out there than the ones that somehow got on these > newsgroups :) > > So the question is, how can this be arranged? I am pretty new to Python > in general, so I don't know how this community's clockwork is arranged > and who to contact about that. I don't know... posting it on Python-dev would raise the attention of some folks, but may bother others, as this is really off-topic there. As far as I know, Python does not have a official contact for marketing issues. Maybe if just need to keep going with the discussion here, until someone who really knows the Python Ways "buys" the idea. And finally, Dimitri - congratulations for the design, but most important, for the attitude. -- Carlos Ribeiro Consultoria em Projetos blog: http://rascunhosrotos.blogspot.com blog: http://pythonnotes.blogspot.com mail: [EMAIL PROTECTED] mail: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-16, Jeremy Bowers schreef <[EMAIL PROTECTED]>: > On Wed, 15 Dec 2004 15:08:09 +, Antoon Pardon wrote: > >> And I think that is a stupid reason. There are enough other situations >> were people work with mutable objects but don't wish to mutate specific >> objects. Like objects in a sorted sequence you want to keep that way >> or objects in a heapqueue etc. >> >> Demanding that users of dictioanaries somehow turn their mutable objects >> into tuples when used as a key and back again when you retrieve the keys >> and need the object can IMO ibe a bigger support nightmare than the >> possibility that code mutates a key in a dictionary. > > Steve plonks you as a troll but I fear this is a point that either I am in > grave error on, or in our zeal to make this point simple for everyone > we've elided an important point and I'm not convinced it is as obvious as > he thinks it is. So, before trusting this message, wait for the angered > replies from those who know. Well IMO there are two sides in this argument. The first is whether or not python allows mutable keys. The second is whether or not limiting keys to immutables in dictionaries provides a performance gain. The two get mixed up a lot in this list, because a reasaonable amount argue that python only allows for immutable keys because of this supposed performance gain and that is why tuples are immutable because otherwise there wouldn't be a sequence type suitable as dictionary key. Then when I give arguments against the performance gain, people come with the argument that it is to protect keys in dictionaries from changing. > A dict key doesn't *really* need to be immutable. What it needs is the > following: the hash does not change over time, and an "equal" key will > always compare equally with no changes over time. Sample run: IMO there is nothing wrong with the hash or the equal comparisson being changable over time as long as the programmer is carefull not to change them while they are a key in a dictionary. Two guidelines can make it easier for a programmer to do this. 1) Put a copy in the dictionary, so that mutating the original object won't affect what is in the dictonary. 2) Don't mutate keys that come from a dictionary iterator. > [ Example ] > > I've seen this go by over and over and ISTM nobody ever clearly says this, > so either I'm in error on some point, or people are afraid to try to > explain the properties that must hold for mutable objects to be used in > hashes. Because the slightest violation can kill you... Yes, I find the python community a bit overprotective about some issues. I wouldn't be surprised the eas of doing something wrong here makes some people shy away from this. On the other hand if you have a sorted list or a heapqueue and you unknowingly mutate one of the elements in it you can be screwed too. Yet I don't see people suggest that only lists with immutable elements should be able to be sorted or that heapqueues should be limited to immutable elements. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: python re - a not needed
kepes.krisztian wrote: I want to get infos from a html, but I need all chars except <. All chars is: over chr(31), and over (128) - hungarian accents. The .* is very hungry, it is eat < chars too. Instead of writing ad-hoc html parsers, use BeautifulSoup instead. http://www.crummy.com/software/BeautifulSoup/ I will most likely do what you want in 2 or 3 lines of code. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list
[ANN] [Hack] Import binary extensions from zipfiles, windows only
Warning: experimental code! Overview zipextimporter.py contains the ZipExtImporter class which allows to load Python binary extension modules contained in a zip.archive, without unpacking them to the file system. Call the zipextimporter.install() function to install the import hook, add a zip-file containing .pyd or .dll extension modules to sys.path, and import them. It uses the _memimporter extension which uses code from Joachim Bauch's MemoryModule library. This library emulates the win32 api function LoadLibrary. Sample usage >>> import zipextimporter >>> zipextimporter.install() >>> import sys >>> sys.path.append("lib.zip") >>> import _socket >>> _socket.__file__ 'c:\\sf\\py2exe\\hacks\\memimp\\lib.zip\\_socket.pyd' >>> _socket.__loader__ >>> Bugs reload() on already imported extension modules does not work correctly: It happily loads the extension a second time. http://starship.python.net/crew/theller/moin.cgi/Hacks_2fZipExtImporter Cheers, Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: NO REALLY
> Isn't there a comp.lang.flame or something? comp.lang.object ? (there don't seem to be a comp.lang.procedural ...) -- http://mail.python.org/mailman/listinfo/python-list
Re: python re - a not needed
kepes.krisztian wrote: > Hi ! > > I want to get infos from a html, but I need all chars except <. > All chars is: over chr(31), and over (128) - hungarian accents. > The .* is very hungry, it is eat < chars too. > > If I can use not, I simply define an regexp. > [not<]* > > It is get all in the href. > > I wrote this programme, but it is too complex - I think: > > import re > > l=[] > for i in range(33,65): > if i<>ord('<') and i<>ord('>'): >l.append('\\'+chr(i)) > s='|'.join(l) > all='\w|\s|\%s-\%s|%s'%(chr(128),chr(255),s) > sre='([%s]{1,1024})'%all > #sre='([?!\\<]{1,1024})' > s='xmvccv ÁÁÁ sdfkdsfj eirfie' > > > print sre > print s > cp=re.compile(sre) > m=cp.search(s) > print m.groups() > > Have the python an regexp exception, or not function ? How to I use it ? > > Thanx for help: > kk You could try these regexps or variants thereof: "([^<]*)" '^' changes the character set to exclude any characters listed after '^' from matching. "(.*?)<" The '?' makes the preceding '*' non-greedy, i. e. the following '<' will match the first '<' character encountered in the string to be searched. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: KeyError
[EMAIL PROTECTED] wrote: Hi "R", The only explanation I can give is that the environment varialbe REMOTE_ADDR does not exist! Wrap your high-level code with try and except. Example: try: tablesDirectory = tablesDirectoryPrefix + os.environ['REMOTE_ADDR'] except KeyError: # Code to handle the fact tht REMOT_ADDR does not exist. ... or just replace os.environ['REMOTE_ADDR'] with os.environ.get('REMOTE_ADDR', 'enter_default_here') to use a default in case of missing REMOTE_ADDR ... HtH, Roland -- http://mail.python.org/mailman/listinfo/python-list
".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
Nick Coghlan schrieb: data = [['foo','bar','baz'],['my','your'],['holy','grail']] result = [] for d in data: .>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']] .>>> from itertools import chain .>>> result = "".join(chain(*data)) 'foobarbazmyyourholygrail' This is the first time I see that and I totally like the idea of writing ".>>>" instead of ">>>" at the beginning of a line. Thank you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the default prompt as it messes up the display on mail/news readers that provide "syntax highlighting" for quotes. I wish everyone would write examples that way! On the other hand - three levels of quoting are really rare, maybe it would be easier to change that in the mail readers... ... or in Py3k ? Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Antoon Pardon wrote: Well IMO there are two sides in this argument. The first is whether or not python allows mutable keys. The second is whether or not limiting keys to immutables in dictionaries provides a performance gain. The problem is that you don't understand what dicts are typically used for. Because of the nonliniarity in dict lookups, dicts are used for optimisation. I actually think it's the most important tool for optimising Python code. If dicts allowed mutable keys, a dict would need to run code that corresponds to:: def has_key(key): for key in self.keys(): if a_key == key: return True return False Using immutable keys, a code can be generated for the key, that can be efficiently stored in something like a binary tree. This makes lookup *very much* faster, and is the speed concern that Python programmers care about. Not the time taken to convert a list into a tuple. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Peter Hansen wrote: Martijn Faassen wrote: Peter Hansen wrote: Well, in any case, thanks for setting the record straight, Martjin. That of course also happens to me once every while. I can take care of myself though -- Dijkstra however needs an advocate for the correct spelling of his name in this earthly realm. Then there's us Danes, with "sen" instead of "son" (as many people think it ought to be). And I can't even claim the wrong form sounds noticably different, making any defense seem petty. Obviously -sen is the only real suffix, as it's -sen in Dutch as well, as in Faas-sen. :) (Darn those Norwegians, influencing people's ideas of how a name like Hansen ought to be spelled, grumble, grumble. If they'd just invent a cell phone that used Python, as the Swedish have, they might deserve all that extra attention.) ;-) That's not the Swedes, it's the Finnish that did that. They typically don't like being mistaken for Swedes. :) Regards, Martijn -- http://mail.python.org/mailman/listinfo/python-list
Avaliable free modules
Hi group, Is there any site like cpan.org for python? Thanks Sam -- http://mail.python.org/mailman/listinfo/python-list
Re: Avaliable free modules
Vaults of Parnassus: http://www.vex.net/parnassus/ On Thu, 16 Dec 2004 18:56:09 +0800, sam <[EMAIL PROTECTED]> wrote: > Hi group, > > Is there any site like cpan.org for python? > > Thanks > Sam > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: libxml2/xpath
Maxim Khesin wrote: I am trying to do some xpath on http://fluidobjects.com/doc.xhtml but cannot get past 'point A' (that is, I am totally stuck): import libxml2 mydoc = libxml2.parseDoc(text) mydoc.xpathEval('/html') [] this returns an empty resultlist, which just seems plain wrong. Can anyone throw a suggestion to the stupid? Is the html element in a namespace? Regards, Martijn -- http://mail.python.org/mailman/listinfo/python-list
MDaemon Warning - virus found: delivery failed
*** WARNING ** Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado un fichero anexo(s) infectado(s). Por favor revise el reporte de abajo. AttachmentVirus name Action taken -- instruction.zip I-Worm.Mydoom.m Removed ** Your message was not delivered due to the following reason(s): Your message was not delivered because the destination server was not reachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most likely there is a network problem that prevented delivery, but it is also possible that the computer is turned off, or does not have a mail system running right now. Your message could not be delivered within 2 days: Host 65.2.190.203 is not responding. The following recipients could not receive this message: <[EMAIL PROTECTED]> Please reply to [EMAIL PROTECTED] if you feel this message to be in error. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help need with converting Hex string to IEEE format float
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > One example I tried was: > > wibble = struct.unpack("f", struct.pack("l", long(conv_str, 16))) > OverflowError: long int too large to convert to int You can't fit 0x8000L into a signed 32-bit integer, use 'L' for an unsigned one. > If I follow the examples I have found on the net using a set value of > 0x8000 in them, everything works fine from the interpreter line. This depends on the Python version: before 2.4 0x8000 corresponds to the bit pattern you expect but will be negative. That's why it's happy as a signed 32-bit integer. >>> 0x8000 == 0x8000L :1: FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up ... False -- http://mail.python.org/mailman/listinfo/python-list
Re: Avaliable free modules
On Thu, 16 Dec 2004 18:56:09 +0800, rumours say that sam <[EMAIL PROTECTED]> might have written: >Hi group, > >Is there any site like cpan.org for python? Google these: "vaults of parnassus" "python package index" They're an approximation of CPAN. If you waited for a week in the newsgroup, you would see a post "Dr. Dobb's Python-URL! - weekly Python news and links" with very useful links. You can google for one of these in groups.google.com, if you are hasty. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
On 15 Dec 2004 12:18:15 -0800, fuzzylollipop <[EMAIL PROTECTED]> wrote: > TruStudio for Eclipse is nice for those everything must be free > socialists. -OR- - Those who are new to python, more comfortable in an IDE, and want a Python-enabled IDE that they can use without having to pay now - Those who would prefer to use one IDE for many different languages that may include Java and C/C++ - Those who have been doing the "Emacs/Vi" and command line thing for a while and would like to try an IDE without having to pay yet - Those who may have to work on multiple different platforms (say Linux, Windows, and OS X) on a day-to-day basis and would rather not have to maintain multiple different IDE skillsets for the same languages - Those who are dabbling in Python, aren't sure that they're going to stick with it, and would have a hard time justifying spending money on a piece of software that they may not use again in a month There are certainly great "for pay" IDE's out there, and Eclipse may lack huge featuresets that these commercial IDE's have. Howerver, to suggest that those who would use Eclipse are socialists kinda rankles, you know? -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient grep using Python?
On Wed, 15 Dec 2004 16:10:08 +, rumours say that [EMAIL PROTECTED] might have written: >> Essentially, want to do efficient grep, i..e from A remove those lines which >> are also present in file B. > >You could implement elegantly using the new sets feature >For reference here is the unix way to do it: > >sort a b b | uniq -u No, like I just wrote in another post, he wants $ grep -vf B A I think that $ sort A B B | uniq -u can be abbreviated to $ sort -u A B B which is the union rather than the intersection of the files, wastes some time by considering B twice, and finally destroys original line order (should it be important). -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-16, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >> That depends on whether the programmes wants value equality >> or identity equality. >> >> In the first case the programmer shouldn't mutate a after >> it was introduced as key in the dictionary; but should >> either introduce a copy or work on a copy later. As >> such your snippet of code would become. >> >> a = [1,2,3] >> d[a[:]] = 9 >> a.append(4) >> print d[a] >> >> And this would raise a KeyError, unless the list [1,2,3,4] >> would be in the dictionary. >> >> In the second case your code would produce 9. > > how does the dictionary know if you want key value equality or key > identity equality? By the __hash__ and __eq__ methods you provide on your object. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Python Test Environment
This seems to work very well. I'm still tweaking the 'stdlibfinder.py' and the setup.py - but it's still ok. In some ways it acts like a basic 'Python Runtime Environment'. Part of the reason for building it was that in one of my jobs I don't have python installed and can't install new programs. I'm now using testenv with wxPython, and DrPython as an IDE - it works fine. Even SPE seems to work fine (it complains about a missing dll and then works anyway). I've even associated '.py' files with testenv... I have prebuilt environments for python 2.4 and python 2.3. I'm not making them available by http because of bandwidth concerns (4meg zipfiles each). If anyone want to try python 2.4 without having to install it, you're welcome to email me and I''ll send you a copy. Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Avaliable free modules
No but a lot of people would like there to be. No one has (to my knowledge) come forward to do the work on it yet though (or offered the bandwidth). There is a *list* of packages available - with information and liks - called the Python Package Index. See http://www.python.org/pypi Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-16, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Two guidelines can make it easier for a programmer to do this. >> >> 1) Put a copy in the dictionary, so that mutating the original >>object won't affect what is in the dictonary. > > What's supposed to happen here? > > a = [1,2,3] > d[a] = 9 > a.append(4) > print d[a] > > It doesn't sound like good dictionary semantics to me. That depends on whether the programmes wants value equality or identity equality. In the first case the programmer shouldn't mutate a after it was introduced as key in the dictionary; but should either introduce a copy or work on a copy later. As such your snippet of code would become. a = [1,2,3] d[a[:]] = 9 a.append(4) print d[a] And this would raise a KeyError, unless the list [1,2,3,4] would be in the dictionary. In the second case your code would produce 9. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: NO REALLY
Peter Hansen wrote: Brian van den Broek wrote: Peter Hansen said unto the world upon 2004-12-15 17:39: I could easily see this thread descending into a flame war in, oh, about another ten posts. That would be so freaky... Without a doubt that is the most ignorant and small-minded thought that ever has been, and ever could be, committed to words! And you, sir, must be, like, one of those Nazi type people, like that guy, uh, what was his name? er.. Godwood, Goodwin, something like that, anyway. (Hey, Jive, you happy yet?) Object oriented programming SUX! And Python too! It's slow and no scientific research exists in its favor! Also it doesn't work. Why would I need polymorphism? Lisp had all of this 50 years ago anyway. But functional programming by the way SUX TOO! So does procedural programming! And structured programming SUX, GOTO all the way! Oh, and Vi SUX, Emacs all the way. Emacs Lisp SUX though. Java is the only true object oriented language, so Python is not truly object oriented and it's slow anyway. The future will be to .NET. Oh and XML sucks! Python developers are above XML! And why doesn't Python have a web framework like Ruby on Rails? Python has way too many web frameworks, that SUX! And oh by the way, Ruby SUX! Perl is way superior to Python as it outperforms it and it's more readable. Indentation SUX! Depending on it is Barbaric, which is like Cobol, which by the way, ROCKS! The decorator syntax SUX! Why didn't they just use the ternary operator syntax for it?? Oh, and Python really went downhill since version 1.5.2! Python will not be a mature language if it doesn't add UNSIGNED INT, SIGNED LONG and FLOAT to the language as basic data types. Oh, and any language that doesn't have True Macros SUX. Guido von Rossam is ITALIAN! And he SUX! I SUX TOO BUT I WILL NEVER ADMIT TO IT EVER IN THIS WHOLE DISCUSSION, I will answer ANY argument indicating that my arguments are fallacious and my behavior unreasonable with the TRUTH, which is that you SUX. Hah! Martijn -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Antoon Pardon wrote: >> how does the dictionary know if you want key value equality or key >> identity equality? > > By the __hash__ and __eq__ methods you provide on your object. so what you're saying is that Python dictionaries should work just like Python dictionaries work today. sorry for wasting my time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
limodou wrote: http://wiki.wookpecker.org.cn/moin.cgi/NewEdit Try this instead: http://wiki.woodpecker.org.cn/moin.cgi/NewEdit ^ SCNR, Roland ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Module question
On Wed, 15 Dec 2004 18:10:40 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: > The difference being that when Excel opens up a *.CSV, it goes through > the import wizard. Are you sure that's true? When I open a *.csv file, Excel *appears* to open it without running any kind of wizard. Certainly I don't see any wizard dialogues. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Winge IDE Issue - an suggestions?
Mike Thompson wrote: I've run into a problem using WingIDE. I have a dead simple script (which uses ElementTree): from elementtree.ElementTree import Element, SubElement, tostring Just to be clear: that's the effbot's ElementTree package at http://effbot.org/zone/element-index.htm -- Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Multithreading tkinter question
"Mark English" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Is there a safe way to run tkinter in a multithreaded app where the mainloop runs in a background thread ? Mark, I tried your code snippet with Python 2.3.4. Worked fine. Only problem was that the program fell off the end and terminated before the second thread could open the Tkinter window. So I added these lines at the end to make the main thread wait:- from msvcrt import kbhit, getch print "\n\nPress key to end" while not kbhit(): pass getch() Both your Hello and Quit buttons worked. However, I have found that tkinter crashes if any components, labels text box etc, are accessed directly from another thread. Below is a posting I did some time ago. My solution to the problem. I'm still interested to know if this is a good/best way to solve this problem. It is not optimal in that 'otherThread' runs continuously even when the label is not being updated. What a waste of cpu cycles! This shows up in that other windows apps slow right down. What is needed is a comms method between threads that causes a thread to block while it's waiting for data rather than my continuous polling approach. Would a Queue help here? John Pote "Martin Franklin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, 09 Nov 2004 17:41:56 GMT, John Pote <[EMAIL PROTECTED]> > wrote: > >> Running my programme in Python 2.3.4 I received the following msg in the >> consol :- >> (Pent III running W2K prof) >> >> """ >> Exception in Tkinter callback >> Traceback (most recent call last): >> File "c:\apps\python\234\lib\lib-tk\Tkinter.py", line 1345, in __call__ >> return self.func(*args) >> File "c:\apps\python\234\lib\lib-tk\Tkinter.py", line 459, in callit >> self.deletecommand(tmp[0]) >> AttributeError: 'str' object has no attribute 'deletecommand' >> UpdateStringProc should not be invoked for type option >> >> abnormal program termination >> """ >> There was no other traceback information. >> >> Could this be related to lines of the ilk:- >> self.infoSpd.config(text="%d.%01d"%spd) >> where infoSpd is a Tkinter Label object placed using the grid manager. >> >> Thousands of these updates were performed so the labels displayed >> progress >> through a memory dump of a system accessed through a serial port. >> >> I had trouble before with Python versions 2.2.1 and 2.2.3 where >> commenting >> out these Label updates stopped the system crashing and it was happy to >> run >> for hours performing tests on the external hardware. (an embedded data >> logger I'm developing) >> >> Anyone any thoughts? >> >> John > > > Only one (thought that is) Are you updating thses Label widgets from > other > threads? and could you possibly post an example? > > Martin A -- Experience had already taught me that lesson about tkinter. On checking my code guess what I found I'd done - called the widget.config method from the other thread. So I put in a list to queue the label updates from the other thread to the tkinter thread and it's now been running for several hours without problem. Thanks for the reminder. BTW the program structure I've been using is:- def otherThread(): while TRUE: if updatelabel: labelQ = "new label text" def guiLoop(): if labelQ: myLabel.config(text=labelQ) labelQ = None #re-register this fn to run again rootWin.after(10, guiLoop) #strangely .after_idle(guiLoop) is slower! . . rootWin = Tk(className=" tester") #rest of GUI set up. then:- thread.start_new( otherThread, () ) rootWin.after(50, guiLoop) rootWin.mainloop() It works but is it the best way to do this sort of thing? The point is that I need moderately fast serial comms, which I do in 'otherThread' and found the 'after' and 'after_idle' call backs were too slow. The timing I did on py2.2.1 indicated that 'after_idle' could not do better than ~70ms and 'after(10, )' was faster, 30-40 ms, but still too slow for my app. Any more thoughts appreciated. John -- http://mail.python.org/mailman/listinfo/python-list
Re: logging in omniORB for python
> > it gets written to stdout - and then looks like this: > > omniORB: ObjRef(IDL:ehotel.de/omphalos/Domain:1.0) -- deleted. It was tricky: PythonWin doesnt display this, only the output of the program. Now I have started it in the DOS Box (startPrg.py >logout.log) and the omniORB uses the DOS Box to display the messages and the output of the prg (in Pythonwin shown in the log window) was logged. OK, I see ORB is displaying the expected tracelevel, now I only must redirekt it. Thanks to all wh helped me. Birgit -- http://mail.python.org/mailman/listinfo/python-list
Re: cygwin python.exe symlink breaks when called from .bat file
George, Please keep your replies on-list. On Wed, Dec 15, 2004 at 01:36:03PM -0500, george young wrote: > On Wed, 15 Dec 2004 10:56:17 -0500 > Jason Tishler <[EMAIL PROTECTED]> threw this fish to the penguins: > > On Wed, Dec 15, 2004 at 07:21:31AM -0800, gry wrote: > > > Under cygwin, the python executable is installed as python2.4.exe > > > with a symbolic link to python.exe. This is fine as long as one > > > is operating only withing the cygwin world. But I execute python > > > from a foo.bat file, and windows barfs on the symbolic link. > > > > You can always do the following as a workaround: > > > > C:\> bash -c python > > Hmm, that's fine for typing a command interactively, but try fitting > it into a DOS "ftype" command so that double-clicking a .py file gets > the right thing with the right args -- nasty, I couldn't get it to > work. Since you are looking for tight integration with Windows, maybe you should use Win32 Python? > > > I replaced it with a hard link and all is well. > > > > Note the above will only work as a true hard link under NTFS. IMO, > > the above is a better approach. > > > > > Is there some reason this shouldn't be the standard installation > > > under cygwin? > > > > Because it would require (more) modification of the Unix build to > > accommodate Windows. IMO, it is not worth the effort. If you feel > > differently, then submit a patch for consideration: > > > > http://sf.net/tracker/?func=add&group_id=5470&atid=305470 > > I'll try that... maybe I can light a fire. > > > BTW, many other Cygwin commands have this issue too: > > > > $ find /bin -type l -name '*.exe' > > /bin/awk.exe > > /bin/c++.exe > > /bin/captoinfo.exe > > /bin/cc.exe > > ... Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Antoon Pardon wrote: > >> That depends on whether the programmes wants value equality >> or identity equality. > > how does the dictionary know if you want key value equality or key > identity equality? Smalltalk has separate Dictionary and IdentityDictionary classes. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Multithreading tkinter question
> Date: Thu, 16 Dec 2004 11:59:53 GMT > From: "John Pote" <[EMAIL PROTECTED]> > > "Mark English" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Is there a safe way to run tkinter in a multithreaded app > where the mainloop runs in a background thread ? > > > I tried your code snippet with Python 2.3.4. Worked fine. > Only problem was > that the program fell off the end and terminated before the > second thread > could open the Tkinter window. John, Thanks for trying that out. I hadn't thought to try another version of python. I should have said that the example code snippet was for entry at the command prompt rather than putting in a module or script. I've tried with activestate Python 2.3.2 and it worked fine. When I submitted the code I was using my own build of Python 2.4. On another machine I installed Python2.4 and pywin32-203.win32-py2.4 to ensure I hadn't messed my build up. Running a normal Tkinter test works fine. Running the test code I submitted at the python prompt (or rather putting the function in a module and calling it from the python prompt as indicated in the test code) caused the Tkinter window to come up on the taskbar, but it was invisible. I can only minimize and attempt to close it - close reports that I will have to kill the program. In other words, it appears to be broken. Has anyone else seen any similar problems with Python 2.4 or, conversely, does it all work ok ? Having now seen the code work with activestate Python 2.3.2 there's this tantalising prospect that it all might "just work" after all. Cheers, mE --- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Op 2004-12-16, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >>> how does the dictionary know if you want key value equality or key >>> identity equality? >> >> By the __hash__ and __eq__ methods you provide on your object. > > so what you're saying is that Python dictionaries should work just like > Python dictionaries work today. > > sorry for wasting my time. In the end yes. I was a bit confused at first because others were asserting that python didn't allow mutable keys and gave reasons for why they thought that was a good thing. I didn't know better so originally just tried to argue why that would be a bad thing. As it turns out those assertions were wrong. Although the documentation on the python site does state this: http://docs.python.org/lib/typesmapping.html Only values containing lists, dictionaries or other mutable types (that are compared by value rather than by object identity) may not be used as keys. And the following: http://docs.python.org/ref/customization.html If a class defines mutable objects and implements a __cmp__() or __eq__() method, it should not implement __hash__(), since the dictionary implementation requires that a key's hash value is immutable (if the object's hash value changes, it will be in the wrong hash bucket). I find the latter to be misleading. The dictionary class probably doesn't require that a key's hash value is immutable, just that a key's hash value doesn't mutate during its lifecycle in the dictionary. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
Stefan Behnel wrote: Nick Coghlan schrieb: data = [['foo','bar','baz'],['my','your'],['holy','grail']] result = [] for d in data: .>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']] .>>> from itertools import chain .>>> result = "".join(chain(*data)) 'foobarbazmyyourholygrail' This is the first time I see that and I totally like the idea of writing ".>>>" instead of ">>>" at the beginning of a line. Thank you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the default prompt as it messes up the display on mail/news readers that provide "syntax highlighting" for quotes. Off topic, but indeed: I use Quote Colors in Mozilla which is very nice for reading mails or news posts with quotes, but it's very confusing with Python's prompt. Prepending every line with . is not an ideal solution though... I think it gets tiresome very quickly. -- "Codito ergo sum" Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: cygwin python.exe symlink breaks when called from .bat file
Jason Tishler wrote: >> > You can always do the following as a workaround: >> > >> > C:\> bash -c python >> >> Hmm, that's fine for typing a command interactively, but try fitting >> it into a DOS "ftype" command so that double-clicking a .py file gets >> the right thing with the right args -- nasty, I couldn't get it to >> work. > > Since you are looking for tight integration with Windows, maybe you > should use Win32 Python? I don't use Cygwin myself, but several Cygwin users have told me that exemaker has been immensely useful for them: http://effbot.org/zone/exemaker.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin Not Updating
Chris wrote: I'm working on a program in PythonWin. The problem I'm running into is that after I make a code change, PythonWin doesn't always see it. Has anyone else had this problem? Chris I've had this problem with older builds of PythonWin. With build 202 tis doesn't seem to be a problem for me. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: cygwin python.exe symlink breaks when called from .bat file
[EMAIL PROTECTED] wrote: [Windows XP Pro, cygwin python 2.4] Under cygwin, the python executable is installed as python2.4.exe with a symbolic link to python.exe. This is fine as long as one is operating only withing the cygwin world. But I execute python from a foo.bat file, and windows barfs on the symbolic link. I replaced it with a hard link and all You could rename the symbolic link python.exe to python. Bash finds it anyway and cmd.exe will it ignore it. Several of the symbolic links are created without .exe by the installation. If you really want to use cygwin-Python from cmd.exe, use doskey to create an alias or create a batch file. > is well. Is there some reason this shouldn't be the standard > installation > under cygwin? Hard links are available only with NTFS volumes. (OK, you could create a hard link with FAT*, but chkdsk will complain.) Daniel -- http://mail.python.org/mailman/listinfo/python-list
bdb question
Hi, I am trying to fix the following problem: 1) I have a gui thread + a background thread that intantiates a bdb child. 2) When I wish to quit in the middle of a debugged program, I roughly do the following: 2.a) set_quit() 2.b) kill my bdb child 2.c) stop my background thread I notice that my debugged program keeps running to its end although the above seems to eventually work. Any clue ? Regards, Philippe -- * Philippe C. Martin SnakeCard LLC www.snakecard.com * -- http://mail.python.org/mailman/listinfo/python-list
Re: NO REALLY
Martijn Faassen wrote: It's slow and no scientific research exists in its favor! Also it doesn't work. Why would I need polymorphism? Lisp had all of this 50 years ago anyway. But functional programming by the way SUX TOO! So does procedural programming! And structured programming SUX, GOTO all the way! Your insightful post here has led me to reflect that a Deterministic Finite-state Automata, the core of our initial studies of computation, while not Turing-Equivalent, is blazes fast and thoroughly understood. Such machines (DFAs) are pure GOTO machines, and therefore incredibly beautiful; a very sharp knife to cut through modern problems. This, of course, means that DJIJSTRA (there, one of the J's is right) SUX!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Module question
Thanks to everyone for the prompt reply, I now have several options to explore. Thanks again, Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Python Test Environment
Hi Fuzzy, I'm quite interested in your test environment project. It would enable me to carry my favorite working environment around on my 1gb flashdisk. Very useful indeed, as I also sometimes am at places where I can't install or don't want to install python and all set of libraries. What is the missing dll SPE is complaining about? Maybe you can email me privately out of this list to discuss this further ([EMAIL PROTECTED], replace nospam with gmx). Maybe I could offer it as a special SPE download for python newbies, if I can convince blender.org concerning bandwith. I rather would call it than 'movable' python. Test environment seems more for hardcore developpers, while this is excellent for newbies to try and play around before installing. What is the unpacked size of this python environment? Any chance if this would work for other platforms as well? Stani http://spe.pycs.net http://www.stani.be Fuzzyman wrote: > This seems to work very well. I'm still tweaking the 'stdlibfinder.py' > and the setup.py - but it's still ok. In some ways it acts like a basic > 'Python Runtime Environment'. > > Part of the reason for building it was that in one of my jobs I don't > have python installed and can't install new programs. I'm now using > testenv with wxPython, and DrPython as an IDE - it works fine. Even SPE > seems to work fine (it complains about a missing dll and then works > anyway). I've even associated '.py' files with testenv... > > I have prebuilt environments for python 2.4 and python 2.3. I'm not > making them available by http because of bandwidth concerns (4meg > zipfiles each). If anyone want to try python 2.4 without having to > install it, you're welcome to email me and I''ll send you a copy. > > Regards, > > Fuzzy > http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: why not arrays?
On Thu, Dec 16, 2004 at 05:51:18AM -0800, Rahul wrote: > Hi. > I just wanted to know why arrays have not been included as a builtin > datatype like lists or dictionaries? The numpy extension shows that it > can be implemented. then why not include arrays in core python? Arrays are included in a module in the standard module called 'array'. -- Gerhard signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: why not arrays?
Because the "list" object covers all the functionality contained in the traditional "array" structure. If it pleases you , you can ignore the additional conveniences the list object offers and just treat it like an ordinary array. Unless, of course, what you are seeking are the joys associated with memory allocation/deallocation :-) Thomas Bartkus "Rahul" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi. > I just wanted to know why arrays have not been included as a builtin > datatype like lists or dictionaries? The numpy extension shows that it > can be implemented. then why not include arrays in core python? > rahul > -- http://mail.python.org/mailman/listinfo/python-list
Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
Roel Schroeven wrote: Stefan Behnel wrote: This is the first time I see that and I totally like the idea of writing ".>>>" instead of ">>>" at the beginning of a line. Thank you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the default prompt as it messes up the display on mail/news readers that provide "syntax highlighting" for quotes. I use Thunderbird, and started doing it so I could read my own posts. I did copy it from someone, though (but I can't recall who). The trick can also be useful for web tools that strip leading whitespace. Prepending every line with . is not an ideal solution though... I think it gets tiresome very quickly. Aye, can't argue with that. It does have the virtues of reliability and portability, though :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Winge IDE Issue - an suggestions?
Without further checking I would propose you let WingIDE ignore this exception - most probably WingIDE is choking on a exception that was thrown intentionally by the module writer. I hope you know how to let WingIDE ignore exceptions? (In the upper part of the Exceptions-tool click on 'Ignore this exception location')... hope this helps. Regards, Marco -- http://mail.python.org/mailman/listinfo/python-list
Re: Unpacking Binary Data - not using struct module
Geoffrey wrote: My questions ... 1) Does anyone recognize this numeric format ? Seem to be some decimal coded binary, where you only use hexa from 0 to 9, coding corresponding decimal digits. The trailing hexa F may be used to indicate the end of the number (if number can have variable length) as it is normally not used as a digit in this coding. 3) I think that the trailing "f" is sometimes used to indicate the sign of the number and perhaps even the number of decimal places ... but am not sure. Maybe... but have you an example of a negative number ? A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient grep using Python?
Christos TZOTZIOY Georgiou wrote: On Wed, 15 Dec 2004 16:10:08 +, rumours say that [EMAIL PROTECTED] might have written: Essentially, want to do efficient grep, i..e from A remove those lines which are also present in file B. You could implement elegantly using the new sets feature For reference here is the unix way to do it: sort a b b | uniq -u No, like I just wrote in another post, he wants $ grep -vf B A I think that $ sort A B B | uniq -u can be abbreviated to $ sort -u A B B which is the union rather than the intersection of the files wrong. Notice the -u option to uniq. http://marc.free.net.ph/message/20021101.043138.1bc24964.html wastes some time by considering B twice I challenge you to a benchmark :-) and finally destroys original line order (should it be important). true -- Pádraig Brady - http://www.pixelbeat.org -- -- http://mail.python.org/mailman/listinfo/python-list
Re: do you master list comprehensions?
Nick Coghlan wrote: (FYI, I filed bug report #1085744 on SF about this) And Raymond Hettinger was able to decipher my somewhat incoherent rambling (tip: don't try to write bug reports in the wee hours of the morning) and produce a potentially useful modification to PySequence_Tuple. Anyway, I guess the results I got emphasizes the fact that it's important to measure performance of the actual methods you're using on representative input data, rather than relying on overly simple demonstrators. And, of course, don't be *too* concerned about optimisations until you know you actually have a performance problem. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
> > But before pushing forward any particular design, maybe it will make > > sense to make some sort of official logo contest on Python's main > > website and post it on /. ? > I was waiting for someone to propose that :-) I'm new to this list and Python in general, but I think that this sort of things are always decided by Guido. I think we have two options: 1) Simply start the contest and see what happens. If it attrackts many competitors, I guess it will be considered by the core developers. 2) Ask for permition and let them define the rules. Perhaps the BDFL is reading this thread and has something to say about it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Unpacking Binary Data - not using struct module
"Geoffrey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 1) Does anyone recognize this numeric format ? Google :) http://www.room42.com/store/computer_center/packed_decimal.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: why not arrays?
Rahul wrote: Hi. I just wanted to know why arrays have not been included as a builtin datatype like lists or dictionaries? The numpy extension shows that it can be implemented. then why not include arrays in core python? rahul As Gerhard mentioned, the standard library module 'array' can be used for data-type specific one-dimensional arrays. For more complex (i.e. multi-dimensional) arrays - the general answer is "get numpy". I'm not aware of the actual reasons why numpy is not included in the standard library, but some possible reasons would be: - size (increase the base Python download too much) - portability (less portable than the core interpreter) - stability (the numpy folks aren't yet prepared to commit to the backwards compatibility issues associated with being part of the standard library) - logistics (merging numpy into Python is likely to be a pain) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: why not arrays?
Rahul wrote: Hi. I just wanted to know why arrays have not been included as a builtin datatype like lists or dictionaries? The numpy extension shows that it can be implemented. then why not include arrays in core python? rahul We know of three implementations of arrays now: the "array" module, the "numpy" implementation, and the "numarray" implementation. Clearly there are some trade offs here with no clear winner. Until there is a clear favorite, it would be a bad idea to choose a winner. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for wget-like module for getching software
Robert P. J. Day schrieb: that is, i can just say, "go get file gcc-3.4.2.tar.bz2", and start searching at "ftp://pub.gnu.org/pub/gcc";. i may not know how far down in the directory structure that file is, but wget will happily search recursively until it finds it. That sounds pretty inefficient and should produce some load on the server side. Imagine everyone doing that. Many FTP-servers provide files like "ls-R.gz" somewhere, meaning, a list of files and directories. And then, there's Google. Why do you have to use FTP? Ask Google for "yourfile.tar.bz2 site:the.domain.name". It will very likely return a suitable URL for you that you can use for download. Just tried it with "site:ftp.gnu.org gcc-3.4.2.tar.bz2" - works. You can even use that link and try to replace "http://"; with "ftp://"; for download. Should work for many source repositories. You can use urllib2 for both querying and download. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
Chris <[EMAIL PROTECTED]> said : > Okay, I searched www.python.org for a date handler and found datetime. > http://www.python.org/dev/doc/devel/lib/module-datetime.html However, > whenever I try to import datetime, I get a No module named datetime > error. What am I missing? The module documentation says "New in version 2.3". Is that what you're running ? -- YAFAP : http://www.multimania.com/fredp/ -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
Okay, I searched www.python.org for a date handler and found datetime. http://www.python.org/dev/doc/devel/lib/module-datetime.html However, whenever I try to import datetime, I get a No module named datetime error. What am I missing? The module documentation says "New in version 2.3". Is that what you're running ? Doh! No, I'm still running 2.2. Anyways, I managed to do what I needed using time. Thanks for the help, though. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
How about just 'time',. import time time.ctime() 'Thu Dec 16 10:25:11 2004' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
> It's a great marketing idea. There was a thread recently on Python-dev > that started with a message from Guido, where he talks about a > seemingly persistent perception that exists in the specialized press > regarding Python as a flexible, nice, but generally slow (or slower > than the alternatives) language. Perception of the press: Python is "flexible, nice, but generally slow" Well, the snake mascot as drawn is, of course, very flexible, appears to be friendly, and is, well, just how fast is a big snake, esp. a python? It'll get there, slithering along, but it doesn't really conjure up a "beaming" between two galaxies in a nanosecond image. I like Monty (the snake), but perhaps there are liabilities arising from having a mascot (what is the mascot for C++?) Of course all those speed comparisons on the web don't help either. EP "Fast enough is only fast enough for today, not for tomorrow's possibilities. Network speeds will increase by a magnitude, ahead of processing power - then code execution speed will be a limiting factor." Oh, and while I'm wishing for the Moon, can I have a builtin Prolog/logic object. ;-) hey, Python is better than I deserve: mucho thanks to Guido and the core Pythonistas... -- http://mail.python.org/mailman/listinfo/python-list
(No subject)
Hi I'm brand new to python and I was wondering if anybody knew of a easy way to change every character in a list into its lower case form. The list is like so: commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] and what I want is: commands = ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Are there any defined method within any known modules to do this in one go? Thanks in advance _ Sign up for eircom broadband now and get a free two month trial.* Phone 1850 73 00 73 or visit http://home.eircom.net/broadbandoffer -- http://mail.python.org/mailman/listinfo/python-list
Re: change windows system path from cygwin python?
The _winreg api looks helpful; unfortunately, I'm trying to stick to what can be got from the cygwin install -- no _winreg. Simplicity of installation is quite important. (I'm using cygwin to get the xfree86 X-server, which is the whole point of this exercise) I have found the cygwin command-line "regtool" for munging the registry, so I plan to use that via os.popen. Thanks all for pointing me to the right place in the registry! -- http://mail.python.org/mailman/listinfo/python-list
Re: Upgrading Python Article
Tim Roberts schreef: > I don't think that's fair. Visual C++ 7.1 is signficantly better at > compliance than their past compilers. AFAIK that's only for C++, not for C...? -- JanC "Be strict when sending and tolerant when receiving." RFC 1958 - Architectural Principles of the Internet - section 3.9 -- http://mail.python.org/mailman/listinfo/python-list
Re: (No subject)
Mark Devine wrote: Hi I'm brand new to python and I was wondering if anybody knew of a easy way to change every character in a list into its lower case form. The list is like so: commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] and what I want is: commands = ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Are there any defined method within any known modules to do this in one go? Thanks in advance _ Sign up for eircom broadband now and get a free two month trial.* Phone 1850 73 00 73 or visit http://home.eircom.net/broadbandoffer You could use string.lower (make sure you "import string"): In [14]: commands Out[14]: ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] In [15]: commands_lower = [string.lower(f) for f in commands] In [16]: commands_lower Out[16]: ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Jeremy Jones -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Responding to Daniel T Try and find and experienced OO developer who would advocate that large, complex generalizations are a good practice. You can write lousy programs in any paradigm. The likelihood increases when you use the most technically deficient of all the OOPLs. (If those developers had used Smalltalk, I'll bet their defect rates would have been substantially lower even if they weren't very good OO developers.) Careful, the paper never claims that C++ produced more defects than C or Pascal. It only claims that the defects found in the C++ program were more costly to fix. That is a very big difference. You're right. That's what I get for responding from memory of my original reading of the paper. The mind is the second thing to go. * There is nothing wrong with me that could not be cured by a capful of Drano. H. S. Lahman [EMAIL PROTECTED] Pathfinder Solutions -- Put MDA to Work http://www.pathfindermda.com blog (under constr): http://pathfinderpeople.blogs.com/hslahman (888)-OOA-PATH -- http://mail.python.org/mailman/listinfo/python-list
Re: libxml2/xpath
On Thursday 16 December 2004 14:46, [EMAIL PROTECTED] wrote: > > # confDocument is a libxml2 document, from parseFile() etc > > xp = confDocument.xpathNewContext() > > xp.xpathRegisterNs("xhtml", "http://www.w3.org/1999/xhtml";) > > dirElement = xp.xpathEval( "/xhtml:html" ) > > Stupid question, but can the namespace somehow be changed to null to > make queries simpler? (I am no libxml2, XML, or Python expert) There's a danger to that; the namespace is there for a reason. For example, if you put all elements in the document into one namespace, that could mean that you get elements which not is XHTML, but something else, totally different. In case you want to ignore namespaces, you must be 100% sure what the files to be processed contains, and that all namespaces that are thrown together can be treated equally. Regarding removing the namespace; you could probably process the DOM tree and remove all namespaces, before doing any XPath lookups. Perhaps libxml2 has utility functions for things like this(something like recursively set namespace for an element). Standard namespace-aware DOM probably has it.. Feel free to post your findings afterwards, although I wouldn't do it in the first place :) Cheers, Frans -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Adam DePrince <[EMAIL PROTECTED]> wrote: > And how exactly do you propose to mutate an object without > changing its hash value? That's easy. Define a hash function that doesn't use all the data in the object. class Foo: def __init__ (self, a, b, c): self.a = a self.b = b self.c = c def __hash__ (self): return (self.a + self.b) You can now alter a Foo's c attribute without changing its hash. To really make the above class work right, you need to define __cmp__(), but this illustrates the point. In C++, this concept is expressed by the mutable keyword. You can have a const object and still be able to change its mutable members. Imagine I'm building a real estate database. My Property class stores block, lot, and zoning. I might very well want to hash and compare based on just block and lot, because those are the things which identify which piece of real estate I'm talking about. Maybe something like: # Demo purposes only; untested code class Property: def __init__ (self, block, lot, zoning="Unknown"): self.block = block self.lot = lot self.zoning = zoning def __hash__ (self): return (self.block + self.lot) def __cmp__ (self, other): # I wish there was a less verbose way to do this! if self.block < other.block: return -1 if self.block > other.block: return 1 if self.lot < other.lot: return -1 if self.lot > other.lot: return 1 return 0 Then I could do something like: p1 = Property (123, 5, "Residential") ownerDict [p1] = "Roy Smith" print ownerDict [Property (123, 5)]# prints my name p1.zoning = "Commercial" print ownerDict [Property (123, 5)]# still prints my name -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
"H. S. Lahman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Responding to Daniel T > > >>Try and find and experienced OO developer who would advocate that large, > >>complex generalizations are a good practice. You can write lousy > >>programs in any paradigm. The likelihood increases when you use the > >>most technically deficient of all the OOPLs. (If those developers had > >>used Smalltalk, I'll bet their defect rates would have been > >>substantially lower even if they weren't very good OO developers.) > > > > > > Careful, the paper never claims that C++ produced more defects than C or > > Pascal. It only claims that the defects found in the C++ program were > > more costly to fix. That is a very big difference. > > You're right. That's what I get for responding from memory of my > original reading of the paper. The mind is the second thing to go. > If it claims there are more defects in C++ than in C, then I am more than willing to believe it, I would struggle to get a 3 line c++ program to compile let alone run. The leap that equates C++ to OOP, and C to SP would seem to be tenuous though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient grep using Python?
On Thu, 16 Dec 2004 14:28:21 +, rumours say that [EMAIL PROTECTED] might have written: [sf] Essentially, want to do efficient grep, i..e from A remove those lines which are also present in file B. [EMAIL PROTECTED] >>>You could implement elegantly using the new sets feature >>>For reference here is the unix way to do it: >>> >>>sort a b b | uniq -u [Christos] >> No, like I just wrote in another post, he wants >> >> $ grep -vf B A >> >> I think that >> >> $ sort A B B | uniq -u >> >> can be abbreviated to >> >> $ sort -u A B B >> >> which is the union rather than the intersection of the files [EMAIL PROTECTED] >wrong. Notice the -u option to uniq. >http://marc.free.net.ph/message/20021101.043138.1bc24964.html I see your point. That's a new to me use of uniq, since I started using Unices long before GNU versions of the tools, but then, I might have missed the -u option. $ cat A aa ss dd ff gg hh jj kk $ cat B aa dd gg jj pp $ time sort A B B | uniq -u ff hh kk ss real0m0.004s user0m0.004s sys 0m0.004s $ time grep -vf B A ss ff hh kk real0m0.003s user0m0.000s sys 0m0.003s So I stand corrected that your solution does *not* give the union. >> wastes some time by considering B twice > >I challenge you to a benchmark :-) Well, the numbers I provided above are almost meaningless with such a small set (and they easily could be reverse, I just kept the convenient-to-me first run :). Do you really believe that sorting three files and then scanning their merged output counting duplicates is faster than scanning two files (and doing lookups during the second scan)? $ python Python 2.3.3 (#1, Aug 31 2004, 13:51:39) [GCC 3.3.3 (SuSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x=open('/usr/share/dict/words').readlines() >>> len(x) 45378 >>> import random >>> random.shuffle(x) >>> open("/tmp/A", "w").writelines(x) >>> random.shuffle(x) >>> open("/tmp/B", "w").writelines(x[:1000]) >>> $ time sort A B B | uniq -u >/dev/null real0m0.311s user0m0.315s sys 0m0.008s $ time grep -Fvf B A >/dev/null real0m0.067s user0m0.064s sys 0m0.003s (Yes, I cheated by adding the F (for no regular expressions) flag :) >> and finally destroys original line >> order (should it be important). > >true That's our final agreement :) -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Best book on Python?
Esmail Bonakdarian wrote: I myself am looking for a small portable quick reference, thinking about the O'Reilly pocket guide but I'm not sure how good it is. I read on amazon that it doesn't have an index - that seems odd for any book, and esp a quick ref. Look into Python Essential Reference for that kind of book -- no fat, lotsa goodies. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Legend problems in MatPlotLib
I've only been able to plot data with both symbols and lines by issuing two plot commands, one for markers and one for lines. That's perfectly fine, but it creates a problem when I try to create a legend for it. For some reason, the legend command by default alternates between using symbols and lines, grabbing displaying the symbol from the first plot command for the first series, then displaying a line type from the second plot for the next series, etc. This behavior is a bit strange, and in fact unacceptable when the same line type is used for each series. For instance, assume I plot four series using these markers: square, circle, x and +, and then plotted a solid line to connect each series of markers. The legend would describe the four series using: square, solid line, x, solid line. Clearly, that wont' work. I've been able get around this previously by issuing the legend command right after the first plot command, before the second plot command. In my current usage, though, I'm looping through a number of files that are being plotted on the same graph. In this case, the fact that I've plotted lines in the preceding loop causes the legend command to revert to this alternating behavior. Is there some way to explicitly define the symbols used by the legend command? Or some way to plot lines with markers in the same command which would presumably avoid this problem? In general, plotting with matplotlib is so easy and intuitive that I'm surprised to be having so much difficulty doing something as simple as this. I'm sure I must be missing something obvious. The documentation of the legend command was unenlightening. Thanks, J.S. -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Dave Benjamin wrote: In article <[EMAIL PROTECTED]>, Adam DePrince wrote: On Tue, 2004-12-14 at 18:27, Roy Smith wrote: Terry Reedy <[EMAIL PROTECTED]> wrote: I did not really 'get' OOP until after learning Python. The relatively simple but powerful user class model made more sense to me than C++. So introducing someone to Python, where OOP is a choice, not a mandate, is how *I* would introduce a procedural programmer to the subject. YMMV. OOP is a choice in C++ too. You can write procedural C++ code; no need to use classes at all if you don't want to. Something like Java is a different story. Java *forces* you to use classes. Nothing exists in Java that's not part of some class. Static methods act like C functions. Sure, they are members of classes, but in name only. Besides, just as you can use a procedural language in an OO fashion with enough programmer discipline, you can write in a procedural style with an OOP language with sufficient rebellion. Just use one class, put everything in it and create one instance on startup. Maybe I'm reading this wrong, but it seems like you're implying that procedural code is inherently unmodular. Why would just one class/instance suffice to represent a procedural program? I think of namespacing and code organization as broad concepts that cut across all styles of programming. Well I can't speak for Terry, but I've observed in the past that object-oriented system complexity can grow beyond the programmer's ability to manage it when objects sprout too many methods. Effectively each instance's namespace becomes a set of global variables that the methods use to intercommunicate. This style of OO programming sometimes drives me nuts (IIRC it was the library modules based on SocketServer that drove me to this conclusion). Interestingly, Python's main unit of modularity is the "module", not the "class". A direct translation of a typical Python module to Java would look something like a Java class containing only static methods and inner classes. Even this would be considered rebellious within the context of ordinary Java programming. Well Java got some things right, but one of the things it got wrongest was the absence of functions and procedures and the consequent need to provide class methods. Though for the life of me I don't *really* know why I find it acceptable in Python to have to write module.func(args) when I dislike having to write class.meth(args) in Java. perhaps-i'm-just-old-and-crotchety-ly y'rs - steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Martijn Faassen wrote: Peter Hansen wrote: Martijn Faassen wrote: Peter Hansen wrote: Well, in any case, thanks for setting the record straight, Martjin. That of course also happens to me once every while. I can take care of myself though -- Dijkstra however needs an advocate for the correct spelling of his name in this earthly realm. Then there's us Danes, with "sen" instead of "son" (as many people think it ought to be). And I can't even claim the wrong form sounds noticably different, making any defense seem petty. Obviously -sen is the only real suffix, as it's -sen in Dutch as well, as in Faas-sen. :) (Darn those Norwegians, influencing people's ideas of how a name like Hansen ought to be spelled, grumble, grumble. If they'd just invent a cell phone that used Python, as the Swedish have, they might deserve all that extra attention.) ;-) That's not the Swedes, it's the Finnish that did that. They typically don't like being mistaken for Swedes. :) That's because their language is derived from Serbo-Croat. But both the Finns and the Swedes will tell you it's the Norwegians who are alcoholics. They're all dreadful liars, these Scandinavians ;-) regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
lowering the case of strings in list -- WAS: (No subject)
Mark Devine said unto the world upon 2004-12-16 10:49: Hi I'm brand new to python and I was wondering if anybody knew of a easy way to change every character in a list into its lower case form. The list is like so: commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] and what I want is: commands = ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Are there any defined method within any known modules to do this in one go? Thanks in advance Hi Mark, I'm learning, too, so no bets this is best, but does this meet your needs: .>>> def lower_list_o_strings(l): nl = [] for s in l: nl.append(s.lower()) return nl .>>> l = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] .>>> lower_list_o_strings(l) ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Best, Brian vdB PS "No subject" is only marginally better than "HELP!!" ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Lowercasing Items in a List
Mark Devine wrote: I'm brand new to python and I was wondering if anybody knew of a easy way to change every character in a list into its lower case form. How about this: >>> commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] >>> [c.lower() for c in commands] ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Re: Legend problems in MatPlotLib
> "Jorl" == Jorl Shefner <[EMAIL PROTECTED]> writes: Jorl>I've only been able to plot data with both symbols and Jorl> lines by issuing two plot commands, one for markers and one Jorl> for lines. That's perfectly fine, but it creates a problem Jorl> when I try to create a legend for it. For some reason, the Jorl> legend command by default alternates between using symbols Jorl> and lines, grabbing displaying the symbol from the first Jorl> plot command for the first series, then displaying a line Jorl> type from the second plot for the next series, etc. This Jorl> behavior is a bit strange, and in fact unacceptable when the Jorl> same line type is used for each series. Example code always helps, but note you can plot a line with lines and markers like this plot(x, y, '--s') # dashed line with square markers. In this case matplotlib will recognize this as one line and should do the legending properly. However, if you do, which I infer you are from your post plot(x, y, 's') # square markers. plot(x, y, '--s') # square markers. the plot will look the same but matplotlib considers this to be two different lines and the legend will be messed up. Note you can explicitly control what gets added to the legend, eg with l1, l2 = plot(x, y, '--s', x1, y1, 'go') p = bar(x3,y2) legend((l1, p), ('My lines', 'My bars')) In other words, if you don't like the way the autolegend is setup, you can explicitly control the process. Hope this helps. JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
EP wrote: It's a great marketing idea. There was a thread recently on Python-dev that started with a message from Guido, where he talks about a seemingly persistent perception that exists in the specialized press regarding Python as a flexible, nice, but generally slow (or slower than the alternatives) language. Perception of the press: Python is "flexible, nice, but generally slow" Which press? I know lots of programmers who have religious issues about (against) Python believe this, or claim to, or want to, but I haven't seen a lot of "press" coverage of Python's supposed slowness... Or was this just a guess on your part? -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Steve Holden wrote: They're all dreadful liars, these Scandinavians ;-) So, you're saying they are not very good at lying? (And be careful what you say about Scandinavians. I may have to bring my axe to the next PyCon... "You! Where is your payment voucher! Thwack! Everybody line up here and deposit your wallets, watches, and villages in this basket and you will be allowed to live!") -Peter P.S.: I'm only half Danish, but the other half is from a particularly bloodthirsty line of Canadians. -- http://mail.python.org/mailman/listinfo/python-list
Re: I DECLARE THIS THREAD FINISHED
Steve Holden wrote: ... I try to remember there are people joining the group all the time, so even my rantings are new to someone. You wish, Steve. ;-) All the same, I'd like to thank Jive for his indirect responsibility for triggering Martijn (who, by the way, SUX) to produce his last outburst. Very few postings do actually make me laugh out loud, but that did. Agreed. A good belly laugh is a good thing, provided the milk dripping out of your nose can avoid the keyboard. -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for wget-like module for getching software
On Thu, 16 Dec 2004, Stefan Behnel wrote: > > Robert P. J. Day schrieb: > > that is, i can just say, "go get file gcc-3.4.2.tar.bz2", and start > > searching at "ftp://pub.gnu.org/pub/gcc";. i may not know how far down > > in the directory structure that file is, but wget will happily search > > recursively until it finds it. > > That sounds pretty inefficient and should produce some load on the > server side. Imagine everyone doing that. Many FTP-servers provide > files like "ls-R.gz" somewhere, meaning, a list of files and > directories. i realize that and, as much as possible, i try to start the process with what i *know* is the actual directory location. but occasionally, if i can't guarantee an exact directory, i just want the option to start a bit higher up the directory structure. i wasn't going to make a habit of it, it's more an absolute last resort, if it comes down to it. > And then, there's Google. Why do you have to use FTP? Ask Google for > "yourfile.tar.bz2 site:the.domain.name". It will very likely return > a suitable URL for you that you can use for download. Just tried it > with "site:ftp.gnu.org gcc-3.4.2.tar.bz2" - works. You can even use > that link and try to replace "http://"; with "ftp://"; for download. > Should work for many source repositories. > > You can use urllib2 for both querying and download. and that pretty much answers the question i had. much thanks. and now that i have my answer, i might have to unsubscribe. you guys sure are a chatty bunch. :) rday p.s. just kidding. -- http://mail.python.org/mailman/listinfo/python-list
Adding paths to sys.path permanently, and another problem...
Hi everyone, I have two problems: 1. How can I keep my changes in sys.path after closing the interpreter? 2. os.path.expanduser("~") always gives me "C:\\" instead of my homepath. I have tried to change my homepath in WinXP using set homepath(in command line), and alsaw using the "Environment Variables" in WinXP system properties, non helped. I really have to fix this somehow. Thanks, Amir -- http://mail.python.org/mailman/listinfo/python-list
module file length limitations on windows?
I've run into some eccentric behavior... It appears that one of my modules is being cut off at exactly 2^14 characters when I try to import it. Has anyone else encountered this? I can't find any mention of such a bug, and stranger yet, other modules that exceed 16384 characters seem to work just fine. In particular, suppose that my module foo.py contains the following as its last line: thing = "goodbye world" Now, suppose that the length of the file is 16383 characters. It works just fine: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo >>> But if I make the string longer, it explodes: thing = "goodbye world spam spam spam spam spam" Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo Traceback (most recent call last): File "", line 1, in ? File "foo.py", line 583 thing = "goodbye world sp ^ SyntaxError: EOL while scanning single-quoted string What in the world is going on here?! This happens with Python 2.4 and 2.3.4 on win2k (under vmware), but it does _not_ happen with 2.3.4 on Linux. Very strange! Could vmware be the problem? I have also tried replacing my unix newlines with DOS \r\n with the exact same result. I don't want to spend much time on this, since the workaround of splitting the code into smaller files works just fine, but wow.. weird. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Max M <[EMAIL PROTECTED]> wrote: > The problem is that you don't understand what dicts are typically used > for. Because of the nonliniarity in dict lookups, dicts are used for > optimisation. To me, dicts are first and foremost used when you want a mapping relationship where the key is not a valid list index (non-negative integer). They are also useful when the key space is very sparse. Imagine I had the following relationship: 1 => "one" 1000=> "one thousand" 100 => "one million" 10 => "one billion" 1 => "one trillion" I could deal with a map that had linear lookup time, but couldn't afford the linear memory requirements. Yes, it's important that dicts are fast, but that's not the primary thing that makes me pick a dict vs. some other container. In some situations, it may be, but not always. I'm a "Get it working first, optimize it later" kind of guy. BTW, when you say nonlinear, I think you really mean sublinear. Quadratic is nonlinear too, but I don't think very many people would be happy with quadratic dictionary lookup times :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: create lowercase strings in lists - was: (No subject)
Mark Devine wrote: Sorry for not putting a subject in the last e-mail. The function lower suited my case exactly. Here however is my main problem: Given that my new list is : [class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Each element in my new list could appear in any order together within another larger list (list1) and I want to count how many matches occur. For example the larger list could have an element 'class-map cmap2 (match any)' and I want to match that but if only 'class-map match-any' or 'class-map cmap2' appears I don't want it to match. Can anybody help? Is my problem clearly stated? Well, let's see: you'd like to know which strings occur in both lists, right? You might like to look at the "Efficient grep using Python?" thread for suggestions. My favorite would be: .>>> lst1 = ["ab", "ac", "ba", "bb", "bc"] .>>> lst2 = ["ac", "ab", "bd", "cb", "bb"] .>>> dct1 = dict.fromkeys(lst1) .>>> [x for x in lst2 if x not in dct1] ['bd', 'cb'] .>>> [x for x in lst2 if x in dct1] ['ac', 'ab', 'bb'] regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: Html or Pdf to Rtf (Linux) with Python
Axel Straschil <[EMAIL PROTECTED]> writes: > Hallo! > >> However, our company's product, PDFTextStream does do a phenomenal >> job of extracting text and metadata out of PDF documents. It's >> crazy-fast, has a clean API, and in general gets the job done very >> nicely. It presents two points of compromise from your idea >> situation: >> 1. It only produces text, so you would have to take the text it >> provides and write it out as an RTF yourself (there are tons of >> packages and tools that do this). Since the RTF format has pretty >> weak formatting capabilities compared > > I've got the Input Source in HTML, the Problem ist converting from any > to RTF. Please give me a hint where the tons of packages are. That's easy. Load the HTML in MS Word, and save it as RTF. Script it via COM using the python win32all (I think that's what it's now called) package. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Please note that to make something official, it has to be passed through the Python Software Foundation, which holds the intellectual property for Python and is responsible for trademarks associated with the language. If you're serious about doing this, you may want to email "psf at python dot org" to get information from the board of directors (I'm one of them, BTW, but I can't speak for the whole group). It would be nice to have a single strongly identifiable visual trademark for Python. There are many icons/logos that people have invented but none that's "official" and having many tends to dilute the ability to build a strong well-known visual trademark. - Stephan -- http://mail.python.org/mailman/listinfo/python-list
Re: Best book on Python?
Maurice LING said the following on 12/12/2004 11:13 PM: Google for Dive Into Python. Its a free online publication, see if is any good for you. Cheers, I like "Dive into Python" for the fact that it tends to explain examples line by line in an annotated form but it may just be my personal preference. I second this. Another one I like is "Textprocessing in Python" by "David Mertz". If the focus is only on printed books and there is some experience with programming, "programming python" by Lutz from O'Reilly might be a good one. So what, "Dive into Python" is available in a printed version as well ;-) (e.g. http://www.amazon.com/exec/obidos/tg/detail/-/1590593561/103-2217423-3565410). Regards Mirko -- http://mail.python.org/mailman/listinfo/python-list
Re: A beginner's problem...
DogWalker wrote: "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> said: In <[EMAIL PROTECTED]>, Amir Dekel wrote: When I import a module I have wrote, and then I find bugs, it seems that I can't import it again after a fix it. It always shows the same problem. I try del module but it doesn't work. (I use Python 2.4 with the ActivePython pack (PythonWin IDE) Solution anyone? Yes -> help(reload) Ciao, Marc 'BlackJack' Rintsch First, save the file using the check option (Ctl+Shift+C, iirc); Second, Fix any errors (attend to Status Bar); Third, press Reload button in Toolbar (or type command from File Menu). Four, assure that Status Bar indicates reload was successful. If still doesn't load correctly, quit PythonWin and start it again. Fifth, use the module unittest and write a test for your module. Just run the test to check your module and fix all errors, then import it into the larger sceme and see if everything works there. Most problems will appear in a good test, so you will not have the reimport issiue at all. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: why not arrays?
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > We know of three implementations of arrays now: the "array" module, This module for mutable linear homogeneous arrays is already included in Python since long ago. It does not compete with the next two. > the "numpy" implementation, and the "numarray" implementation. Numpy is the original multidimensional array numerical computation package from about a decade ago. As far as I know, it is no longer being supported/upgraded. However, it is still used be other packages that people use. Numarray is a newer package that I believe is intended to replace numpy and which has only recently reached perhaps the same level of stability. (Updates welcome) Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
In message <[EMAIL PROTECTED]>, EP <[EMAIL PROTECTED]> writes Well, the snake mascot as drawn is, of course, very flexible, appears to be friendly, and is, well, just how fast is a big snake, esp. a python? I don't know about Pythons but there is a black snake in Africa (a black mamba?) that when it stands up is taller than a man. This snake can out "run" a man in straight line or over rough ground. I saw a TV program where they'd attached a camera to its head. Absolutely incredible watching this thing whizzing through the undergrowth in search of a mate. Don't think all snakes are slow - they aren't. BTW. The suggestions - I like them, for what little that is worth. Stephen -- Stephen Kellett Object Media Limitedhttp://www.objmedia.demon.co.uk RSI Information:http://www.objmedia.demon.co.uk/rsi.html -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
projecktzero wrote: A co-worker considers himself "old school" in that he hasn't seen the light of OOP.(It might be because he's in love with Perl...but that's another story.) He thinks that OOP has more overhead and is slower than programs written the procedural way. The problem with OOP is not overhead in the sense of slower programs. It's overhead in terms of complexity. OOP frameworks also make doing simple things require way too much effort and study. Inheritance is a very inflexible way of organizing code - it makes it impossible/extremely difficult/expensive to change the design of base classes. Hence, the recent popularity of interfaces as an alternative. The thing I love about Python is how it manages to hide its OOP-ness most of the time compared to languages like Java and C++. Python concepts like 'protocols' greatly lessen the need to deal with awkward OOP ideas. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best book on Python?
This is a very good introduction online: www.g2swaroop.net/byte-of-python I also suggest: - Learning Python 2nd Ed. - Core Python You can also try these online resources: - Dive into Python - Thinking in Python -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
On Thu, 16 Dec 2004 11:51:18 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote: > EP wrote: > >>It's a great marketing idea. There was a thread recently on Python-dev > >>that started with a message from Guido, where he talks about a > >>seemingly persistent perception that exists in the specialized press > >>regarding Python as a flexible, nice, but generally slow (or slower > >>than the alternatives) language. > > > > Perception of the press: Python is "flexible, nice, but generally slow" > > Which press? I know lots of programmers who have religious issues > about (against) Python believe this, or claim to, or want to, but > I haven't seen a lot of "press" coverage of Python's supposed slowness... > > Or was this just a guess on your part? Check Guido's original message on the topic, you can find it on python-dev articles. It`s recenet -- possibly less than one week old. He seemed to be sincerely concerned about it, having read an article published at some prestigious academic journal (something from ACM or IEEE, I think). If the BDFL wrote it, what more can I say? ;-) -- Carlos Ribeiro Consultoria em Projetos blog: http://rascunhosrotos.blogspot.com blog: http://pythonnotes.blogspot.com mail: [EMAIL PROTECTED] mail: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: BASIC vs Python
abisofile wrote: hi I'm new to programming.I've try a little BASIC so I want ask since Python is also interpreted lang if it's similar to BASIC. Which BASIC did you try? Realbasic? Visual Basic? You should check out some of these beginner's python tutorials: http://www.honors.montana.edu/~jjc/easytut/easytut.pdf http://www.dickbaldwin.com/tocpyth.htm http://www.freenetpages.co.uk/hp/alan.gauld/ and then if you have any questions at all about anything, people on the python-tutor list would be glad to help: http://mail.python.org/mailman/listinfo/tutor If you want to make applications with a graphical user interface (GUI), check out wxpython, although they haven't yet released a version that works with the new python 2.4 however: http://wxpython.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt: Make argument mandatory
On Wednesday 15 December 2004 14:07, Diez B. Roggisch wrote: > > In my use of getopt.getopt, I would like to make a certain parameter > > mandatory. I know how to specify such that a parameter must have a value > > if it's specified, but I also want to make the parameter itself > > mandatory(combined with a mandatory value, the result is that the user > > must specify a value). > > Use optparse - in the examples section you'll find what you need. I'm slow here, do you mean in of the callback examples in 6.21.4? http://docs.python.org/lib/module-optparse.html Cheers, Frans -- http://mail.python.org/mailman/listinfo/python-list
Re: module file length limitations on windows?
No non-printing characters. However, I just tried copying the file (from a windows cmd prompt), and the copy was cut off at the same point the interpreter is getting to. When I edit the file with vim, though, the whole thing comes through. I think this is a pretty strong indication that this monkey-business is happening either in Windows or in vmware, and has nothing to do with Python. Confirmed. I rebooted the (virtual) machine and the problem is gone. Weird. -- http://mail.python.org/mailman/listinfo/python-list
os.walk bug?
Title: os.walk bug? Hi I'm new to the list. i found a bad behaviour of os.walk that i can reproduce 100% but didn't find an answer to why it does that I have the folowing tree: t:\dir1 t:\dir1\2000 t:\dir1\2001 t:\dir1\content t:\dir2 t:\dir2\2000 t:\dir2\2001 t:\dir2\2002 t:\dir2\2003 t:\dir2\2004 t:\dir2\content t:\dir2\templates what i wanted was to loop in each dir and skip the years (i don't want to touch archive). So i wrote: for root, dirs, files in os.walk('t:\'): # -- do stuff print "working on", root # -- stuff done print 'DEBUG: dirs =', dirs for d in dirs: # -- remove archive if d[:2] == '20': print "--- removing:", d dirs.remove(d) And when i run it i got the following output working on t:\ working on t:\dir1 DEBUG: dirs = ['2000', '2001', 'content'] --- removing 2000 --- removing 2001 working on t:\dir1\content working on t:\dir2 DEBUG: dirs = ['2000', '2001', '2003', '2002', '2004', 'content'] <- why is this in this sequence? --- removing 2000 --- removing 2003 --- removing 2004 working on t:\dir2\2001 . . . I am nuts? running as os.walk('t:\dir2') make it ignore the same dirs. i'm using python 2.3 on windows 2000. The t: drive is a webdav mount. Thanks, Gabriel -- http://mail.python.org/mailman/listinfo/python-list