xlrd 0.7.4 released!
Hi All, I'm pleased to announce the release of xlrd 0.7.4. This release features the following changes: - Fixed a bug where xlrd was silently truncating long text formula results - Avoid parsing STYLE records when formatting_info=False - More tolerance of out-of-spec files. - Minor performance improvements. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 8:05 AM, Dennis Lee Bieber wrote: > On Thu, 29 Mar 2012 08:48:53 -0700 (PDT), Steve Howell > declaimed the following in > gmane.comp.python.general: > > REXX is inhibited by the architectures to which it has been ported > -- limiting the ADDRESS targets to variations of Python's os.system() or > popen() calls; even the subprocess module can't get beyond the all or > nothing execution model. > > Much different from the original IBM environment (and, biased, the > Amiga implementation may have gone beyond the IBM one in capabilities) > wherein compliant programs become the "command shell" for REXX command > processing -- actual bidirectional interactive interprocess > communication. Window's COM system offers some of that capability, but > buried in a cryptic object programming system -- nothing like having a > script sending the /same/ command that one would use in a text interface > to the target program. Some years ago, I wrote a MUD that used REXX as its scripting language. (The server's still running, but not so much to be a MUD as to be my administrative interface to that particular box. I'm like that with MUDs.) I thought it was really cool to be able to simply put a bare string and have that get sent to the player - for instance: /* Command handler for some particular location in the MUD */ if arg(1)="foo" then do "You begin to foo." /* do some stuff */ "You finish fooing." end Having now built MUDs in Pike, I'm not so impressed with the syntax. But hey, it's a completely different use of the ADDRESS command! :) And of course, I can always use ADDRESS CMD "blah blah" to execute commands. On Tue, Apr 3, 2012 at 10:25 AM, Steve Howell wrote: > On Apr 2, 2:50 pm, Chris Angelico wrote: >> Hmm... How do you pipe one command's output into another's input using >> Python? It's not nearly as clean as it is in bash. > > For pipes, I'd still call out to bash. I know that's cheating, but > the idea is that Python can wrap all the good parts of bash while > still allowing you to use Python's more modern syntax, standard > library, etc. So, it's not that Python is a superset of bash, but that Python+bash is a superset of bash. Well, that is certainly understandable. And needn't be too onerous syntactically either: from os import system as x x('do_stuff') ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.7.4 released!
Hey Chris, On Tuesday, April 3, 2012 9:04:43 AM UTC+2, Chris Withers wrote: > > Hi All, > > I'm pleased to announce the release of xlrd 0.7.4. > There seems to have been a mistake during release of 0.7.4: version.txt referenced in setup.py:24 is missing (forgot MANIFEST?) and therefore the package can't be installed. Getting distribution for 'xlrd'. error: /var/folders/_l/m3y541vx5m1dzgjm6rjljf5wgn/T/easy_install-KeGyEg/xlrd-0.7.4/xlrd/version.txt: No such file or directory An error occured when trying to install xlrd 0.7.4. Look above this message for any errors that were output by easy_install. Regards, Lukas -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyxl] xlrd 0.7.4 released!
On 03/04/2012 08:04, Chris Withers wrote: Hi All, I'm pleased to announce the release of xlrd 0.7.4. *sigh* As pointed out, I stuffed up the release by not including a new file in the MANIFEST. My bad. I've just release a 0.7.5 that fixes this. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyxl] xlrd 0.7.4 released!
On Tuesday, April 3, 2012 9:34:27 AM UTC+2, Chris Withers wrote: > As pointed out, I stuffed up the release by not including a new file in > the MANIFEST. My bad. > > I've just release a 0.7.5 that fixes this. > Works! Thanks for the quick reaction! Regards, Lukas -- http://mail.python.org/mailman/listinfo/python-list
Re: why can't I pickle a class containing this dispatch dictionary?
jkn wrote: > I'm clearly not understanding the 'can't pickle instancemethod > objects' error; can someone help me to understand, I think classes implemented in C need some extra work to make them picklable, and that hasn't been done for instance methods. > & maybe suggest a > workaround, (apart from the obvious if ... elif...). You can implement pickling yourself: import copy_reg import types def pickle_instancemethod(m): return unpickle_instancemethod, (m.im_func.__name__, m.im_self, m.im_class) def unpickle_instancemethod(name, im_self, im_class): im_func = getattr(im_class, name) return im_func.__get__(im_self, im_class) copy_reg.pickle(types.MethodType, pickle_instancemethod) > I'm running Python 2.6 on an embedded system. > > == testpickle.py == > import pickle > > class Test(object): > def __init__(self): > self.myDict = { > 1: self.tag1, > 2: self.tag2 > } > def dispatch(self, v): > try: > self.myDict[v]() > except KeyError: > print "No corresponding dictionary entry!" > # > def tag1(self): > print "one" > def tag2(self): > print "two" > > > t = Test() > t.dispatch(1) > t.dispatch(2) > t.dispatch(0) > > fd = open("pickle.out", "w") > pickle.dump(t, fd) > fd.close() > # EOF > > $ python testpickle.py > one > two > No corresponding dictionary entry! > TypeError: can't pickle instancemethod objects > $ -- http://mail.python.org/mailman/listinfo/python-list
Re: No os.copy()? Why not?
I use subprocess.call() for quite a few other things. I just figured that I should use the tidier modules whenever I can. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
On 2012-04-03 00:52:35 +0100, Jürgen Exner said: Oh, that's why it is tought in trade schools alongside butchery, plumbing, masonry, and chimney sweeping and why you don't find any programming classes at university. So, you know, no one would do law or medicine at a university. Oh, wait. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
On Tue, Apr 3, 2012 at 12:26 AM, Chiron <"chiron613.no.spam."@no.spam.please.gmail.com> wrote: >> ãIs Programing Art or Scienceã > > Why is this question important? That's the whole point of the article/email. Xah basically says "This question is stupid and only stupid people care about it." You probably should have read the email before replying to it. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
Xah Lee wrote: > So, is programing a art or science? is it art or science? I really > need to know. Sience? Almost never. It's handcraft. Seldom, in very rare cases, it's true art for a very limited audience, mostly it's routine, and in many cases it's also idiocy. T.M. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
Hi, Xah, In comp.emacs Xah Lee wrote: > For these computing jockeys, there remains the question of why Knuth > named his books the ?Art? of Computer Programing, or why some > computing luminaries litter the caution that programing is as much a > art as science. What elite dimwits need to realize is that these > authors are not defining or correcting, but breaking precepts among > the automatons in programing industry. He was using art in the sense of "the exercise of human skill (as distinguished from nature)". That's the second definition in my dictionary. When people talk about, for example, the art of painting water colours, they mean the techniques of mixing paints, depicting objects on paper, etc. They are not referring to the artistic value of the painting painted. > yours humbly, > > Xah -- Alan Mackenzie (Nuremberg, Germany). -- http://mail.python.org/mailman/listinfo/python-list
Re: weird behaviour: pygame plays in shell but not in script
On Thu, Mar 29, 2012 at 11:41 PM, Mik wrote: > > I can't believe I am so dumb! > > after sound.play() the script was terminating > I didn't notice that 'play()' actually returns... > > What a nice way to introduce myself to the group!!! :-) > > sorry for bothering you guys :-) You've just proven one of the great benefits of asking a question: you suddenly discover the answer for yourself. It's arguable whether it's primarily caused by the action of coalescing your question into text, or some outworking of Murphy's Law, but both are involved. Welcome to the party. There's some trolls over there *gestures to the corner* and some smart guys over there *gestures to the other corner* and a few snakes and comedians around *gestures to the random pythons and Pythons and Pythons and pythons* and don't forget the lurkers lurking around. Enjoy yourself, learn something, educate someone! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Works Locally But Not Remotely with SSH
On Sun, 1 Apr 2012 12:32:16 -0700 (PDT) Jedrzej Krzysztof Dec wrote: > > > > Why the does the window not open when the script is started > > remotely? > > > > Thanks. > > Do You have a GUI over SSH? Something like ssh -X in Linux systems, > or do You just have a terminal window? If You just have a terminal, > You wont be able to run GUI apps. > You need an X server on the XP machine. I've use Xming for this. http://sourceforge.net/projects/xming/?_test=b -- Rod Person http://www.rodperson.com rodper...@rodperson.com 'Silence is a fence around wisdom' -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 1:40 AM, alex23 wrote: > On Apr 3, 2:55 pm, Nathan Rice > wrote: >> I don't care what people do related to legacy systems. > > And that's what earns you the label 'architecture astronaut'. Legacy > systems are _part_ of the problem; it's very easy to hold to a purist > approach when you ignore the bulk of the domain that causes the > issues. There's _never_ going to be an InfoTech3k where we just stop > supporting older code. There are people who are paid pretty well to support crappy old COBOL apps, but I am not among them (nor are you, with very high likelihood), so your "we" is misplaced. For all intents and purposes that software exists in an alternate reality. Remember the tutorial on global vs local optimization I made previously? Let me distill it... If you are unwilling to endure pain to move towards a better world you will always be trapped in a sub-optimal situation. >> I do care about programmers that are too lazy to >> learn, and would be happy to ignore the fact that programming is hard >> for most people to learn, so they can continue not learning. Those >> programmers are scumbags. > > Wait, what? > > Programmers are both "too lazy to learn" and yet somehow happy that > the skills they've acquired are "too hard for most people to learn"? > So how did they learn them? > > And they're also somehow "lazy" because they have to learn multiple > languages to be effective, rather than one mythical ur-language? > > In my 20 years as a software developer, I have _never_ encountered > anyone trying to deliberately expand the knowledge gap. This isn't a > priesthood. Did you miss the part where I said that most people who learn to program are fascinated by computers and highly motivated to do so? I've never met a BROgrammer, those people go into sales. It isn't because there aren't smart BROmosapiens (sadly, there are), they just couldn't give two shits about computers so programming seems like a colossal waste of time to them. It isn't about people scheming to "dis-empower then plebs" rather it is about people who don't want to move outside their comfort zone. You can talk about people learning multiple languages all you want, but for the most part they will be 10 descendants of ALGOL, with minor variations. Very few people are willing to tackle something like Haskell or ML if they weren't taught functional programming in university, though there are a few that view it as an endurance trial or mountain to climb. Those people get a pass on most of what I've said thus far. >> Just don't let me hear you complaining because some syntax is not "C >> like" enough for you. Whenever I hear that I want to strangle the >> self-serving 'tard that wrote it. When I see people defending "C >> like" syntax as optimal or somehow much more expressive, that makes me >> doubly irritated. These are the people who are selfishly defending >> the status quo because they're invested. > > Syntax is never the issue, it's the deeper semantics. Is the scoping > of one C-like language the same as C? How does it differ? Why does it > differ? Is the difference a fundamental implementation issue that you > really need to know before you actually grok the language? Are > functions first-class objects? Are they actual objects or some kind of > magical stub? Can you extend those objects with properties? etc etc Syntax and semantics are both a big mess right now. That is why I always address them both. > Every language tackles _so many_ things differently. It's not lazy to > say that you prefer something to resemble/be based on a language you > have experience with, that's human nature. If you're insistent that > your non-typical syntax is so much better, the onus is on you to prove > it, not to insist that the lack of uptake is 'laziness'. The winds of change generally blow for programming when generations of older programmers leave the workforce. Alan Kay was a smart man, viewing programming as an educational tool and designing for youth is absolutely the right way to do things. If you try to retrain older programmers, you are basically telling them they have to change decades of learning for a moderate (but not huge) productivity increase, so that programming is accessible to a much wider group of people. Much like with the terminal to GUI transition, you will have people attacking declarative natural language programming as a stupid practice for noobs, and the end of computing (even though it will allow people with much less experience to be more productive than them). > And one again: code is _communication_. Not having to understand new > optimal patterns for every single language is a Good Thing. Code is a horrible medium for communication. If it weren't, I wouldn't be trolling this thread. >> Don't try to delude people that our modern >> ALGOL derivatives are the best possible way to model knowledge >> (including process knowledge) to a computer, because that is a lie. > > Um,
Re: Is Programing Art or Science?
Programming is neither Art nor Science It's practically maths [pun intended] -- http://mail.python.org/mailman/listinfo/python-list
Re: weird behaviour: pygame plays in shell but not in script
Mik wrote: Oh thanks alex! that's kind! PS: It looks like a party indeed: plenty of interesting discussions :-) On Mar 30, 4:33 am, alex23 wrote: On Mar 29, 10:41 pm, Mik wrote: What a nice way to introduce myself to the group!!! :-) Hey, don't beat yourself up, you: - summarised the problem in the subject heading - included actual code showing the problem - reported back on the problem you found That puts you ahead of most new posters. sorry for bothering you guys :-) No bother at all, welcome to the party :) Welcome Mik ! JM PS : please don't top post in this list -- http://mail.python.org/mailman/listinfo/python-list
Re: why can't I pickle a class containing this dispatch dictionary?
Hi Peter On Apr 3, 8:54 am, Peter Otten <__pete...@web.de> wrote: > jkn wrote: > > I'm clearly not understanding the 'can't pickle instancemethod > > objects' error; can someone help me to understand, > > I think classes implemented in C need some extra work to make them > picklable, and that hasn't been done for instance methods. by 'classes implemented in C', doyou mean new-style classes', or what, please? > > > & maybe suggest a > > workaround, (apart from the obvious if ... elif...). > > You can implement pickling yourself: > > [...] Hmm - interesting, thanks. I'm more trying to understand the issue at the moment, but it's always nice to learn... Thanks J^n -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
On 3/30/2012 4:27 AM, Xah Lee wrote: Is Programing Art or Science? Programming itself is a bit like being a natural language translator for an autistic person. You have to understand the "message" to be communicated, and then interpret it *very* literally for the listener. Note that programming is just one of a set of activities and skills that are part of software engineering. Others include UI design (which combines visual design, psychology, etc.), software architecture (which is like ... well, architecture) and various other skills. Collectively, "engineering" is the best catch-all description. Is building a bridge art or science? A little of both, and some other things as well. -pd -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-URL! - weekly Python news and links (Mar 31)
On 31/03/2012 11:38 AM, Cameron Laird wrote: I pine for the fjords. And it's time to bring "Python-URL!" to a close. "Python-URL!", which Jean-Claude Wippler and I appear to have launched in 1998, has reached the end of its utility. We still have many loyal and enthusiastic readers--one subscription request arrived within the last day, in fact--and certainly much writing turns up every week that *deserves* the spotlight "Python-URL!" has shone in the past. However, the Python world has changed a great deal over the last fourteen years. There are many, MANY other ways for those with an interest in Python to nourish themselves, and Python itself has grown and "normalized" so much that it no longer fits particularly well in the "Python-URL!" format. Enjoy "Mouse vs. Python"http://www.blog.pythonlibrary.org/>, the Python areas of DZone, Reddit, developerWorks, stackoverflow, and so on. For your reference, I append below the most-recent-but-not- particularly- current version of "Python-URL!"'s coda of related readings. That is all. Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers Planet Python: you want to visit there: http://planet.python.org But don't confuse it with Planet SciPy: http://planet.scipy.org And don't confuse *that* with SciPyTip, a high-quality daily (!) tip for the numerically-inclined: http://twitter.com/SciPyTip Python Insider is the official blog of the Python core development team: http://pyfound.blogspot.com/2011/03/python-dev-launches-python-insider -blog.html The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donations/ Keep up with the PSF at "Python Software Foundation News": http://pyfound.blogspot.com The Python Papers aims to publish "the efforts of Python enthusiasts": http://pythonpapers.org/ Doug Hellman's "Module of the week" is essential reading: http://www.doughellmann.com/PyMOTW/ comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/group/comp.lang.python.announce/topics Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html The Python Package Index catalogues packages. http://www.python.org/pypi/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Summary of Python Tracker Issues is an automatically generated report summarizing new bugs, closed ones, and patch submissions. http://search.gmane.org/?author=status%40bugs.python.org&group=gmane.c omp.python.devel&sort=date nullege is an interesting search Web application, with the intelligence to distinguish between Python code and comments. It provides what appear to be relevant results, and demands neither Java nor CSS be enabled: http://www.nullege.com Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html The Cookbook is a collaborative effort to capture useful and interesting recipes: http://code.activestate.com/recipes/langs/python/ Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available, see: http://www.python.org/channews.rdf For more, see: http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Apr 3, 5:39 pm, Nathan Rice wrote: > > Don't think "underlying", instead think "canonical". > > Ultimately, the answers to your questions exist in the world for you > to see. How does a surgeon describe a surgical procedure? How does a > chef describe a recipe? How does a carpenter describe the process of > building cabinets? Aside from specific words, they all use natural > language, and it works just fine. A carpenter describes his carpentry-process in English A CSist describes his programming-process in English (at least all my CS books are in English) A carpenter uses his tools -- screwdriver, saw, planer --to do carpentry A programmer uses his tools to to programming -- one of which is called 'programming language' Doing programming without programming languages is like using toenails to tighten screws -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 03/04/2012 14:51, rusi wrote: On Apr 3, 5:39 pm, Nathan Rice wrote: Don't think "underlying", instead think "canonical". Ultimately, the answers to your questions exist in the world for you to see. How does a surgeon describe a surgical procedure? How does a chef describe a recipe? How does a carpenter describe the process of building cabinets? Aside from specific words, they all use natural language, and it works just fine. A carpenter describes his carpentry-process in English A CSist describes his programming-process in English (at least all my CS books are in English) A carpenter uses his tools -- screwdriver, saw, planer --to do carpentry A programmer uses his tools to to programming -- one of which is called 'programming language' Doing programming without programming languages is like using toenails to tighten screws The latter is extremely difficult if you bite your toenails :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: why can't I pickle a class containing this dispatch dictionary?
Peter Otten於 2012年4月3日星期二UTC+8下午3時54分50秒寫道: > jkn wrote: > > > I'm clearly not understanding the 'can't pickle instancemethod > > objects' error; can someone help me to understand, > > I think classes implemented in C need some extra work to make them > picklable, and that hasn't been done for instance methods. > > > & maybe suggest a > > workaround, (apart from the obvious if ... elif...). > > You can implement pickling yourself: > > import copy_reg > import types > > def pickle_instancemethod(m): > return unpickle_instancemethod, (m.im_func.__name__, m.im_self, > m.im_class) > > def unpickle_instancemethod(name, im_self, im_class): > im_func = getattr(im_class, name) > return im_func.__get__(im_self, im_class) > > copy_reg.pickle(types.MethodType, pickle_instancemethod) > > > > I'm running Python 2.6 on an embedded system. > > > > == testpickle.py == > > import pickle > > > > class Test(object): > > def __init__(self): > > self.myDict = { > > 1: self.tag1, > > 2: self.tag2 > > } > > def dispatch(self, v): > > try: > > self.myDict[v]() > > except KeyError: > > print "No corresponding dictionary entry!" > > # > > def tag1(self): > > print "one" > > def tag2(self): > > print "two" > > > > > > t = Test() > > t.dispatch(1) > > t.dispatch(2) > > t.dispatch(0) > > > > fd = open("pickle.out", "w") > > pickle.dump(t, fd) > > fd.close() > > # EOF > > > > $ python testpickle.py > > one > > two > > No corresponding dictionary entry! > > > TypeError: can't pickle instancemethod objects > > $ Save your python files as a package in .pyd or .py and use exec to get what you want. Of course you can use the data compression package to perform serialization operations, but that will increase start up time in loading your objects. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Wed, Apr 4, 2012 at 12:26 AM, Mark Lawrence wrote: > On 03/04/2012 14:51, rusi wrote: >> Doing programming without programming languages is like using toenails >> to tighten screws > > > The latter is extremely difficult if you bite your toenails :) I agree, thumbnails are far better suited. Mine are often pushed into that service. But to extend the analogy: Using a thumbnail to tighten a screw is like directly patching a binary to fix a bug. It works, but it's not exactly a practical way to build a system. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: why can't I pickle a class containing this dispatch dictionary?
jkn wrote: > Hi Peter > > On Apr 3, 8:54 am, Peter Otten <__pete...@web.de> wrote: >> jkn wrote: >> > I'm clearly not understanding the 'can't pickle instancemethod >> > objects' error; can someone help me to understand, >> >> I think classes implemented in C need some extra work to make them >> picklable, and that hasn't been done for instance methods. > > by 'classes implemented in C', doyou mean new-style classes', or what, > please? Given >>> class A(object): ... def __init__(self, name): ... self.name = name ... def hello(self): ... print "Hello,", self.name ... >>> a = A("Peter") >>> hello = a.hello >>> hello() Hello, Peter the object bound to the name 'hello' is an instance of the 'instancemethod' type: >>> type(hello) That type is implemented in C, see http://hg.python.org/cpython/file/9599f091faa6/Objects/classobject.c and doesn't support the pickle protocol while a similar class, functools.partial which is also written in C, see http://hg.python.org/cpython/file/9599f091faa6/Modules/_functoolsmodule.c does: >>> from functools import partial >>> import pickle >>> def hello(obj): ... print "Hi,", obj.name ... >>> hello2 = partial(hello, a) >>> hello2() Hi, Peter >>> s = pickle.dumps(hello2) >>> pickle.loads(s)() Hi, Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 2012-04-03, Chris Angelico wrote: > On Wed, Apr 4, 2012 at 12:26 AM, Mark Lawrence > wrote: >> On 03/04/2012 14:51, rusi wrote: >>> Doing programming without programming languages is like using toenails >>> to tighten screws >> >> >> The latter is extremely difficult if you bite your toenails :) > > I agree, thumbnails are far better suited. Mine are often pushed into > that service. But to extend the analogy: Using a thumbnail to tighten > a screw is like directly patching a binary to fix a bug. It works, but > it's not exactly a practical way to build a system. Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC thought it was a practical way to fix things. It had a built-in assembler and let you "insert" new code into a function by auto-allocating a location for the new code an hooking it into the indicated spot with jump instructions. The mind wobbled. -- Grant Edwards grant.b.edwardsYow! I'm a fuschia bowling at ball somewhere in Brittany gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Python and Bloomberg
Hello, I was just wondering if anyone had experience using Python to interact with Bloomberg. Ideally, I'd look to use Python to feed Bloomberg's OVML calculator with a list of inputs, and then use an additional program to grab the results of the calculator for each calculation, and pull them into another document, ideally an excel spreadsheet or alternatively a delimited .txt file. Any thoughts or ideas are very much appreciated. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Is there a better way to do this snippet?
I played around with a few things and this works but was wondering if there was a better way to do this. My first thought was list comprehension but could not get a figure out the syntax. tag23gr is a list of lists each with two items. g23tag is an empty dictionary when I run the for loop below. When is is complete each key is a graphic name who's values are a list of tags. for item in tag23gr: ... value, key = tuple(item) ... if(g23tag.get(key)): ... g23tag[key].append(value) ... else: ... g23tag[key] = [value] -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Wed, Apr 4, 2012 at 12:46 AM, Grant Edwards wrote: > Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC > thought it was a practical way to fix things. It had a built-in > assembler and let you "insert" new code into a function by > auto-allocating a location for the new code an hooking it into the > indicated spot with jump instructions. > > The mind wobbled. Not specifically, but I _have_ heard of various systems whose source code and binary were multiple years divergent. It's actually not a difficult trap to fall into, especially once you start patching running systems. I've had quite a few computers that have been unable to reboot without assistance, because they go for months or years without ever having to go through that initial program load. (I've had _programs_ that were unable to load, for the same reason.) But auto-allocating a new spot for your expanded function? That's just... awesome. My mind is, indeed, wobbling. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 6:39 AM, Nathan Rice wrote: > Did you miss the part where I said that most people who learn to > program are fascinated by computers and highly motivated to do so? > I've never met a BROgrammer, those people go into sales. It isn't > because there aren't smart BROmosapiens (sadly, there are), they just > couldn't give two shits about computers so programming seems like a > colossal waste of time to them. I have never met the brogrammer stereotype. I have also never met the non-brogrammer stereotype of nerdy solitude (well, maybe once). That's all these things are -- stereotypes. Real programmers are much more complex. > Computers require you to state the exact words you're searching for as > well. Try looking again, and this time allow for sub-categories and > synonyms, along with some variation in word order. Lazy troll. You made the claim. The onus is on you to provide the evidence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
python writes: > tag23gr is a list of lists each with two items. > g23tag is an empty dictionary when I run the for loop below. > When is is complete each key is a graphic name who's values are a list > of tags. > > for item in tag23gr: > ... value, key = tuple(item) > ... if(g23tag.get(key)): > ... g23tag[key].append(value) > ... else: > ... g23tag[key] = [value] for item in tag23gr: g23tag.setdefault(item[0],[]).append(item[1]) -- Alain. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Wed, Apr 4, 2012 at 1:01 AM, Ian Kelly wrote: > Real programmers are much more complex. Are you saying that some part of all of us is imaginary?? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
On Wed, Apr 4, 2012 at 12:36 AM, python wrote: > for item in tag23gr: > ... value, key = tuple(item) > ... if(g23tag.get(key)): > ... g23tag[key].append(value) > ... else: > ... g23tag[key] = [value] Simple enhancement: Use setdefault. Instead of the if, just use: g23tag.setdefault(key,[]).append(value) That'll cover both cases in one. You can leave off the explicit tuple construction; if item is a two-element list, you can unpack it directly. You can also embed that straight into your for loop: for value,key in tag23gr: Do both and you cut your loop down to two lines. Cool! :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 03/04/2012 15:56, Chris Angelico wrote: On Wed, Apr 4, 2012 at 12:46 AM, Grant Edwards wrote: Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC thought it was a practical way to fix things. It had a built-in assembler and let you "insert" new code into a function by auto-allocating a location for the new code an hooking it into the indicated spot with jump instructions. The mind wobbled. Not specifically, but I _have_ heard of various systems whose source code and binary were multiple years divergent. It's actually not a difficult trap to fall into, especially once you start patching running systems. I've had quite a few computers that have been unable to reboot without assistance, because they go for months or years without ever having to go through that initial program load. (I've had _programs_ that were unable to load, for the same reason.) But auto-allocating a new spot for your expanded function? That's just... awesome. My mind is, indeed, wobbling. ChrisA Around 1990 I worked on Telematics kit. The patches on all their software were implemented via assembler once the original binary had been loaded into memory. They even came up with a system that let you select which patches you wanted and which you didn't, as e.g. some patches were customer specific. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
python wrote: > I played around with a few things and this works but was wondering if > there was a better way to do this. > My first thought was list comprehension but could not get a figure out > the syntax. > > tag23gr is a list of lists each with two items. > g23tag is an empty dictionary when I run the for loop below. > When is is complete each key is a graphic name who's values are a list > of tags. > > for item in tag23gr: > ... value, key = tuple(item) > ... if(g23tag.get(key)): That should be if key in g23tag: Your version means trouble for keys that evaluate to False in a boolean context, e. g. 0, False, None, "", (),... > ... g23tag[key].append(value) > ... else: > ... g23tag[key] = [value] from collections import defaultdict g23tag = defaultdict(list) for value, key in tag23gr: g23tag[key].append(value) -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
Xah Lee writes: [...] > For example, “Is mathematics science or art?”, is the same type of > question that has been broached by dabblers now and then. http://en.wikipedia.org/wiki/Liberal_arts HTH. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
On Apr 3, 11:02 am, Alain Ketterlin wrote: > python writes: > > tag23gr is a list of lists each with two items. > > g23tag is an empty dictionary when I run the for loop below. > > When is is complete each key is a graphic name who's values are a list > > of tags. > > > for item in tag23gr: > > ... value, key = tuple(item) > > ... if(g23tag.get(key)): > > ... g23tag[key].append(value) > > ... else: > > ... g23tag[key] = [value] > > for item in tag23gr: > g23tag.setdefault(item[0],[]).append(item[1]) > > -- Alain. Or alternatively: from collections import defaultdict g23tag = defaultdict(list) for item in tag23gr: g23tag[item[0]].append(item[1]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 9:51 AM, rusi wrote: > On Apr 3, 5:39 pm, Nathan Rice > wrote: >> >> Don't think "underlying", instead think "canonical". >> >> Ultimately, the answers to your questions exist in the world for you >> to see. How does a surgeon describe a surgical procedure? How does a >> chef describe a recipe? How does a carpenter describe the process of >> building cabinets? Aside from specific words, they all use natural >> language, and it works just fine. > > A carpenter describes his carpentry-process in English > A CSist describes his programming-process in English (at least all my > CS books are in English) > > A carpenter uses his tools -- screwdriver, saw, planer --to do > carpentry > A programmer uses his tools to to programming -- one of which is > called 'programming language' > > Doing programming without programming languages is like using toenails > to tighten screws I would argue that the computer is the tool, not the language. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 04/03/2012 11:16 AM, Mark Lawrence wrote: > On 03/04/2012 15:56, Chris Angelico wrote: >> On Wed, Apr 4, 2012 at 12:46 AM, Grant >> Edwards wrote: >>> Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC >>> thought it was a practical way to fix things. It had a built-in >>> assembler and let you "insert" new code into a function by >>> auto-allocating a location for the new code an hooking it into the >>> indicated spot with jump instructions. >>> >>> The mind wobbled. >> >> Not specifically, but I _have_ heard of various systems whose source >> code and binary were multiple years divergent. It's actually not a >> difficult trap to fall into, especially once you start patching >> running systems. I've had quite a few computers that have been unable >> to reboot without assistance, because they go for months or years >> without ever having to go through that initial program load. (I've had >> _programs_ that were unable to load, for the same reason.) But >> auto-allocating a new spot for your expanded function? That's just... >> awesome. My mind is, indeed, wobbling. >> >> ChrisA > > Around 1990 I worked on Telematics kit. The patches on all their > software were implemented via assembler once the original binary had > been loaded into memory. They even came up with a system that let you > select which patches you wanted and which you didn't, as e.g. some > patches were customer specific. > And I worked on a system where the microcode was in ROM, and there was a "patch board" consisting of lots of diodes and some EPROMs. The diodes were soldered into place to specfy the instruction(s) to be patched, and the actual patches were in the EPROMs, which were reusable. The diodes were the only thing fast enough to "patch" the ROM, by responding more quickly than the ROM. This was back when issuing a new ROM was a very expensive proposition; there were masking charges, so you couldn't reasonably do low quantities. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: No os.copy()? Why not?
On Tue, Apr 3, 2012 at 12:24 AM, Thomas Rachel wrote: > Am 02.04.2012 23:11 schrieb HoneyMonster: > > >> One way: >> import os >> >> os.system ("cp src sink") > > > Yes. The worst way you could imagine. > > Why not the much much better > > from subprocess > subprocess.call(['cp', 'src', 'sink']) In any case, either of these approaches will only work in UNIX, whereas shutil is cross-platform. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
nn writes: >> > for item in tag23gr: >> > ... value, key = tuple(item) >> > ... if(g23tag.get(key)): >> > ... g23tag[key].append(value) >> > ... else: >> > ... g23tag[key] = [value] >> >> for item in tag23gr: >> g23tag.setdefault(item[0],[]).append(item[1]) > Or alternatively: > > from collections import defaultdict > g23tag = defaultdict(list) > for item in tag23gr: > g23tag[item[0]].append(item[1]) Very handy in that case, but in general I dislike the idea of silently inserting a default value when the access is a read, e.g., in x=g23tag[wrung]. Explicit is better than implicit, as they say. YMMV. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to structure data for efficient searching
On 3/28/2012 11:39 AM, larry.mart...@gmail.com wrote: I have the following use case: I have a set of data that is contains 3 fields, K1, K2 and a timestamp. There are duplicates in the data set, and they all have to processed. Then I have another set of data with 4 fields: K3, K4, K5, and a timestamp. There are also duplicates in that data set, and they also all have to be processed. I need to find all the items in the second data set where K1==K3 and K2==K4 and the 2 timestamps are within 20 seconds of each other. I have this working, but the way I did it seems very inefficient - I simply put the data in 2 arrays (as tuples) and then walked through the entire second data set once for each item in the first data set, looking for matches. Is there a better, more efficient way I could have done this? How big are the data sets? Millions of entries? Billions? Trillions? Will all the data fit in memory, or will this need files or a database. In-memory, it's not hard. First, decide which data set is smaller. That one gets a dictionary keyed by K1 or K3, with each entry being a list of tuples. Then go through the other data set linearly. You can also sort one database by K1, the other by K3, and match. Then take the matches, sort by K2 and K4, and match again. Sort the remaining matches by timestamp and pull the ones within the threshold. Or you can load all the data into a database with a query optimizer, like MySQL, and let it figure out, based on the index sizes, how to do the join. All of these approaches are roughly O(N log N), which beats the O(N^2) approach you have now. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
On Apr 2, 5:48Â pm, "Pascal J. Bourguignon" > This is a narrow-minded definition of programming. Well, that's the point. If we make a list and include things like: computer science software engineering computer engineering discrete math logic formal methods web development computer graphics information technology information management data processing database management database administration network administration artificial intelligence ... and so on and so forth ... Some of these involve real art. Some of these involve real science. Even engineering can be considered as science, in a way, and perhaps art in a way. All these include programming! HOWEVER, 'programming' seen as 'talking to a computer' is neither an art nor a science, but simply a learned skill, like plumbing or cabinet making, or even medicine or law. I was a lawyer for 14 years, so I know what I'm talking about: the practice of law in the ordinary sense is simply that, the practice of law, and as such it's not an art nor a science, but simply a trade, albeit a highly skilled and abstract trade. And yes, lawyers can be artists and scientists, but neither one of these is basic to the practice of law. I'm not saying that artists and scientists can't be programmers. Many of them are. What I'm saying is that you can program a computer (i.e., practice programming) without being either an artist or a scientist. CC. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 11:01 AM, Ian Kelly wrote: > On Tue, Apr 3, 2012 at 6:39 AM, Nathan Rice > wrote: >> Did you miss the part where I said that most people who learn to >> program are fascinated by computers and highly motivated to do so? >> I've never met a BROgrammer, those people go into sales. It isn't >> because there aren't smart BROmosapiens (sadly, there are), they just >> couldn't give two shits about computers so programming seems like a >> colossal waste of time to them. > > I have never met the brogrammer stereotype. I have also never met the > non-brogrammer stereotype of nerdy solitude (well, maybe once). > That's all these things are -- stereotypes. Real programmers are much > more complex. I have never met a programmer that was not completely into computers. That leaves a lot unspecified though. >> Computers require you to state the exact words you're searching for as >> well. Try looking again, and this time allow for sub-categories and >> synonyms, along with some variation in word order. > > Lazy troll. You made the claim. The onus is on you to provide the evidence. I reserve the right to be lazy :) As part of my troll-outreach effort, I will indulge here. I was specifically thinking about some earlier claims that programming languages as they currently exist are somehow inherently superior to a formalized natural language in expressive power. I think part of this comes from the misconception that terse is better (e.g. Paul Graham's thoughts on car/cdr), which doesn't take into account that your brain compresses frequently occurring English words VERY efficiently, so they actually take up less cognitive bandwidth than a much shorter non-word. This behavior extends to the phrase level as well; longer phrases that are meaningful in their own right take up less bandwidth than short nonsensical word combinations. On the semantic side, most people already understand branched processes and procedures with conditional actions pretty well. People "program" other people to perform tasks constantly, and have been doing so for the entirety of our existence. The problem occurs when programming language specific semantic artifacts must be considered. These artifacts are for the most part somewhat arbitrary, or you would see them frequently in other areas, and they wouldn't confuse people so much. I think the majority of these relate to how the computer operates internally - this is the stuff that really turns most people off to programming. The crux of my view is that programming languages exist in part because computers in general are not smart enough to converse with humans on their own level, so we have to talk to them like autistic 5 year-olds. That was fine when we didn't have any other options, but all the pieces exist now to let computers talk to us very close to our own level, and represent information at the same way we do. Projects like IBM's Watson, Siri, Wolfram Alpha and Cyc demonstrate pretty clearly to me that we are capable of taking the next step, and the resurgence of the technology sector along with the shortage of qualified developers indicates to me that we need to move now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Apr 3, 9:15 pm, Nathan Rice wrote: > On Tue, Apr 3, 2012 at 9:51 AM, rusi wrote: > > On Apr 3, 5:39 pm, Nathan Rice > > wrote: > > >> Don't think "underlying", instead think "canonical". > > >> Ultimately, the answers to your questions exist in the world for you > >> to see. How does a surgeon describe a surgical procedure? How does a > >> chef describe a recipe? How does a carpenter describe the process of > >> building cabinets? Aside from specific words, they all use natural > >> language, and it works just fine. > > > A carpenter describes his carpentry-process in English > > A CSist describes his programming-process in English (at least all my > > CS books are in English) > > > A carpenter uses his tools -- screwdriver, saw, planer --to do > > carpentry > > A programmer uses his tools to to programming -- one of which is > > called 'programming language' > > > Doing programming without programming languages is like using toenails > > to tighten screws > > I would argue that the computer is the tool, not the language. "Computer science is as much about computers as astronomy is about telescopes" -- E W Dijkstra Here are some other attempted corrections of the misnomer "computer science": http://en.wikipedia.org/wiki/Computer_science#Name_of_the_field -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 2012-04-03, Dave Angel wrote: > And I worked on a system where the microcode was in ROM, and > there was a "patch board" consisting of lots of diodes and some > EPROMs. The diodes were soldered into place to specfy the > instruction(s) to be patched, and the actual patches were in > the EPROMs, which were reusable. The diodes were the only > thing fast enough to "patch" the ROM, by responding more > quickly than the ROM. This was back when issuing a new ROM was > a very expensive proposition; there were masking charges, so > you couldn't reasonably do low quantities. I worked on a system where the main interface to the system was poking and peeking numbers at memory addresses. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
All this futuristic grandiloquence: On Apr 3, 10:17 pm, Nathan Rice wrote: > The crux of my view is that programming languages exist in part > because computers in general are not smart enough to converse with > humans on their own level, so we have to talk to them like autistic 5 > year-olds. That was fine when we didn't have any other options, but > all the pieces exist now to let computers talk to us very close to our > own level, and represent information at the same way we do. Projects > like IBM's Watson, Siri, Wolfram Alpha and Cyc demonstrate pretty > clearly to me that we are capable of taking the next step, and the > resurgence of the technology sector along with the shortage of > qualified developers indicates to me that we need to move now. needs to be juxtaposed with this antiquated view > I would argue that the computer is the tool, not the language. ... a view that could not be held by an educated person after the 1960s -- ie when it became amply clear to all that the essential and hard issues in CS are about software and not hardware -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
ccc31807 writes: > On Apr 2, 5:48Â pm, "Pascal J. Bourguignon" >> This is a narrow-minded definition of programming. > > Well, that's the point. > > If we make a list and include things like: > computer science > software engineering > computer engineering > discrete math > logic > formal methods > web development > computer graphics > information technology > information management > data processing > database management > database administration > network administration > artificial intelligence > ... and so on and so forth ... > > Some of these involve real art. Some of these involve real science. > Even engineering can be considered as science, in a way, and perhaps > art in a way. All these include programming! HOWEVER, 'programming' > seen as 'talking to a computer' is neither an art nor a science, but > simply a learned skill, like plumbing or cabinet making, or even > medicine or law. > > I was a lawyer for 14 years, so I know what I'm talking about: the > practice of law in the ordinary sense is simply that, the practice of > law, and as such it's not an art nor a science, but simply a trade, > albeit a highly skilled and abstract trade. And yes, lawyers can be > artists and scientists, but neither one of these is basic to the > practice of law. > > I'm not saying that artists and scientists can't be programmers. Many > of them are. What I'm saying is that you can program a computer (i.e., > practice programming) without being either an artist or a scientist. Well, of course. Those words designate different categories that are not exclusive. So it's meaningless to say that programming is or is not art or science. Art is something that comes from a quality of the would-be artist. Science is something that comes from a methodology applied by the would-be scientist. Program is something that comes from the work applied by the would-be programmer. You can be both a programmer and artist and produce a program arstistically (like a torero), or an artistic program (like a painter). You can be both a programmer and scientist, and produce a program scientifically (like a mathematician), or a science program (like a physicist). You can be both a scientist and artist and produce science artistically, or art scientifically. You can be the three, producing programs artistically and scientifically, or producing artisctic programs scientifically, or producing scientific programs artistically, etc. When you produce programs scientifically and artistically you're a hacker. It could be nice to produce scientific programs scientifically, and even better if your scientific programs are also artistic (so that you can show the science in an interesting way to the public). http://www.ted.com/talks/joann_kuchera_morin_tours_the_allosphere.html You can also produce art programmatically. For that you need to be both an artist or a programmer. http://animusic.com/ Or you may try to split the qualities among a team like at Pixar producing artistic movies programmatically and scientifically like http://www.pixar.com/featurefilms/index.html http://graphics.pixar.com/library/UntanglingCloth/paper.pdf And the best is to produce scientific programs that are artistic, scientifically and artistically. Then you're an scientifico-artistico-hacker. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
>> > A carpenter uses his tools -- screwdriver, saw, planer --to do >> > carpentry >> > A programmer uses his tools to to programming -- one of which is >> > called 'programming language' >> >> > Doing programming without programming languages is like using toenails >> > to tighten screws >> >> I would argue that the computer is the tool, not the language. > > "Computer science is as much about computers as astronomy is about > telescopes" -- E W Dijkstra > > Here are some other attempted corrections of the misnomer "computer > science": > http://en.wikipedia.org/wiki/Computer_science#Name_of_the_field I view "computer science" as applied mathematics, when it deserves that moniker. When it doesn't, it is merely engineering. Ironically, telescopes are a tool that astronomers use to view the stars. On Tue, Apr 3, 2012 at 1:25 PM, rusi wrote: > All this futuristic grandiloquence: > > On Apr 3, 10:17 pm, Nathan Rice > wrote: >> The crux of my view is that programming languages exist in part >> because computers in general are not smart enough to converse with >> humans on their own level, so we have to talk to them like autistic 5 >> year-olds. That was fine when we didn't have any other options, but >> all the pieces exist now to let computers talk to us very close to our >> own level, and represent information at the same way we do. Projects >> like IBM's Watson, Siri, Wolfram Alpha and Cyc demonstrate pretty >> clearly to me that we are capable of taking the next step, and the >> resurgence of the technology sector along with the shortage of >> qualified developers indicates to me that we need to move now. > > needs to be juxtaposed with this antiquated view > >> I would argue that the computer is the tool, not the language. > > > ... a view that could not be held by an educated person after the > 1960s -- ie when it became amply clear to all that the essential and > hard issues in CS are about software and not hardware I'll go ahead and forgive the club handed fallacies, so we can have a nice discussion of your primary point. What a civil troll I am :) Lets start with some analogies. In cooking, chefs use recipes to produce a meal; the recipe is not a tool. In architecture, a builder uses a blueprint to produce a building; the blueprint is not a tool. In manufacturing, expensive machines use plans to produce physical goods; the plans are not the tool. You could say the compiler is a tool, or a development environment is a tool. The programming language is a mechanism for communication. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this snippet?
On Apr 3, 12:26 pm, Alain Ketterlin wrote: > nn writes: > >> > for item in tag23gr: > >> > ... value, key = tuple(item) > >> > ... if(g23tag.get(key)): > >> > ... g23tag[key].append(value) > >> > ... else: > >> > ... g23tag[key] = [value] > > >> for item in tag23gr: > >> g23tag.setdefault(item[0],[]).append(item[1]) > > Or alternatively: > > > from collections import defaultdict > > g23tag = defaultdict(list) > > for item in tag23gr: > > g23tag[item[0]].append(item[1]) > > Very handy in that case, but in general I dislike the idea of silently > inserting a default value when the access is a read, e.g., in > x=g23tag[wrung]. Explicit is better than implicit, as they say. YMMV. > > -- Alain. Valid point. Preferred choice depends on the access patterns to the dict (e.g. one write and multiple reads, multiple writes and one loop over items, etc.) -- http://mail.python.org/mailman/listinfo/python-list
Re: No os.copy()? Why not?
On 03/28/12 16:12, John Ladasky wrote: I'm looking for a Python (2.7) equivalent to the Unix "cp" command. Since the equivalents of "rm" and "mkdir" are in the os module, I figured I look there. I haven't found anything in the documentation. I am also looking through the Python source code in os.py and its child, posixfile.py. cp is not a system command, it's a shell command. Why not just use the incredibly simple and portable >>>open("outfile", "w").write(open("infile").read()) put it into a method if you find that too much to type: def cp(infile, outfile): open(outfile, "w").write(open(infile).read()) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
What is the best way to freeze a Python 3 app (Windows)?
I want to package up some of my Python 3 scripts to run standalone, without depending on a system-installed Python. For my development, I use virtualenv and install all my dependencies in the virtualenv, develop the script and test it. When I'm done, I want to build an executable which can run without depending on a system Python. What's the best way of doing this? I previously would have used py2exe, but that seems not to have Python 3 support. I have heard good things about bbfreeze, but the author has stated that he has no intention of supporting Python 3 just yet. I've tried cx_Freeze, but I've hit a number of niggly problems which make me think it's not quite suitable (I've reported some of them on the cx_Freeze mailing list, but it seems pretty quiet - no real response). That leaves me wondering if there's another option, or whether I should just roll my own. if I zip up the stdlib, and my virtualenv site-packages, and then put them plus the various Python DLLs in a directory, copy my script in, and write a small EXE to set PYTHONHOME and run Py_Main with my script as argument, that should do. But it seems a bit laborious :-( Is that really the best way? Things I care about: - Easy to package up a script - Works with dependencies in a virtualenv - Completely isolated from system Python (not even leaving directories on sys.path, so I can do basic tests without having to create a clean system with no Python installed). Things I don't (really) care about: - Stripping ununsed modules (although I'd like to omit "big" parts of the stdlib that aren't used - tkinter and test come to mind) - Space (the full stdlib is only 30M including pyc files, after all) Any suggestions gratefully accepted :-) Paul. -- http://mail.python.org/mailman/listinfo/python-list
Re: No os.copy()? Why not?
On Tue, Apr 03, 2012 at 03:46:31PM -0400, D'Arcy Cain wrote: > On 03/28/12 16:12, John Ladasky wrote: > >I'm looking for a Python (2.7) equivalent to the Unix "cp" command. > >Since the equivalents of "rm" and "mkdir" are in the os module, I > >figured I look there. I haven't found anything in the documentation. > >I am also looking through the Python source code in os.py and its > >child, posixfile.py. > > cp is not a system command, it's a shell command. Why not just use the > incredibly simple and portable > > >>>open("outfile", "w").write(open("infile").read()) Note, though, that this reads the whole file into memory. As many others have said, shutil is the most idiomatic option. \t -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 4/3/2012 8:39 AM, Nathan Rice wrote: Ultimately, the answers to your questions exist in the world for you to see. How does a surgeon describe a surgical procedure? How does a chef describe a recipe? How does a carpenter describe the process of building cabinets? Aside from specific words, they all use natural language, and it works just fine. Not really. Surgeon's learn by *watching* a surgeon who knows the operation and next (hopefully) doing a particular surgery under supervision of such a surgeon, who watches and talks, and may even grab the instruments and re-show. They then really learn by doing the procedure on multiple people. They often kill a few on the way to mastery. I first learned basic carpentry and other skills by watching my father. I don't remember that he ever said anything about how to hold the tools. I similarly learned basic cooking by watching my mom. My knowledge of how to crack open an egg properly and separate the yolk from the rest is a wordless memory movie. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the best way to freeze a Python 3 app (Windows)?
cx_Freeze is the only program that can freeze py3k code that I know of. I didn't have any major issues with it, but I've only played with it. In any case, if you're going to roll your own, I'd be happy to help test it. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: No os.copy()? Why not?
On 01/-10/-28163 01:59 PM, Tycho Andersen wrote: Note, though, that this reads the whole file into memory. As many others have said, shutil is the most idiomatic option. * most idiomatic * clearest in terms of showing intent * potentially fastest * hardest to screw up (unlike concatenating file names into a 'system' call) * has at least a snowball's chance of persisting metadata associated with the file (even if shutil doesn't now, it could theoretically change) * portable There's basically nothing NOT to like about shutil, and at least one significant problems with all the other suggestions. Evan -- http://mail.python.org/mailman/listinfo/python-list
Run once while loop
Hi, I'm trying to do a while loop with condition of time if time is 12:00:00 print text, but for this one second the text is printed at least 50 times, how can I print only once? Thank Anatoli -- http://mail.python.org/mailman/listinfo/python-list
Re: Run once while loop
On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov wrote: > Hi, > > I'm trying to do a while loop with condition of time if time is > 12:00:00 print text, but for this one second the text is printed at > least 50 times, how can I print only once? Set a flag when you print the text to indicate that you've already printed it, and don't print it again if the flag is set. When it's no longer 12:00:00, reset the flag. That said, a busy while loop is probably the wrong way to do this, because it will run your CPU at 100%. Better would be to put the thread to sleep with time.sleep() calls or a real event loop with a timer event. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.7.4 released!
Maybe it's just me, but I tried to upgrade my previous versions of xlrd, xlwt, an xlutils and now some of the modules aren't loading properly. I am currently using Portable Python 2.7 at this workstation. I ran "easy_install --upgrade xlrd" and the result said it had updated. If I try to update again, it says it's already there. When I try to import xlrd, I get an error IOError: [Errno 2] No such file or directory: 'C:\\Users\\josh\\Desktop\\Portable Python\\App\\lib\\site-packages\\xlrd-0.7.5-py2.7.egg\\xlrd\\version.txt' I also noticed that in my Site Packages folder, I have xlrd-0.7.1-py2.7-win32.egg as an egg file, but xlrd-0.7.5-py2.7.egg as a folder. This in on a Windows 7 machine. I didn't think EGG files could be folders. Is there a change in the way the EGG file was meant to be distributed? Josh English Confused Data Geek >-- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, Apr 3, 2012 at 4:20 PM, Terry Reedy wrote: > On 4/3/2012 8:39 AM, Nathan Rice wrote: > >> Ultimately, the answers to your questions exist in the world for you >> to see. How does a surgeon describe a surgical procedure? How does a >> chef describe a recipe? How does a carpenter describe the process of >> building cabinets? Aside from specific words, they all use natural >> language, and it works just fine. > > > Not really. Surgeon's learn by *watching* a surgeon who knows the operation > and next (hopefully) doing a particular surgery under supervision of such a > surgeon, who watches and talks, and may even grab the instruments and > re-show. They then really learn by doing the procedure on multiple people. > They often kill a few on the way to mastery. Well, there is declarative knowledge and procedural knowledge. In all these cases, only the procedural knowledge is absolutely necessary, but the declarative knowledge is usually a prerequisite to learning the procedure in any sort of reasonable manner. > I first learned basic carpentry and other skills by watching my father. I > don't remember that he ever said anything about how to hold the tools. > > I similarly learned basic cooking by watching my mom. My knowledge of how to > crack open an egg properly and separate the yolk from the rest is a wordless > memory movie. A picture is worth a thousand words :) If you would like, I don't have any problem incorporating visual programming and programming by demonstration. I didn't go in that direction because I have enough to defend as it is. I like to look at it from the perspective of teaching/communicating, rather than operating a simple machine. -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyxl] Re: xlrd 0.7.4 released!
On 04/03/2012 01:46 PM, Josh English wrote: Maybe it's just me, but I tried to upgrade my previous versions of xlrd, xlwt, an xlutils and now some of the modules aren't loading properly. I am currently using Portable Python 2.7 at this workstation. I ran "easy_install --upgrade xlrd" and the result said it had updated. If I try to update again, it says it's already there. When I try to import xlrd, I get an error IOError: [Errno 2] No such file or directory: 'C:\\Users\\josh\\Desktop\\Portable Python\\App\\lib\\site-packages\\xlrd-0.7.5-py2.7.egg\\xlrd\\version.txt' I also noticed that in my Site Packages folder, I have xlrd-0.7.1-py2.7-win32.egg as an egg file, but xlrd-0.7.5-py2.7.egg as a folder. This in on a Windows 7 machine. I didn't think EGG files could be folders. Is there a change in the way the EGG file was meant to be distributed? Interesting the below seemed to have got lost on way to Google Groups: From Chris: " As pointed out, I stuffed up the release by not including a new file in the MANIFEST. My bad. I've just release a 0.7.5 that fixes this. cheers, Chris " Josh English Confused Data Geek -- Adrian Klaver adrian.kla...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Run once while loop
On 03 Apr 2012, at 22:45, Ian Kelly wrote: > On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov wrote: >> Hi, >> >> I'm trying to do a while loop with condition of time if time is >> 12:00:00 print text, but for this one second the text is printed at >> least 50 times, how can I print only once? > > Set a flag when you print the text to indicate that you've already > printed it, and don't print it again if the flag is set. When it's no > longer 12:00:00, reset the flag. > > That said, a busy while loop is probably the wrong way to do this, > because it will run your CPU at 100%. Better would be to put the > thread to sleep with time.sleep() calls or a real event loop with a > timer event. > > Cheers, > Ian Thank you Ian, what if I wait for other conditions if I use time.sleep for 1 sec? it means that all the program is sleeping for a sec. Regards Hristov Anatoli -- http://mail.python.org/mailman/listinfo/python-list
Re: Run once while loop
On Tue, Apr 3, 2012 at 3:00 PM, Anatoli Hristov wrote: > On 03 Apr 2012, at 22:45, Ian Kelly wrote: > >> On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov wrote: >>> Hi, >>> >>> I'm trying to do a while loop with condition of time if time is >>> 12:00:00 print text, but for this one second the text is printed at >>> least 50 times, how can I print only once? >> >> Set a flag when you print the text to indicate that you've already >> printed it, and don't print it again if the flag is set. When it's no >> longer 12:00:00, reset the flag. >> >> That said, a busy while loop is probably the wrong way to do this, >> because it will run your CPU at 100%. Better would be to put the >> thread to sleep with time.sleep() calls or a real event loop with a >> timer event. >> >> Cheers, >> Ian > > Thank you Ian, > > what if I wait for other conditions if I use time.sleep for 1 sec? it > means that all the program is sleeping for a sec. You can sleep for less than a second. 0.2 seconds or so allows a pretty nice response time while still limiting how much your script will spin the CPU. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Programing Art or Science?
On Apr 3, 8:22 am, Rainer Weikusat wrote: > Xah Lee writes: > > [...] > > > For example, “Is mathematics science or art?”, is the same type of > > question that has been broached by dabblers now and then. > http://en.wikipedia.org/wiki/Liberal_arts this is the best reply in this thread! Xah -- http://mail.python.org/mailman/listinfo/python-list
RE: Number of languages known [was Re: Python is readable] - somewhat OT
> -Original Message- > From: Mark Lawrence [mailto:breamore...@yahoo.co.uk] > Sent: Wednesday, 4 April 2012 3:16 a.m. > To: python-list@python.org > Subject: Re: Number of languages known [was Re: Python is readable] - > somewhat OT > > On 03/04/2012 15:56, Chris Angelico wrote: > > On Wed, Apr 4, 2012 at 12:46 AM, Grant > Edwards wrote: > >> Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC > >> thought it was a practical way to fix things. It had a built-in > >> assembler and let you "insert" new code into a function by > >> auto-allocating a location for the new code an hooking it into the > >> indicated spot with jump instructions. > >> > >> The mind wobbled. > > > > Not specifically, but I _have_ heard of various systems whose source > > code and binary were multiple years divergent. It's actually not a > > difficult trap to fall into, especially once you start patching > > running systems. I've had quite a few computers that have been unable > > to reboot without assistance, because they go for months or years > > without ever having to go through that initial program load. (I've > had > > _programs_ that were unable to load, for the same reason.) But > > auto-allocating a new spot for your expanded function? That's just... > > awesome. My mind is, indeed, wobbling. > > > > ChrisA > > Around 1990 I worked on Telematics kit. The patches on all their > software were implemented via assembler once the original binary had > been loaded into memory. They even came up with a system that let you > select which patches you wanted and which you didn't, as e.g. some > patches were customer specific. > > -- > Cheers. > > Mark Lawrence. > In the 70's I worked with Honeywell 16 Series computers controlling a variety of systems. The patches were loaded as a starting address followed by machine code, using a piece of software for this purpose. This all sounds rather similar to Mark's situation. The reason however is less obvious. On the H16 series we did not have a multi-access O/S and the process of assembling and linking a large system involved many steps. Often the modifications required were trivial. It was generally easier to reload a memory dump from off paper tape and then apply the patches. Phil Runciman -- http://mail.python.org/mailman/listinfo/python-list
ANN: yamlish 0.8 released
yamlish 0.8 is now available at http://pypi.python.org/pypi/yamlish yamlish is a module for generating (and parsing) YAMLish (http://testanything.org/wiki/index.php/YAMLish). Release notes: -- * Don't leak tempfiles * setup.py test actually runs tests * add requires to setup.py * generate compact multiline strings (don't add empty lines) Links: -- * homepage http://pypi.python.org/pypi/yamlish * code repository https://gitorious.org/yamlish/yamlish * bug reports and enhancement requests to mcepl_at_redhat_dot_com or to https://luther.ceplovi.cz/bugzilla/ (product TAP) -- http://mail.python.org/mailman/listinfo/python-list
ANN: bayeux 0.2 released
Bayeux 0.2 is now available at http://pypi.python.org/pypi/bayeux bayeux is a module for generating TAP (http://testanything.org/). Version 0.2 is an initial version registered in the Cheesshop. Release notes: -- * module tap.py for programatic writing of TAP stream * clone of unittest2 generating TAP stream instead of the normal unittest output. * example script for generating TAP stream from JSON results of piglit test suite. Links: -- * homepage http://pypi.python.org/pypi/bayeux * code repository https://gitorious.org/bayeux/bayeux * bug reports and enhancement requests to mcepl_at_redhat_dot_com or to https://luther.ceplovi.cz/bugzilla/ (product TAP) -- http://mail.python.org/mailman/listinfo/python-list
Async IO Server with Blocking DB
Hi We are thinking about building a webservice server and considering python event-driven servers i.e. Gevent/Tornado/ Twisted or some combination thereof etc. We are having doubts about the db io part. Even with connection pooling and cache, there is a strong chance that server will block on db. Blocking for even few ms is bad. can someone suggest some solutions or is async-io is not at the prime- time yet. Thanks -- http://mail.python.org/mailman/listinfo/python-list
RE: Number of languages known [was Re: Python is readable] - somewhat OT
> On Tue, Apr 3, 2012 at 4:20 PM, Terry Reedy wrote: > > On 4/3/2012 8:39 AM, Nathan Rice wrote: > > > > > Ultimately, the answers to your questions exist in the world for you > > > to see. How does a surgeon describe a surgical procedure? How does > > > a chef describe a recipe? How does a carpenter describe the process > > > of building cabinets? Aside from specific words, they all use > > > natural language, and it works just fine. > > > > > > Not really. Surgeon's learn by *watching* a surgeon who knows the operation > > and next (hopefully) doing a particular surgery under supervision of such a > > surgeon, who watches and talks, and may even grab the instruments and > > re-show. They then really learn by doing the procedure on multiple > > people. They often kill a few on the way to mastery. > > > Well, there is declarative knowledge and procedural knowledge. In all > these cases, only the procedural knowledge is absolutely necessary, > but the declarative knowledge is usually a prerequisite to learning > the procedure in any sort of reasonable manner. There is also tacit knowledge. Such knowledge is a precursor to declarative knowledge and therefore procedural knowledge. "Tacit knowledge is not easily shared. It involves learning and skill, but not in a way that can be written down. Tacit knowledge consists often of habits and culture that we do not recognize in ourselves." Wikipedia. The process of eliciting tacit knowledge may be time consuming and require patience and skill. The following book covers aspects of this: Nonaka, Ikujiro; Takeuchi, Hirotaka (1995), The knowledge creating company: how Japanese companies create the dynamics of innovation. Phil Runciman -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On 03/04/2012 19:42, Nathan Rice wrote: I view "computer science" as applied mathematics, when it deserves that moniker. When it doesn't, it is merely engineering. Is it still April first in your time zone? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to structure data for efficient searching
> On 3/28/2012 11:39 AM, larry.mart...@gmail.com wrote: > > I have a set of data that is contains 3 fields, K1, K2 and a > > timestamp. There are duplicates in the data set, and they all have to > > processed. > > > > Then I have another set of data with 4 fields: K3, K4, K5, and a > > timestamp. There are also duplicates in that data set, and they also > > all have to be processed. > > > > I need to find all the items in the second data set where K1==K3 and > > K2==K4 and the 2 timestamps are within 20 seconds of each other. In article , John Nagle wrote: > [some good ideas] >All of these approaches are roughly O(N log N), which > beats the O(N^2) approach you have now. If the timestamps are sparse enough, I can think of a way that's O(N), or pretty close to it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, 03 Apr 2012 13:17:18 -0400, Nathan Rice wrote: > I have never met a programmer that was not completely into computers. > That leaves a lot unspecified though. You haven't looked hard enough. There are *thousands* of VB, Java, etc. code monkeys who got into programming for the money only and who have zero inclination to expand their skills or knowledge beyond that necessary to keep their job. Go to programming blogs, and you will find many examples of some allegedly professional programmer selecting an arbitrary blog post to ask "Pls sombody write me this code", where "this code" is either an utterly trivial question or a six month project. > As part of my troll-outreach effort, I will indulge here. I was > specifically thinking about some earlier claims that programming > languages as they currently exist are somehow inherently superior to a > formalized natural language in expressive power. I would argue that they are, but only for the very limited purpose for which they are written. With the possible exception of Inform 7, most programming languages are useless at describing (say) human interactions. Human languages are optimised for many things, but careful, step-by-step algorithms are not one of them. This is why mathematicians use a specialist language for their problem domain, as do programmers. Human language is awfully imprecise and often ambiguous, it encourages implicit reasoning, and requires a lot of domain knowledge: Joe snatched the hammer from Fred. "Hey," he said, "what are you doing? Don't you know that he'll hit the roof if he catches you with that?" > I think part of this comes from the misconception that terse is better +1 > The crux of my view is that programming languages exist in part because > computers in general are not smart enough to converse with humans on > their own level, so we have to talk to them like autistic 5 year-olds. > That was fine when we didn't have any other options, but all the pieces > exist now to let computers talk to us very close to our own level, and > represent information at the same way we do. I think you're dreaming. We (that is to say, human beings in general, not you and I specifically) cannot even talk to each other accurately, precisely and unambiguously all the time. Natural language simply isn't designed for that -- hence we have specialist languages like legal jargon, mathematics, and programming languages, for specialist purposes. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: No os.copy()? Why not?
On Tue, 03 Apr 2012 15:46:31 -0400, D'Arcy Cain wrote: > On 03/28/12 16:12, John Ladasky wrote: >> I'm looking for a Python (2.7) equivalent to the Unix "cp" command. >> Since the equivalents of "rm" and "mkdir" are in the os module, I >> figured I look there. I haven't found anything in the documentation. I >> am also looking through the Python source code in os.py and its child, >> posixfile.py. > > cp is not a system command, it's a shell command. Why not just use the > incredibly simple and portable > >>>>open("outfile", "w").write(open("infile").read()) > > put it into a method if you find that too much to type: > > def cp(infile, outfile): >open(outfile, "w").write(open(infile).read()) Because your cp doesn't copy the FILE, it copies the file's CONTENTS, which are not the same thing. Consider: * permissions * access times * file ownership * other metadata * alternate streams and/or resource fork, on platforms that support them * sparse files By the time you finish supporting the concept of copying the file itself, rather than merely its content, you will have something similar to the shutil.copy command -- only less tested. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Number of languages known [was Re: Python is readable] - somewhat OT
On Tue, 03 Apr 2012 08:39:14 -0400, Nathan Rice wrote: > Much like > with the terminal to GUI transition, you will have people attacking > declarative natural language programming as a stupid practice for noobs, > and the end of computing (even though it will allow people with much > less experience to be more productive than them). I cry every time I consider GUI programming these days. In the late 1980s and early 1990s, Apple released a product, Hypercard, that was a combination GUI framework and natural-ish language programming language. It was an astonishing hit with non-programmers, as it allowed people to easily move up from "point and click" programming to "real" programming as their skills improved. Alas, it has been abandoned by Apple, and while a few of its intellectual successors still exit, it very niche. I *really* miss Hypercard. Not so much for the natural language syntax, as for the astonishingly simple and obvious GUI framework. To get a flavour of the syntax, see OpenXION: http://www.openxion.org and for a hint of the framework, see Pythoncard: http://pythoncard.sourceforge.net > Ultimately, the answers to your questions exist in the world for you to > see. How does a surgeon describe a surgical procedure? How does a chef > describe a recipe? How does a carpenter describe the process of > building cabinets? Aside from specific words, they all use natural > language, and it works just fine. No they don't. In general they don't use written language at all, but when they are forced to, they use a combination of drawings or illustrations plus a subset of natural language plus specialist jargon. Programming languages include both specialist grammar and specialist semantics. That makes it a cant or an argot. -- Steven -- http://mail.python.org/mailman/listinfo/python-list