Re: Python obfuscation
Alex Martelli wrote: > Modern equivalent of serialization (publishing one chapter at a time on > the web, the next chapter to come only if the author receives enough > payment for the previous one) have been attempted, but without much > success so far; however, the holy grail of "micropayments" might yet > afford a rebirth for such a model -- if paying for a chapter was > extremely convenient and cheap, enough people might choose to do so > rather than risk the next chapter never appearing. Remember that, by > totally disintermediating publishers and bookstores, a novelist may > require maybe 1/10th of what the book would need to gross in stores, in > order to end up with the same amount of cash in his or her pockets. > > One could go on for a long time, but the key point is that there may or > may not exist viable monetization models for all sorts of endeavours, > including the writing of novels, depending on a lot of other issues of > social as well as legal structures. Let's not be blinded by one model > that has worked sort of decently for a small time in certain sets of > conditions, into believing that model is the only workable one today or > tomorrow, with conditions that may be in fact very different. Maybe this micropayment thing is already working and active. What is the cost of a mouseclick and what is the monetarial value of the fact that someone is clicking on a link? Someone bought virtual property for real money and sold it later with a lot of profit. There are pages where one can buy pixels. Maybe me replying to you will provoke some other chain of events with payoffs for you or me (I hope positive :-) The idea of using a webservice to hide essential secret parts of your application can only work well if one makes some random alterations to the results of the queries. Like GPS signals that are deliberately made less exact. Obfuscated Python code could for example return variable precision numbers with a slight random alteration. I think such things would make it harder to reverse engineer the code behind the server. But the more one messes with the ideal output the more often the user will rather click another link. (or launch another satellite) Anton. what's the current exchange rate for clicks and dollars? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Bengt Richter wrote: > On Thu, 17 Nov 2005 10:53:24 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote: > > >Anton Vredegoor <[EMAIL PROTECTED]> wrote: > [...] > >> The idea of using a webservice to hide essential secret parts of your > >> application can only work well if one makes some random alterations to > >> the results of the queries. Like GPS signals that are deliberately made > > > >I disagree on this general statement and I have already given two > >counterexamples: > I agree with your disagreement in general, but I think Antoon may be > alluding to the "covert channel" problem, where sometimes randomization > of an external observable is a defense. E.g., if a web site login process > responds faster with a rejection of a bad user name (i.e. is not in the > authorized > user list) than it does for a valid user name and a bad password, the timing > difference can be used over time to eke out the private user name list, and > make subsequent password attacks that much easier. Pardon me, but I'm Anton, not Antoon (well maybe I am but lets keep this distinction in order to avoid mental hash collisions) I agree with Alex and Bengt that my statement was too general and I even admit that as I wrote it down the thought of making it less provocative crossed my mind . However I felt safe because I wrote 'only work *well*' instead of 'only work *if*' and what is working well is open for discussion isn't it? Further in my post I wrote something about adding random fluctuations making it harder to reverse engineer a procedure so I felt even safer. Not so with Alex's thorough analysis though :-) What was mostly on my mind (but I didn't mention it) is that for something to be commercially viable there should be some kind of pricing strategy (NB in our current economic view of the world) where a better paying user gets a vip interface and poor people get the standard treatment. Since one has to have the optimal result anyway in order to sell it to the best payers it would be impractical to recompute less accurate values. Why not just add a random part to make it less valuable for the unpaying user? I'm thinking about things like specifiying a real value interval where the user can extract data from (this is also a data compression method, see arithmetic coding for more info). > Which perhaps gets towards Antoon's point (or my projection thereof ;-) -- > i.e., > that the anwers provided in an experimental probe of an algorithm are "signal" > for what you want to detect, and randomization may put noise in the signal to > defeat detection (even though enough noise might make the algorithm output > unsaleable ;-) > Yeah, sometimes people measure temperature fluctuactions in the CPU in order to get clues about how an algorithm works :-) But in fact my mind works more like some intuitive device that suggests that maybe some point is safe enough to post or not, without always thinking through all the details. > > > >a. a webservice which, for some amount X of money, gives an excellent > >heuristic estimate of a good cutting-path for a woodcutting tool (for a > >set of shapes to be cut out of standard-sized planks of wood by a > >numerically driven cutter): this is a case where ESR, acting as a > >consultant, advised his clients (who had developed a heuristic for this > >task which saved a lot of wood compared to their competitors') to keep > >their code closed-source, and it makes a good use case for the "hide > >essential secret parts" in general; > > If the heuristic always gives the same answer to the same problem it would be easier to predict the results. Oh no, now some mathematician surely will prove me wrong :-) > >b. a (hypothetical) website that, given time-space coordinates (and some > >amount Y of money), produces and returns weather predictions that are > >better than those you can get from its competitors. > > > >It appears to me that any application of this kind could work well > >without at all "making random alterations" to whatever. Point is, if > >you develop a better algorithm (or, more likely, heuristic) for good > >solutions to such problems, or predictions of just about anything which > >might have economic value to somebody, using a webservice to hide the > >essential secret parts of your discovery is an option, and it might be a > >preferable alternative to relying on patents (since software patents may > >not be enforceable everywhere in the world, and even where they're > >nominally enforceable it could prove problematic and costly to actually > >deter all would-be competitors from undercutting you). I do not see > >anything
Re: Python obfuscation
Alex Martelli wrote: > Money is made in many ways, essentially by creating (perceived) buyer > advantage and capturing some part of it -- but market segmentation is > just one of many ways. IF your predictions are ENORMOUSLY better than > those the competition can make, then offering for free "slightly > damaged" predictions, that are still better than the competition's > despite the damage, MIGHT be a way to market your wares -- under a lot > of other assumptions, e.g., that there is actual demand for the best > predictions you can make, the ones you get paid for, so that your free > service doesn't undermine your for-pay one. It just seems unlikely that > all of these preconditions would be satisfied at the same time; better > to limit your "free" predictions along other axes, such as duration or > location, which doesn't require your predictions' accuracy advantage to > be ENORMOUS _and_ gives you a lot of control on "usefulness" of what > you're supplying for free -- damaging the quality by randomization just > seems to be unlikely to be the optimal strategy here, even if you had > determined (or were willing to bet the firm that) marked segmentation is > really the way to go here. Suppose I grant all your theories about optimal marketing strategies. This still doesn't account for the way the market is behaving *now*. It isn't in any way logical or optimal. For example in Holland (where I live) complete governmental departments are dedicated to make life miserable for the unemployed, for asylum seekers, for people that disagree with any official policy. If looking at the recent developments in France I find it hard to believe that such social inequality an injustice develops naturally. To me it looks more like it's caused by organized crime, where *official* legal governmental organizations are either crimimal organizations themselves or are cooperating with such organizations. You seem to tackle the problem of python obfuscation by first proving that it isn't feasible and then giving some kind of solution that will work and give the desired result: webservices. However when I look at obfuscation techniques I see a desire to profit from giving some person the idea that he or she is superior to someone else because he has a better product. In order to avoid copying we now need obfuscation. The difficulty to copy the thing (whether it is a swiss watch, a sportscar, designer clothes, the latest computer game, an ipod, a computer program) is part of the advertising game and is the basis for associating it with a certain status. If you look for a few minutes at a TV screen and notice what the commercials are trying to tell you, you will see that it's almost always that you will be better, stronger, more popular or beautyfull etc. if only you use product X. You are perfectly right if you would say that it is an illogical strategy to make people feel better relative to other people in order to get them to do something you want. Commercial entities could in principle be free of such things but we live in a world that is dominated by this worldview and if one tries to sell something one has to take that into account. So how to get the same kind of market segmentation (as you call it) when you deploy your program as a webservice and where essentially the cost for you (moving a few electrons to produce a solution to a problem) is exactly the same whether you give the user a good or a bad result. If you give optimal results to everyone, users will go to other sites just because these sites give them opportunity to feel better than other people, not because this is objectively better, but just because that is how they think the world "works". > I hope this analogy clarifies why, while I don't think deliberate damage > of result quality can be entirely ruled out, I think it's extremely > unlikely to make any sense compared to ofher market segmentation > tactics, even if you DO grant that it's worth segmenting (free samples > are an extremely ancient and traditional tactic in all kind of food > selling situations, after all, and when well-designed and promoting a > product whose taste is indeed worth a premium price, they have been > repeatedly shown to be potentially quite effective -- so, I'm hoping > there will be no debate that the segmentation might perfectly well be > appropriate for this "analogy" case, whether it is or isn't in the > originally discussed case of selling predictions-via-webservices). I agree it doesn't make sense. Like uncle Harry who thinks he can lay golden eggs. We could cure him but we need the egss :-) Alternatively, lets just forget about obfuscation and try to get people to freely share by promoting open source (and open webservices). Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > Suppose I grant all your theories about optimal marketing strategies. I wish I hadn't done that :-) But seriously, I'm having trouble answering in detail all of your points (which doesn't mean I don't value them highly) because my online time is limited by the time period this library is open, and I also want to scavange as much offline reading material as possible while I'm connected. > > This still doesn't account for the way the market is behaving *now*. It > > isn't in any way logical or optimal. For example in Holland (where I > > live) complete governmental departments are dedicated to make life > > What makes you think that governmental departments are part of the > *market*?! Government behavior is controlled by laws that are vastly > different from those controlling market behavior; if you're interested, > you could study the "theory of public choice". I don't think so, so the question can't be answered. It's the same logic that enabled me to say "payed webservices can only work well if" when in context of replacing obfuscation techniques. From 1+1 == 3 I can derive anything. I know its lame, but my time limitation forces me to go back (or up) one level in order to refute you. > > You seem to tackle the problem of python obfuscation by first proving > > that it isn't feasible and then giving some kind of solution that will > > work and give the desired result: webservices. However when I look at > > That seems to me to be a practicable technical approach, yes. > > > obfuscation techniques I see a desire to profit from giving some person > > the idea that he or she is superior to someone else because he has a > > better product. In order to avoid copying we now need obfuscation. The > > You're discussing the *motivation* for obfuscating, while what I was > giving was a possible way of *implementing* similar effects. Yes, that's the point. If you can produce at zero cost then the whole economic theory falters. You enter another continuum where traditional economic values become meaningless. From obfuscation to webservices is a big step in that direction. > Since redistribution of value, as long as a lot of value is created, can > be dealt with by other means, maximizing the creation of value tends to > be the goal I prefer -- a policy that quashes part or all of value > creation based on redistributive precepts is, by this very fact, going > to be something I look askance at (making the pie smaller to try to > ensure that what little is left gets sliced according to your political > preferences, rather than ensuring the pie is as big as possible as the > first order of business, and dealing with the slicing issues as > _secondary_ ones). I agree with your sentiment, but in order to maximize value creation we should leave material payments out of the equation when they only slow things down. From your writing I gather you already live in those quarters but you are still using materialistic concepts to describe the world. I don't blame you for it because I wouldn't know myself what would be applicable to a zero cost - maximal gain economy. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are there no ordered dictionaries?
Christoph Zwerschke wrote: > But of course, it will always be slower since it is constructed on top > of the built-in dict. In end effect, you always have to maintain a > sequence *plus* a dictionary, which will be always slower than a sheer > dictionary. The ordered dictionary class just hides this uglyness of > having to maintain a dictionary plus a sequence, so it's rather an issue > of convenience in writing and reading programs than a performance issue. > > It may be different if the ordered dict would be implemented directly as > an ordered hash table in C. The problem with hashing is that one is storing data from a possibly wildly varying range in a set of values with a limited range. That's where the ordering problems come from in the first place. If one wants to solve it once and for all one has to give up the speed advantage that makes hashing so popular. I wonder if optimized C code using bisect would be very much slower for small ranges? The current set implementation uses dicts to implement sets, while sets are a more basic data type than dicts. At least dicts and sets should be derived from the same type. Just speaking from an intuitive point of view of course :-) Here's a sorted dict implementation without using hashes, which maybe would be fast if implemented in C. The insertion order can be retrieved using the keys and values lists from the object itself, items() gives a sorted sequence. Anton. NB warning untested code. When using mutables as keys which is possible by this implementation, don't change the keys after they're used in the object. from array import array class VDict: def __init__(self,sequence = []): self.keys = [] self.values = [] self.unranks = array('L',[]) for key,value in sequence: self[key] = value def __setitem__(self,key,value): keys = self.keys values = self.values unranks = self.unranks n = len(keys) i = self.bisect_left(key) if i == n or keys[unranks[i]] != key: keys.append(key) values.append(value) unranks.insert(i,n) else: values[i] = value def __getitem__(self,key): i = self.bisect_left(key) return self.values[self.unranks[i]] def bisect_left(self,key, lo=0, hi=None): keys = self.keys unranks = self.unranks if hi is None: hi = len(keys) while lo < hi: mid = (lo+hi)//2 if keys[unranks[mid]] < key: lo = mid+1 else: hi = mid return lo def __contains__(self,key): keys = self.keys unranks = self.unranks n = len(keys) i = self.bisect_left(key) return i < n and keys[unranks[i]] == key def __len__(self): return len(self.keys) def items(self): keys = self.keys values = self.values unranks = self.unranks return [(keys[i],values[i]) for i in unranks] def __iter__(self): return iter(self.items()) def remove(self,key): keys = self.keys values = self.values unranks = self.unranks n = len(keys) i = self.bisect_left(key) x = unranks[i] if i < n and keys[x] == key: del keys[x] del values[x] del unranks[i] for j,k in enumerate(unranks): if k > x: unranks[j] -= 1 def test(): V = VDict() L = [1,2,3] V[L] = 10 print V[L] V[L] = 20 print V[L] V.remove(L) print V.items() V = VDict(zip('edcba',range(5))) print V.items() print V['d'] V.remove('d') print V.items() if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
How to wake up the jython list moderator
I'm trying to post messages to the jython mailing list via gmane. I this possible? I've got all kinds of messages confirming that I exist and that my message has arrived and will be either approved or rejected with an explanation, but since then nothing but silence and my message doesn't show up either. Anton "maybe I'm just impatient" -- http://mail.python.org/mailman/listinfo/python-list
Re: How to wake up the jython list moderator
Thomas Heller wrote: > The easiest solution for this is to join the mailing list (with the > email address that you use to post), disable list delivery, and repost > your message via gmane. > Thanks. Anton -- http://mail.python.org/mailman/listinfo/python-list
Python on a public library computer
This is about how to start a Python interpreter on a very locked down library computer. Some time ago I started a thread about it.(Google won't let me reply to older topics so I'm starting a new topic with the same title) A few days ago I found a Jython console applet that can be run from a webpage: http://tams-www.informatik.uni-hamburg.de/applets/jython/primacheck.html This opens a webpage (well, maybe after some editing, I can't get google to display this link on the same line) which after some time aks the user to sign an applet which then turns out to be a complete Jython editor and interpreter! I'm looking for the sourcecode of a project like this so that I can host such a page myself and include more modules. Can anyone reach the author or has anyone written something like it and is willing to share the code? Alternatively can someone give me some tips about how to write it myself? Currently I'm at the stage where I can compile and run the examples (and the applets!) on the Jython homepage. I'm still wondering about how to sign applets. Maybe the interpreter could be done by using the code.py module from Jython itself and just redirect stdin and stdout to an applet? Anton p.s. John Lee: You remembered correctly, such a thing exists. -- http://mail.python.org/mailman/listinfo/python-list
Re: all possible combinations
John Machin wrote: > You don't need to use random sampling. Paul Rubin has shown how it can > be done deterministically. The following is a generalisation of his > code; it generates all possible assemblies of size n from a list of > parts. Is this helpful? > > def all_size_n_knickers(rqd_size, pieces): > npieces = len(pieces) > knicker_count = npieces ** rqd_size > austen = [npieces ** (rqd_size-k-1) for k in xrange(rqd_size)] > for i in xrange(knicker_count): > knicker = [pieces[j] for j in [(i // d) % npieces for d in austen]] > yield knicker > > for alist in all_size_n_knickers(4, 'abc'): > print ''.join(alist) > > print > print list(all_size_n_knickers(2, [1, 42, 666])) Just testing out my ELCH JythonConsole :-) def unint(i,symbols): res = [] radix = len(symbols) while i: i,r = divmod(i,radix) res.append(symbols[r]) return res[::-1] start = int('1',3) finish = int('2',3) for i in range(start,finish): print ''.join(unint(i,'abc')[1:]) This makes me wonder why we still don't have something like the unint function above in the standard distribution. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: all possible combinations
Steve Holden wrote: > > This makes me wonder why we still don't have something like the unint > > function above in the standard distribution. > > > Because it's not what you'd call (or, at least, it's not what I'd call) > universally required. As you have shown it is relatively easy to hack > something supp when it's needed, so since it isn't something that's > required by the majority it hasn't been added to the library. How about the symmetry argument? One can use int for radix 1 to 32 (I think) but for the reverse problem we only have hex or oct (and cannot choose symbol lists but that's not so very important, if the whole matter has any significance of course :-). Hey, unint might even win the "more general" approval! Anton "or maybe it's just because it's difficult to find a good name for it" -- http://mail.python.org/mailman/listinfo/python-list
Re: Brute force sudoku cracker
Diez B. Roggisch wrote: > As everyone posts his, I'll do the same :) It uses some constraint based > solving techniques - but not too complicated ones. When stuck, it > backtracks. So far it never failed me, but I haven't tested it too > thouroughly. Thanks to all for sharing. I like to program sudoku and review such code. So below here is my current file, I think it uses some techniques not yet posted here. It also has a difficult 16x16 puzzle which I know to be solvable (barring typing mistakes) but which my file can't solve before I get tired of waiting, this might draw some heavyweights in the ring :-) I have also read the sudoku wiki page: http://en.wikipedia.org/wiki/Sudoku which was very helpfull and interesting (especially the link to Knuths paper about dancing links was nice, even though I think (but maybe wrongly so) that we don't need dancing links now that we've got sets, but it's still a very very interesting paper) I think the first important step is to realize that some variations have fewer values so that it is possible to reduce the search space early. Currently I'm exploring ideas about contigengies as explained in the wiki above which seems promising, but I haven't found a nice way to implement them yet. Maybe an easy optimization would be to find values that don't come up often and choose variations containing those. And maybe I should switch to an approach that has possibility values inside the cells instead of computing them on the fly each time, that could make contigency elimination easier. Anton from __future__ import generators from sets import Set as set problem1 = ['063000700','000690008','97002', '002010080','050806090','090070200', '60013','700045000','009000140'] problem2 = ['030009007','01008','000100090', '004905006','02010','500607400', '050001000','40020','700500030'] problem3 = ['030500810','000760090','4', '043905006','01070','600801930', '9','090086000','061002080'] problem4 = ['004530080','060009000','90005', '000800350','0','027006000', '80007','000300040','090072600'] X =[' 1 0 0 0 0 12 0 10 11 7 6 0 0 4 0 0', ' 0 7 0 0 15 13 0 0 0 0 2 0 0 8 0 0', ' 3 0 0 0 4 0 0 0 0 5 0 12 0 16 0 0', ' 0 0 14 2 0 9 0 0 0 0 1 0 0 0 0 0', '10 15 0 1 0 0 0 2 0 16 0 0 3 0 0 0', '12 0 0 3 0 0 15 0 0 13 0 4 0 1 9 5', ' 5 0 11 0 7 0 8 0 0 0 0 0 0 15 0 0', ' 7 13 0 16 0 0 0 6 0 0 0 14 0 10 0 0', ' 0 0 13 0 11 0 0 0 10 0 0 0 1 0 12 0', ' 0 0 7 0 0 0 0 0 0 3 0 16 0 14 0 13', '16 8 0 0 14 0 5 0 0 15 0 0 4 0 0 6', ' 0 0 0 9 0 0 4 0 1 0 0 0 2 0 0 7', ' 0 0 0 0 0 16 0 0 0 0 8 0 10 5 0 0', ' 0 0 4 0 12 0 6 0 0 0 16 7 0 0 0 14', ' 0 0 6 0 0 1 0 0 0 0 12 13 0 0 11 0', ' 0 0 15 0 0 8 11 3 2 0 9 0 0 0 0 1'] problem5 = [row.split() for row in X] class State: def __init__(self,solved,unsolved): self.solved = solved self.unsolved = unsolved self.size = int((len(solved)+len(unsolved))**.25) def choiceset(self,x,y): "the set of possible choices for an empty cell" sz = self.size res = set(range(1,sz*sz+1)) r,c = x/sz*sz,y/sz*sz for (i,j),v in self.solved.iteritems(): if x == i or y == j or (r<=ihttp://mail.python.org/mailman/listinfo/python-list
Re: subset permutations
Steven D'Aprano wrote: > On Fri, 09 Dec 2005 16:03:46 +1100, Ben Finney wrote: > > >> Do you want the result to be: > >> AB, AC, AD, BC, BD, CD > > > > That is the complete set of combinations of the letters. > > > >> Or, do you want AB,BA,AC,CA,AD,DA,BC,CB,BD,DB,CD,DB ? > > > > That is the complete set of permutations of the letters. > > > Only if you are choosing without replacement. If you are choosing with > replacement, you also get AA, BB, CC, DD. > > Unfortunately, there is ambiguity in the terms "permutation" and > "combination", not just between English common usage and mathematics, but > even in mathematics. Why is that unfortunate? Now we can all post our favorite scripts and let them be severely criticized :-) Anton def ncycle(seq,n): while True: for x in seq: i = 0 while i < n: yield x i += 1 def cross(*args): p = 1 R = [] for seq in reversed(args): R.append(ncycle(seq,p)) p *= len(seq) R.reverse() i = 0 while i < p: yield tuple(x.next() for x in R) i += 1 def test(): s1='a1','a2','a3','a4' s2='b1','b2' s3='c1','c2','c3' for x in cross(s1,s2,s3): print x if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Michael wrote: > Ilias Lazaridis wrote: > > [ panic, fear, worry ] > > What's wrong with just saying "Congratulations!" ? First thing I thought was > "ooh, maybe Guido will be able to work on P3K there" - after all that would > benefit Google *and* everyone else :-) Google's not a nice company (yeah, I know I'm posting from a google account). If you look at their job requirements it's clear they will only hire people with long backstabbing histories. There seems to be no room left for world improving undamaged souls in that company. > (Especially if he uses PyPy to experiment and play in ... :) Yes PyPy could save Python, or destroy the world. I have the impression not many enough people realize that a selfhosting programming language is something on the same level as a nano assembler or an artificial intelligence. There is not much time anymore for idealists to start trying to save the world, and I don't think we can count on google in that respect. Anton 'make my day, prove me wrong' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Robert Kern wrote: > I have a friend who works at Google. He has no backstabbing history at all. > Stop > insulting my friends. Your friends work for people who would never hire me. My resume sucks, but I'm not a bad person or a mediocre programmer. They sold out. > For Software Engineer: > > """ > Requirements: > > * BS or MS in Computer Science or equivalent (PhD a plus). Right here. > * Several years of software development experience. > * Enthusiasm for solving interesting problems. > * Experience with Unix/Linux or Windows environments, C++ development, > distributed systems, machine learning, information retrieval, network > programming and/or developing large software systems a plus. > """ > > I don't see any "damaged soul" requirement. I do. Experience here is an eufemism for having worked for the man. > >>(Especially if he uses PyPy to experiment and play in ... :) > > > > Yes PyPy could save Python, or destroy the world. I have the impression > > not many enough people realize that a selfhosting programming language > > is something on the same level as a nano assembler or an artificial > > intelligence. > > ??? What the hell are you smoking? We already have self-hosting programming > languages. Yes. We have humans too. > > Anton > > > > 'make my day, prove me wrong' > > Prove yourself right. Ok. That's a bit harder. I suppose we agree that if we have an intelligent program that is more intelligent than a human and have this program design an even more intelligent program than things start to accelerate pretty fast? Now the combination of a programmer with a tool (program) that can be used to make a better tool. This gives a better human-machine combination, which then can be used to further improve the combination. I don't think I have completely proven my point now, but since the danger is very real and big, coming close is already reason enough to watch this carefully. Why hasn't it happened yet with lisp? I don't know, why didn't the world get destroyed by all out atomic warfare? Couldn't it have happened? If we create AI why would AI keep us around if we ourselves won't even hire people that do not comply to absurdly specific preconditions? Don't we let our poor people starve in the undeveloped countries or even in our own cities? If we want to prove we belong to the next world we should start now. Open work communities where everyone can start working and get paid. The same thing as open source code or usenet but now with money for everyone. Anton 'sorry, I don't want to start a flamewar, but I really believe what I wrote here' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > Google's not a nice company (yeah, I know I'm posting from a google > > account). If you look at their job requirements it's clear they will > > only hire people with long backstabbing histories. > > Such as...? Guido van Rossum? Greg Stein? Vint Cerf? Ben Goodger? > Please DO share your insider-information about the "long backstabbing > histories" of each and every one of these people, I'm sure it will be > most fascinating (as well as useful for self-protection to future > potential victims), and, after all, they ARE all rather public > figures... TIA! No insider information is necessary, the job requirements make it absolutely clear (at least to me) that Google is a company with an elitist culture, just like most universities. In fact I am convinced that universities (and this time I have extensive, first person and historic information) are elitist. We can discuss that if you want but to me it's appararent that *titles* are a strong indication of elitism. Further more I am convinced that universities spend about 95 percent of their effort into maintaining the hierarchy (socializing the students), and spend almost no time on creating new knowledge. A kind of 'piltdown' phenomenon. Also when considering this massive scientific fraude (because that's what it is) it is very illustrative to use the same deconstructing methods that Randi, if that's not the name of a beverage, no: http://en.wikipedia.org/wiki/James_Randi uses to discredit paranormal phenomena. For example, careers are "construed" because scientific success is credited to persons higher in the hierarchy and mistakes are the faults of research assistents or students. Only if this system breaks down we see reports of "scientific fraude" in the media, which according to me is more a sign of the social network around the scientist collapsing than it is a sign of their research data being any more "fabricated" than other scientific data. There is a lot of this inbred and invisible corruption everywhere in our societies and I tried to name it by using the term "working for the man" by which I meant throwing away ones own moral compass and confining ones efforts to further the interests of a small sub-system (like soldiers) and thereby stabbing oneself and the rest of humanity in the back (figuratively) and often not even sparing coworkers in order to please the master. Why is this not absolutely clear and apparent? Because when trying to "feed ones wife and children" it is almost impossible to do so without *proving* that one has *experience* in working for these corrupt entities (and possibly having become corrupt oneself) and doing a lot for the community but still being blind to the faults of ones employer does count as condoning corruption, at least in my world. Most people can survive (without damaging their souls so to speak) when working for corruption themselves in this way, but sooner or later one is asked to corrupt others (defending one's title during a promotion, leading a community and so on). This is the crucial point where corruption definitively occurs: where silence is not enough anymore to keep one employed. The human brain can withstand extreme amounts of conficting sensory data and still maintain a sense of continuity and order while from all sides things seem to fall apart. Such continuity is highly valuable because it is the only thing that keeps chaos at arms length. The same thing can be applied to whole societies (see for example the state American politics is in now). So that is the reason these kind of things normally are swept under the carpet. However for *me* personally, because I am deserted by my government, the university community, friends and family, and left to fend for myself, there is no pressing need to keep up the facade so I can finally see it for what it is. I hope this answers some of your questions about my position. Anyway, I think its better to talk about positive things, like trying to convince google to hire any and all people who can program irrespective of their corruption history. For example to help manning their commercial "ask google" service. I read that nowadays people can get payed for playing *games*, by taking the virtual personae of people who don't have time to play themselves. Oh, and here [1] is another job posting, which seems a lot better than the Google example IMO, but which still misses a plan for what to do when thousands of programmers would apply and which also misses a mission statement for what they plan to do to save the world community from becoming slaves to a select group of elitists hiding behind webservices. The junior/senior divisioning in the job offerring below worries me too. Well I guess it
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Michael Sparks wrote: > Sorry to reply to the thread so late in the day, but I noticed (via > QOTW :-( ) that Anton got worked up at me suggesting that congratulating > someone with a new job was a nice idea (surprised me too - all the > Google employees I've met have been very nice people), read the > thread (got sad) and then saw this: Strange, I *did* get worked up at you some (long) time ago, probably without you ever noticing, it was about your pythagorean proof about anyone being able to learn kamelia quickly because you had some student who had no problems whatsoever with it, http://www.atopia.tk/anamnesis/kittleren.htm while I could not find a clue what your software was supposed to do, except being something very exciting (and I think I know python well enough to not often have that problem), but I did not get worked up at you because of you congratulating Guido. To make it more clear : Congratulations Guido, with your new job! However I still maintain that I was never able to meet these fine people you speak about and which you seem to know because the cost involved (a few hundred euro to visit pycon for example) was too high compared to my food budget. What I was trying to explain was that the world gets closer and closer to the singularity (something I believe other people got worked up at *me* about) and the world is now at the stage where everything gets reinvented in about 5 years. This means that during the next 2.5 years some phenomenon like Google changing internet history (which happened in the last five years) will happen again (in a shorter time period). Since we are going to reinvent ourselves faster and faster there is no need to take old corrupt methods with us into the future. Some people (maybe suffering from a wierd kind of conceptual static typing) equate me talking about 'people having a backstabbing history' with implying those exact people actually stab other people in the back literally. 'Having a backstabbing history' can also be explained as having been into places where backstabbing was common, without implying any actual backstabbing of these people themselves, except maybe the greater whole they belonged to being instrumental to backstabbing, for example mathemathics professors helping to crack codes which are used to decipher or encode messages in a war situation. I've already mentioned somewhere that I meant it figuratively and I will further qualify it now by saying that Googles selection process does them and the world a disservice by using some kind of elitist criteria, or by hiring people who can prove that they -forced by market mechanisms no doubt- have in the past collaborated with or worked for companies that selected them on the basis of elitist criteria. The elitist selection process suffers from the same problems that for example IQ-tests have: Trying to scale something in one (or at least too few) dimensions, where that something is very, very, very multidimensional. It is insulting, inappropriate and denigrating when applied to humans. Of course, irony will have people using elitist selection processes being very personally offended by people pointing out that it is unfair. Just like those who stole my money and job opportunities now claim I'm a parasite or some wrathfull loser who doesn't want to work. In fact, although I still don't condone corruption, my vision has cleared up a lot by not eating its fruits anymore. I am not jealous at anyone still 'inside' and although I dream about trying to save people from places where people get murdered randomly (the dreaded backstabbing reference again), it gets less and less often as time goes by. My current worry is about how I can survive for another 2.5 years (the projected time period for the world to renew itself again) without me jumping off a ledge because I dont want to be (and possibly live forever without dying) with irrational people who don't deserve my company or get offed by someone who can't stand me not joining corruption. It's possible some next generation of people don't want the current population to survive because they are not advancing fast enough or lack compassion with lower lifeforms. If anything, my post was about trying to save the world from that fate by trying to induce that compassion into this newsgroup. I think it would be beneficial for our people working for google (and for google itself) if they freed themselves of any remaining corruption so that world evolution will be synchronized with social evolution and no unnecessary tensions will occur. Anton 'workout' -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]
DaveM wrote: > On 3 Jan 2006 20:09:34 -0800, [EMAIL PROTECTED] (Aahz) wrote: > > >Unfortunately, this isn't quite true. Medicine and law both require the > >passing of an apprenticeship, so there's still some room for favoritism > >and blackballing. > > In the UK, in Medicine, House Officer jobs pretty much match the > qualification numbers. Sure, which HO post you get can give your career a > head start, but that advantage is evanescent if you can't cut the mustard. > > Fouling your career by upsetting the wrong people is, OTOH, easy to do. Maybe not many people realize that it's also possible that *having* a degree or having the *wrong* degree can also be a barrier. Or maybe that's just the case in highly bureaucratic societies like the Netherlands. I finished a study in the social sciences, but since I refused draft I had to do some social service work as a replacement. This was explicitly meant to be *careerbreaking*, because if it were otherwise it would be an advantage over other people who voluntarily went into the preparing to kill people business. However, women, and people who got out on a medical indication or because of surplus draftee numbers did not have to do this. Also, during draft a lot of people got free drivers licenses (for all vehicles). Having done draft is generally seen as some positive contribution to society. My social service work consisted of working as a programmer for a mad computer scientist who just threw me out after I had doubts about machine intelligence being feasible in less than a decade or so (and he badly needed a publication). This completely (for science) useless and overpayed guy (doctor at a public university) could practically do anything he liked with me because I just had to break my career anyway according to my social service contact person. Before I had my degree as a social scientist I had spend many years in the same kind of situation but then serving as an intermediary person between a computer running statistical programs and an elderly professor who was almost retiring but wanted to make one big publication before he vanished into oblivion. Of course this guy was very reluctant to let me finish my thesis because he would be without a computer programmer then, and he was already to old to learn it himself, while I seem to have a natural talent for handling computers, even among people who are of my age. Going back a little further in time, I remember a period as an intern where I was not allowed to publish my seperate analysis of the data *before* the same data was exhaustively studied and published by the guy who had ordered the survey to take place (payed by government money of course). Since this guy *never* seemed to be ready to publish anything (personal problems, divorce and such things) my complete internship was wasted in terms of getting anything I wrote out of this, officially. Now returning to being thrown out by the mad professor, I had the choice between labeling books for the rest of my time doing social service or finding some other careerbreaker. Luckily I had made some friends while playing go (the oriental boardgame) and they introduced me to their mathematics professor who subsequently let me do some programming work there. What struck me most was that the abyss between the social sciences and mathematics was nearly absolute. While social scientists use mathematics in a statistical way, their main aim is always to assert that they are actually measuring what is supposed to be measured. This can get quite sophisticated, for example if you give a person two possible choices, will the data be comparable to data acquired with the person having five possible answers? On the other hand, mathematicians want to cut loose from the data acquiring stage as soon as possible and just work with their formulas without making any assumptions about reality. Lines have no thickness, scales are neat continuous variables, correlations can be nicely separated in orthogonal factors, and so on. After my social service was over I tried to find jobs at universities or public institutions. I did find a research job at the headquarter of the institution that gives money to unemployed or sick people. I soon noticed that even before I had begun to work there it was decided that there could be no way for me to publish anything based on data from that site, because that data was hoarded by other people in much the same way as the research data was guarded by the guy from my internship. The trick was to let me handle anonimizing and security, and being the only person officially able to link data to persons, of course I was not allowed to publish anything. However, in this capacity I met a lot of people from smaller executive departements from all over the country and I noticed that they too were guarding their data as if their jobs depended on them, which was probably not completely a strange assumption, from their perspective. What they did was to se
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > >> However I still maintain that I was never able to meet these fine >> people you speak about and which you seem to know because the cost >> involved (a few hundred euro to visit pycon for example) was too high >> compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I already sent some reply via google, got a server error, resent, got a confirmation that my message was posted, but it doesn't show up and also there's no way to retrieve my message except fishing in the cache? Yesterday I had a post not showing up (in another group) but today it was there. This makes me feel insecure enough about whether or not my replies come through via google to start using another provider. It's not like I'm on a secret google no fly list no? (slightly paranoic) Anyway, I'm not typing all that again. Maybe it will show up tomorrow. The gist of it is that for me a few hundred euros is and was a *lot* of money, and that this talk about 'cheap to attend' irritates me a lot. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > > However I still maintain that I was never able to meet these fine > > people you speak about and which you seem to know because the cost > > involved (a few hundred euro to visit pycon for example) was too high > > compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I looked it up: 160 euro (early registration). My food budget is about 16 euro a week now, maybe even less if I want to keep feeding myself a bit longer, maybe in 2003 my reserves were a bit higher than now, but I had not yet learned then to be without a regular income, so I was very scared to become pennyless at that time. I am perfectly used to sleeping at other peoples' places, for example I was at many go (baduk) tournaments and if the prices and atmosphere would be anything comparable to that I guarantee you that I would have been present. IIRC I got an offer from Laura Creighton at the time to borrow me the money, so one could say it was a choice, although by that time the price had gone up to 270 euro. But frankly indeed, I just don't even like to participate to events that claim to be open for all but don't even acknowledge that the barriers are extremely high compared to some participants budgets. Your hype about it being cheap has a very chilling effect on my enthousiasm, it's the same way with pypy congresses, which I also would have liked to attend (and this thing even seems to be sponsored by public EU money). Probably I am still a *rich* person, on a global scale, because I live in a place with free internet (from a public library). You *do* realize that even posting to usenet is impossible (or at least very hard) for a lot of people, including me for at least 6 months. I had to find someone to invite me to gmail and also a way to access my previous internet account, which I lost access to when they cut my phone line, to recieve the mail that finally enabled me to post via google. Nowadays it's probably possible to open a hotmail account and get invited to gmail from there, so one can post to usenet. Theoretically I have now yet another option to post (except via google), but IMO it remains true that one needs at least one link to corruption to be able to post to usenet. Anton 'hey, and my laptop doesn't even have a cdrom, needs almost continous electricity, it's keyboard is broken (but it works fine with external keyboard), and it networks via a pcmcia card with a *cable* ' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > > However I still maintain that I was never able to meet these fine > > people you speak about and which you seem to know because the cost > > involved (a few hundred euro to visit pycon for example) was too high > > compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I looked it up: 160 euro (early registration). My food budget is about 16 euro a week now, maybe even less if I want to keep feeding myself a bit longer, maybe in 2003 my reserves were a bit higher than now, but I had not yet learned then to be without a regular income, so I was very scared to become pennyless at that time. I am perfectly used to sleeping at other peoples' places, for example I was at many go (baduk) tournaments and if the prices and atmosphere would be anything comparable to that I guarantee you that I would have been present. IIRC I got an offer from Laura Creighton at the time to borrow me the money, so one could say it was a choice, although by that time the price had gone up to 270 euro. But frankly indeed, I just don't even like to participate to events that claim to be open for all but don't even acknowledge that the barriers are extremely high compared to some participants budgets. Your hype about it being cheap has a very chilling effect on my enthousiasm, it's the same way with pypy congresses, which I also would have liked to attend (and this thing even seems to be sponsored by public EU money). Probably I am still a *rich* person, on a global scale, because I live in a place with free internet (from a public library). You *do* realize that even posting to usenet is impossible (or at least very hard) for a lot of people, including me for at least 6 months. I had to find someone to invite me to gmail and also a way to access my previous internet account, which I lost access to when they cut my phone line, to recieve the mail that finally enabled me to post via google. Nowadays it's probably possible to open a hotmail account and get invited to gmail from there, so one can post to usenet. Theoretically I have now yet another option to post (except via google), but IMO it remains true that one needs at least one link to corruption to be able to post to usenet. Anton 'hey, and my laptop doesn't even have a cdrom, needs almost continous electricity, it's keyboard is broken (but it works fine with external keyboard), and it networks via a pcmcia card with a *cable* ' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > I just don't understand, always assuming you're in the Netherlands, how > attending Europython in Belgium (as opposed to Pycon in the US) could > have cost hundreds of euros. Conference registration is free to > speakers, bicycling NL->BE not costly (many were driving from NL, so > bumming a ride was far from impossible either), many attendants arranged > to "crash" for free thanks to the hospitality of others, food costs in > Belgium aren't much different from those in NL. Ah, I see. You're approaching this from a 'speaker' scenario. You already have a lot of contacts, know where you can sleep, where to eat and so on. > I'm not saying a few hundred euros is 'cheap' -- it obviously isn't, if > your income is low to nonexistent; rather, I'm wondering where that > "hundreds" amount comes from. You originally mentioned only pycon > (where the need to fly to the US, for people living in Europe, can > obviously account for "hundreds of euros" already); Europython is > specifically held in Europe to be cheaper and more convenient to attend > for Europeans, and I've always met many people there who fell in the > "income low to nonexistent" bracket for one reason or another. Now going back to my claim that elitism is bad, I think you are the perfect proof of my point. You live in luxurious (with respect to community, education and financial aspects of being a computer scientist or programmer) conditions and can just not understand why some people have problems entering that same environment and privileged conditions as yourself. This attitude is very common and needs only some kind Blair-alike kind of selfhypnosis in order to effectively not being aware of lying. What is shunned is any form selfanalysis, because it would immediately reveal that you yourself are violently keeping all these people out of opportunities (the backstabbing), in your case for example by requesting certain degrees, without realizing that what you are selecting for is not what you think it is. It is selection for socialization and belonging to some kind of social group, not any mental ability really, not even the likeliness of being able to grasp Haskell which you somehow seem to link to having a mathematical education. Seriously, this is just a fraction of a unit above craniometry and you would be wiser if you dropped this attitude. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Armin Rigo wrote: > We have some procedure now for funding > travel costs, although it's admittedly very bureaucratic :-( Since next sprint is in Palma de Mallorca I trust I can count on PyPy to refund me the money? > Anyway, independently of this, there are some people we are happy to see > come back again and again to PyPy sprints even though we know their budget > is extremely limited. We have always arranged things for them to minimize > the costs. It's nothing like a "congress" where you have to pay XXX/day > for having water and cake brought to the tables by the staff at 10am. I > can certainly say that attending a PyPy sprint is not expensive at all; > I'd expect the major problem to be rather to find a week's free time for > it. There seems to have been a relatively inexpensive sprint in Heidelberg. So yes sometimes PyPy sprints can be inexpensive. But the associated costs if one has to rent a room in a hotel would still make it impossible for me to attend. What prompted me to cluster PyPy sprints with the expensive stuff was this sprint: http://www.trillke.net/images/HomePagePictureSmall.jpg Although I can't find pricing info now, I believe that at the time I considered the costs involved with the rent of the meeting place exorbitant. > On the bureaucratic side: Alex, we *have* a procedure at this point, and > we have been trying to contact you several time in the past months -- with > no success as far as I know, so I'll try via comp.lang.python this time > :-) If you still feel like seeing your money back in exchange for some > papers to fill and sign, please show up... Maybe Mr Martelli will ease his conscience (it's hard to see how it would not bother him to refuse to pick up checks while his opponents barely have enough to feed themselves) by donating the money to me, so that I might increase my efforts to squelch any remaining trace of elitism at google. Anton "I'd even look into PyPy sprint options at Maastricht, so you'd get extra value for your money" -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > situations, and in a few cases been able to help them back up. People > who attempt to *guilt-trip* me into helping have never been and will > never been in that lot: in this way, I'm definitely not a typical, guilt > driven "bleeding heart". I try to help people who are trying to help > themselves, and the kind of mixed whining and attacks which you are > producing is a great example of the very opposite: you don't want help > getting up, you want to drag others down. That's a game I don't play. You got that all wrong. I am trying to save google (and our precious Python personel there) from vanishing into oblivion because they would be unfit for the future because of their elitist selection procedures. Yes, refusing to give in to corruption has cost me a lot, but it has also cleared my mind. You are not my superior (or even considered to be more succesfull) as you seem to imply. Rather you are suffering from delusions of grandiosity and from unfounded assumptions of connections between programming abilities and academic educations. I am merely giving my point of view to the community. If that bothers you that is *your* problem. I would understand if you would settle matters rather by arguments than just waiting for me to run out of food. You might even make a small donation to prove your good intentions, but it shouldn't influence the discussion in the way of argumentation. > I am perfectly aware of what university degrees mean and don't mean: in > a situation of asymmetric information, they're signals (ones somewhat > hard to fake) about how much somebody believes in themselves and are > willing to invest in themselves. The literature is quite vast and > exhaustive on this analysis, and I'm reasonably well-read in it, even > though it's not my professional field. The problem is that universities now have very strong competition in the form of internet, where noone bothers with trying to keep university title structures intact. Since that always was more than 95 percent of the universities' effort (as I claimed before, but noone has given arguments against, and in fact some agreed implicitly) one can understand that this competition is fierce. If we want Google to survive in the noosphere it *has* to lose this attitude problem, be it the hard way or out of its own reflection. > The mental jump from this to "violently" and "backstabbing" singles you > out as a particularly weird lunatic, of course. But it's not quite as > laughable as your unsupported assumption about "lack of self-analysis", > resting only on your erroneous premise that "it would immediately > reveal" these absurdities. The unexamined life is not worth living, and > I do examine mine, but what the examination reveals has absolutely > nothing to do with what you baldly assert it would. Since your elitist selection process has you at the top, you don't even have the slightest chance of coming around as a reasonable person, unless you would explicitly consider the idea that you could be wrong and degrees *are* BS. > > It is selection for socialization and > > belonging to some kind of social group, not any mental ability really, > > Both: there are people who belong and are socialized but just lack the > mental ability (including sticktoitiveness and stamina) to stay the > course, and others who, despite coming from the most disadvantaged > backgrounds, still make it all the way through, bases on sheer ability > and determination. Adding the "or equivalent", and "or equivalent > experience", clauses, as present in many of our job offers, tries to > widen the catchment area to at least some people who didn't make it but > can still demonstrate they have the "mental abilities" in question. Can't you see that you have the guards guarding the guards here? > > not even the likeliness of being able to grasp Haskell which you somehow > > seem to link to having a mathematical education. > > My working hypothesis in the matter is that there is a mindset, a kind > or way of thinking, which helps with both grasping FP languages AND > grasping abstract mathematical disciplines. I guess it would seriously hurt you if programming abilities would be linked to your other forte, the (considered as soft alpha scientific) linguistic abilities. > > Seriously, this is just a fraction of a unit above craniometry and you > > would be wiser if you dropped this attitude. > > And hired hundreds of thousands of people a year (that's about the > number of resumes we get now, WITH the current job offers) without > selection? Sure, that would definitely ensure wisdom. Yeah, right. > > You're so pathetic you aren't even funny. Wait till I remove all hashing code from dictionaries. Sometimes giving up speed in the short term, results in speeding up the process as a whole because it becomes possible to use intermediary results more effectively. I have seen groups of mathematicians splitting up and each going into their own room
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > You are not my superior (or even considered to be more succesfull) as > > you seem to imply. > > Depends on who does the considering, I'm sure. If the considerer loves > the English language, for example, a horrible mis-spelling such as > "successfull" with two final L's would count for a lot in their judgment > (English is neither your native language nor mine, so it's not unfair to > either of us to consider it...;-). Well this sums it all up for me, about you. Making stupid claims to superiority while comfortably sitting at a computer *with a spellchecker* and denying me the same priviliges, not even by correcting google's _usenet_ interface (while its mail interface includes at least a minimally functional editor/spellchecker) to the point where a comparison would be fair. Stop whining and being insulted, your elitist selection policies have far more worldwrecking consequences than a few artificially magnified and misunderstood 'insults'. Anton 'you could always join the dutch unemployment inquisition' -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]
Steve Holden wrote: > Consider yourself excused. Thanks. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: > You can see my amended code in the link above. Thanks, I will look into it sometime. At the moment I'm at a library computer, which severely limits my Python options. Meanwhile I have been thinking about the sudoku problem, maybe it will prompt you, me or someone else to make some kind of other implementation which would resemble what I am thinking about now. Imagine a sudoku representation which is inside a 9x9x9 cube. The values in the cubes' cells are just 1 or 0. The height of a '1' is determined by the value in the original (flat) sudoku grid. There are 81 filled cells in the cube, just like in a sudoku solution. If one would look at the cube from a side it would always be the case that a filled cell at some depth inside the cube would block your line of vision wichever column one would be looking at. In a way a sudoku is a special case of a magic square, and a magic square can be transformed to this view, and this way it can be seen as the solution to the problem of making a cube not transparent by filling the minimum number of cells. Now such a cube can be mirrored in 48 ways and it would still be the same 'kind' of solution. Also it would be possible to swap horizontal layers at will and still have some kind of solution that is the 'same' in some way. One could also swap vertical layers iff (and only if) one would stay inside a 3-block group of layers. On the other hand it would be possible to swap complete 3-block groups of layers (if I'm still making sense) and maybe there are other symmetries that would leave the original solution somewhat intact. Suppose one would be able to generate all these possible symmetries and only use the 'smallest' representation of the original position, this 'hash code' would consist of just letting Python sort the possible 'same' cubes and selecting the smallest. It could be used to prevent us from computing the same cube twice since we could check if we already saw something with the same hash code. Now to the optimization part. If we find empty cells in the cube where there are only few positions in the same row, column, or depth available, we can limit the search space considerably because cutting off leaves early is most profitable. Maybe it would even pay off to consider complete layers and selecting possible fillable cells that have minimal fillable layers' sums. Sorry, I guess I'm getting a little bit pataforical here, expect my Python script any day now :-). It will be implemented as a sparse matrix based on sets of triplets (3-tuples) where for example tuple (0,0,0) will mean that the cell with x , y and z coordinate having value '0', is filled (virtually has a '1' inside, the 'unfilled' cells in the cube (the zeros) are not represented). I wonder if I still make sense, it's hard to stay programming Python without a computer to correct my thinking. Can someone write an implementation to check my ideas? Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > For an absolutely amazing translation feat, try Michael Kandel's > Polish-to-English translation of Stanislaw Lem's "The Cyberiad". Returning to the original book, why did they write a lot of it (at least the first few pages until I gave up, after having trouble understanding formulas about concepts I have no such trouble with when framed in less jargonized from) in unintelligible mathemathical notation when there's Python? I prefer a nice Python function over some strange latech symbols. If not Python there's always pseudo code or good old natural language. Don't tell me those math formulas are what it 'really' is, or even that it's more precise that way. The old trick of 'but there are some things that cannot be expressed in any other way than by using formulas' doesn't get one many optimization points in my world. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Juho Schultz wrote: > Last month I spent about an hour trying to explain why > a*2.5e-8 = x > raises a SyntaxError and why it should be written > x = a*2.5e-8 > The guy who wrote the 1st line has MSc in Physics from Cambridge (UK). > In mathematics, there is no difference between the two lines. Some time ago I tried to 'sell' Python to a mathematician. The crucial point was that it was not (in standard Python) possible to have a matrix A and a matrix B and then do for example: A = A * B and have a matrix multiplication performed. Since the whole conversation started because there was a need to use this notation for a standard mathematics course this didn't result in adopting Python for it. Meanwhile there has been some progress in Python use there, and of course there are specialized Python packages that enable this kind of notation, but it remains true that there *is* an abyss between computer science and mathematics. Mathematics should change ;-) But that doesn't mean that I wouldn't like standard Python to have A*B for matrices. The problem is that so called 'conventional' mathematical notations leave many options for interpretation, depending on the context and on mutual understanding between mathematicians, excluding non-mathematicians very effectively. A (Python) interpreter has no such problems and will allow precise inspection of what is meant by a piece of code. It has additional advantages in that it can function as a kind of "mathematical spellchecker" for people like me who often miscode things. Some mathematicians I know can write formulas page after page, while I, if I were to write (or read) a page of formulas there would be at least one mistake throwing me of course for the rest of the document, so that I would need to go back again and again. Does that make me a bad mathematician or does it signify that mathematical notation should change? For me the answer is clear, but that could be because I can't read the stuff without the documentation, and the documentation (mathematics) is considered to be known to everyone (with a math education of course) but I doubt if that is really the case and, even if it were the case it doesn't imply that being explicit (in giving the procedures in computer and human readable form at the same time, for example in Python) wouldn't be even better. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: > Do you think it is possible to reduce the set of all possible solutions > to a small enough set? I personally doubt it, but IF that was the case > an efficient solver could be easily created. No I don't think so, but it's a great idea :-) . Iff we would have some ultimate symmetry detector we could reduce all positions to variations of a few base types and start *generating* solutions from there in stead of checking possible mistakes. > In reducing the set of all solutions for instance you could always swap > the numbers (3rd axis) so that the first submatrix reads > [[1,2,3],[4,5,6],[7,8,9]]. By this we reduced the set of solutions by > 362880. You can then always move blocks, columns and rows to fix the > following elements (1,4)=4, (4,1)=2, (9,9)=9. Further reductions are > still possible, but I do not know how far can this go and if the end > result is a small enough set. I think one could reduce more than just a factor 9! . A 3-dim cube has 48 symmetric mirror images and we could multiply 9! by this. Then there are the horizontal slice swaps and the whole 3-slice swaps. Anyway I wasn't thinking about a grand unified theory but more about limiting the search space (in a depth first tree) early. If for example some field would allow only 2 values it would pay off to check that field first in the search (before fields that can have say 9 values) because that would be the next best thing to having that value as a fixed starting value. Similarly if we would only check a subtree position once (by using the hash) it could save some computations, but I have no idea how effective it would be, all this mirrorring could be expensive too. On the other hand this is done on the single leaf level, perhaps cutting off whole branches, so it might indeed pay off very much. Remember that some subtrees can be identical even though the routes to get to there were different. Here's the idea to make all the mirrors (I have the code at home, but I can't reach it now, but it should be easy to code): Say one has dimension x with values [0,1,,8] Now rescale this to [-4,-3,...,+4] Then do this for all x,y and z coordinates. Now to generate all mirrors, make all 6 permutations and all +- variations of all coordinate points x,y,z for each mirror. So x,y,z gives 6 permutations and doing +-x,+-y,+-z for each of these makes for 48 (6*2**3) mirror images of each point. for example a coordinate [-3,-2,-1] mirrored through mirror [z,-x,y] would give coordinate point [-1,3,-2]. Do this for all points. Repeat for each mirror. Now convert back to [0,1,..8] coordinates and select the smallest mirrored cube. Eh, maybe math notation wouldn't be such a bad idea after all, only then I wouldn't be able to read what I wrote here. I hope you can :-) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Terry Hancock wrote: > On 19 Jan 2006 13:57:06 +0100 > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > Some time ago I tried to 'sell' Python to a mathematician. > > The crucial point was that it was not (in standard Python) > > possible to have a matrix A and a matrix B and then do for > > example: > > > > A = A * B > > > > and have a matrix multiplication performed. > > Um, why not? I'm trying to think what would be the stumbling > block. I don't use matrix multiplies much, but I have > implemented 3D vector math so that "*" is the "dot product" > and "%" is the "cross product", which is pretty trivial to > do. Of course ! And to think that I even have used this trick a few times, for example to implement set operations using long integers. I feel ashamed. In my defense I can only explain what happened. Four years ago (when I knew a lot less of Python) I tried to use Numeric to do A*B for matrices, but that resulted in something else than expected. So I redefined the star operator by subclassing a *numeric python* object but then it didn't work (the subclassing IIRC). Then it turned out there was a Matrix module for Numeric that did exacly what was asked, but by that time I was trying to understand Numeric by reading the docs and 'selling Python' at the same time, which didn't work too well ... The main reason for that was that it was necessary to convince someone not having any Python knowledge to install Python *and* some module that I didn't know about and then that module needed *another* install which I didn't know about, and the docs for Numeric were separate from Python. Just too much at once. I believe if I just had implemented matrix multiplication myself at the time in plain Python I wouldn't have overcomplicated the matter in such a way that I couldn't convince anyone else anymore :-) So I got lost in Numerics complexities and that made me forget the basic option. By now I have used Numeric enough to make it likely that I could explain its use to someone. But even when I cured myself of this deficiency, the memory of failure stayed in my head. Witness a classic freudian fixation phenomenon in a Python learning curve :-) In order to prevent such mental damage for future Python programmers, I propose to add a simple matrix multiplication module to the standard distribution. > > The only obstacle I've run into is that you can't > (easily) define *new* operators and precedence levels. > > There *is* a trick for doing this that was posted on > the list some time back, which involved overloading an > operator to "apply an operator": > > It would've allowed you to do something like this: > > a |dot| b > a |cross| b > > or perhaps > > a b > a b > > I don't remember where this is posted. The trick was in > overloading the <, >, or | to interact specially with > "operator" objects. That's very nice. Thanks to you for mentioning this and to Jorge, who provided the link to activestate for this recipe in another message. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: [Something I mostly agree with] > According to Anton the number of possible solutions can be reduced > using 1) number swapping, 2) mirroring, 3) blocks/rows/columns > swapping. All those operations create equivalent matrices. For a 9X9 > grid, this should give a reduction factor = (9!)*(48)*(6^12) minus the > number of duplicated combinations given by the methods above. I am not > sure how to calculate the number of duplicated combinations and > therefore do not know if the result is "good enough". As mentioned, I > doubt that it is a viable approach, but I find it an intriguing > approach nevertheless. We could start hunting down net sites giving sudoku problems and claim they are trying to sell us the same problem twice :-) Or produce counterfeit problems ourselves and get rich quick. But I wonder about that 6^12 term. Within each 3-row block there are 6 permutations. There are 3 3-row blocks and 3 3-column blocks. Then between blocks (swapping complete 3-row blocks) permutations also give a factor 6. So in my count (but I suck at math) this term schould be: 6**8 (also switching to Python exponentiation notation) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > The first few pages are a review of probability theory but I think > they assume you've seen it before. The book's subject matter is more > mathematical by nature than what most programmers deal with from day > to day, and as such, the book is not for everyone. And so the cycle repeats itself. We teach our students the world is all about money, and sure enough, the world is all about money. If we would continue to keep the interesting things away from most of the people, by hiding it behind mathematical jargon we end up believing that functional programming is connected to having a math degree and more such self serving and self fullfilling prophecies. An excellent book would break with this jargon advertising salesmanship. Anton "but I'll give it one more try" -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > signal processing, for example. Perhaps it could be improved by being > more explicit about what the reader needs to know, and giving > references to other books where the prerequisites can be found. There are lots of good explanations, graphs, diagrams and such things in the margins (I'm a few pages further in the book now) but the main course seems to be mathematical formulas. The author should reverse the roles these presentations play, move the archaic math jargon to the margin, or better to a separate latech document, suitable for those unwilling to join the rest of humanity. A separate Python library would be handy too, and if not in the main text it could still be useful for those who lack training in obscure scientific dialects and want to understand things without any agreed upon beforehand gibberish that is mainly meant to exclude those not in the guild. > I also don't think presenting the math in Python would make things any > easier conceptually. The math in Sussman and Wisdom's "Structure and > Interpretation of Classical Mechanics" is all presented in Scheme, but > it's still the same math that's normally presented as equations, and > you have to think just as hard to understand it. The problem for me is that I recognize many of the used concepts, but they seem to be deliberately put in cryptic greek letters and undecipherable gibberish. It would not be necessary to present the math in Python, any reasonably consistent kind of pseudocode (but not Scheme or math notation) would made things a lot more clear to me. Something on a related subject with a presentation I like a bit better (but it has its problems too, while your book has more of these nice explanations and stuff, although in the margin): http://www.math.mtu.edu/~kreher/cages.html The authors of this book also seems to think we cannot do without obscure math notation, something which I disagree with very much, but at least they provide some pseudo code and some computer code, unfortunately in C but still better than nothing. The text of the book is not downloadable, but the algorithms source codes are. All of the books writers seem to have not caught up with the idea of hyperlinks and continue to dwell in neolithical paper dreams :-) If they only woke up and let someone like me write some Visual Python code to illustrate the algorithms or even let me just write Python implementations of the algorithms to accompany the books, I'd probably have work for years to come. > Math is a beautiful subject, and is not at all secret or inaccessible. > Try to broaden your horizons a bit ;-). I hope you're not trying to outexpertize me. You seem to be thinking that you know more about math than me, probably because you have a formal education in the subject? If so, you're proving my point, and thank you very much. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: integer to binary...
[EMAIL PROTECTED] wrote: > does anyone know a module or something to convert numbers like integer > to binary format ? > > for example I want to convert number 7 to 0111 so I can make some > bitwise operations... >>> def bits(i,n): return tuple((0,1)[i>>j & 1] for j in xrange(n-1,-1,-1)) >>> bits(7,4) (0, 1, 1, 1) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: An oddity in list comparison and element assignment
Alex Martelli wrote: [snip] Can somebody please shut down this bot? I think it's running out of control. It seems to be unable to understand that "don't be evil" might be good when you're small (at least it's not very bad) but that it becomes distinctly evil when you're big. What is good when you're big? I really don't know and I think there's even not many other people who do. But simply forbidding things that are not precisely definable -the way mathematicians have been doing before physicists shook them out of it- seems to do more harm than good. In my opinion it looks like there is a path from rigid rule adherence to slowly accepting more doubt and inconsistencies -because we're all adults here- and this has something to do with letting go of things like childish adherence to static typing and confusion between equality and identity. Let me qualify that last paragraph before anyone concludes I have become disfunctional too and will lead everyone to their destruction. There seem to always be certain unclear parts in a programming language and people are constantly trying out new structures in order to map some new territory. I remember sets, generators and metaclasses. Only after people noticing problems (don't modify the thing you're iterating over) ways are found to solve them (you can if you put everything back just at the right moment) and finally these ways are condensed into officially endorsed coding practices. Now we're struggling with immutability and sequences. They're not a problem if you know what you're doing, but what exactly is it that those who know what they're doing do? It indicates that maybe it's the birth of a new language construct. But why should it stop there? I expect a certain openness and willingness to discuss controversial matters from a community even if it were only to educate newcomers. But it might be the case that such willingness to accept doubt, without it turning into actively seeking it -that seems to be foolish, but who am I to judge even that- is what makes it possible to develop higher language and cognitive structures. Anton 'even if it means turning into lisp before moving on' -- http://mail.python.org/mailman/listinfo/python-list
Re: An oddity in list comparison and element assignment
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >> Can somebody please shut down this bot? I think it's running out of > > Much as you might love for somebody to "shut me down", that > (unfortunately, no doubt, from your viewpoint) is quite unlikely to > happen. Although "making predictions is always difficult, especially > about the future", the most likely course of events is that I shall > continue for a while to survive, probably in tolerable health. You've got that completely wrong. I was not trying to kill you but I was trying to revive you. A process that is not evolving is dead. Stopping it frees up valuable resources that enable it to become alive again. Anton 'being alive is being mutable' -- http://mail.python.org/mailman/listinfo/python-list
[OT] code is data
With the inclusion of ElementTree (an XML-parser) in Python25 and recent developments concerning JSON (a very Pythonesque but somewhat limited XML notation scheme, let's call it statically typed XML) Python seems to have reached a stage where it now seems to be possible to completely swallow lesser languages code, modify it, and spit out new source code targeting the original language the code was written in, or even make a translation to other languages. The idea is that we now have a fast parser (ElementTree) with a reasonable 'API' and a data type (XML or JSON) that can be used as an intermediate form to store parsing trees. Especially statically typed little languages seem to be very swallow-able. Maybe I will be able to reimplement GFABasic (my first love computer language, although not my first relationship) someday, just for fun. Then there are things like cTypes (calling functions from native DLL's) and PyPy (implementing Python in Python). All this taken together, to me it starts looking like we're now entering a territory that traditionally was exclusively in the Lisp domain. Yes, Python had eval and exec for a long time already, and metatypes and generators are having some strange unexplored possibilities too, but the day will come soon (and at last when PyPy is reaching execution speeds close to cPython) where Python will be able to swallow smaller languages, and finally it will be able to swallow its own tail, like Lisp but then more powerful (because of the widely used standard data types and the code exchange between languages that that makes possible). Your thoughts please. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
bruno at modulix wrote: > I still don't get the point. Well, I've got to be careful here, lest I'd be associated with the terr.., eh, the childp..., eh the macro-enablers. The idea is to have a way to transform a Python (.py) module into XML and then do source code manipulations in XML-space using ElementTree. But rest assured, there is no such module, nor will we ever need it for anything. Anton "use cases are for the faint-hearted" -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
Diez B. Roggisch wrote: <...> >> The whole point of a code transformation mechanism like the one Anton is >> talking about is to be dynamic. Else one just needs a preprocessor... > > No, it is not the whole point. The point is > > "" > The idea is that we now have a fast parser (ElementTree) with a > reasonable 'API' and a data type (XML or JSON) that can be used as an > intermediate form to store parsing trees. Especially statically typed > little languages seem to be very swallow-able. Maybe I will be able to > reimplement GFABasic (my first love computer language, although not my > first relationship) someday, just for fun. > """ > > No on-the-fly code generation here. He essentially wants lisp-style-macros > with better parsing. Still a programming language. Not a data-monger. The 'problem' is that a lot of incredibly smart people are reading and replying here who are seeing a lot more into my post than I was prepared for :-) Anyway, the last few weeks I have been busy transforming MsWord documents into XML using Open Office, and next parsing this XML and transforming it into a special subset of HTML using ElementTree's XMLWriter class. Then the output of the XMLWriter was put into a Zope/Plone page but I added special markup for footnotes, making them plone objects that could be separately edited, and I added image tags for images that were retrieved from a separate server using an XSLT script. To accomplish that a special zope parser was written to recognize my nonstandard footnote and image tags, and to create the necessary objects, and to insert them into the page. After that I came across some turbogears code (which is stacking code at different levels like it were those things you put under your beer glass) and still later I saw some JSON equivalents of XML. JSON looks a lot like Python dicts which makes it seem likely that javascript will be able to interface with Python more efficiently. Remember that ElementTree comes from the same place that brought us PIL which is a package that can transform images into different types. So if we can transform documents, images and XML, why not sourcecode? Especially if it's not a conversion into a 'lossy' file format, (I consider dynamically typed code versus statically typed code the analog thing to JPEG versus bitmaps) it would be easy to convert all datatypes into the datatypes of another language, thereby making it possible to exchange code between languages. Algorithms just being things that convert sets of data-objects into other sets of data-objects. Now if one would equate standardized code exchange between languages and within a language with macros then I guess there is nothing left for me to do but wait till a certain google bot comes knocking at my ip-address port 80 and transfers me to the google equivalent of Guantanamo. But the whole point of distinguishing macros from official language structures *is* standardization, as some other clever poster already pointed out, so it would be extremely unfair to equate trans-language standardized code exchange with the guerrilla type macro activities that are plaguing the Lisp community. Then there are some people who keep insisting they don't understand what I'm talking about until I simplify things enough to get them on-board, but then simply dismiss my ideas with 'you can already do that easily with this standard python construct'. This strategy was also eloquently refuted by some other poster, so I don't need to repeat it :-) I've gotten a lot of things to think about, so thanks all for your thoughts, but since this is getting way above my head I'll just wimp out and leave the rest of the thread to the experts! Regards, Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
Bruno Desthuilliers wrote: > You mean like 'converting' javascript to python or python to ruby (or > converting any home-grown DSL to Python, etc) ? Yes, but also what some other posters mentioned, making Pythons internal parsing tree available to other programs (and to Python itself) by using a widely used standard like XML as its datatype. >> Then there are some people who keep insisting they don't understand what >> I'm talking about until I simplify things enough to get them on-board, > > count me in then :( Sorry about that. >> but then simply dismiss my ideas with 'you can already do that easily >> with this standard python construct'. This strategy was also eloquently >> refuted by some other poster, so I don't need to repeat it :-) >> >> I've gotten a lot of things to think about, so thanks all for your >> thoughts, but since this is getting way above my head I'll just wimp out >> and leave the rest of the thread to the experts! > > No way you will escape from your responsabilities so easily !-) Ok, count me back in then too :-) Of course I will be available for further discussion. If more than ten people demand a PEP and no better champion is available (very unlikely) I'll even write a proposal. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Girish Sahani wrote: > I want to generate all permutations of a string. I've managed to > generate all cyclic permutations. Please help :) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496724 anton -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Paul Boddie wrote: > Anton Vredegoor wrote: >> Yes, but also what some other posters mentioned, making Pythons internal >> parsing tree available to other programs (and to Python itself) by using >> a widely used standard like XML as its datatype. > > http://pysch.sourceforge.net/ast.html Very interesting, it led me to some sxml describing pages and it also tricked me into reading some Python documentation that I had always considered to be hiding some arcane deep Python magic. I guess now that Python is officially entering tree territory (as opposed to providing third party functionality) it seems unavoidable that Python's officially endorsed tree datatype will also be used for some of its internal structures, thereby making it more accessible to programmers like me and to outside programmers. > I was going to write a long reply to one of your previous messages, but > the above link references a project which may intersect with some of > your expectations. Meanwhile, it should be noted that the availability Somehow I get the impression of getting away with my posts luckily, while you now are duping other interested readers into not reading your innermost feelings about this subject. Let's get it in the open, don't spare me :-) > of Python AST processing tools is not a recent thing: the compiler > module has been around for a long time, and it is possible to modify > the AST and to generate bytecode from it; my own experiments have > centred on producing other representations from the AST, and other more > successful projects (eg. ShedSkin) produce other languages (eg. C++) > from the AST. Well maybe this trick of vehemently denying the existence of something on Usenet worked again, by materializing the thing as a reaction. However, I knew of the existence of such languages but I am mostly interested in standardized code interchange, like for example with JSONP which fetches some external javascriptcode from another server using JSON and places the translated javascript into a webpage at the request of the clients browser or so it seems. Maybe a Python webserver could also emit pieces of javascript code by getting them from a *Python* code library after translating Python code on the fly? That would open up the web to Python programmers without browsers needing to understand Python. Like Jython, but now as separately distributed functions from different servers. Anton -- http://mail.python.org/mailman/listinfo/python-list
proof of concept python and tkinter gnugo interface
For the last few days I've been doodling with a script that provides a graphical interface to gnugo by using its GTP protocol. At the moment the script is *very* basic, in fact the only thing it does is to allow one to click on a coordinate and place a move there OR press the space bar in order to let gnugo generate a move. However, I feel that this idea has some potential, it could be made to undo or redo moves or load sgf-games. But most importantly: It could load the list of move suggestions from gnugo, do some computations itself in *Python* on that list and then generate a move. So I thought that it would be best to present this script while it is still small and modifications can be done easily. In the end there's possibly a lot of potential and I think I'm going to need some help from people that are enthousiastic about Python or gnugo. What I want to accomplish with this post is to get to know whether it would be a good idea to make it a sourceforge project (it would be even better if some more experienced sourceforger would do it for me :-) or whether I should just go on doodling on this script by myself, gradually adapting it to fit my personal interests and come back to you in a few years with a more complete script. Is there any need for such a beast for *more* people than just me to work on? Here's the proof of concept, just copy it to some dir and run the Python script: http://home.hccnet.nl/a.vredegoor/gnugo/ It needs Python 2.5 which you can get at: http://www.python.org/ Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I access a main frunction from an import module?
Jim wrote: > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > # > from abc import * > def m(): > print 'something' > return None > > a() import sys def a(): sys.modules['__main__'].m() return None Anton 'now why would anyone want to do *that* ?' -- http://mail.python.org/mailman/listinfo/python-list
Re: proof of concept python and tkinter gnugo interface
grindel wrote: > Anton Vredegoor wrote: [...] >> Here's the proof of concept, just copy it to some dir and run the >> Python script: >> >> http://home.hccnet.nl/a.vredegoor/gnugo/ >> >> It needs Python 2.5 which you can get at: >> >> http://www.python.org/ > If you talking about a simple gui for gnu go it's been done to death. > see any misc. pandanet client and numerous other softwares such as > durish or go knot. If your client is going to do something uniquely > different from programs like this then you should focus in this aspect > of the program and develop other features later. It's also important > that it be able to read and write sgf files It's uniquely different from numerous other softwares in that it is completely open source and runs from a standard Python installation (but of course one has to get a Gnugo executable from somewhere). I also implemented reading and writing SGF files and browsing through the move history now. Total command set at the moment: -click on a coordinate: generate a move there and go out of replay mode -space bar: computer makes a move and goes out of replay mode -up key: save an SGF file (only the moves) -down key: read an SGF file -left key: go into replay mode and undo a move -right key: show next move, if at end goes out of replay mode Remember we're still only talking about a proof of concept script! I just want to attract people, and put this script into an SVN somewhere. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: permutations - fast & with low memory consumption?
Gerard Flanagan wrote: > No claims with respect to speed, but the kslice function here: > > http://gflanagan.net/site/python/utils/sequtils/ > > will give the 'k-subsets' which then need to be permuted - > alternatively Google. Maybe the function below could then do these permutations. Anton. def _sorted(seq): """ Return a sorted copy of seq, preserving the type. """ res = seq[0:0] decorated = ((x,i) for i,x in enumerate(seq)) for x,i in sorted(decorated): res += seq[i:i+1] return res def _swap_and_reverse_tail(R,i,j): """ Swap R[i] and R[j], reverse R[i+1:]. Returns a copy, preserving the type. """ a,b,c,d,e = R[:i],R[i:i+1],R[i+1:j],R[j:j+1],R[j+1:] return a+d+(c+b+e)[::-1] def permutations(seq): """ Generate sorted permutations of any sequence that can be indexed and sliced, preserving the type. e.g. seq can be a string, list, tuple or array. """ n = len(seq) if n == 1: yield seq[:] elif n >= 2: R = _sorted(seq) while True: yield R i,j = n-2,n-1 while R[i] >= R[i+1] : i -= 1 if i == -1: return while R[i] >= R[j]: j -= 1 R = _swap_and_reverse_tail(R,i,j) def test(): seq = 'gkDr217sKGMNLPsrtqeiczxyq' P = permutations(seq) for i,x in enumerate(P): print '%s' %(x) if i == 10: break if __name__ == '__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Paul Rubin wrote: > def deals(): > for i in xrange(13**5): > cards = [(i//p) % 13 for p in (1, 13, 169, 2197, 28561)] > yield cards This gives hands like [0,0,0,0,1] and [0,0,0,1,0] which are permutations of one another. Below is a piece of code that avoids this. Here's how to interprete its output. Suppose one gets a hand like [0,1,2,3,4]. This means that it would be possible to create 1024 (4**5) poker hands from this, by "coloring" the cards. Another hand, for example [0,0,1,2,3], would allow only 384 colorings, because the two zeros would contribute choose 2 out of 4 (colors), so 6 colorings. The other numbers remain available for 4 colorings, which gives 6*4**3 (==384) colorings for this hand. Similar things happen for other partionings of the hands into numbers. In fact I am now investigating a description based on integer partitions of the number 5. I am not sure whether I want to partition based on colors or on numbers, that seems to arbitrary. This is very fascinating. Maybe someday I'll make a tkinter script with a visual tree structure allowing all kinds of numbers of "cards", and arbitrary numbers of variables to partition by. This would then give result sets like those strange quantum particles, such as quarks. Have fun, Anton def hands(L = [0]): if len(L) == 6: if L[1] != L[-1]: #no five of a kind yield L[1:] else: for i in range(L[-1],13): for H in hands(L+[i]): yield H def pprint(i,hand): print '%5i: ' %i, for x in hand: print '%2i ' % x, print def test(): H = hands() total = 0 for i,x in enumerate(H): pprint(i,x) if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: "Intro to Pyparsing" Article at ONLamp
Paul McGuire wrote: > I just published my first article on ONLamp, a beginner's walkthrough for > pyparsing. > > Please check it out at > http://www.onlamp.com/pub/a/python/2006/01/26/pyparsing.html, and be sure to > post any questions or comments. I like your article and pyparsing. But since you ask for comments I'll give some. For unchanging datafile formats pyparsing seems to be OK. But for highly volatile data like videotext pages or maybe some html tables one often has the experience of failure after investing some time in writing a grammar because the dataformats seem to change between the times one uses the script. For example, I had this experience when parsing chess games from videotext pages I grab from my videotext enabled TV capture card. Maybe once or twice in a year there's a chess page with games on videotext, but videotext chess display format always changes slightly in the meantime so I have to adapt my script. For such things I've switched back to 'hand' coding because it seems to be more flexible. (Or use a live internet connection to view the game instead of parsing videotext, but that's a lot less fun, and I don't have internet in some places.) What I would like to see, in order to improve on this situation is a graphical (tkinter) editor-highlighter in which it would be possible to select blocks of text from an (example) page and 'name' this block of text and select a grammar which it complies with, in order to assign a role to it later. That would be the perfect companion to pyparsing. At the moment I don't even know if such a thing would be feasible, or how hard it would be to make it, but I remember having seen data analyzing tools based on fixed column width data files, which is of course in a whole other league of difficulty of programming, but at least it gives some encouragement to the idea that it would be possible. Thank you for your ONLamp article and for making pyparsing available. I had some fun experimenting with it and it gave me some insights in parsing grammars. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Paul Rubin wrote: > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > by just doing the arithmetic and comparing the results. Maybe your > tkinter script can show that. That seems to be very hard :-) Unless I'm missing something. Anton def noverk(n,k): return reduce(lambda a,b: a*(n-b)/(b+1),range(k),1) print noverk(52,5) print 13**5-13 #prints: 2598960 371280 -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Anton Vredegoor wrote: > Paul Rubin wrote: > > > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > > by just doing the arithmetic and comparing the results. Maybe your > > tkinter script can show that. > > That seems to be very hard :-) Unless I'm missing something. Like a factor seven, you mentioned that a few posts back. Sorry about that. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: "Intro to Pyparsing" Article at ONLamp
Paul McGuire wrote: > There are two types of parsers: design-driven and data-driven. With > design-driven parsing, you start with a BNF that defines your language or > data format, and then construct the corresponding grammar parser. As the > design evolves and expands (new features, keywords, additional options), the > parser has to be adjusted to keep up. > > With data-driven parsing, you are starting with data to be parsed, and you > have to discern the patterns that structure this data. Data-driven parsing > usually shows this exact phenomenon that you describe, that new structures > that were not seen or recognized before arrive in new data files, and the > parser breaks. There are a number of steps you can take to make your parser > less fragile in the face of uncertain data inputs: > - using results names to access parsed tokens, instead of relying on simple > position within an array of tokens > - anticipating features that are not shown in the input data, but that are > known to be supported (for example, the grammar expressions returned by > pyparsing's makeHTMLTags method support arbitrary HTML attributes - this > creates a more robust parser than simply coding a parser or regexp to match > "' > For example, I had this > > experience when parsing chess games from videotext pages I grab from my > > videotext enabled TV capture card. Maybe once or twice in a year > > there's a chess page with games on videotext, but videotext chess > > display format always changes slightly in the meantime so I have to > > adapt my script. For such things I've switched back to 'hand' coding > > because it seems to be more flexible. > > > > Do these chess games display in PGN format (for instance, "15. Bg5 Rf8 16. > a3 Bd5 17. Re1+ Nde5")? The examples directory that comes with pyparsing > includes a PGN parser (submitted by Alberto Santini). Ah, now I remember, I think this was what got me started on pyparsing some time ago. The dutch videotext pages are online too (and there's a game today): http://teletekst.nos.nl/tekst/683-01.html But as I said there can be transmission errors and human errors. And the dutch notation is used, for example a L is a B, a P is a K, D is Q, T is R. I'd be interested in a parser that could make inferences about chess games and use it to correct these pages! > > What I would like to see, in order to improve on this situation is a > > graphical (tkinter) editor-highlighter in which it would be possible to > > select blocks of text from an (example) page and 'name' this block of > > text and select a grammar which it complies with, in order to assign a > > role to it later. That would be the perfect companion to pyparsing. > > > > At the moment I don't even know if such a thing would be feasible... > > There are some commercial parser generator products that work exactly this > way, so I'm sure it's feasible. Yes, this would be a huge enabler for > creating grammars. And pave the way for a natural language parser. Maybe there's even some (sketchy) path now to link computer languages and natural languages. In my mind Python has always been closer to human languages than other programming languages. From what I learned about it, language recognition is the easy part, language production is what is hard. But even the easy part has a long way to go, and since we're also using a *visual* interface for something that in the end originates from sound sequences (even what I type here is essentially a representation of a verbal report) we have ultimately a difficult switch back to auditory parsing ahead of us. But in the meantime the tools produced (even if only for text parsing) are already useful and entertaining. Keep up the good work. Anton. -- http://mail.python.org/mailman/listinfo/python-list
Re: two generators working in tandem
Michael Spencer wrote: > This returns an iterator that 'nests' an arbitrary number of sequences > (odometer-style). > > def nest(*sequences): > def _nest(outer, inner): > for outer_item in outer: > if not isinstance(outer_item, tuple): > outer_item = (outer_item,) > for inner_item in inner: > yield outer_item + (inner_item,) > return reduce(_nest, sequences) Nice! Here's a nonrecursive version. It creates a list of iterators that are repeating their values just enough times to sychronize the nesting. I wonder if 'ncycle' would be a useful generalization for itertools' 'cycle' function. Anton def ncycle(seq,n): while True: for x in seq: for dummy in xrange(n): yield x def cross(*args): p = 1 R = [] for arg in args[::-1]: L = list(arg) R.append(ncycle(L,p)) p *= len(L) R.reverse() for dummy in xrange(p): yield [x.next() for x in R] def test(): s1='a1','a2','a3','a4' s2='b1','b2' s3='c1','c2','c3' for x in cross(s1,s2,s3): print x if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
John J. Lee wrote: > Why not Jython? There's no command prompt! The file menu from IE is also gone. There is a sun Java console but it looks like this: Java(TM) Plug-in: Version 1.4.2_06 Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\x c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to Thanks for replying anyway! Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
John J. Lee wrote: > Why not Jython? There's no command prompt! The file menu from IE is also gone. There is a sun Java console but it looks like this: Java(TM) Plug-in: Version 1.4.2_06 Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\x c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to Thanks for replying anyway! Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Timothy Smith wrote: > how locked down is the computer? there's a few (brave) public access > unix shell providers out there. if you could run telnet you could use them Sorry, no telnet. Every executable that is not listed is blocked. For example I can download: http://prdownloads.sourceforge.net/scintilla/Sc1.exe but if I run it I get two error messages: a) a 15 seconds "appguard" message b} 'access to the specified device, path or file is denied' Maybe some shell provider is a good idea, however I still think I should make a cherrypy form of 24 lines or so and run it over there and simulate a python interpreter on a webpage which I can access from here. Has this been tried before? How can I use cookies to identify interpreter sessions? Anton 'webpython_3000_server_at_xxx.xxx.xxx.xxx_>>>' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Robert Kern wrote: > There is a Java SSH client that runs in the browser. > > http://www.oit.duke.edu/sa/security/ssh.html Great! I have a terminal. I can't figure out how to start jython from there though. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Chris Lambacher topposted: > usb key and moveable python. > http://www.voidspace.org.uk/python/movpy/ I have a usb card reader and I can use it. That saves me from having to have remote storage at least. However I can only save files, not open them, except if I use word, excel or powerpoint. The moveable python is great indeed. This worked here before, but then I could even access *other* peoples usb sticks in this whole building ... Crazy. Not anymore though. They could really use someone like me here for a sensible security policy that doesn't cripple the users. I can't even set internet options, that means I can't remove my history or clear my cache :-( Anton 'security doesn't mean shooting everyone in the foot' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Christos TZOTZIOY Georgiou wrote: > I am not sure I will help you (uncertainty based on the part I snipped), > but the part so far can be easilly solved if you install Python for > single user inside the "Documents and settings\" folder (or > whatever it is called). I did in a similar case. .msi is blocked by the appguard. I knew that because I tried it a week ago, but just to be sure I tried again. > End of reply here; and now for some completely minor python success > story. [snip story] > Thanks, that was a nice story! However I still think ... But you know what I think by now don't you :-) Anton '[EMAIL PROTECTED]>>> import NNTP ' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Mike Meyer wrote: > > Sorry, no telnet. Every executable that is not listed is blocked. > > You sure? IE used to understand telnet: URLs, and would open a console > window talking to the remote end. It may have been doing it with an > external application, in which case this won't help you. Yes, I'm sure. At least now I am. I just did a "telnet://localhost"; and there was an error message from the appguard stating that "telnet.exe" wasn't allowed to run. Since some posters keep replying as if I just could install this here or run that there (from a memory stick for example) I will say something about what kind of solution I want. I have little doubt that I could find a way to pass the security system here if I really wanted that. The printing routine allows printing to a file and has a filebrowser that can see all the 'forbidden' directories. Also everytime someone prints anything around here the complete network freezes for about half a minute so there's little doubt that we have a high priority process here. However that's *not* what I want (not saying that's what you think I want, just speaking to the third person in general here). What I want is to use the principle of flowing around the obstacle, leaving the blocking instance out of the loop thereby "punishing" it for it's own stupidity. It's the way internet works. So if a telnet is offered I use it. If I have to create a webform on *another* computer that I can access from here and which looks like a telnet command line, that would be ok too. So far I have received a valuable tip about a javabased terminal which would in the end enable me to log in to some other computer and from there I could possibly start a python interpreter session. This also makes me think it should be possible to load a java based python somehow. Maybe from a java text editor that can run jython? However jython implies running jview.exe or at least some other java interpreter? But then how does this ssh terminal run java? It's a thin line between philosophy, fear of breaking the rules and having the security personnel throw me out of here, and trying to live in a just world. Assume I can't or won't run .exe that are blacklisted. Any way to start a python interpreter? This is a python challenge too isn't it :-) Anton 'this parrot.exe is dead' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
alex23 wrote: > You know, there _are_ valid reasons for libraries et.al. 'locking down' > public terminals other than fascism... Maybe, but in this case I can run only IE, word, excel and powerpoint. Do you think there is a rational reason for that? Like Tim Peters showing up, explaining that it's just a natural side effect of binary floating point implementations? On the other hand one might look at public libraries as places suited to inspire people and showing them how one is to treat the users of a public service. Since Dutch government is beyond hope in that department and the local governments of Cities are also becoming more and more corrupt (what does one expect if one gives the City rulers a bag of money and says "it's your problem now, do whatever you like with it, just don't come back for more") one can only hope that public services stay functional until there's an anti-fascistic movement that can remove those people that sold public freedom, right, and dignity to the highest commercial bidding party. As to my personal situation, I just wanna run python here without having to 'educate' the computer infrastructure persons of this library. Anton 'any buyers for the european constitution?' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
alex23 wrote: > In this case, it sounds like the library is providing computers for two > purposes: access to Office tools and to the internet. Given the > "everything not forbidden is permissable" attitude of most people, > unless the use is restricted to only those two activities people > legitimately wanting access will tend to end up waiting for others who > have co-opted the services for their own personal end. But who are those people using this *public* library for their own personal end? Is it the cannibal elite that is using this public space to promote microsoft products and 'reducing' their workload (actually I believe they are making their own job harder) or is it the user who wants to run public domain software? The current situation is such that in order to make the system 'safer' I cannot clear my own cache, so my internet history is visible for the next user, which compromises *my* security. Surely there should be a balance between the interests of the provider and the client, but since in this case the client is also the 'owner' of the service (it's a *public* library) there should be room to run non-proprietary software. The connection with the european constitution is exactly about this shifting of the ownership of public buildings, institutions, infrastructure etc. *from* the persons using the service *towards* the people accidentally working in that place. So social security starts to act like it's an employer, but since they are also the state, they don't have to pay minimum wages, if one is treated unfairly it's impossible to get a fair trial. If one doesn't agree with this treatment they just keep the money they are obliged to pay (according to our national constituton) to themselves. Universities start to act like the buildings are extra living room for the persons working there and in order to get a degree one has to *work* for a professor. The elite in the city starts building luxury appartments for their own people (who are payed with public money stolen one way or the other from the normal residents in the city) in the natural resorts because their is some kind of 'shortage' in the housing market. On the other hand one wants to "make the polluter pay" and creates taxes for garbage. But these taxes are 'equal' for everyone, meaning that they are negligible for the rich but a large part of the income of the poor. The same goes for fines for speeding or parking tickets. If you're rich or know the people in the elite you can get away with anything. The *european* constitution is related to this because our government wants to limit the discussion to the merits of the document. The problem is that even with a good constitution a corrupt elite can interpret the terms in a way that is unfavorable for the poor (almost anyone is poor or becoming poor by now). And secondly the document is only intelligible for specialists, so even if it was good, there's no way to tell. So we might find ourselves in a situation one day when walking to the water tap to fill our teakettle a voice will come out of it asking whether we want *coca* cola or *pepsi* cola. When complaning about this to our government we will hear something like: 'Look you *have* a choice it's not like we prefer one brand over the other, so what are you complaining about? Be silent out you will be removed from our administration, which means no food, health care, money or friends." I'm currently mentally analogizing this discussion with the one on python dev about whether the decimal module should give users 'what they expect' or conform to industry standards, but I guess one has to be Dutch to see any connection at all here :-) The rationale for all of this is that the economy is bad and we have close to zero growth. We should be like China or other low wage countries in order to be more competitive. However the rationale is false! Because we have better infrastructure here we are *further* up the exponential development curve so we could have fenomenal growth if we wanted! The fact that this isn't happening at all has nothing to do with with the economic potential but all the more with conservative power consolidation tactics. The media play a very nasty role in all of this. For example the newspapers are complaining nobody reads paper anymore because of the internet. IMO it is caused more by nobody wanting to read the same old selfpromotion anymore. Something comparable is happening with public television which is not a true representation of the public opinion at all. Not to say public opinion is always good, but if noone thinks you are giving the right characterization of the current situation, one is not likely to want to join the discussion. Ok, this is getting way to far off topic. Thanks to all for the hints to get python running here. I'm now contemplating to access the already running java interpreter that must hide somewher in this IE, and to start a jython console from there (without even running a ne
Re: first release of PyPy
Carl Friedrich Bolz wrote: > Rumors have it that the secret goal is being faster-than-C which is > nonsense, isn't it? Maybe not. If one can call functions from a system dll (a la ctypes, some other poster already mentioned there was some investigation in this area) one can skip a layer of the hierarchy (remove the c-coded middleman!) and this would possibly result in faster code. I'm not involved in PyPy myself but this would seem a logical possibility. To go a step further, if the compiler somehow would know about the shortest machine code sequence which would produce the desired effect then there would be no reason to limit onself to only those relatively inefficent standard code sequences that are inside system dll's. Just design specific optimized dll's on the fly :-) (Now going into turbo overdive) One could have a central computer checking which data transformations (at a polymorfic level) a specific program is accomplishing and 'reengineer or restructure' the code inductively to check whether some other coder already had 'said the same thing' in 'better python code'. So one would get a warning when reinventing the wheel even if one had invented a square one :-) or if one had distributed functionality in an inefficent way. Next, after standardizing the input code this way one could have a list of these 'frequently used standard sequences' memoized at the central location in order to speed up the compilation phase. Of course the central interpreter would be sensitive to local code history so this would ease the code recognition process. This would work like the way human attention works in that we recognize the word 'wheel' sooner if we first saw a picture of a car. The only problem with this approach seems to be that it looks like a straight path to borghood ... Anton 'resistance is futile, all your codes are belong to us!' -- http://mail.python.org/mailman/listinfo/python-list
Re: first release of PyPy
Kay Schluehr wrote: > Anton Vredegoor wrote: > > > I'm not involved in PyPy myself but this would seem a logical > > possibility. To go a step further, if the compiler somehow would know > > about the shortest machine code sequence which would produce the > > desired effect then there would be no reason to limit onself to only > > those relatively inefficent standard code sequences that are inside > > system dll's. > > Are You shure that this problem is effectively solvable in any > language? Since You did not precise Your idea I'm not shure whether You > want to solve the halting-problem in PyPy or not ;) Since PyPy is covering new territory it seemed important to provide new ideas so that they have something to look forward to and will not fall asleep at the entrance of the new area. Maybe I failed with the new part but at least I tried :-) Whether they are supposed to solve the halting problem or if that can reasonably be expected I don't now either. Is it ethical to send people on an impossible mission in order to harvest the spinoff? Some evil genius might have created this universe in order to do just that! However, people posting code to this list are often reminded of other algorithms (are you sorting this list? why not use quicksort?) so it seems possible at least for humans to guess the intentions of another coder sometimes, and provide better code. Every time something is described at a higher level (these levels cannot be found within the original system but must be created by a leap of the imagination or by divine intervention) there seem to be ways to remove superfluous things and be more effective even at the lower level. Anton 'answering all questions destroys the universe?' -- http://mail.python.org/mailman/listinfo/python-list
nice OOP training problem
I found this on the web: http://www.setgame.com/set/puzzle_frame.htm and I'm currently trying to develop a script that models this space and that gives a nice graphic display. Also developing a solver for this or larger spaces looks interesting. I'm not asking for assistance, it just looks like some interesting programming experience and why should there be all work and no play? So code solving any part of this problem (the grafics) or the solver (find all solutions) would be interesting. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a new class on the fly
Alex Martelli wrote: > You can find a few examples of me demonstrating the subject of your > interest by searching for my name e.g. on video.google.com; searching > for my name on Amazon will show some books using similar techniques, and > searching for my name on groups.google.com will find about 50,000 posts > many of which exhibit essentially the same approach. Unfortunately, I > can't currently offer such courses commercially while staying employed > as Uber Tech Lead for Google, Inc, but if the monies on offer make it > worth my while for me to drop million bucks worth of stock options, plus > a vigorish for my other comp package _and_ the incredible amount of > happiness I get every day from my job (where I get to interact with > truly brlliant people, who, if and when they "leave an erroneous snippet > in", are GRATEFUL to me for pointing it out, rather than RESENTFUL and > DEFENSIVE), I'll surely consider that most seriously (as long as the > monies in question are in escrow for my personal reassurance). And still you are not bored with yourself? What a waste. > Until such conditions should obtain, I'll just have to keep freely > helping the people who are WORTH helping, and poking sarcastic funs at > those who prove themselves ot be a waste of oxygen instead. So you have found out about the trick of never being wrong, and what's worse you now have a large group of followers continually reinforcing you and thus keeping you stuck in the psychic plane. > May you have the life you deserve, It seems you already have it. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Permutation over a list with selected elements
[EMAIL PROTECTED] wrote: > Given a list of elements that are either a character or a character > follows by a number, e.g. > > ['a', 'b', 'c1', 'd', 'e1', 'f', 'c2', 'x', 'e2'] > > find all the permutations that are given by switching the positions of > the elements that: > (1) begins with the same letter, and > (2) follows by a number. > > With the above list, some possible permutations are: > > ['a', 'b', 'c2', 'd', 'e1', 'f', 'c1', 'x', 'e2'] > ['a', 'b', 'c1', 'd', 'e2', 'f', 'c2', 'x', 'e1'] > ['a', 'b', 'c2', 'd', 'e2', 'f', 'c1', 'x', 'e1'] Another idea, untested. Also I am not sure whether sequences types are supposed to be returning functions ... A. from operator import mul from collections import defaultdict class Swapper: """ Given a set of indices this class returns functions which will swap elements in a list *in place*. Each function corresponds to a permutation of the set of indices. """ def __init__(self,L): self.L = L self.n = reduce(mul,range(2,len(L)+1),1) #faculty def __getitem__(self,i): L = self.L if not -11: set_by_letter[elem[0]].append(i) return set_by_letter.values() def test(): L = ['a', 'b', 'c1', 'd', 'e1', 'f', 'c2', 'x', 'e2'] I = find_sets_of_indices_to_permute(L) #Alex Martelli's function M = map(Swapper,I) for F in cross(M): # conserve the original list because #the functions modify a list in place R = list(L) # apply each permutation function one by one, # each is acting on a different set of indices for fn in F: fn(R) print R if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: need help with converting c function to python function
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > i have a c function from some modbus documentation that i need to > translate into python. > > it looks like this: > > > unsigned short CRC16(puchMsg, usDataLen) > unsigned char *puchMsg ; > unsigned short usDataLen ; > { >unsigned char uchCRCHi = 0xFF ; >unsigned char uchCRCLo = 0xFF ; >unsigned uIndex ; >while (usDataLen--) >{ >uIndex = uchCRCHi ^ *puchMsgg++ ; >uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ; >uchCRCLo = auchCRCLo[uIndex] ; >} >return (uchCRCHi << 8 | uchCRCLo) ; > } > > some of it i can make out, but i can't seem to figgure out > this part ' auchCRCHi[uIndex}; > it looks like a typo, because there is a closing } that does not match > the opening [. > > > here is what i have so far, but is not giving me the right values > > def crc16(data): > crc_hi = 0xff > crc_lo = 0xff > for x in data: > crc_index = crc_hi ^ x > crc_hi = crc_lo ^ (crc_hi | crc_index) > crc_lo = crc_lo | crc_index > return (crc_hi << 8 | crc_lo) > > whaddya think? Use lateral thinking. CRC usually means some standard data checking algorithm. If you google for crc16 you will find various python implementations. Off hand I would first try this one because he seems to have been thinking about it: http://mail.python.org/pipermail/python-list/2005-September/342097.html But I don't really know what it is you are looking for, cyclic redundancy check? http://en.wikipedia.org/wiki/Cyclic_redundancy_check A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
[EMAIL PROTECTED] wrote: > Try it with > > def test(): > L = 'a', 1, 2, 'a' > it1, it2 = xsplitter(L, lambda x: x == 'a') > print it1.next() > print it2.next() > print it1.next() > print it2.next() > > > The last print statement raises StopIteration... > We, however, expected each iterator to contain > two elements (one yielding 'a' then 'a', and > the other yielding 1 then 2). Ouch! I never understood much about generators anyway. A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > [EMAIL PROTECTED] wrote: > >> Try it with >> >> def test(): >> L = 'a', 1, 2, 'a' >> it1, it2 = xsplitter(L, lambda x: x == 'a') >> print it1.next() >> print it2.next() >> print it1.next() >> print it2.next() >> >> >> The last print statement raises StopIteration... >> We, however, expected each iterator to contain >> two elements (one yielding 'a' then 'a', and >> the other yielding 1 then 2). > > Ouch! I never understood much about generators anyway. How about this one? from collections import deque class sentinel(object): pass class myiter(object): def __init__(self,seq): self.seq = seq self.index = -1 def __iter__(self): return self def next(self): self.index +=1 if self.index < len(self.seq): return self.seq[self.index] else: return sentinel def mygen(seq): for x in seq: if x is sentinel: #way past bedtime raise StopIteration yield x def xsplitter(seq, pred): Q = deque(),deque() it = myiter(seq) def gen(p): for x in it: while Q[p]: yield Q[p].popleft() if pred(x) == p: yield x else: Q[~p].append(x) for x in gen(p): yield x return map(mygen,[gen(1),gen(0)]) def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > Anton Vredegoor wrote: >> [EMAIL PROTECTED] wrote: >> >>> Try it with >>> >>> def test(): >>> L = 'a', 1, 2, 'a' >>> it1, it2 = xsplitter(L, lambda x: x == 'a') >>> print it1.next() >>> print it2.next() >>> print it1.next() >>> print it2.next() >>> >>> >>> The last print statement raises StopIteration... >>> We, however, expected each iterator to contain >>> two elements (one yielding 'a' then 'a', and >>> the other yielding 1 then 2). >> Ouch! I never understood much about generators anyway. > > How about this one? No that can result in an infinite loop after yet another print it1.next() This one however ... from collections import deque class sentinel(object): pass class myiter(object): def __init__(self,seq): self.seq = seq self.index = -1 def __iter__(self): return self def next(self): self.index +=1 if self.index < len(self.seq): return self.seq[self.index] else: return sentinel def xsplitter(seq, pred): Q = deque(),deque() it = myiter(seq) def gen(p): for x in it: while Q[p]: yield Q[p].popleft() if x is sentinel: break if pred(x) == p: yield x else: Q[~p].append(x) for x in gen(p): yield x return gen(1),gen(0) def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
[EMAIL PROTECTED] wrote: > Um, no. That one stops prematurely if > your input sequence is: > > L = 1, 2, 3, 'a', 'a' Ah, thanks! > You get points for persistence, however. :) Maybe this one is better? from collections import deque from itertools import chain, repeat def xsplitter(seq, pred): Q = deque(),deque() sentinel = object() it = chain(seq,repeat(sentinel)) def gen(p): for x in it: if pred(x) != p and x is not sentinel: Q[~p].append(x) for x in gen(p): yield x else: while Q[p]: yield Q[p].popleft() if pred(x) == p: yield x else: break return gen(1),gen(0) def test(): L = 1, 2, 3, 'a', 'a' #L = 'a', 1, 2, 'a' #L = 1, 'a', 3, 'a', 4, 5, 6, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > Maybe this one is better? No, this one keeps generating output. But this one stops at least: from collections import deque from itertools import chain, repeat def xsplitter(seq, pred): Q = deque(),deque() sentinel = object() it = chain(seq,repeat(sentinel)) def gen(p): for x in it: if x is sentinel: while Q[p]: yield Q[p].popleft() break elif pred(x) == p: while Q[p]: yield Q[p].popleft() yield x else: Q[~p].append(x) for x in gen(p): yield x return gen(1),gen(0) def test(): L = 1, 2, 3, 'a', 'a' #L = 'a', 1, 2, 'a' #L = 1, 'a', 3, 'a', 4, 5, 6, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() Are there any other cases this doesn't cover? A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
[EMAIL PROTECTED] wrote: > This one gets the order wrong. With > > def test(): > L = 1, 2, 3, 'a', 4, 'a', 5, 'a', 6, 'a' > it1, it2 = xsplitter(L, lambda x: x == 'a') > print it1.next() > print it2.next() > print it1.next() > print it2.next() > print it1.next() > print it2.next() > print it1.next() > print it2.next() > > 5 will appear before 4. Thanks. This one will give 4 first and it uses a normal iterator. from collections import deque def xsplitter(seq, pred): Q = deque(),deque() it = iter(seq) def gen(p): for x in it: if pred(x) == p: Q[p].append(x) while Q[p]: yield Q[p].popleft() else: Q[~p].append(x) for x in gen(p): yield x while Q[p]: yield Q[p].popleft() return gen(1),gen(0) def test(): #L = 1, 2, 3, 'a', 'a' #L = 'a', 1, 2, 'a' #L = 1, 'a', 3, 'a', 4, 5, 6, 'a' L = 1, 2, 3, 'a', 4, 'a', 5, 'a', 6, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() print it1.next() print it2.next() print it1.next() print it2.next() print it2.next() print it2.next() if __name__=='__main__': test() Because the function can be stopped and resumed anytime, it is possible that at the new point of execution the queue has changed. For example if in these lines from the code above: if pred(x) == p: Q[p].append(x) while Q[p]: yield Q[p].popleft() I would make the change: if pred(x) == p: while Q[p]: yield Q[p].popleft() yield x Then the output will be out of order ... I wonder if this function is OK now. A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > from collections import deque > > def xsplitter(seq, pred): > Q = deque(),deque() > it = iter(seq) > def gen(p): > for x in it: > if pred(x) == p: > Q[p].append(x) > while Q[p]: yield Q[p].popleft() > else: > Q[~p].append(x) > for x in gen(p): yield x > while Q[p]: yield Q[p].popleft() > return gen(1),gen(0) Do we even need the line > for x in gen(p): yield x ??!! It seems to work the same without it. from collections import deque def xsplitter(seq, pred): Q = deque(),deque() it = iter(seq) def gen(p): for x in it: if pred(x) == p: Q[p].append(x) while Q[p]: yield Q[p].popleft() else: Q[~p].append(x) while Q[p]: yield Q[p].popleft() return gen(1),gen(0) What's up here? Was it a fata morgana? Am I overlooking something? A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > What's up here? Was it a fata morgana? Am I overlooking something? Even more crazy version: def xsplitter(seq, pred): Q = deque(),deque() it = iter(seq) def gen(p): for x in it: Q[pred(x) == p].append(x) while Q[p]: yield Q[p].popleft() while Q[p]: yield Q[p].popleft() return gen(1),gen(0) A. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Anton Vredegoor wrote: > def xsplitter(seq, pred): > Q = deque(),deque() > it = iter(seq) > def gen(p): > for x in it: > Q[pred(x) == p].append(x) > while Q[p]: yield Q[p].popleft() > while Q[p]: yield Q[p].popleft() > return gen(1),gen(0) This should be: def xsplitter(seq, pred): Q = deque(),deque() it = iter(seq) def gen(p): for x in it: Q[pred(x)].append(x) while Q[p]: yield Q[p].popleft() while Q[p]: yield Q[p].popleft() return gen(1),gen(0) But I'm still not sure if this is the desired function. Is it normal for people to start replying to their own messages when they're studying coroutines? A -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding tkinter widgets to fill the window
KDawg44 wrote: > I am writing a GUI front end in Python using Tkinter. I have > developed the GUI in a grid and specified the size of the window. The > widgets are centered into the middle of the window. I would like them > to fill the window. I tried using the sticky=E+W+N+S option on the > widgets themselves and the window itself. > > How can I get this? If at all possible post a short, self-contained, correct, example demonstrating your question. http://homepage1.nifty.com/algafield/sscce.html A. -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Ray wrote: > hi, I have a question about how to use .grid_forget (in python/TK) > > I need to work on grid repeatly. everytime when a button is pressed, > the rows of grid is different. such like, first time, it generate 10 > rows of data. > 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data > every time. how can I do it? by grid_forger()?, then would anyone can > help on > how to use grid_forget() > the sample code as following: I'm not sure if it solves your problem but this modification of your code at least *looks* like it works better. The entries are completely destroyed so that the next time you call the function they can be recreated. The trick I am using is to use a list in the arguments of the function but that is a bit of a hack, the list 'remembers' its state from the last time the function was called, I think one should use classes for bookkeeping such things instead. from Tkinter import * def mygrid(text,M = []): how to use grid_forget() to clean the grid??### while M: x = M.pop() x.destroy() rows = [] count=int(text) for i in range(count): cols = [] for j in range(4): e = Entry(frame3, relief=RIDGE) M.append(e) e.grid(row=i, column=j, sticky=NSEW) e.insert(END, '%d.%d' % (i, j)) cols.append(e) rows.append(cols) root=Tk() frame1=Frame(root, width=150, height=100) frame1.pack() text=Entry(frame1) text.pack(side=LEFT) button=Button(frame1, text='generate grid', command=(lambda: mygrid(text.get( button.pack() frame2=Frame(root, width=150, height=100) frame2.pack() button2=Button(frame2, text='exit', command=root.quit) button2.pack() frame3=Frame(root, width=150, height=300) frame3.pack() root.mainloop() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Would You Write Python Articles or Screencasts for Money?
Steve Holden wrote: >> When cash is involved, it's important to avoid even the slightest >> hint of a suggestion of a suspicion of a conflict of interest; >> that, I guess, is why firms that run contests with cash prizes >> always declare employees and their families "not eligible", and why >> I think the PSF should do likewise in this case. >> > That's a good point, and also a valid reason for restricting the > voting community to PSF members. Thanks, Alex. So in order to avoid a suspicion of a conflict of interest you want to turn the whole thing into private property of the PSF? That is the most ridiculous suggestion I have ever -- http://mail.python.org/mailman/listinfo/python-list
Re: Would You Write Python Articles or Screencasts for Money?
Antoon Pardon wrote: >>> That's a good point, and also a valid reason for restricting the >>> voting community to PSF members. Thanks, Alex. >> So in order to avoid a suspicion of a conflict of interest you want to >> turn the whole thing into private property of the PSF? >> >> That is the most ridiculous suggestion I have ever > > I kind of understand why they would want to do this. If you have > no limitations on who may vote, such a contest can easily turn > into a contest of who can mobilize the biggest clan of supporters. Sure, any democratic process can be derailed by a coordinated effort of people with a different mentality. To prevent such things by killing the democratic process oneself right at the beginning of a project is a peculiar way of avoiding this risk. > Now maybe there are better ways to avoid this kind of unwanted > effect but I wouldn't call Steve's suggestion ridiculous. It's about as ridiculous as proving that a stiff parrot is dead by grabbing it by the legs and repeatedly hitting it's head on the counter. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Would You Write Python Articles or Screencasts for Money?
Anton Vredegoor wrote: > It's about as ridiculous as proving that a stiff parrot is dead by > grabbing it by the legs and repeatedly hitting it's head on the counter. Or to write "it's" where its is more appropriate. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Would You Write Python Articles or Screencasts for Money?
Antoon Pardon wrote: > On 2007-04-25, Anton Vredegoor <[EMAIL PROTECTED]> wrote: >> Antoon Pardon wrote: >> >>>>> That's a good point, and also a valid reason for restricting the >>>>> voting community to PSF members. Thanks, Alex. >>>> So in order to avoid a suspicion of a conflict of interest you want to >>>> turn the whole thing into private property of the PSF? >>>> >>>> That is the most ridiculous suggestion I have ever >>> I kind of understand why they would want to do this. If you have >>> no limitations on who may vote, such a contest can easily turn >>> into a contest of who can mobilize the biggest clan of supporters. >> Sure, any democratic process can be derailed by a coordinated effort of >> people with a different mentality. To prevent such things by killing the >> democratic process oneself right at the beginning of a project is a >> peculiar way of avoiding this risk. > > As far as I understood the idea was to reward excellence. The process > to achieve this can be democratic, but in that case it is just a means > to an end. The democratic process was not an end itself. Yes, but this sub thread was about avoiding a suspicion of a conflict of interests. If this suspicion is to be avoided by just openly promoting the interests of the members of the PSF that is one hell of a way of solving the problem. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Would You Write Python Articles or Screencasts for Money?
Steve Holden wrote: > I'm sorry, but while the PSF is a democratically-run organization its > franchise doesn't extend beyond the membership. I didn't realize this was about an PSF internal affair. Of course a group of people can decide on its internal matters without asking anyone else, as long as its actions do not damage the larger community around it. I'm sorry to have interfered with your private discussions, they took place on an international newsgroup aimed at the global python community at large, you might consider taking it elsewhere, but since there is no moderation, go and spam this group with your posts as much as you like. > You might as well suggest that America isn't being democratic because it > doesn't allow the French to vote for its president. Neither France nor America strike me as being very democratic at the moment, because large parts of their communities have no way of voting on a person or party that represents their specific interests. It's the same way in the Netherlands where I live by he way, so no criticism is intended by me, in any way. I was picturing this thread more in terms like the international court which at least constitutionally *tries* to be democratic in a global community alike manner, albeit unfortunately also failing miserably. It seems current western democracies are preferable over the total chaos that we see in Iraq because its internal legal structure was removed without providing a functional alternative. History shows -to me- that even an evil dictator is better than that. That doesn't mean people shouldn't try to aim higher. Higher than accepting even a benevolent dictator. So in my case the question becomes if I would be willing to promote the interests of some group that doesn't represent me, for a chance that I may comply with their objectives, which I cannot influence. I'd say: No I don't want to do that, although I also wouldn't go out of my way in order to *not* comply. Thanks for clearing it all up. Have a nice life. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT somewhat: Do you telecommute? What do you wish the boss understood about it?
estherschindler wrote: > * If you telecommute, full- or part-time, what *one* thing do you wish > the CIO or IT Management would understand that they don't currently > "get"? I'm not currently telecommuting but last year I had a telecommuting job for half a year. What I would want to say to all future employers considering to hire telecommuting personnel is : Don't let the telecommuter pay the extra costs that are caused by telecommuting. And I don't mean only the financial aspects, I also mean the immaterial costs. For example if one is working at home it can be hard for an employer to check whether the work is still progressing and if there are no immediate results there can be some suspicion that the employee is just sitting at home watching television or is out shopping, because hey, there's no way to check that anyway and people tend to become lazy if no one is watching them? So the employer can become tempted to find ways to check upon his employee by other means. Why not let him write a daily report of his activities even if you never read it? Why not ask for an open MSN chat window at all times so that one can check how fast the employee is responding? Is he at his desk *right now*? These are all things that are not usually asked of the people sitting in the main office and create an extra burden for the employee. In fact the employee gets burdened with the costs of the employers insecurities. If one doesn't trust the employee then don't hire him or don't let him telecommute in the first place! Then there are other aspects. For example sometimes I had to use an expensive mobile Internet connection when I was on the road or when the Internet connection at home didn't work. It was some account that lets one use some amount of megabytes for free but after that was used up there were high costs for each further megabyte. It was certainly the wrong kind of subscription but sometimes it's hard to determine whether one buys an expensive flat rate subscription with the risk of all this money never being used because one is using the home Internet connection all the time. On the other hand things can really get expensive if one has the cheap fixed megabytes type of account and the home Internet connection fails for an extended period or if one has to be on location often. So sometimes the wrong business decision was made. But if someone at the workplace has a HD crash or some other costly error happens this is normally not something the employee has to pay for. If one is informed about the costs and one doesn't read the emails but just says "fix that server malfunction *now*, don't mind the connection costs" one should not be scolding the employee for the large bills that appear one month later. Then there are things like travel costs and hotel costs, say we want the employee to be present at the office for a few days each month, the employee can pay for it in advance and the employer will reimburse him later on. Normally employees get a fixed paycheck each month and there are few extra costs involved and things can get arranged quickly. However the extra costs for the telecommuter are highly variable and so there can be a situation where one has payed in advance out of ones own pocket and one has to ask more than once to receive the money back. If one has to ask too often this can be highly demoralizing, because this is time and money spent on the company without earning anything. The employer maybe starts to think: "Hey this guy is living in an expensive hotel and eating in restaurants while other people go there to have a vacation, so why should I have to pay for that?" Well for the employee it's a completely different story, hotel rooms aren't fun if one arrives late at night and leaves early in the morning and cities remain tantalizing mysteries if one never has the time to do some sightseeing. There is also the idea that working at home is some luxurious privilege that the employee should be thankful for. I can tell you that even the nicest home can become a prison if one has to be there all the time. In fact any escape can be a relief so one is thankful to spend some time in a hotel room ... But that doesn't mean it's vacation! No way. It's just that other people get out of their homes normally at the beginning of the day, a telecommuter *has* to go out for a walk or go bicycling for half an hour or so during lunch break just to keep fit. A normal employee can integrate that into his routine of coming to work and having lunch at a nearby restaurant. So all in all my conclusion is, if one wants the employee to be happy and loyal, don't destroy his good intentions by letting him pay for all kinds of luxuries that he didn't ask for and that aren't even much fun anyway. Even though such things might seem the most desirable working environments for those having to work in a crowded office where they have to go to each day, sitting al
Re: PEP 3131: Supporting Non-ASCII Identifiers
Martin v. Löwis wrote: > In summary, this PEP proposes to allow non-ASCII letters as > identifiers in Python. If the PEP is accepted, the following > identifiers would also become valid as class, function, or > variable names: Löffelstiel, changé, ошибка, or 売り場 > (hoping that the latter one means "counter"). I am against this PEP for the following reasons: It will split up the Python user community into different language or interest groups without having any benefit as to making the language more expressive in an algorithmic way. Some time ago there was a discussion about introducing macros into the language. Among the reasons why macros were excluded was precisely because anyone could start writing their own kind of dialect of Python code, resulting in less people being able to read what other programmers wrote. And that last thing: 'Being able to easily read what other people wrote' (sometimes that 'other people' is yourself half a year later, but that isn't relevant in this specific case) is one of the main virtues in the Python programming community. Correct me if I'm wrong please. At that time I was considering to give up some user conformity because the very powerful syntax extensions would make Python rival Lisp. It's worth sacrificing something if one gets some other thing in return. However since then we have gained metaclasses, iterators and generators and even a C-like 'if' construct. Personally I'd also like to have a 'repeat-until'. These things are enough to keep us busy for a long time and in some respects this new syntax is even more powerful/dangerous than macros. But most importantly these extra burdens on the ease with which one is to read code are offset by gaining more expressiveness in the *coding* of scripts. While I have little doubt that in the end some stubborn mathematician or Frenchman will succeed in writing a preprocessor that would enable him to indoctrinate his students into his specific version of reality, I see little reason to actively endorse such foolishness. The last argument I'd like to make is about the very possibly reality that in a few years the Internet will be dominated by the Chinese language instead of by the English language. As a Dutchman I have no special interest in English being the language of the Internet but -given the status quo- I can see the advantages of everyone speaking the *same* language. If it be Chinese, Chinese I will start to learn, however inept I might be at it at first. That doesn't mean however that one should actively open up to a kind of contest as to which language will become the main language! On the contrary one should hold out as long as possible to the united group one has instead of dispersing into all kinds of experimental directions. Do we harm the Chinese in this way one might ask by making it harder for them to gain access to the net? Do we harm ourselves by not opening up in time to the new status quo? Yes, in a way these are valid points, but one should not forget that more advanced countries also have a responsibility to lead the way by providing an example, one should not think too lightly about that. Anyway, I feel that it will not be possible to hold off these developments in the long run, but great beneficial effects can still be attained by keeping the language as simple and expressive as possible and to adjust to new realities as soon as one of them becomes undeniably apparent (which is something entirely different than enthusiastically inviting them in and let them fight it out against each other in your own house) all the time taking responsibility to lead the way as long as one has any consensus left. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > Martin v. Löwis: > > > This PEP suggests to support non-ASCII letters (such as accented > > characters, Cyrillic, Greek, Kanji, etc.) in Python identifiers. > > I support this to ease integration with other languages and > platforms that allow non-ASCII letters to be used in identifiers. Python > has a strong heritage as a glue language and this has been enabled by > adapting to the features of various environments rather than trying to > assert a Pythonic view of how things should work. > > Neil > Ouch! Now I seem to be disagreeing with the one who writes my editor. What will become of me now? A. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Neil Hodgson wrote: > Anton Vredegoor: > >> Ouch! Now I seem to be disagreeing with the one who writes my editor. >> What will become of me now? > > It should be OK. I try to keep my anger under control and not cut > off the pixel supply at the first stirrings of dissent. Thanks! I guess I won't have to make the obligatory Sovjet Russia joke now :-) > It may be an idea to provide some more help for multilingual text > such as allowing ranges of characters to be represented as hex escapes > or character names automatically. Then someone who only normally uses > ASCII can more easily audit patches that could contain non-ASCII characters. Now that I read about IronPython already supporting some larger character set I feel like I'm somewhat caught in a side effect of an embrace and extend scheme. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sorting troubles
[EMAIL PROTECTED] wrote: > I see. I figured that list comprehensions made another list(duh), but > I thought I could relink the object(List) to the new list and keep it > once the function ended. > > Is it possible to pass a reference(to an object.. Like 'List', > basically) to a function and change the reference to point to > something created inside a function? Or all data unreturned from a > function is lost and no references kept?(The second, I'd guess, since > it's local temporary scope, but you never know, maybe Python can :) ) Maybe this (untested): def qsort(seq): if seq: pivot = seq.pop() Q = L,R = [],[] for x in seq: Q[x>=pivot].append(x) qsort(R) seq[:] = L+[pivot]+R A. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Duncan Booth wrote: > Recently there has been quite a bit of publicity about the One Laptop Per > Child project. The XO laptop is just beginning rollout to children and > provides two main programming environments: Squeak and Python. It is an > exciting thought that that soon there will be millions of children in > countries such as Nigeria, Brazil, Uruguay or Nepal[*] who have the > potential to learn to program, but tragic if the Python community is too > arrogant to consider it acceptable to use anything but English and ASCII. Please don't be too quick with assuming arrogance. I have studied social psychology for eleven years and my thesis was just about such a subject. I even held a degree in social psychology for some time before my government in their infinite wisdom decided to 'upgrade' the system so that only people holding *working* positions at a university would be able to convert their degrees to the new system. I suspect discerning people can still sense a twinge of disagreement with that in my professional attitude. However I still think the results of my research were valid. The idea was to try and measure whether it would be better for foreign students visiting the Netherlands to be kept in their own separate groups being able to speak their native language and to hold on to their own culture versus directly integrating them with the main culture by mixing them up with Dutch student groups (in this case the main culture was Dutch). I think I my research data supported the idea that it is best even for the foreigners themselves to adapt as quickly as possible to the main culture and start to interact with it by socializing with 'main culture' persons. My research at that time didn't fit in at all with the political climate of the time and subsequently it was impossible for me to find a job. That didn't mean that I forgot about it. I think a lot of the same ideas would help the OLPC project so that they will not make the same mistake of creating separate student populations. I believe -but that is a personal belief which I haven't been able to prove yet by doing research- that those people currently holding positions of power in the main culture actively *prevent* new groups to integrate because it would threaten their positions of power. So instead of having a favorable view of teachers who are 'adapting' to their students culture I have in fact quite the opposite view: Those teachers are actually harming the future prospects of their students. I'm not sure either whether they do it because they're trying to protect their own positions or are merely complicit to higher up political forces. Whatever you make of my position I would appreciate if you'd not directly conclude that I'm just being arrogant or haven't thought about the matter if I am of a different opinion than you. > Yes, any sensible widespread project is going to mandate a particular > language for variable names and comments, but I see no reason at all why > they all have to use English. Well I clearly do see a reason why it would be in their very best interest to immediately start to use English and to interact with the main Python community. > [*] BTW, I see OLPC Nepal is looking for volunteer Python programmers this > Summer: if anyone fancies spending 6+ weeks in Nepal this Summer for no > pay, see http://www.mail-archive.com/[EMAIL PROTECTED]/msg04109.html Thanks. I'll think about it. The main problem I see for my participation is that I have absolutely *no* personal funds to contribute to this project, not even to pay for my trip to that country or to pay my rent while I'm abroad. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
HYRY wrote: >> - should non-ASCII identifiers be supported? why? > Yes. I want this for years. I am Chinese, and teaching some 12 years > old children learning programming. The biggest problem is we cannot > use Chinese words for the identifiers. As the program source becomes > longer, they always lost their thought about the program logic. That is probably because they are just entering the developmental phase of being able to use formal operational reasoning. I can understand that they are looking for something to put the blame on but it is an error to give in to the idea that it is hard for 12 year olds to learn a foreign language. You realize that children learn new languages a lot faster than adults? > English keywords and libraries is not the problem, because we only use > about 30 - 50 of these words for teaching programming idea. They can > remember these words in one week. But for the name of variable or > function, it is difficult to remember all the English word. For > example, when we are doing numbers, maybe these words: [odd, even, > prime, minus ...], when we are programming for drawing: [line, circle, > pixel, ...], when it's for GUI: [ button, event, menu...]. There are > so many words that they cannot just remeber and use these words to > explain there idea. Again, it's probably not the language but the formal logic they have problems with. Please do *not* conclude that some child is not very good at math or logic or programming when they are slow at first. It doesn't tell one very much how good they might become later on and some premature idea the teacher might have formed about a pupil in that phase can even be harmful for their later perspectives. > Eventlly, when these children go to high school and study enough > English, I think they can use English words for programming. But as > the beginning step, it is difficult to learn both programming and > English. The older they get the harder it is for them to learn language. By withholding them English language experience at an early age you are doing them a disservice because later on they will have more trouble. The other thing is trying to teach them formal operational logic when they are not yet ready for it. In that case it would be better to wait until they are ready, but unfortunately there are large variations in the age at which children become ready. Please do not confuse the two very different matters of language acquisition and formal operational logic. Language is learned at an early age while formal logic starts at about the age of eleven (but with very large variation among children). > So, I made a little program, just replace all the Chinese words in the > program to some sequency identifiers such as [a1, a2, a3, ...], So we > can do programming in Chinese, and Python can still run it. Why not use IronPython? But anyway you are actually making things worse by *not* teaching them the language now that they will need later on and by *teaching* them formal operational logic at an age when they just get disappointed and frustrated by not yet being able to understand it. Better go easy on them and teach them lots of English computing terms and only introduce logic when they show they are ready. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Raymond Hettinger wrote: > To make the solutions equi-probable, a simple approach is to > recursively enumerate all possibilities and then choose one of them > with random.choice(). Maybe it is possible to generate the possibilities by an indexing function and then use randint to pick one of them. I suppose this is like the bricks and bins problem this thread was about: http://groups.google.nl/group/comp.lang.python/browse_thread/thread/4782b54fa39b3bad Except that the bins now have at least 1 brick in them (if we have positive numbers). I posted a rather simplistic solution (but working I think) after Steven Taschuk made some insightful remarks. I believe it is possible to generate the list of numbers directly instead of permuting a list of '0' and '1' characters and then finding the positions of the '1' elements. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Terry Reedy wrote: > Partitioning positive count m into n positive counts that sum to m is a > standard combinatorial problem at least 300 years old. The number of such > partitions, P(m,n) has no known exact formula but can be computed > inductively rather easily. The partitions for m and n can be ranked in > lexicographic order from 0 to P(m,n)-1. Given a rank r in that range, one > can calculate the particular partition that has that rank. So a > equi-probable random count in the range can be turned into a equi-probable > random partition. Yes that was one of my first ideas too. But later on Steven pointed out that one can view the problem like this: 0001100010100 That would be [3,4,3,1,2] where the '1' elements are like dividing shutters that partition the row of '0'. This means that the problem is reduced to permutations (albeit unique permutations) which are a lot simpler to compute than partitions. Ok I'll admit that I succeeded in translating my 'Goldberg' solution to this case, I can't expect anyone to dust off and read 4 year old threads anyway :-) (by the way I'm still convinced that this code can be simplified a lot) def starters(L): n,np,R = len(L),1,range(len(L)) bf = [L[:i].count(L[i]) for i in R] for i in R: np = np*(n-i)/(bf[i]+1) return [(i,np*L[i:].count(L[i])/n) for i in R if not bf[i]] def perm(index,L): remain,n = index,len(L) res,T = L[:],L[:] for i in range(n): for j,k in starters(T): if remain-k < 0: res[i] = T.pop(j) break remain -= k return res def nperm(L): return reduce(lambda a,b:a+b,[k for j,k in starters(L)]) def bb(i,bricks,bins): L = [1] * (bins-1) + [0] * (bins-1) R = [1] for x in perm(i,L): if x: R.append(1) else: R[-1]+=1 return R def test(): bricks,bins = 7, 4 L = [1] * (bins-1) + [0] * (bins-1) for i in range(nperm(L)): print bb(i,bricks,bins) if __name__=='__main__': test() > This topic is section 3.1 in Combinatorial Algorithms: Generation, > Enumeration, and Search by Kreher and Stinson. The authors reference > several other books as their sources. Great book! > I plan to someday rewrite many of their pseudocode algorithms in Python. That would be my dream job. If only I understood more of them. But I'm slowly making progress in other areas so that one day I will maybe reread the book and also understand the second half. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Anton Vredegoor wrote: > L = [1] * (bins-1) + [0] * (bins-1) replace these lines in the code by: L = [1] * (bins-1) + [0] * (bricks-bins) A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Terry Reedy wrote: > "Anton Vredegoor" <[EMAIL PROTECTED]> wrote in message > | Yes that was one of my first ideas too. But later on Steven pointed out > | that one can view the problem like this: > | > | 0001100010100 > | > | That would be [3,4,3,1,2] > | > | where the '1' elements are like dividing shutters that partition the row > | of '0'. This means that the problem is reduced to permutations (albeit > > If any of the 1s appear at the ends or together, then you would have 0s in > the partition, which is not allowed, as I understood the spec. Yes, I was writing about the bricks and bins problem from 4 years ago which is very similar. > | unique permutations) which are a lot simpler to compute than partitions. > > I think the simplicity is actually about the same. Probably yes. It's like the difference between Pascal's triangle and the partition numbers' triangle. Anyway, Paul Rubin's idea in this same thread stimulated me to simplify my code a lot. It's rather late here so I hope I haven't slipped up again. def comb(i,n,k): for j in range(k,0,-1): while noverk(n,j) > i : n -= 1 i -= noverk(n,j) yield n def noverk(n,k): return reduce(lambda a,b: a*(n-b)/(b+1),range(k),1) def bb(i,bricks,bins): L = [j+1 for j in comb(i,bricks,bins-1)] return [(i-j) for i,j in zip([bricks]+L,L+[0])] def test(): bricks, bins = 6,4 n = noverk(bricks-1,bins-1) for i in range(n): print bb(i,bricks,bins) if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Dick Moores wrote: > If the added constraint is instead that the probability of generating > a given list of length N be the same as that of generating any other > list of length N, then I believe my function does the job. Of course, > [1,46,1,1,1] and [1,1,46,1,1], as Python lists, are distinct. I ran > this test for M == 8 and N == 4: Yes, I believe your function is OK. But the 'fencepost' method posted earlier in this thread also does this and it's faster AND it's only two line of code ... > A = [] > B = [] > for x in range(10): > lst = sumRndInt(8,4) > if lst not in A: > A.append(lst) > B.append(1) > else: > i = A.index(lst) > B[i] += 1 > > A.sort() Doesn't sorting break the correspondence between A and B? Also, a more pythonic way to count would be to convert the lst into a tuple and then do something with a dictionary. Dictionaries have faster lookup. For example: T = tuple(lst) D[T] = D.get(T,0) + 1 in the loop in order to count the occurrences. I'm totally fascinated with this stuff myself so it's a bit hard to guess whether someone still is interested, but anyway, here are some further explorations involving partitions. The code prints the number of distinct permutations for each partition. from operator import mul def part(m,n,r): L = [0]*n while m: x = pn(m-1,n-1) if r < x: L[n-1] += 1 m -= 1 n -= 1 else: for i in range(n): L[i] += 1 r -= x m -= n return L def memoize(fn): cache = {} def proxy(*args): try: return cache[args] except KeyError: return cache.setdefault(args, fn(*args)) return proxy @memoize def pn(m,n): if mhttp://mail.python.org/mailman/listinfo/python-list
Re: number generator
Dick Moores wrote: > Paul Rubin's fencepost method is about 14 times faster than mine for > the same M == 8 and N == 4! :( Actually they looked a bit similar after I had mucked a bit with them :-) But indeed it's slow. > Sorry, I don't understand this. Could you spell it out for me by > rewriting my above test to use it? Thanks! OK here you go. I'm copying a modification from something that I used to check something else, I hope you recognize the code after my refactoring. from itertools import islice import random def sumRndInt(m,n): while 1: L = [random.randint(1,m-n+1) for i in xrange(n)] if sum(L) == m: yield tuple(L) def fencepost(m,n): while 1: t = sorted(random.sample(xrange(1,m), n-1)) yield tuple((j-i) for i,j in zip([0]+t, t+[m])) def freq(g,k): D = {} for x in islice(g,k): D[x] = D.get(x,0)+1 return D def test(): m = 7 n = 4 k = 2 R = freq(sumRndInt(m,n),k) F = freq(fencepost(m,n),k) assert sorted(R) == sorted(F) for x in sorted(R): print x,R[x],F[x] if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Raymond Hettinger wrote: > Since people are posting their solutions now (originally only hints > were provided for the homework problem), here's mine: Homework problem? Do you have some information from the OP that I can't find in this thread? Anyway, I consider the 'homework' idea and the associated self concept that turns people into -for example- backstabbing computer scientists who never release their code as the root of all evil in the educational system. Why should I uphold a moral code that I don't agree with? To me people posting homework problems are like refugees which I will help if I can. > def genpool(n, m): > if n == 1: > yield [m] > else: > for i in xrange(1, m): > for rest in genpool(n-1, m-i): > yield rest + [i] > > import random > print random.choice(list(genpool(n=4, m=20))) OK back to the *computer* code. Great function! And it's ideally suited for memoization too. Too bad this memoizor doesn't accept keyword arguments, but for the rest it works fine and greatly speeds it up. import random def memoize(fn): cache = {} def proxy(*args): try: return cache[args] except KeyError: return cache.setdefault(args, fn(*args)) return proxy @memoize def genpool(n, m): if n == 1: yield [m] else: for i in xrange(1, m): for rest in genpool(n-1, m-i): yield rest + [i] def test(): print random.choice(list(genpool(5,50))) if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Paul Rubin wrote: >> def genpool(n, m): >> if n == 1: >> yield [m] >> else: >> for i in xrange(1, m): >> for rest in genpool(n-1, m-i): >> yield rest + [i] >> >> import random >> print random.choice(list(genpool(n=4, m=20))) > > This generates a lot of the partitions more than once, with > possibly unequal probability. Well, I just noticed that with my memoization function it produces too little :-( But I hope you notice that this function doesn't create only partitions but all possible outcomes? A. -- http://mail.python.org/mailman/listinfo/python-list
Re: number generator
Anton Vredegoor wrote: > def memoize(fn): > cache = {} > def proxy(*args): > try: return cache[args] > except KeyError: return cache.setdefault(args, fn(*args)) > return proxy Sorry this doesn't work in this case. This works: def memoize(fn): cache = {} def proxy(*args): try: return cache[args] except KeyError: return cache.setdefault(args, list(fn(*args))) return proxy But then we lose all speed advantages from memoizing so it's no good either. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: To count number of quadruplets with sum = 0
n00m wrote: > 62.5030784639 Maybe this one could save a few seconds, it works best when there are multiple occurrences of the same value. A. from time import time def freq(L): D = {} for x in L: D[x] = D.get(x,0)+1 return D def test(): t = time() f = file('m4000.txt') f.readline() L = [] for line in f: L.append(map(int,line.split())) q,w,e,r = map(freq,zip(*L)) sch,h = 0,{} for xk,xv in q.iteritems(): for yk,yv in w.iteritems(): if h.has_key(xk+yk): h[xk+yk] += xv*yv else: h[xk+yk] = xv*yv for xk,xv in e.iteritems(): for yk,yv in r.iteritems(): if h.has_key(-(xk+yk)): sch += h[-(xk+yk)]*xv*yv print sch print time()-t if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list