Re: Returning actual argument expression to a function call?

2007-11-10 Thread Piet van Oostrum
that for my application to work, >P> # Python newbies would have to write lambda when they >P> # know they are after the result. Its my program >P> # that would require the lambda (or def), which >P> # is a distraction from their problem. >P> Any ideas on imp

Re: security code whit python

2007-11-11 Thread Piet van Oostrum
hon\lib\pyx\dvifile.py", line 386, in >oc> readfontmap >oc> raise RuntimeError("cannot find font mapping file '%s'" % >oc> filename) >oc> RuntimeError: cannot find font mapping file 'psfonts.map' >oc> """ >oc> I have setuped pyx i wonder i have mistake? Do you have TeX installed? -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributed RVS, Darcs, tech love

2007-11-13 Thread Piet van Oostrum
be called just 'TeX' because these new versions contain extensions. So they get new names with 'tex' being part of their name. PdfTeX and LuaTeX are new versions that are being developed right now. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~pie

Re: why there is no pythonscript insine web browsers?

2007-11-14 Thread Piet van Oostrum
upport. it would be really nice and easy for me to use >>> python instead of javascript to write those ajax scripts. >>> >>> Please tell me, is there a python substitude for JRE ? >k> You can also use Python's cgi module. It's pretty cool, from what I&

Re: SOAPpy port reuse

2007-11-18 Thread Piet van Oostrum
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html or the Unix socket FAQ (http://www.faqs.org/faqs/unix-faq/socket/) 2.7 Normally the solution is to set the SO_REUSEADDR option in the socket (the original one) before binding it: s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) However, SOAP

Re: converting to and from octal escaped UTF--8

2007-12-04 Thread Piet van Oostrum
e long strings it would be better to use join. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: read lines

2007-12-04 Thread Piet van Oostrum
ives you only 1 item instead of 2. So add the following: if not line: break Also your choice for 0 as initial values of minimum and maximum isn't good. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL P

Re: Getting wxPython to work on a Mac

2007-12-05 Thread Piet van Oostrum
luding the MessageBox, on Tiger with python 2.5.1. I run the in Terminal (pythonw python_compare.py) both with and without your PYTHONPATH. How did you run the examples? -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: "Python" is not a good name, should rename to "Athon"

2007-12-05 Thread Piet van Oostrum
>>>>> "Adrian Cherry" <[EMAIL PROTECTED]> (AC) wrote: >AC> For that matter C# is no better, I thought that # was pronounced >AC> hash, I still refer to C# as C-hash. Are you musically illiterate? -- Piet van Oostrum <[EMAIL PROTECTED]> URL

Re: YOU MUST KNOW THIS MAN

2007-12-05 Thread Piet van Oostrum
>>>>> Deltantor <[EMAIL PROTECTED]> (D) wrote: >D> Does c.l.python get religious spam that much? Of all of the places to be >D> spammed the least likely I expected would be here. Is that the reason you find it necessary to repeat it? -- Piet van Oost

Re: "Python" is not a good name, should rename to "Athon"

2007-12-06 Thread Piet van Oostrum
>>>>> "Adrian Cherry" <[EMAIL PROTECTED]> (AC) wrote: >AC> Piet van Oostrum <[EMAIL PROTECTED]> wrote in >AC> news:[EMAIL PROTECTED]: >>>>>>>> "Adrian Cherry" <[EMAIL PROTECTED]> (AC) wrote: >>>

Re: Is Python really a scripting language?

2007-12-15 Thread Piet van Oostrum
spite >SD> the lack of JIT compilers. The above is not a description of the language but of an implementation. Albeit the currently major implementation. But it could be that in the future python would be compiled to machine code. That wouldn't change the language. -- Piet van Oostrum

Re: Is Python really a scripting language?

2007-12-15 Thread Piet van Oostrum
".pdf" >JN> file by invoking OpenOffice via CORBA. At least in theory, this is >JN> possible. All the necessary parts supposedly exist. Somebody >JN> tried back in 2003, but gave up. See >JN> "http://mail.python.org/pipermail/python-list/2003-April/198094.h

Re: Best way to protect my new commercial software.

2007-12-18 Thread Piet van Oostrum
anslation of the introduction of the law). Otherwise someone else could publish it if he got hold of it in some legitimate way. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to protect my new commercial software.

2007-12-19 Thread Piet van Oostrum
nobody dares copy them lest the >SD> unknown copyright owners descend like vultures and sue you for >SD> copyright infringement *after* you've done the hard work of restoring >SD> our cultural heritage. Our (Dutch) copyright law has a specific exemption for this particular cas

Re: convert pdf to png

2007-12-26 Thread Piet van Oostrum
nd read the PNG output back. However you must be aware that this can deadlock if the output is large enough. So putting the input or the output in a real file is probably safer anyway. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private emai

Re: Queue can result in nested monitor deadlock

2006-04-18 Thread Piet van Oostrum
ample M and the mutex for the Queue should be the same to solve the problem. And that the Queue API should allow you to do that. I think he is right. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Joining stdout & stderr of subprocess ?

2006-04-21 Thread Piet van Oostrum
How can I get ahold of all the out and err joined synchronously in the >R> order, it is created ? Make sure that myapp writes it synchronously. Probably myapp has it buffered, so it writes out at the end of the run. It is not caused by python. -- Piet van Oostrum <[EMAIL PROTECTED]&

Re: Passing data attributes as method parameters

2006-04-24 Thread Piet van Oostrum
class >PL> instantiation. What do you mean 'variables in the class namespace'? Which variable is in the class namespace? Please note that you can access variables in the class namespace: class MyClass: a = 10 b = 20 def my_method(self, param1=a, param2=b):

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-12 Thread Piet van Oostrum
rty of symbols but of values. So it doesn't make sense to declare an identifier to be immutable. And mutability is tied to the object's type, not to individual instances. What you want can only be obtained if Python would have an immutable variant for each type or would add an immuta

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-15 Thread Piet van Oostrum
>>>>> Edward Elliott <[EMAIL PROTECTED]> (EE) wrote: >EE> Piet van Oostrum wrote: >>>>>>>> [EMAIL PROTECTED] (T) wrote: >>> >T> As you can see, the "constant" A can be modified this easily. But if >T> there were a

Re: getattr for modules not classes

2006-05-24 Thread Piet van Oostrum
>>>>> Heiko Wundram <[EMAIL PROTECTED]> (HW) wrote: >HW> y.py >HW> --- >HW> from x import test >HW> print test.one >HW> print test.two >HW> print test.three >HW> --- Or even: import x x = x.test print x.one print x.two pr

Re: Request for comments on python distributed technologies

2006-05-25 Thread Piet van Oostrum
'm looking at XML-RPC, RPyC, >CJVA> CORBA, and Twisted. Although it doesn't cover exactly the technologies mentioned above the following article may be interesting for you: Python Web services developer: Messaging technologies compared http://www.ibm.com/developerworks

Re: getattr for modules not classes

2006-05-27 Thread Piet van Oostrum
>>>>> Heiko Wundram <[EMAIL PROTECTED]> (HW) schreef: >HW> from x import test as x >HW> print x.one >HW> print x.two >HW> print x.three Or replace test by x in x.py :=) -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PG

Re: pdf library.

2008-01-01 Thread Piet van Oostrum
o this ? AFAIK PDF doesn't have the concept of "Chapter". If the document has an outline, you could try to use the first level of that hierarchy as the chapter starting points. But you don't have a guarantee that they really are chapters. -- Piet van Oostrum <[EMAIL PROTEC

Re: different encodings for unicode() and u''.encode(), bug?

2008-01-02 Thread Piet van Oostrum
own encoding: mbcs >>>>> >M> Hmmn, strange. Same behaviour for "raboof". Apparently for the empty string the encoding is irrelevant as it will not be used. I guess there is an early check for this special case in the code. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Details about pythons set implementation

2008-01-04 Thread Piet van Oostrum
> bukzor <[EMAIL PROTECTED]> (B) wrote: >B> Why cant you implement < for complex numbers? Maybe I'm being naive, >B> but isn't this the normal definition? >B> a + bi < c + di iff sqrt(a**2 + b**2) < sqrt(c**2, d**2) There doesn't exist a `normal' definition of < for the complex numbers. F

Re: dictionary/hash and '1' versus 1

2008-01-08 Thread Piet van Oostrum
a toString method it is OK. This is special-cased in the compiler. It is defined in the language definition, not in the library definition. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: starting programs from python script on windows

2008-01-30 Thread Piet van Oostrum
>BV> import time >BV> print " Starting app 1" >BV> time.sleep(1) >BV> try: >BV> p1 = Popen(["C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE"], Use raw strings or escape the \'s. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http

Re: Unicode literals to latin-1

2008-01-30 Thread Piet van Oostrum
r\u00f8ya".decode('latin-1') >DR> but to no avail. You have to use encode instead of decode, and the input string must be a unicode string. >>> print u"Fr\u00f8ya".encode('latin-1') Frøya >>> -- Piet van Oostrum <[EMAIL PROTECTED]>

Re: Python-URL! - weekly Python news and links (Feb 18)

2008-02-27 Thread Piet van Oostrum
ompiler has performed the further smattering of semantically puny >GG> 'verifications' allowed by mandatory-declaration, stating-typing >GG> languages?" - Alex Martelli I couldn't find the original of this. I would like to see it in its context. Googling didn't reveal

Re: float / rounding question

2008-03-07 Thread Piet van Oostrum
is more than one representation that has this property. I would guess (but didn't check) that 53.6010001 also gives the same number. From all these representations it would be best to choose the simplest one, i.e. 53.6. This problem and a solution has been described in one

Re: Python-URL! - weekly Python news and links (Feb 18)

2008-03-10 Thread Piet van Oostrum
>>>>> Peter Otten <[EMAIL PROTECTED]> (PO) wrote: >PO> Piet van Oostrum wrote: >>>>>>>> "Gabriel Genellina" <[EMAIL PROTECTED]> (GG) wrote: >>> >GG> "Given this indispensable process and architecture issue

Re: float / rounding question

2008-03-10 Thread Piet van Oostrum
>>>>> Dennis Lee Bieber <[EMAIL PROTECTED]> (DLB) wrote: >DLB> On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum <[EMAIL PROTECTED]> >DLB> declaimed the following in comp.lang.python: >>> Sorry to come in so late in this discussion. Although

Re: execute python script question

2008-03-11 Thread Piet van Oostrum
will have to change the sys.path before the import, e.g. in your main program. Or do what is usually done: put MyPackage in the site-packages directory. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-03-12 Thread Piet van Oostrum
accuracy". >GG> A stopped clock shows the right time twice a day; a clock that loses one >GG> minute per day shows the right time once every two years. Clearly the >GG> stopped clock is much better! But if the answer is incorrect (in the float calculation) the error is limited. IEEE 754 prescribes that the error should be at most 1 LSB, IIRC. And then the number of errors is the proper measure. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no string return?

2008-03-12 Thread Piet van Oostrum
#x27;t test with `is' but with `=='. >g> return x >g> else: print "No String for you...False!" >g> def SendMethod(request): >g> xstring = "Some text" >g> ReturnMethod(request, xstring) >g> SendMethod(&

Re: Distributing simple tasks

2009-02-11 Thread Piet van Oostrum
nes, i.e give each machine half of the > slices and let it run them in threads as described above. Is there an > easy way, or an article on this matter you can point me to? Have a look at MapReduce (google for MapReduce Python). -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE1

Re: Inverse of dict(zip(x,y))

2009-03-04 Thread Piet van Oostrum
values() might also work, but I am not sure whether d.keys() and >AE> d.values() are guaranteed to use the same order. Yes, they are if the dictionary is not changed in the meantime (not even inserting and removing the same thing). See the library documentation, section dict. -- Piet v

Re: factory functions & methods

2009-03-11 Thread Piet van Oostrum
wobj = OtherType(arg) self.add(newobj) class SomeType(object): def __init__(self): pass class OtherType(SomeType): def __init__(self, arg): SomeType.__init__(self) self.x = arg cA = Container() obA = cA.SomeType() obB = cA.OtherType(5) print cA.items -- Piet van

Re: calling class methods from class methods, help?

2009-03-11 Thread Piet van Oostrum
27;] >O> for i in range(0,self.times): >O> for site in sites: >O> self.name = site >O> self.html=SendRequest() # This line throws an error self.html=self.SendRequest() -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Input data from .txt file and object array problem

2009-03-12 Thread Piet van Oostrum
en use objList.append(temp) here and objList = [] before the loop. >S> How can I do that? I am a beginner to Python. Any help would be >S> appreciated. You can use pickle to store the list is a file after reading. Something like (untested): imp

Re: How to find "in" in the documentation

2009-03-13 Thread Piet van Oostrum
; section but not a lot. It is explained in The Python Language Reference, chapter Expressions, section Comparisons. At least that's were it is in the 2.6 doc. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: SOAPpy help needed

2009-03-18 Thread Piet van Oostrum
e in different locations but that should not matter. The real differences are: 1. The order of the parameters is different. This could well be the problem if the server is not paying attention to the parameter names but only to the order. 2. The types are included in Python. this is the RPC.

Re: objectoriented -?- functional

2009-03-18 Thread Piet van Oostrum
made copies of the inner lists and these are the important ones. So the reverse will reverse the *original* inner lists which are both in ll and in l. If you still want to do destructive reverses on the inner list you should make a deep copy: >>> import copy >>> l = copy.deepcopy(

Re: Cannot allocate memory when using os.spawn for moving files

2009-03-18 Thread Piet van Oostrum
any processes running or you have too little swap space. Maybe you can have a `top' process running or run `ps' occasionally to see how many processes there are and how big they are. Moving files from a local file system to a network file system means copying and maybe the mv tries to copy the files in very large chunks. What you could do is to put the filenames in a work queue when your Fortran program has finished and run a separate thread that moves the files one by one. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Class methods read-only by default?

2009-04-03 Thread Piet van Oostrum
iptor#implementing-descriptors (Actually, IIRC, the function object is its own descriptor) >>> class C(object): ... def method(self): ... pass ... >>> c=C() >>> C.__dict__['method'] >>> C.__dict__['method'].__get__ >>> C.__dict

Re: How to go about. On read/write locks

2009-04-06 Thread Piet van Oostrum
before all other readers have finished. You need at least one more lock and probably a writer counter to solve this. 3. See also http://code.activestate.com/recipes/465156/ 4. The code has not been tested, not even for syntax errors. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: An executable operational semantics for Python

2009-04-06 Thread Piet van Oostrum
scription from Gideon's thesis, put it in a small Haskell program and now I can easily try it out. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to go about. On read/write locks

2009-04-07 Thread Piet van Oostrum
would be the natural >DBR> choice anyway) they can block the writer from writing alltogether. >DBR> Or do I miss something here? Yes, you missed note 2 at the end of my posting. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to go about. On read/write locks

2009-04-08 Thread Piet van Oostrum
nd “writers”, Communications of the ACM, v.14 n.10, p.667-668, Oct. 1971 [2] Jalal Kawash, Process Synchronization with Readers and Writers Revisited Journal of Computing and Information Technology - CIT 13, 2005, 1, 43–51 [3] http://pages.cs.wisc.edu/~haryadi/537/slides/lec18-semaphores.ppt [4] http://vorlon.case.edu/~jrh23/338/HW3.pdf -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: object cannot be interpreted as an index

2009-04-08 Thread Piet van Oostrum
>>>>> "tleeuwenb...@gmail.com" (tc) wrote: >tc> What, exactly, needs to be in place for an object to be a valid >tc> dictionary key? It must have __hash__ and __cmp__ or __eq__ methods. Newstyle classes inherit these from object. -- Piet van Oostrum

Re: Can't create list of dictionaries

2009-04-10 Thread Piet van Oostrum
tion is definately returning different dictionaries each >sn> time as I can see that when I print them. >sn> I know this is something to do with the dictionries being stored as >sn> references but I've no idea how to fix it seeing as the copy() >sn> function didn

Re: writing array

2009-04-10 Thread Piet van Oostrum
ke sense? Not much. As 1.1^2=1.21, I would think this would then take 2 datapoints, not 4. If you take at each step n = 1.1^n (rounded up) n will stay at 2 forever. And first you talk about rounding down, later about rounding up. So what is it. Maybe you should give a better specifica

Re: multiprocessing and Locks

2009-04-12 Thread Piet van Oostrum
k() pool = multiprocessing.Pool(processes=5) for i in xrange(100): pool.apply_async(func=RunFunc, args=(i,lock)) pool.close() pool.join() -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: read file with multiple data per line

2009-04-14 Thread Piet van Oostrum
len(line) == 30: f1 = float(line[0:10]) f2 = float(line[10:20]) f3 = float(line[20:30]) print f1,f2,f3 else: print("Sorry, I don't understand this format: %s" % line) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: design question, metaclasses?

2009-04-14 Thread Piet van Oostrum
gt; return "Group2" >DD> def _SubGroup(superclass): >DD> class SubGroup(superclass): >DD> pass >DD> return SubGroup >DD> SubGroup = _SubGroup(Group2) What is the difference of this with: class SubGroup(Group2): pass ? &

Re: any(), all() and empty iterable

2009-04-14 Thread Piet van Oostrum
MD> an exception. That is so because 'all' and 'any' are reduce (or fold) operations on the logical operations 'and' and 'or', respectively. And the reduce operation on an empty sequence should be the identity of the underlying operation. The identity of '

Re: Modifying the value of a float-like object

2009-04-15 Thread Piet van Oostrum
2 >>> x.value = -3.14 >>> print x -3.14 >>> sin(x) -0.0015926529164868282 >>> x + 1 -2.1401 >>> y = Float(7.0, 0.3) >>> print y 7.0 >>> x + y 3.8599 >>> If you write your own functions they might have to coerce your Float objects to real floats ocassionally by using float(param) instead of param. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrupt Python C API

2009-04-15 Thread Piet van Oostrum
ot; signal.signal(signal.SIGALRM, handler) def execute(command, timeout): signal.alarm(timeout); try: exec(command) except AlarmError, e: print e print 'Aborted "%s"' % (command,) print "continue work" print "The everlas

Re: Modifying the value of a float-like object

2009-04-15 Thread Piet van Oostrum
>>>>> eric.le.bi...@spectro.jussieu.fr (ELB) wrote: >ELB> To Dave A. and Piet: I appreciate your taking the time to make >ELB> suggestions. I understand that there is a hitch in the approach that >ELB> you describe, which I would like to insist on: how do yo

Re: Modifying the value of a float-like object

2009-04-15 Thread Piet van Oostrum
at is something Python does not support. That also would be very close to C++'s ref (&) parameters. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda alternative?

2009-04-15 Thread Piet van Oostrum
(only 6 chars more per def): def airdensity(T): return 10/(287*T) air=material(airdensity) def steeldensity(T): return interp(T,[0,1000],[7856,7813]) steel=material(steeldensity) def rockdensity(T): return 5000 rock=material(rockdensity) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrupt Python C API

2009-04-16 Thread Piet van Oostrum
nalcode) def execute(command, timeout): threading.Timer(timeout, interrupt).start() try: exec(command) except AlarmError, e: print e print 'Aborted "%s"' % (command,) print "continue work" print "The everlasting command"

Re: How to check all elements of a list are same or different

2009-04-16 Thread Piet van Oostrum
JM> @ OP: These are very reasonable interpretations of "all same" and "all >JM> different" but of course can both return False for the same input. They can even both return True for the same input! -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue() question. This post is pretty long.

2009-04-16 Thread Piet van Oostrum
g> is >g> a >g> test >g> done >g> [3]+ Stopped python >g> [cdal...@localhost ~]$ kill %3 >g> It appears that only item = queue.get() called. Ie, the block never >g> advances to if item == 'done': >g> like in the first e

Re: get text from rogramms runn by subprocess.Popen immediatetly

2009-04-17 Thread Piet van Oostrum
e programm finishes. Since the >RR> output of the programm is used to generate a progress indicator, I need >RR> a way to acces the values written to stdout/stderr as fast as possible. >RR> print p.stderr.read() Use p.stderr.readline() or p.stderr.read(1) in a loop. -- Piet va

Re: [Python-Dev] RELEASED Python 2.6.2

2009-04-17 Thread Piet van Oostrum
atsnew/2.6.html >BW> Source tarballs, Windows installers, and (soon) Mac OS X disk images can >BW> be downloaded from the Python 2.6.2 page: >BW> http://www.python.org/download/releases/2.6.2/ Maybe a link to the MacOSX image can also be added to http://www.python.or

Re: script question

2009-04-17 Thread Piet van Oostrum
t; import myscript >S> for i in range(1,n): >S>myscript.func?? Others have suggested getattr. I think a cleaner (more pythonic) way would be: funclist = [func01, func02, func03, ... ] for i in range(1,n): funclist[i]() Or myscript.funclist[i]() from another module. -

Re: cPickle and subclassing lists?

2009-04-17 Thread Piet van Oostrum
_init__(self,x) >R> and I cannot even get this to pickle right. >>>> w=Mylist([1,2,3]) >>>> dumps(w) >R> PicklingError: Can't pickle : attribute lookup >R> __main__.p fa >R> iled Where does the 'p' come from? What is w.__

Re: binary file compare...

2009-04-18 Thread Piet van Oostrum
ou just take two files, not fabricated to collide, the probability of them having the same hash under MD5 is 2**-128 which I think is way smaller than the probability of the bit representing the answer being swapped by some physical cause in your computer. But then again, it doesn't make sen

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-18 Thread Piet van Oostrum
__repaint() |t = time.time() |self._mod_lock.release() |print >> sys.stderr, "at loop end" |self._mod_lock.acquire() ` Your loop ends with self._mod_lock.acquire() but in the next round there is another self._mod_lock.acquire() at the

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-18 Thread Piet van Oostrum
it continues because the timeout has expired. >GG> Please file a bug report at http://bugs.python.org/ It is not a bug. I see the Hello World temporarily suspended and then continuing. That's how it should be. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-18 Thread Piet van Oostrum
>>>>> stephane.bisin...@gmail.com (SB) wrote: >SB> On Apr 18, 10:24 am, Piet van Oostrum wrote: >>> >>> I haven't run it (too much hassle to setup) but I noticed one strange >>> thing in your code: >>> >>> , >

Re: Overriding methods per-object

2009-04-18 Thread Piet van Oostrum
_special_object(list, [1,2,3]) >>> a [1, 2, 3] >>> a.__class__ >>> a.__class__.__nonzero__ = lambda self: False >>> bool(a) False >>> a.__nonzero__() False >>> a.append(4) >>> a [1, 2, 3, 4] >>> -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Variables vs attributes

2009-04-18 Thread Piet van Oostrum
ide that confusing >SD> variables and attributes of variables was a good thing? What's next, >SD> describing dictionary keys as "dictionary variables"? If you google for '"instance variable" python' you get quite a number of hits, not only recent ones.

Re: __getattribute__ for operators

2009-04-18 Thread Piet van Oostrum
gt;M> 6 >>>>> >M> Why doesn't "a + 2" look up the __add__ attribute and use my lambda? >M> If I manually define __add__(self, other) then "a + 2" will of course >M> use that method. This has just been discussed in the thread "Ov

Re: Any adv. in importing a module and some objects in the same module, into the same file?

2009-04-18 Thread Piet van Oostrum
line 1, in AttributeError: 'module' object has no attribute 'handlers' >>> import logging.handlers >>> logging.handlers >>> 'logging' is a package. The 'logging' module does not contain a definition of 'handlers' but there is a modul

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-19 Thread Piet van Oostrum
gtk in contact_list.py. Then it should work. By the way, I wonder why you need a timeout in your wait. I think the notifications should be sufficient to keep the gui updated. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-19 Thread Piet van Oostrum
; self.__repaint() t = time.time() But the timeout thing will continue after that, so you have a continuous polling loop which wastes some CPU time. I think what you want can be more easily achieved by doing a sleep(0.5) before the outer while loop, i.e. as the firs

Re: sorting two corresponding lists?

2009-04-23 Thread Piet van Oostrum
a list of pairs, but demonstrates the general idea. This will fail if there are duplicates in the items. And if we assume no duplicates the key doesn't need the k part: sorted_items = sorted(d.iteritems(), key=lambda (k,v): v) or from operator import itemgetter sorted_items = sorted(d.iteritem

Re: gethostbyname blocking

2009-04-23 Thread Piet van Oostrum
et from the second queue. The lookup thread could even do caching of the results if you often have to repeat the pings for thew same host. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression to capture model numbers

2009-04-23 Thread Piet van Oostrum
]+[-A-Za-z]|-+[0-9A-Za-z])[-0-9A-Za-z]*') >>> re.findall(obj, 'TestThis;1234;Test123AB-x') ['Test123AB-x'] Or you can use re.I and mention only one case of letters: obj = re.compile(r'(?:[a-z]+[-0-9]|[0-9]+[-a-z]|-+[0-9a-z])[-0-9a-z]*', re.I) -- Piet van

Re: Using optparse

2009-04-23 Thread Piet van Oostrum
to expect --PARAM1 and -- >L> PARAM2 See the doc: Some other option syntaxes that the world has seen include: [...] * a hyphen followed by a whole word, e.g. "-file" [...] These option syntaxes are not supported by optparse, and they never will be. -- Piet van Oostrum URL:

Re: Regular expression to capture model numbers

2009-04-24 Thread Piet van Oostrum
>>>>> John Machin (JM) wrote: >JM> On Apr 24, 1:29 am, Piet van Oostrum wrote: >>> obj = re.compile(r'(?:[a-z]+[-0-9]|[0-9]+[-a-z]|-+[0-9a-z])[-0-9a-z]*', >>> re.I) >JM> Understandable and maintainable, I don't think. Suppo

Re: best way to compare contents of 2 lists?

2009-04-24 Thread Piet van Oostrum
b = [2, 3+4j, 1] >>> set(a) == set(b) True >>> sorted(a)==sorted(b) Traceback (most recent call last): File "", line 1, in TypeError: no ordering relation is defined for complex numbers In Python 3 there are even more incomparable objects pairs. -- Piet van Oostrum URL

Re: getter and setter and list appends

2009-04-24 Thread Piet van Oostrum
_children = obj What is the added value of using a property for the children attribute? Why not just use an instance variable directly? Also a Java inheritance? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert numpy.ndarray into "normal" array

2009-04-24 Thread Piet van Oostrum
eases of pygtk are still built with Numeric instead of numpy. In SVN it has been converted to use Numpy instead, so then type(pb_pixels) would also be 'numpy.ndarray' and no conversion would be necessary. So try to install the version from SVN. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Piet van Oostrum
ntain Vla >SD> What's wrong with that? Missing ')' or better spurious '(' :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: getter and setter and list appends

2009-04-24 Thread Piet van Oostrum
rom the parent (becoming its own parent) as a gui event. Oh, I saw that in the parent setter but not in the children setter. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python servlet for Java applet ?

2009-04-24 Thread Piet van Oostrum
lready do this by default because they are based on HTTP). >L> How does it work compared to a Java servlet with a Java applet ? With a Java applet communicating with a Java servlet you also have the option of using RMI. For the rest it is similar. -- Piet van Oostrum URL: http://pietvanoos

Re: Thread lag

2009-04-25 Thread Piet van Oostrum
>A> start" is printed, there is sometimes (it vary a lot) several seconds. >A> How could it be? Why thread is not started instantly? How can I improve >A> that? I don't know if it is related to our problem but I guess it is. It appears that GTK and Python threads

Re: Lisp mentality vs. Python mentality

2009-04-26 Thread Piet van Oostrum
>>>>> "Ciprian Dorin, Craciun" (CDC) wrote: >CDC> About the compare (a, b, operator.lt) it does the same as a < b, >CDC> where a and b are lists of numbers. >>> a=[1, 2, 3] >>> b=[1, 2, 4] >>> compare (a, b,

Re: Python servlet for Java applet ?

2009-04-30 Thread Piet van Oostrum
>>>>> Linuxguy123 (L) wrote: >L> On Sat, 2009-04-25 at 02:00 +0200, Piet van Oostrum wrote: >>> >>>>> Linuxguy123 (L) wrote: >>> >>> >L> Hi guys. >>> >L> Is there a way to use a python application as the

Re: Python servlet for Java applet ?

2009-04-30 Thread Piet van Oostrum
our original post you wanted RPC. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 Install on OSX Server 10.5: lWhich flag to use in "configure" to Change the Install location?

2009-04-30 Thread Piet van Oostrum
he install >O> location to be here: >O> /System/Library/Frameworks/Python.framework/ That's a good recipe to ruin your system software. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Which flag to use in "configure" to Change the Install location?

2009-04-30 Thread Piet van Oostrum
> be here: >O> /System/Library/Frameworks/Python.framework/ >O> Do I need to use the "--libdir" flag? Or is that referring to "lib" >O> not "Library"? Why do you ask the same question twice, and with different subjects? This makes answering diffi

Re: subprocess & shared environments

2009-05-01 Thread Piet van Oostrum
urce, parse it and extract the environment variables from it. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing Pool and functions with many arguments

2009-05-01 Thread Piet van Oostrum
ults: results = [pool.apply_async(f, a) for a in args] print [r.get() for r in results] Now the calls to f are done in parallel, which you can check by putting a sleep inside f. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: string processing question

2009-05-01 Thread Piet van Oostrum
n Emacs I get: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) because my Emacs doesn't pass the encoding of its terminal emulation. However: python -c '# -*- coding:utf-8 -*- print len(u"ä")' will correctly print 1. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   >