Re: how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-10 Thread Boris Borcic
Rustom Mody wrote: def fl1(l): return [y for x in l for y in x] # recursive flatten def fr(l): ... if not isinstance(l,list): return [l] ... return fl1([fr(x) for x in l]) For a short non-recursive procedure - not a function, modifies L in-place but none of its sublists. >>> def flat

Re: how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-10 Thread Boris Borcic
Boris Borcic wrote: Rustom Mody wrote: def fl1(l): return [y for x in l for y in x] # recursive flatten def fr(l): ... if not isinstance(l,list): return [l] ... return fl1([fr(x) for x in l]) For a short non-recursive procedure - not a function, modifies L in-place but none of its

Re: More than you ever wanted to know about objects

2006-01-16 Thread Boris Borcic
Mike Meyer wrote : > > For even more fun, consider 1.0 == 1 == decimal.Decimal('1.0'). > Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import decimal >>> 1 == 1.0 == decimal.Decimal('1.0') Fa

Re: More than you ever wanted to know about objects [was: Is everything a refrence or isn't it]

2006-01-16 Thread Boris Borcic
Tim Peters a écrit : > [Alex Martelli] > ... >>> In mathematics, 1 is not "the same" as 1.0 -- there exists a natural >>> morphism of integers into reals that _maps_ 1 to 1.0, but they're still >>> NOT "the same" thing. And similarly for the real-vs-complex case. - but does there exists any sense

Re: Recursive function returning a list

2006-07-18 Thread Boris Borcic
> Do you have any ideas? you could use a recursive generator, like def genAllChildren(self) : for child in self.children : yield child for childchild in child.genAllChildren() : yield childchild -- http://mail.python.org/mailman/listinfo/python-list

Re: array alice of [:-0] ??

2006-07-18 Thread Boris Borcic
guthrie wrote: > Beginner question! :-) > > x=[1,2,3,4] > for i in range(len(x)): >print x[:-i] > > >>> [] > >>> [1,2,3] > >>> [1,2] > >>> [1] > > 1) The x[:-0] result seems inconsistent to me; > I get the idea that -0=0, so it is taken as x[:0] -> [] that's what you get. > 2) how

Re: Recursive function returning a list

2006-07-18 Thread Boris Borcic
Hello Bruno, Bruno Desthuilliers wrote: > Boris Borcic wrote: >>> Do you have any ideas? >> >> you could use a recursive generator, like >> >> def genAllChildren(self) : >> for child in self.children : >> yield child &

Re: Coding style

2006-07-19 Thread Boris Borcic
PTY wrote: > Which is better? > > lst = [1,2,3,4,5] > > while lst: > lst.pop() > > OR > > while len(lst) > 0: > lst.pop() > allways that either-or stuff ! And why did you not consider while len(lst) : list.pop() a neat middle ground, wouldn't you say ? Cheers, BB -- 666 ?? - 666 ~ .666

Re: Coding style

2006-07-19 Thread Boris Borcic
Bruno Desthuilliers wrote: > > empty_list = [] > bool(empty_list) is False > => True it's just a pity that the symmetric expression list(False) is [] doesn't hold. I guess the problem is that if list(False) was thus defined, it would be difficult not to define list(True). And then the zen of

Re: Coding style

2006-07-19 Thread Boris Borcic
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Boris Borcic wrote: > >> Bruno Desthuilliers wrote: >>> empty_list = [] >>> bool(empty_list) is False >>> => True >> it's just a pity that the symmetric expression >&g

Re: Recursive function returning a list

2006-07-19 Thread Boris Borcic
Bruno Desthuilliers wrote: > Boris Borcic a écrit : >> Hello Bruno, >> >> Bruno Desthuilliers wrote: >> >>> Boris Borcic wrote: >>> >>>>> Do you have any ideas? >>>> >>>> >>>> you could use a re

Re: Augument assignment versus regular assignment

2006-07-19 Thread Boris Borcic
Antoon Pardon wrote: > The language reference doesn't talk about objects. And IMO you > should be carefull if you want to use the word "object" here. > In the line: "foo += 1", you can't talk about the object foo, > since foo will possibly > be bound to a different object after the assignment >

Re: Number combinations

2006-07-19 Thread Boris Borcic
Tim Chase wrote: ... > If you need the individual digits for something, you can use > > for i in xrange(0,1): > d1,d2,d3,d4 = list("%04i" % i) strings are sequences too, and you need only write d1,d2,d3,d4 = "%04i" % i -- http://mail.python.org/mailman/listinfo/pytho

Re: Recursive function returning a list

2006-07-19 Thread Boris Borcic
Bruno Desthuilliers wrote: > > Nope, it's about trying to make sure that anyone googling for a similar > problem will notice the canonical solution somehow. > Hey, I challenge you to cook up a plausible query even loosely fitting your "googling for a similar problem" that would return my answe

random shuffles

2006-07-21 Thread Boris Borcic
does x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) pick a random shuffle of x with uniform distribution ? Intuitively, assuming list.sort() does a minimal number of comparisons to achieve the sort, I'd say the answer is yes. But I don't feel quite confortable with the intuition... can an

Re: random shuffles

2006-07-21 Thread Boris Borcic
Paul Rubin wrote: > Boris Borcic <[EMAIL PROTECTED]> writes: >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> pick a random shuffle of x with uniform distribution ? > > You really can't assume anything like that. Sorting assumes an order > relation on

Re: random shuffles

2006-07-21 Thread Boris Borcic
Thanks for these details. BB Tim Peters wrote: > [ Boris Borcic] >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> >> pick a random shuffle of x with uniform distribution ? > > Say len(x) == N. With Python's current sort, the conjecture is true > if an

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like

Re: random shuffles

2006-07-24 Thread Boris Borcic
Paul Rubin wrote: > Boris Borcic <[EMAIL PROTECTED]> writes: >> To be more convincing... assume the algorithm is optimal and calls > > That assumption is not even slightly realistic. Real-world sorting > algorithms almost never do a precisely minimal amount of comparison

Re: random shuffles

2006-07-26 Thread Boris Borcic
I wrote : > > ...in this sense, it is clear that quicksort for instance is optimal* > > It is easy to see, when you detail this algorithm, that never during its > run is the result of a comparison it makes, preordained by comparisons > already made; iow : it doesn't make superfluous or redundan

Re: cleaner way to write this try/except statement?

2006-08-01 Thread Boris Borcic
John Salerno wrote: > The code to look at is the try statement in the NumbersValidator class, > just a few lines down. Is this a clean way to write it? i.e. is it okay > to have all those return statements? Is this a good use of try? Etc. > > Thanks. > > > > import

Re: cleaner way to write this try/except statement?

2006-08-03 Thread Boris Borcic
Simon Forman wrote: > Boris Borcic wrote: >> John Salerno wrote: >>> The code to look at is the try statement in the NumbersValidator class, >>> just a few lines down. Is this a clean way to write it? i.e. is it okay >>> to have all those return statem

Re: How to reverse tuples in a list?

2006-08-09 Thread Boris Borcic
Applying the perl motto (there is more than one way to do it) sure enough leads to a perlish solution... as measured by line noise. >>> t = [('a', 11,1.0), ('b',22,2.0),('c',33,3.0)] >>> zip(*zip(*t)[::-1]) [(1.0, 11, 'a'), (2.0, 22, 'b'), (3.0, 33, 'c')] -- http://mail.python.org/mailman/lis

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread Boris Borcic
Slawomir Nowaczyk wrote: > > try: > if int(text) > 0: >return True > except ValueError: > pass > self.error_message() > return False > Nicely DRY. To make it even more compact, it may be noticed that the default return value None is false in a boolean context - so that the last

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread Boris Borcic
Bruno Desthuilliers wrote: > Boris Borcic a écrit : >> Slawomir Nowaczyk wrote: >> >>> >>> try: >>> if int(text) > 0: >>>return True >>> except ValueError: >>> pass >>> self.error_message() >>&g

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread Boris Borcic
John Salerno wrote: > In this case the method must return False, because it's a wxPython > method that needs a True or False value. If it doesn't, the program will > continue even after the error message. Just as it should do if the method returns True and no error message is produced if I und

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread Boris Borcic
Boris Borcic wrote: > John Salerno wrote: >> In this case the method must return False, because it's a wxPython >> method that needs a True or False value. If it doesn't, the program >> will continue even after the error message. > > Just as it should do if

Re: swapping numeric items in a list

2006-08-23 Thread Boris Borcic
Jiang Nutao wrote: > Hi, > > I simplify my problem like below > > To convert list > aa = [0x12, 0x34, 0x56, 0x78] > into > [0x34, 0x12, 0x78, 0x56] > > How to do it fast? My real list is huge. Mark Rintsch's suggestion appears best if applicable, but just to cite yet other ways to do

Re: Logic Programming

2006-10-10 Thread Boris Borcic
I believe some work has been down in pypy to bring logic programming to python. You might ask pypy-dev Google leads to http://codespeak.net/pypy/dist/pypy/doc/howto-logicobjspace-0.9.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries

2006-10-18 Thread Boris Borcic
dict(a.items() + b.items()) Lad wrote: > How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. > > Is it possible? -- http://mail.python.org/mailman/listinfo/python-list

Re: Is x.f() <==>MyClass.f(x) a kind of algebraic structure?

2006-10-21 Thread Boris Borcic
steve wrote: > What can we think that? When much stretch definitions -- http://mail.python.org/mailman/listinfo/python-list

Re: how is python not the same as java?

2006-11-10 Thread Boris Borcic
Jorge Vargas wrote: > can you open a commandline and start writting java code? beanshell, iirc -- http://mail.python.org/mailman/listinfo/python-list

Re: Will GPL Java eat into Python marketshare?

2006-11-16 Thread Boris Borcic
John Bokma wrote: >> Seriously though, there is no contradiction between the idea of >> "people use Python instead of Java because they prefer to avoid pain" > > It sounds like a typical fanboy statement to me, since it implies that > Java is always a pain, and Python is perfect. That inferenc

Re: John Bokma harassment

2006-05-29 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > We seem to have strayed a long way from Voltaire's > "I do not agree with what you say, but I will defend to the death your > right to say it.", > but that was of course the age of enlightenment. Obviously this wisdom is getting stale and should be updated to something l

Re: Ricerca Programmatore Python

2006-05-29 Thread Boris Borcic
Nic wrote: > Please accept my apologies for the use of the Italian language. accepted -- http://mail.python.org/mailman/listinfo/python-list

numpy bug

2006-06-01 Thread Boris Borcic
after a while trying to find the legal manner to file numpy bug reports, since it's a simple one, I thought maybe a first step is to describe the bug here. Then maybe someone will direct me to the right channel. So, numpy appears not to correctly compute bitwise_and.reduce and bitwise_or.reduce

Re: Python language problem

2006-06-07 Thread Boris Borcic
[EMAIL PROTECTED] wrote: class A: > ... pass > ... a = A() b = a del b a > <__main__.A instance at 0x00B91BC0> > I want to delete 'a' through 'b', why It does't? > How can I do that? del a,b -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-08 Thread Boris Borcic
Girish Sahani wrote: > I have a list of strings all of length k. For every pair of k length > strings which have k-1 characters in common, i want to generate a k+1 > length string(the k-1 common characters + 2 not common characters). > e.g i want to join 'abcd' with bcde' to get 'abcde' but i dont

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-08 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > Boris Borcic: >> I'd favor the following, that I find most readable >> sets = map(set,list_of_strings) >> res = set(''.join(sorted(s1|s2)) for s1 in sets for s2 in sets if >> len(s1^s2)==2) > > I think there can be wri

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-09 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > Boris Borcic: > >> I challenge you to write simpler code to do the equivalent. context ? > > I don't do challenges. Pfff... and you don't do real debates either. > I too have written the code to solve that > problem, Why ? When ?

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-09 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > Boris Borcic: >>> I don't do challenges. >> Pfff... and you don't do real debates either. > > Different nations have different values and different cultures, in mine > challenges are often seen as things for children, and a waste

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-09 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > It's not that difficult to improve the readability of a quite long > line, you can start splitting it. The point is that it is observer and context dependent whether res = set(''.join(sorted(X|Y)) for X in sets for Y in sets

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-09 Thread Boris Borcic
> Hum, since your code is not syntactically correct, anything will run > faster :) in fact it parses, I was fooled by this line >> if k in range(1,len(prunedK),1) & i+k <= len(prunedK) -1: I was fooled because the form "k in range(" tends to imply a for statement ; in the case of an

Re: Error in Chain of Function calls

2006-06-09 Thread Boris Borcic
Girish Sahani wrote: > > Also,i am getting a ValueError in the code below: > > for s in prunedNew: > substrings = [s[:i]+s[i+1:] for i in range(len(s))] > for string in substrings: > if string not in prunedK: >

Re: [noob question] References and copying

2006-06-09 Thread Boris Borcic
zefciu wrote: > Hello! > > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. I thought I understand > it, but I have just typed in following commands: > a=[[1,2],[3,4]] b=a[1] b=[5,6] a > [[1, 2], [3, 4]] >>>

Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread Boris Borcic
Girish Sahani wrote: >>> However i am getting an error at the line marked with ***. >> Which error ? How do you hope us to be of any help here if you don't *at >> least* provide the full traceback ? FWIW, the canonical way to do things >> is to: >> - provide minimal *runnable* code exposing the p

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Boris Borcic
Girish Sahani wrote: > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Please help! > Its possible

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-16 Thread Boris Borcic
Josiah Carlson wrote: >> >> [BB] >> >> I'd say a first step in convincing me I am wrong would be to show me >> examples of >> >> object methods of the standard library that are recursive, and cut out >> for >> >> recursion. >> >> [JC] >> > Actually, I don't believe that is necessary. I've sh

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-19 Thread Boris Borcic
Hello, just a couple points On 6/17/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: [errors involving the shadowing of a variable by another] > > Of course everybody makes errors, but it doesn't follow from this, that > > all make the same errors, or should. > > If I implied that everyone has

Re: [OT] code is data

2006-06-20 Thread Boris Borcic
bruno at modulix wrote: > Anton Vredegoor wrote: >> 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) m

Re: How to generate all permutations of a string?

2006-06-23 Thread Boris Borcic
Another generator solution, based on computing a permutation from its rank according to some natural order. Written for strings. def perms(s) : def nth(n,L,k=1) : if k>len(L) : if n : raise StopIteration return '' return nth(n/k,L,

Re: How to generate all permutations of a string?

2006-06-26 Thread Boris Borcic
I wrote: > Another generator solution, based on computing a permutation from its > rank according to some natural order. Written for strings. > > def perms(s) : > def nth(n,L,k=1) : > if k>len(L) : > if n : > raise StopIteration > return '' >

Re: Python SOAP and XML-RPC performance extremely low?

2006-07-06 Thread Boris Borcic
Jack wrote: > When I try TooFPy with the SOAP and XML-RPC sample client code > provided in TooFPy tutorials, a log entry shows up quickly on web server > log window, but it takes a long time (5 seconds or longer) for the client > to output a "Hello you." It seems like the web server is fast because

Re: iterator question

2006-09-26 Thread Boris Borcic
Neal Becker wrote: > Any suggestions for transforming the sequence: > > [1, 2, 3, 4...] > Where 1,2,3.. are it the ith item in an arbitrary sequence > > into a succession of tuples: > > [(1, 2), (3, 4)...] > > In other words, given a seq and an integer that specifies the size of tuple > to retu

Re: Will GPL Java eat into Python marketshare?

2006-11-17 Thread Boris Borcic
Harry George wrote: > > Personally, I've never gotten jpype to work. Is it just me, or is it > a troublesome install? > It worked for my purpose (connecting to a 4D database via JDBC over Open4D, as the ODBC driver for that db is really horrible) until I tried to use this setup together with

psyco-simplified idioms ?

2006-11-23 Thread Boris Borcic
I am curious about idioms instinctively avoided by experienced programmers because of inefficiencies that psyco eliminates. IOW, are there any identifiable ways in which the backing of psyco promotes simpler code by eliminating efficiency concerns ? Best, BB -- http://mail.python.org/mailman/

Re: Routine for prefixing '>' before every line of a string

2006-12-14 Thread Boris Borcic
Sanjay wrote: > Hi All, > > Is somewhere a routine useful to convert a string to lines of maxsize, > each prefixed with a '>'. This is a typical requirement for 'keeping > existing text while replying to a post in a forum'. > > It can be developed, but if something obvious is already there(I bein

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-23 Thread Boris Borcic
Xah Lee wrote: > Of Interest: to which of comp.lang.perl.misc, comp.lang.python, comp.lang.lisp, comp.lang.java.programmer, comp.lang.functional ? -- http://mail.python.org/mailman/listinfo/python-list

Re: pow() works but sqrt() not!?

2007-01-04 Thread Boris Borcic
siggi wrote: > Hi all, > > this is a newbie question on : > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on > win32 > PC with WinXP > > In > http://www.python.org/doc/2.3.5/lib/module-math.html > I read: > > "sqrt( x) Return the square root of x." > > Now the test f

lambda generator - curious behavior in 2.5

2007-04-21 Thread Boris Borcic
>>> x = (lambda : ((yield 666),(yield 777),(yield 888)))() >>> x.next() 666 >>> x.next() 777 >>> x.next() 888 >>> x.next() (None, None, None) >>> x = (lambda : ((yield 666),(yield 777),(yield 888)) and None)() >>> x.next() 666 >>> x.next() 777 >>> x.next() 888 >>> x.next() Traceback (mos

Re: File record separators.

2007-05-15 Thread Boris Borcic
HMS Surprise wrote: > Thanks folks. Was unaware of enumerate , still have a lot to learn > about python. > > Sorry for the poorly phrased request, but you gathered the gist of it. > My wonderment is how to write the following 2 lines and make sure they > are saved as separate records or lines so t

Re: make images with python

2007-08-15 Thread Boris Borcic
Lawrence Oluyede wrote: > stefano <[EMAIL PROTECTED]> wrote: >> I need make some images using python but i'm lost :P > > > If you want to do antialiased drawings into images, you might rather want to look for pil at http://effbot.org/downloads/ and gra

Re: List Comprehension Question: One to Many Mapping?

2007-08-24 Thread Boris Borcic
Paul Rubin wrote: > beginner <[EMAIL PROTECTED]> writes: >> For example, if I have x=[ [1,2], [3,4] ] >> >> What I want is a new list of list that has four sub-lists: >> >> [[1,2], [f(1), f(2)], [3,4], [f(3), f(4)]] > > [[a, map(f,a)] for a in x] no, that one will be [[[1,2], [f(1), f(2)]], [[3,4

Re: SOAP : ZSI error

2007-09-03 Thread Boris Borcic
linuxprog wrote: > hello i need some help with ZSI module > i want to use the web service located here > www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch > the wsdl file : > http://www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/wsdl/IDutch > that web service is very simple , the funct

Re: So what exactly is a complex number?

2007-09-03 Thread Boris Borcic
Lamonte Harris wrote: > Like in math where you put letters that represent numbers for place > holders to try to find the answer type complex numbers? > Not quite. Relating them to (plane) trigonometry is much closer to the mark. Complex numbers are like a subclass of real numbers that elegantly

Re: So what exactly is a complex number?

2007-09-05 Thread Boris Borcic
Roy Smith wrote: > Boris Borcic <[EMAIL PROTECTED]> wrote: >> Complex numbers are like a subclass of real numbers > > I wouldn't use the term "subclass". Really you should name yourself as the author when you butcher someone else's prose to such

Re: So what exactly is a complex number?

2007-09-05 Thread Boris Borcic
Paul Rubin wrote: > Also, for > example, the derivative of a complex valued function means something > considerably stronger than the derivative of a real valued function. I vaguely remember (it has been decades) an amazingly beautiful russian doll system of four of five theorems, the first hypot

Re: How to calculate a file of equations in python

2007-03-21 Thread Boris Borcic
r='' for line in file : r = str(eval(r+line)) John wrote: > Hi, > I have a text file which contains math expression, like this > 134 > +234 > +234 > > (i.e. an operation (e.g. '+) and then a number and then a new line). > > Can you please tell me what is the easiest way to calculate that file? >

Re: Need some help...

2007-10-30 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > I want to create a program that I type in a word. > > for example... > > chaos > > each letter equals a number > > A=1 > B=20 > > and so on. > > So Chaos would be > > C=13 H=4 A=1 O=7 S=5 > > I want to then have those numbers > 13+4+1+7+5 added together to be

Re: Iteration for Factorials

2007-10-30 Thread Boris Borcic
Py-Fun wrote: > I'm stuck trying to write a function that generates a factorial of a > number using iteration and not recursion. Any simple ideas would be > appreciated. > fact = lambda n : len(map([1].__imul__,range(1,n+1))[0]) hth :) BB -- http://mail.python.org/mailman/listinfo/python-list

Re: permuting over nested dicts?

2007-11-01 Thread Boris Borcic
Christian Meesters wrote: > Hoi, > > I have the following data structure (of variable size actually, to make > things simple, just that one): > d = {'a': {'x':[1,2,3], 'y':[4,5,6]}, > 'b': {'x':[7,8,9], 'y':[10,11,12]}} > This can be read as a dict of possibilities: The entities 'a' and 'b' h

Re: Need some help...

2007-11-01 Thread Boris Borcic
Ricardo Aráoz wrote: > Boris Borcic wrote: >> [EMAIL PROTECTED] wrote: >>> I want to create a program that I type in a word. >>> >>> for example... >>> >>> chaos >>> >>> each letter equals a number >>> >>&g

Re: setting and getting column in numpymatrix

2007-11-01 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > hi > i am looking for an efficient way to get a specific column of a > numpy.matrix .. > also i want to set a column of the matrix with a given set of > values ..i couldn't find any methods for this in matrix doc..do i have > to write the functions from scratch? > >

Re: Need some help...

2007-11-02 Thread Boris Borcic
Ricardo Aráoz wrote: > Boris Borcic wrote: >> Ricardo Aráoz wrote: >>> Boris Borcic wrote: >>>> [EMAIL PROTECTED] wrote: >>>>> I want to create a program that I type in a word. >>>>> >>>>> for example... >>

Re: new style class

2007-11-02 Thread Boris Borcic
gert wrote: > Could not one of you just say "@staticmethod" for once damnit :) > I did, did I not ? -- http://mail.python.org/mailman/listinfo/python-list

Re: new style class

2007-11-02 Thread Boris Borcic
gert wrote: > class Test(object): > > def execute(self,v): > return v > > def escape(v): > return v > > if __name__ == '__main__': > gert = Test() > print gert.m1('1') > print Test.m2('2') > > Why doesn't this new style class work in python 2.5.1 ? > why s

Re: new style class

2007-11-02 Thread Boris Borcic
gert wrote: [...] Why doesn't this new style class work in python 2.5.1 ? >>> why should it ? >> I don't know I thought it was supported from 2.2? > > oops the code is like this but doesn't work > > class Test(object): > > def m1(self,v): > return v > > def m2(v): >

Rendering text question (context is MSWin UI Automation)

2007-01-23 Thread Boris Borcic
with Tkinter or otherwise - way to wrap access to the MS Windows UI text rendering engine, as a function that would return a picture of rendered text, given a string, a font, a size and colors ? And ideally, without interfering with screen contents ? Thanks in advance for any guidanc

Re: Rendering text question (context is MSWin UI Automation)

2007-01-24 Thread Boris Borcic
hat er, counts for me). I could probably manage such imprecisions but I would rather have an exact solution. ... > > I work with wxPython and Win32 applications exclusively. > > So if I can be of any help or assistance, please let me know. > > Geoff. > Thanks f

Re: Rendering text question (context is MSWin UI Automation)

2007-01-24 Thread Boris Borcic
Chris Mellon wrote: > On 1/23/07, Boris Borcic <[EMAIL PROTECTED]> wrote: >> ...A simple - >> with Tkinter or otherwise - way to wrap access to the MS Windows UI text >> rendering engine, as a function that would return a picture of rendered >> text, >

Re: Rendering text question (context is MSWin UI Automation)

2007-01-24 Thread Boris Borcic
this make sense ? Is it possible to position text with subpixel accuracy ? Regards, Boris Borcic -- http://mail.python.org/mailman/listinfo/python-list

Re: Rendering text question (context is MSWin UI Automation)

2007-01-25 Thread Boris Borcic
Chris Mellon wrote: > On 1/24/07, Boris Borcic <[EMAIL PROTECTED]> wrote: >> Chris Mellon wrote: >>> Using either win32 or wxPython you will be able to produce bitmaps >>> directly, without needing to create a visible window. >>> >>> >>>

Re: Rendering text question (context is MSWin UI Automation)

2007-01-25 Thread Boris Borcic
Chris Mellon wrote: > On 1/25/07, Boris Borcic <[EMAIL PROTECTED]> wrote: >> Chris Mellon wrote: >>>>> >>>>> Some quick & dirty wxPython code >>>>> >>>>> def getTextBitmap(text, font, fgcolor, bgcolor):

Re: Do I need Python to run Blender correctly?

2007-01-25 Thread Boris Borcic
years ago. YMMV, Boris Borcic -- http://mail.python.org/mailman/listinfo/python-list

Re: Rendering text question (context is MSWin UI Automation)

2007-01-25 Thread Boris Borcic
Chris Mellon wrote: >> Maybe. In any case, color separation solves my (sub)problem : the blue layer >> from the wx generated model matches the green layer from the app's window, >> pixel >> for pixel (at least with antialiasing and cleartype on, while writing black >> on >> white). >> > > That's

Re: Germany issues warrants for 13 American CIA agents

2007-02-02 Thread Boris Borcic
Vance P. Frickey wrote: > I understand that Mengele's old boss is still alive and well > in Deutschland What else do you understand ? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use list as key of dictionary?

2007-11-05 Thread Boris Borcic
Davy wrote: > Hi all, > > We know that list cannot be used as key of dictionary. Yeah, but do we know why ? > So, how to work > around it? That's a subsidiary question. > > For example, there is random list like l=[1,323,54,67]. Don't use 1owercase L as a variab1e name, p1ease ! > > Any su

Re: How to use list as key of dictionary?

2007-11-06 Thread Boris Borcic
You could also index on the repr() of your objects, which is an immutable str value. Davy wrote: > And there may be more complex list(vector like 3 or 4 dimentional data > structure), is there any easy method to tackle this problem? > > Any suggestions are welcome! > > Best regards, > Davy > >

Re: List to Tuple and Tuple to List?

2007-11-06 Thread Boris Borcic
Davy wrote: > Hi all, > > I am curious about whether there is function to fransform pure List to > pure Tuple and pure Tuple to pure List? > > For example, > > I have list L = [[1,2,3],[4,5,6]] > something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6)) > > And the tuple2list() > > An

Re: Trouble with for loop

2007-11-06 Thread Boris Borcic
Shriphani wrote: > On Nov 6, 3:09 pm, Ant <[EMAIL PROTECTED]> wrote: >> On Nov 6, 9:59 am, Shriphani <[EMAIL PROTECTED]> wrote: >> ... >> >>> My main intention is to state that each of the variables namely a, b, >>> c, ## can take value from 1 to 9. >>> How do I go about this ? >> It sounds like yo

Re: What about a Python Tree container?

2007-11-06 Thread Boris Borcic
Roc Zhou wrote: > Hello, Hello, This post is too long. The right place for such is as a python reciepe on ActiveState. BTW, I bet you can find 3+ equivalents to you Tree type in the recorded reciepes. Regards, BB -- http://mail.python.org/mailman/listinfo/python-list

Re: permuting over nested dicts?

2007-11-08 Thread Boris Borcic
Boris Borcic wrote: > Christian Meesters wrote: >> Hoi, >> >> I have the following data structure (of variable size actually, to make >> things simple, just that one): >> d = {'a': {'x':[1,2,3], 'y':[4,5,6]}, >>

Re: How to link different site-packages to different Python?

2007-11-09 Thread Boris Borcic
Davy wrote: > Hi all, > > I have Python 2.4 and 2.5 in my PC. And PythonWin is installed as IDE. > > When I tried to use site-packages "Numpy", I installed the both > version (i.e. for 2.4 and 2.5). > > Python 2.4 and Numpy for it work together well. > > But when I type "from numpy import *" in

Re: Closure/binding problem or misunderstanding

2007-11-09 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > If I run the following code: > > class path(object): > def __init__(self, **subdirs): > for name, path in subdirs.iteritems(): > def getpath(): > return path > setattr(self, name, getpath) > > export = path( > one

Re: Using python as primary language

2007-11-09 Thread Boris Borcic
Michel Albert wrote: > > What I meant was that one should be able to "draw" a report template. > Basically a graphical user interface for RML in this case. I > personally would opt for writing RML or whatever code myself. But it's > impossible to convice my boss. The dialog usually goes like this:

Re: implement random selection in Python

2007-11-16 Thread Boris Borcic
Bruza wrote: > No. That does not solve the problem. What I want is a function > > def randomPick(n, the_items): > > which will return n DISTINCT items from "the_items" such that > the n items returned are according to their probabilities specified > in the (item, pro) elements inside "the_items

Re: implement random selection in Python

2007-11-16 Thread Boris Borcic
Bruza wrote: > No. That does not solve the problem. What I want is a function > > def randomPick(n, the_items): > > which will return n DISTINCT items from "the_items" such that > the n items returned are according to their probabilities specified > in the (item, pro) elements inside "the_items

Re: sorting contacts alphabetically, sorted by surname

2007-11-16 Thread Boris Borcic
Marie Hughes wrote: > HI > > I have to write a program that contains a text file in the following format: > > AcademicPositionRoom Ext. Email > Prof Marie Maguire Head of > School M9002 [EMAIL PROTECTED] > > > And

Re: sorting contacts alphabetically, sorted by surname

2007-11-16 Thread Boris Borcic
Wow J. Clifford Dyer wrote: > On Fri, Nov 16, 2007 at 12:31:19PM +, Marie Hughes wrote regarding > sorting contacts alphabetically, sorted by surname: >>HI >> >>I have to write a program that contains a text file in the following >>format: >> >>AcademicPosition

  1   2   >