package search

2006-06-11 Thread boris
x27;t. My questions: - Have I done anything wrong? - If not, is this behaviour of Python a bug or intentional? - If it it intentional, what is the intent? Thank you for your help Boris -- http://mail.python.org/mailman/listinfo/python-list

Re: package search

2006-06-11 Thread boris
Sybren Stuvel wrote: > Simplicity and explicitness. You have two packages 'foo', and it > simply loads the first one it finds. Yes, here you are right. It is indeed simple. Boris -- http://mail.python.org/mailman/listinfo/python-list

Re: package search

2006-06-11 Thread boris
fter the package. > > HTH :-) > > Diego. COOL! You just saved me an awful lot of work. Thanks, Diego! Boris -- http://mail.python.org/mailman/listinfo/python-list

newbie:this program stops responding after pressing quit button

2007-12-04 Thread Boris
I am using windows vista and python 2.5 .This program stops responding after pressing quit button. I am not able to figure the problem out. please help. from Tkinter import * def greeting( ): print 'Hello stdout world!...' win = Frame( ) win.pack( ) Label(win, text='Hello container world')

Using utidylib, empty string returned in some cases

2008-01-22 Thread Boris
Hello I'm using debian linux, Python 2.4.4, and utidylib (http:// utidylib.berlios.de/). I wrote simple functions to get a web page, convert it from windows-1251 to utf8 and then I'd like to clean html with it. Here is two pages I use to check my program: http://www.ya.ru/ (in this case everythin

Re: Testing against multiple versions of Python

2012-10-19 Thread Boris FELD
Did you take a look at https://www.shiningpanda-ci.com/? 2012/10/19 andrea crotti : > 2012/10/19 Michele Simionato : >> Yesterday I released a new version of the decorator module. It should run >> under Python 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3. I did not have the will >> to install on my ma

Re: open URL in the current tab

2012-12-10 Thread Boris FELD
Don't think that it's possible with webbrowser, you should try with Selenium. For example with sst (Simple Selenium Test), it open url in current tab or create a new one if no one exists: from sst.actions import * go_to('http://www.ubuntu.com/') 2012/12/10 Jabba Laci : > Hi, > > With the webbrow

Re: Help with unittest2

2012-12-13 Thread Boris FELD
How are you importing unittest2, do you have something like this ? try: import unittest2 as unittest except ImportError: import unittest If it's the case, you are maybe using default unittest while you think you are using unittest2. 2012/12/13 Daniel Laird : > On Thursday, December 13, 2012

Re: For Loop in List

2013-01-13 Thread Boris FELD
2013/1/13 Tim Chase : > On 01/13/13 06:45, [email protected] wrote: > SIZE = 3 for i in range(len(list1)//SICE): > ... print list1[i*SIZE:i*SIZE+SIZE] > ... > [1, 2, 3] > [4, 5, 6] > [7, 8, 9] > [10, 11, 12] > A little shorter and simpler version: >>> x = x[1:] >>> for i in ra

Re: Writing Android application using GPS data with Python

2012-04-15 Thread Boris FELD
You can try appaccelerator, it seems to support python and you should be able to access geolocalisation (according to wikipedia: https://en.wikipedia.org/wiki/Appcelerator_Titanium) Le 15 avril 2012 16:44, Noam Peled a écrit : > I want to write an Android application using Python. I've found 2 o

Re: (*args **kwargs) how do I use' em?

2011-06-11 Thread FELD Boris
A good tutorial will surely help : http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/ The idea between *args and *kwargs is to create function (callables) which accepts an arbitrary number of anonymous and/or keyword arguments. It's useful when you want to create a fu

Re: [OSX] side by side python

2011-03-21 Thread FELD Boris
lation. No specific problem, i use these Python versions without any problem on mac os x : 2.5, 2.6, 2.7, 3.0, 3.1, 3.2. -- FELD Boris Sent with Sparrow On lundi 21 mars 2011 at 13:31, Robert wrote: > Can I install Python 2.7 and 3.2 (from python.org) side by side on OSX > without them st

Re: side by side python

2011-03-21 Thread FELD Boris
Yes, i did not mention this solution, using virtualenv is a very good practice, but before create a virtualenv with a specific version of python, you must have installed it globally, isn't it ? Regards, -- FELD Boris Sent with Sparrow On lundi 21 mars 2011 at 14:45, macm wrote: > On M

Re: Threading with Socket Server

2011-03-23 Thread Boris FELD
n.org/library/socketserver.html). I'm not sure about how shelve manage concurrency, but in my opinion, you'll need to create a single process or thread which manage read and write operation in order to avoiding race conditions. Cheers, Feld Boris 2011/3/23 T : > Hello all, I am writing

Re: Validating Command Line Options

2011-03-23 Thread Boris FELD
If you're using argparse, you have a method for that named "add_mutually_exclusive_group". Tutorial : http://www.doughellmann.com/PyMOTW/argparse/#mutually-exclusive-options Cheers, Feld Boris 2011/3/23 T : > For a Python script with multiple command line options, what is th

Re: Dump interpreter history?

2011-03-25 Thread FELD Boris
Take a look at : http://ipython.scipy.org/doc/manual/html/interactive/tutorial.html#use-your-input-history Cheers, FELD Boris -- FELD Boris Sent with Sparrow On vendredi 25 mars 2011 at 22:03, Ken D'Ambrosio wrote: > Hey, all. A co-worker asked me a question, and I've got no idea

Re: Python benefits over Cobra

2011-04-05 Thread Boris FELD
Cobra seems interessant, open-source, but the dependance on Mono and .Net annoy me a bit. Otherwise, cobra have good ideas, a syntax similar to python. One thing i really love is the "How-To" and the "Samples" pages on it's website, i think it's a very good thing fo

Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread FELD Boris
's an excellent idea and, when the tutorials were expanded enough, i should be good to integrate it with python.org website (but it's more a dream than something else...) One question, if i want to write a tutorial about import mechanism, how can i manage the file system ? Nice work ! --

Re: on slices, negative indices, which are the equivalent procedures?

2021-08-06 Thread Boris Dorestand
Jach Feng writes: >> > s = "Jack Brandom" >> > s[3 : -13 : -1] >> >> 'kcaJ' >> >> I have no idea how to replace that -13 with a positive index. Is it >> >> possible at all? > That's not possible because a positive index is relative to the leftmost item > 0 And the middle index is al

how to let argument be optional falling back to certain integer

2020-06-20 Thread Boris Dorestand
I just wrote def f(y, N, k = None): k = k or (N - 1) return k I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. I'd like 0 to be a valid choice for k. How do you guys let k be an optional argument such that it defaults to N - 1? Thank you. -- https://mail.pytho

Re: how to let argument be optional falling back to certain integer

2020-06-20 Thread Boris Dorestand
Chris Angelico writes: > On Sun, Jun 21, 2020 at 2:02 AM Boris Dorestand > wrote: >> >> I just wrote >> >> def f(y, N, k = None): >> k = k or (N - 1) >> return k >> >> I was surprised to find out that 0 == False, so f(7, 31, 0) pr

Re: how to let argument be optional falling back to certain integer

2020-06-21 Thread Boris Dorestand
Chris Angelico writes: [...] >> Anyway, I kind of replied just to thank you all for the great group this >> is. ChrisA, I don't know how can keep up with this newsgroup, but you >> do. This is crazy. Years go by and when I come back, there you are >> still. You're priceless. > > You're most

Re: how to let argument be optional falling back to certain integer

2020-06-22 Thread Boris Dorestand
David Raymond writes: >> This is true. I have written 0 as false in C so many times. But >> clearly for me times have changed... I now look at numbers as a thing >> in their own special class not to be confused as truth-values. (So much >> so that I fell for this.) But I confess I still thin

on generating combinations among a variable list of lists

2020-06-28 Thread Boris Dorestand
Say we have [1,3,5,7], [2,3], [1,10]. I'd like to generate [1,2,1] [1,2,10] [1,3,1] [1,3,10] [3,2,1] [3,2,10] [3,3,1] [3,3,10] [5, ...] ... [7,3,10] The number of input lists is variable. The example shows three lists, but there could be only one or ten lists or any other

Re: on generating combinations among a variable list of lists

2020-06-28 Thread Boris Dorestand
Peter Otten <[email protected]> writes: > Boris Dorestand wrote: > >> Say we have [1,3,5,7], [2,3], [1,10]. I'd like to generate >> >> [1,2,1] >> [1,2,10] >> [1,3,1] >> [1,3,10] >> [3,2,1] >> [3,2,10] >> [3,3,

how to plot the FFT of a list of values

2020-12-05 Thread Boris Dorestand
I have 16 values of the period sequence 1, 2, 4, 8, 1, 2, 4, 8, ... I compute its fourier transform using >>> from scipy import fft, ifft >>> x = [1,2,4,8,1,2,4,8] >>> fft(x) array([ 30. +0.j, 0. +0.j, -6.+12.j, 0. +0.j, -10. +0.j, 0. +0.j, -6.-12.j, 0. +0.j]) Now how can I plot

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: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Boris FELD
You can use [random.random() * 5 for x in range(100)] but works only on range [0, 5). If you want to include 5, you will need more code. Cheers, FELD Boris 2013/3/12 Norah Jones : > I want to create a random float array of size 100, with the values in the > array ranging from 0 to 5.

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

extract text from a string

2006-11-09 Thread boris . smirnov
t string? thank you very much in advance regards, boris -- http://mail.python.org/mailman/listinfo/python-list

Re: extract text from a string

2006-11-09 Thread boris . smirnov
Thank you very much. I needed this kick. :) Rg, Boris Grant Edwards napísal(a): > On 2006-11-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hallo all, > > > > I have tried for a couple of hours to solve my problem with re but I > > have no success. &

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
is to anticipate too much on them, and, given their diversity, to overestimate the scope of the lessons learned from the sample of them that most caught our attention (usually because of their painful consequences). Besides, I think there are subtle issues with taking errors as building material for policies destined to public consomption by new generations. It is vital to find a self-standing positive goal to substitute to the negative goal of avoiding the repetition of the error, etc. Btw, how you dealt with my case tells me you don't particularly fear diagnostic errors, but your way of presenting closures and classes in Python tells me that you probably agree with my later remark. > > You talk about "Designing for assumed chronic lusers", Again, this has lost its proper context. > I'm talking about > designing for human beings, some of whom are new to the language. This starts resembling the disputes I had with my wife over the education of our child. Total divergence as to the adequacy of trying to control the child's POV. > > > - Josiah > Boris -- "on naît tous les mètres du même monde" -- http://mail.python.org/mailman/listinfo/python-list

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

2006-06-19 Thread Boris Borcic
ested function scopes was critical to the shape of the "feature". Indeed, speaking of "status quo ante" : augmented assignments arrived with Python 2.0, while nested scopes where first introduced with 2.1. > > Have a good weekend, Thank you. I had a good weekend. I hope you too. And together with my thanks for your efforts, please recieve my apologies for temper... > - Josiah > > [1] http://www.csmonitor.com/2006/0515/p13s01-stct.html ...as this seems to imply you would. Boris -- "On naît tous les mètres du même monde" -- http://mail.python.org/mailman/listinfo/python-list

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

AIML, Python, Java

2007-07-04 Thread Boris Ozegovic
Hi I have a chatterbot written in AIML. I am using PyAIML, and HTTP server as a mediator between user and PyAIML. Server calls PyAIML, and sends the result string to the sensor network which is written in Java; and in the end, server returns value from Java method. Can I somehow call Java metho

httplib module

2007-07-07 Thread Boris Ozegovic
Why do I get double new lines when geting data from server? Example: I have a following file: --start- Ovo je testni primjerak --end--- And the code is: conn = httplib.HTTPConnection("localhost:8000") conn.request("GET", "/folder/index.html") response = conn.g

Re: httplib module

2007-07-07 Thread Boris Ozegovic
Boris Ozegovic wrote: > Why do I get double new lines when geting data from server? Example: Fixed. -- Ne dajte da nas lažljivac Bandić truje: http://cnn.blog.hr/arhiva-2007-06.html#1622776372 -- http://mail.python.org/mailman/listinfo/python-list

Re: httplib module

2007-07-08 Thread Boris Ozegovic
Steve Holden wrote: >>> Why do I get double new lines when geting data from server? Example: > How? It's customary to include details when you've solved your own > problem in case someone else gets the same issue. Ok. In do_GET I had this two lines: for line in file: print line As you c

Significance of "start" parameter to string method "endswith"

2007-04-19 Thread Boris Dušek
nly case where it would make difference is if we had start + len(suffix) < len(a) (excuse possible "of-by-one" error :-) Then the function would never return True. But is there a real use case when we would test for endswith like this? (knowing that it must return false?) Thanks for any ideas/experience. Boris -- http://mail.python.org/mailman/listinfo/python-list

Re: Significance of "start" parameter to string method "endswith"

2007-04-19 Thread Boris Dušek
On Apr 19, 10:36 pm, subscriber123 <[EMAIL PROTECTED]> wrote: > On Apr 19, 3:58 pm, Boris Dušek <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > what is the use-case of parameter "start" in string's "endswith" > > method? &g

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

Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-24 Thread Boris Dušek
some base class to "file"-like (or "stream"-like) objects in Python? And if not, is it at least planned for Python 3.0? Thanks for any suggestions, Boris Dušek P.S.: The code should finally look in esence something like this: if isinstance(f, file): pass elif isinstance(f, string): f = urllib.urlopen(f) else: raise "..." process_stream(f) -- http://mail.python.org/mailman/listinfo/python-list

cookielib

2007-08-10 Thread Boris Ozegovic
Hi I have HTTP client which accepts cookies. If client allready has cookie, but that cookie has expired, server sends him new cookie, and in response object Set-Cookie: header everything is fine, but if I reload request, client sends expired cookie, and not the new one. In cookiejar there is onl

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

  1   2   3   >