Re: Notebook Ariel

2009-05-01 Thread Piet van Oostrum
>>>>> Gabriel Genellina (GG) escribió: >GG> Hola >GG> La notebook de Ariel esta en el placard, atrás de Walter. ¿Quién es Walter y dónde esta? :=( -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- htt

Re: urllib2 and threading

2009-05-01 Thread Piet van Oostrum
TPError (like a 404 File not found) it will be caught by the "except URLError", but it will not have a reason attribute, and then you get an exception in the except clause and the thread will crash. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: writing consecutive data to subprocess command 'more'

2009-05-02 Thread Piet van Oostrum
ast line, stdout should come out empty because the output of more doesn't come back to the parent process, but goes to the original stdout of the calling script. Also I would use the following: viewer = ['more', '-EMR'] proc = subprocess.Popen(viewer, stdin=subproce

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Piet van Oostrum
) >AJ>for thread in THREADS: >AJ>thread.run() You should use thread.start(), not thread.run(). When you use run(), it will be sequential execution, as you experience. With start() you get concurrency -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17

Re: Is there is any way to send messages to chunk of emails ID's concurrently using smptlib

2009-05-04 Thread Piet van Oostrum
>>>>> gganesh (g) wrote: >g> Hi friends, >g> I suppose sendmail() can send mails one by one ,how to send mails >g> concurrently , >g> It would be very grateful,if someone could point out a solution. There is a discussion about this in the thread `Threaded

Re: problem in using sendmail in multi thread

2009-05-05 Thread Piet van Oostrum
As I said above you should do the SMTP connection setup, including the login, here, and store the connection either in self.s or in a local variable s in the method. As you don't use the s in another method, I think a local variable is better. >g> print "Emailed for site %s&quo

Re: Error in running python -v on Mac ox 10.5.

2009-05-05 Thread Piet van Oostrum
#x27; message' when i run 'python - >s> v'? I don't think I see that many >s> install message on linux. I don't see 'install' messages in the included text. >s> Here is the full message. Thanks for any help. [deleted] -- Piet van Oostrum UR

Re: object query assigned variable name?

2009-05-06 Thread Piet van Oostrum
D_CONST 3 (1) 28 ROT_TWO 29 STORE_FAST 1 (brian) 32 STORE_FAST 2 (test) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Piet van Oostrum
>L> arguments? How can I do it? cls.__init__.im_func.__code__.co_argcount This will include self, so it will be 1 in First and 2 in Second. However this is very dirty trickery and should not be recommended. It may also change in future versions and other implementations of Python. I thin

Re: Checking for required arguments when instantiating class.

2009-05-07 Thread Piet van Oostrum
>>>>> Chris Rebert (CR) wrote: >CR> On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum wrote: >>>>>>>> Lacrima (L) wrote: >L> But what if I have to instantiate any class with 3 or 4 required >L> arguments? How can I do it? >>>

Re: Unable to build libpython2.5.so on OS X 10.4

2009-05-07 Thread Piet van Oostrum
derstand, but if you are trying to build a C extension >>> for an existing Python 2.5 installation, using Distutils from that >>> installation should take care of everything for you.  Is there a >>> setup.py file by any chance?  Are you using a standard python &g

Re: SimpleXMLRPCServer and creating a new object on for each new client request.

2009-05-07 Thread Piet van Oostrum
a function that creates a new instance on every call. But as Martin P. Hellwig has noted, it wouldn't give you sessions anyway. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXMLRPCServer and creating a new object on for each new client request.

2009-05-08 Thread Piet van Oostrum
is no advantage in having two of them instead of one. And the name session is misleading. Please note also that XMLRPC isn't object-oriented. There is just the server; in the protocol there are no objects other than the server. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXMLRPCServer and creating a new object on for each new client request.

2009-05-08 Thread Piet van Oostrum
>>>>> Piet van Oostrum (PvO) wrote: >>>>> Jelle Smet (JS) wrote: >PvO> One more thing: >JS> I start python interactively: >>>>> import xmlrpclib >>>>> session1=xmlrpclib.ServerProxy('http://localhost:8000')

Re: Simple programme - Just want to know whether this is correct way of coding

2009-05-08 Thread Piet van Oostrum
econd, the mail server probably doesn't like it that you make such a large number of connections simultaneously. If the mail server doesn't protest, probably its systems administrator will. Moreover there is probably no benefit in having 1000 connections open to the same mail server because long before there will be another bottleneck such as your network connection or the CPU load of either your computer or the mail server, unless you are on a very scalable infrastructure. A better solution will be to use a Thread Pool with a limited number of simultaneous threads (my guess is that 10-20 or so would be good enough). And as I said to my students yesterday: You shouldn't program multithreaded applications unless you have studied this subject thoroughly. Of course I don't know how this applies to you. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-08 Thread Piet van Oostrum
ing should be chosen when the string goes to the output channel, i.e. outside of the object. Unfortunately this is one of the leftovers from Python's pre-unicode heritage. Hopefully in Python3 this will work without problems. Anyway, in Python 3 the string type is unicode, so at least __repr__ can return unicode. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
>>>>> "anuraguni...@yahoo.com" (ac) a écrit: >ac> also not sure why (python 2.5) >ac> print a # works >ac> print unicode(a) # works >ac> print [a] # works >ac> print unicode([a]) # doesn't works Which code do you use now? And what doe

Re: ANN: Python process utility (psutil) 0.1.2 released

2009-05-09 Thread Piet van Oostrum
ctually virtual memory size of the process) when your announcement came along. Fortunately I had not yet started writing the code :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Thread locking question.

2009-05-09 Thread Piet van Oostrum
r 4 sites have to wait >gs> for the thread to release the lock? No. Where does it set a lock? There is only a short lock period in the queue when an item is put in the queue or got from the queue. And of course we have the GIL, but this is released as soon as a long during operation is started - in this case when the Internet communication is done. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
It does not depend on the source code's encoding (supposing that the encoding declaration in the source is correct). repr returns unicode(self).encode("utf-8"), so it is utf-8 encoded even when the source code had a different encoding. The u"©au" string is not dependent on the source encoding. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Thread locking question.

2009-05-09 Thread Piet van Oostrum
e) t.start() threads.append(t) ... for t in threads: t.join() Or just don't make them daemonic. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXMLRPCServer and creating a new object on for each new client request.

2009-05-09 Thread Piet van Oostrum
.ServerProxy(URL_PORT) print(SESSION.show_random()) print(SESSION.show_random()) SESSION.shutdown_service() -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
>>>>> "anuraguni...@yahoo.com" (ac) wrote: >ac> and yes replace string by u'\N{COPYRIGHT SIGN}au' >ac> as mentioned earlier non-ascii char may not come correct posted here. That shouldn't be a problem for any decent new agent when there is a

Re: xml in python

2009-05-10 Thread Piet van Oostrum
d modules are listed on http://docs.python.org/library/. >SM> import xml.dom.minidom as minidom These days ElementTree is considered the most pythonic way. http://docs.python.org/library/xml.etree.elementtree.html There is also a reimplementation of the ElementTree API based on libxml2 and

Re: import overwrites __name__

2009-05-10 Thread Piet van Oostrum
;t do**. There are now two namespaces: one for __main__ and one for x. These are distinct and have no relationship. The reason that the first number is 119 and the second is 117 is that while importing x the variables a and b are not created. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: import overwrites __name__

2009-05-10 Thread Piet van Oostrum
>>>>> Peter Otten <__pete...@web.de> (PO) wrote: >PO> Piet van Oostrum wrote: >>> >>> This is perfectly normal. >PO> I'm not 100% sure of that. Why not? >PO> Just in case you didn't notice: I'm not the OP. The above p

Re: Wrapping comments

2009-05-12 Thread Piet van Oostrum
>LD> I tried using Emacs via SSH from a Mac once. Made me run screaming for the >LD> nearest Windows box The standard Windows box doesn't even have SSH AFAIK. I edit remote files on my local Emacs on Mac OS X with tramp, certainly when they are on a SSH-accessible machine. Works like

Re: Representing a Tree in Python

2009-05-13 Thread Piet van Oostrum
o a >g> tree?. And what is the best way to represent a tree in Python?. http://networkx.lanl.gov/ has all kinds of Dijkstra's algorithms. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Nimrod programming language

2009-05-14 Thread Piet van Oostrum
not have seen it, but Fortran and Algol 60 belong to that category. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributed locking

2009-05-14 Thread Piet van Oostrum
hich might well fit your requirements. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: SOAPpy(10060, 'Operation timed out')

2009-05-15 Thread Piet van Oostrum
27;s firewall blocks SOAP calls? maybe you should ask your network manager. I used this example in my last lectures and it worked also today: from SOAPpy import SOAPProxy url = "http://xurrency.com/servidor_soap.php"; namespace = "http://xurrency.com/api.wsdl"; server = SOAP

Re: Help with Tkinter on OS X --- driving me insane!

2009-05-17 Thread Piet van Oostrum
elded >EG> results ranging from suggestions it has been fixed (not for me) to >EG> recommendations that the user rebuild python against a newer version >EG> of libtk (which I have no idea how to do). >EG> I would greatly appreciate any assistance the communit

Re: strip char from list of strings

2009-05-19 Thread Piet van Oostrum
e is a matter of taste. You can do some timing experiments yourself to see if there are significant differences, but I wouldn't expect so. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a better way to chose a slice of a list?

2009-05-20 Thread Piet van Oostrum
not isinstance(stop, int): stop = self.index(stop) return list.__getitem__(self, slice(start,stop)) return list.__getitem__(self, indx) week = KeyList(['sun','mon','tue','wed','thu','fri','sat'

Re: Background subprocess help?

2009-05-24 Thread Piet van Oostrum
IPE pid = os.fork() if pid == 0: # child code p1 = Popen(["sleep", "10"], stdout=PIPE) p2 = Popen(["mail", "-s", "test", "dans"], stdin=p1.stdout) os._exit(0) You could use: os._exit(os.waitpid(p2.pid, 0)[1]) but as you don't wait for the child the actual exit status code is useless. On Windows there is no fork(), therefore you would have to spawn a separate Python program that only does the body of the if. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython gurus, please help

2009-05-24 Thread Piet van Oostrum
w do you think that anybody will be able to divine what is happening? http://catb.org/esr/faqs/smart-questions.html -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help

2009-05-24 Thread Piet van Oostrum
without correction.I think it didn't enter the method or >a> any method above the gui. >a> Please if you have any information,inform me You don't call correct() or textcorrect() anywhere in your GUI code. I think instead of self.res= words(self.string) you should call one of these. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help

2009-05-25 Thread Piet van Oostrum
o give it a self parameter. The same applies to the other methods, so in textcorrect you have to call self.correct(i) and give correct a self parameter. etc. Or you make them all static methods and use Ex3.textcorrect(). I don't think putting all the methods in a class is a good ide

Re: Can I get a technical explanation on the following error

2009-05-25 Thread Piet van Oostrum
, a raw string cannot have a backslash as >JG> its last character. Cannot have an odd number of backslashes as its last characters. >>> print r'test \\' test \\ -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: What text editor is everyone using for Python

2009-05-26 Thread Piet van Oostrum
>>>>> Esmail (E) wrote: >E> LittleGrasshopper wrote: >>> >>> So what do you guys use, and why? Hopefully we can keep this civil. >E> I use Emacs, just because I have been using this editor for >E> all sorts of things in the last 20+ years. M

Re: multiprocessing / forking memory usage

2009-05-26 Thread Piet van Oostrum
te as much in the child as you can, for example by del wx; del sys.modules['wx'] etc, delete all variables that you don't need, and hope the garbage collector will clean up enough. But it will make you application quite complicated. From the python level you can't get rid of loa

Re: pyparsing question: single word values with a double quoted string every once in a while

2009-05-27 Thread Piet van Oostrum
or quotes ? Use the MatchFirst (|) I have also split it up to make it more readable kw = Word(alphas + "+_-.").setResultsName("keyword") eq = Suppress(Literal ("=")) value = dblQuotedString | Optional(Word(printables)) pattern = Group(kw + eq + value) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing problem with producer/consumer

2009-05-27 Thread Piet van Oostrum
y to stop the >WZ> HTTP server gracefully? In don't think it is useful to put the HTTP server in its own process as the Manager process has hardly anything to do. But if you do you can make it wait by doing the join of the worker processes at the end, instead of inside the stop().

Re: what I would like python.el to do (and maybe it does)

2009-05-28 Thread Piet van Oostrum
as >JKK> usual. I never get any feedback. Just C-x o to the interpreter and >JKK> print out the variable you just defined. It should be there. What kind of feedback do you expect? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, Tkinter and popen problem

2009-05-29 Thread Piet van Oostrum
s that you wanted to solve. Maybe you are dyslectic or something similar, in which case I apologize. But anyway, I think you should learn to express yourself more clearly. There are also courses for that. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Global variables from a class

2009-05-29 Thread Piet van Oostrum
ces use the same value 'lala' but some need 'lele' or sometime later in the life of the instance the value will be changed to 'lele' class Bletch: var = 'lala' def update(self): self.var = 'lele' In this case it is a matter of taste w

Re: Parsing DTDs

2009-05-29 Thread Piet van Oostrum
that PyXML is no longer maintained. >TA> Is there a DTD parser that is being maintained? Or does it not really >TA> matter that PyXML is no longer maintained, given that it's not like the DTD >TA> spec has changed very much? http://codespeak.net/lxml/validation.html#dtd -

Re: CRLF when doing os.system("ls -l") while using curses !!!

2009-05-29 Thread Piet van Oostrum
the curses screen with addstr. But a curses screen has a limited length, whereas your ls -l output may be larger so then you must implement some form of scrolling. >l> import curses, os >l> screen = curses.initscr() >l> os.system("ls -l") >l> curses.endwin() --

Re: Python, Tkinter and popen problem

2009-05-30 Thread Piet van Oostrum
>>>>> norseman (n) wrote: >n> Piet van Oostrum wrote: >>>>>>>> norseman (n) wrote: >>> >n> I have tried both and Popen2.popen2(). >n> os.popen runs both way, contrary to docs. >>> >>> What do you mean `os.p

Re: MySQLdb 1.2.2 + python 2.6.2

2009-05-30 Thread Piet van Oostrum
ease candidate http://sourceforge.net/project/showfiles.php?group_id=22307&package_id=34790&release_id=672239 -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: CRLF when doing os.system("ls -l") while using curses !!!

2009-05-30 Thread Piet van Oostrum
t;PLEASE HIT RETURN FOR NEXT SCREEN OR q TO STOP") screen.refresh() key = screen.getkey() if key.lower() == 'q': break else: # end of listing reached screen.addstr(height-1, 0, "** END OF LISTING ** HIT RETURN") screen.re

Re: hash and __eq__

2009-05-30 Thread Piet van Oostrum
eys in the `bucket' that belongs to the hash value. The average complexity of looking up a key is O(1). See http://wiki.python.org/moin/DictionaryKeys -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: hash and __eq__

2009-05-30 Thread Piet van Oostrum
>>>>> Arnaud Delobelle (AD) wrote: >AD> Piet van Oostrum writes: >>>>>>>> Aaron Brady (AB) wrote: >>> >AB> I am writing a mapping object, and I want to ask about the details of >AB> __hash__ and __eq__. IIUC if I understan

Re: what I would like python.el to do (and maybe it does)

2009-06-01 Thread Piet van Oostrum
in my Python mode such that the ## working on region in file /tmp/python-26084kfr.py... message will be replaced by the actual code executed, if that code is not too big (size configurable). And that looks nicer. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple metaclass code failing

2009-06-01 Thread Piet van Oostrum
ssues. But I'll read the paper to figure out what >L> the problem is, thanks. Here is exactly the problem. Merging the two MRO's as you state would give C3, C2, C1, object, i.e. C2 before C1. But your class definition: class C3(C1, C2): says that C1 should be before C2. Conflict!! Change it to class C3(C2, C1): You see it has nothing to do with the metaclasses. The following code gives the same error: class C1(object): pass class C2(C1): pass class C3(C1, C2): pass -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple metaclass code failing

2009-06-01 Thread Piet van Oostrum
>>>>> Piet van Oostrum (I) wrote: >I> But your class definition: >I> class C3(C1, C2): >I> says that C1 should be before C2. Conflict!! >I> Change it to class C3(C2, C1): Of course the C1 is then superfluous. I wonder why you want this. What is the pro

Re: Terminate a python script from linux shell / bash script

2008-07-10 Thread Piet van Oostrum
here a way from the Linux shell or a bash script to terminate >GB> just one specific Python script ? So just kill it. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Terminate a python script from linux shell / bash script

2008-07-10 Thread Piet van Oostrum
ript in bash (or any other process for that matter) in the background you can get the process id (pid) with $! (immediately after starting the process). Later on you can use this to kill the process: python myscript myargs & savepid=$! later: kill $savepid That is much better than trying t

Re: The Importance of Terminology's Quality

2008-08-21 Thread Piet van Oostrum
he location that the instruction referenced and then jumped to the address following that location. To implement a recursive procedure you started the code of the procedure with saving the return address to a stack. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Which GUI toolkit is THE best?

2006-03-22 Thread Piet van Oostrum
it for PyGTK. But AFAIK GTK doesn't have a native implementation on the Mac, only X11. At least not in a stable version. -- 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: How to inplement Session in CGI

2006-03-28 Thread Piet van Oostrum
http://starship.python.net/~davem/cgifaq/faqw.cgi?req=show&file=faq02.011.htp or google for python cgi session for more. But why write it yourself if someone else has already done the work? -- 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 2.5 licensing: stop this change

2006-04-01 Thread Piet van Oostrum
tandard >F> CPython as an executable, using tools like py2exe, won't be covered. >F> Right ? As I understand it, distributing Python is also covered. For a commercial vendor $1.25 is peanuts, but for the PSA it is a significant amount (think about all the Mac OSX copies if Apple

Re: any() and all() on empty list?

2006-04-10 Thread Piet van Oostrum
) tally([line[0] in vowels for line in f]) >SRH> # counts is a dict; counts.keys() == [False, True] No guarantee about the order. It could be [True, False]. >SRH> count_nonvowels, count_vowels = counts.values() So you must use counts[False] and counts[True]. -- Piet van Oostrum <[E

Re: Most "active" coroutine library project?

2009-09-27 Thread Piet van Oostrum
>>>>> Grant Edwards (GE) wrote: >GE> On 2009-09-25, Piet van Oostrum wrote: >>>>>>>> exar...@twistedmatrix.com (e) wrote: >>> >e> I specifically left out all "yield" statements in my version, since that's >e&g

Re: os.listdir unwanted behaviour

2009-09-29 Thread Piet van Oostrum
ecked Python 3.1.) He's not using Python3, see the print statement and the file function. But even with the appropriate changes the behaviour will be the same in 3.1 as in 2.x. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: print object attributes recursively

2009-09-30 Thread Piet van Oostrum
= [X(x) for x in xrange(0, n)] >l> t = Y(5) >l> How can I easily print "t" and all its nested attributes? (Something like >l> PHP's print_r()) I don't know what print_r does, but in your example above print [x.L for x in t.M] would work. Probably

Re: Cannot get POST to work

2009-09-30 Thread Piet van Oostrum
onn.request("POST", "/programming/bots/test.php", "ted=fred", headers) >t> r1 = conn.getresponse() >t> print r1.status, r1.reason >t> data1 = r1.read() >t> print data1 >t> conn.close() >t> print "new ok" >t> The PHP script is >t> print"hello "; >t> print $_POST["ted"]; >t> Ted post -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode issue

2009-09-30 Thread Piet van Oostrum
haracters won't be representable in latin-1. The reason it worked is that these characters were translated into two- or more-bytes sequences and replace did work with these. But it's dangerous, as they are then no longer the unicode characters they were intended to be. -- Piet van Oostrum

Re: unicode issue

2009-09-30 Thread Piet van Oostrum
a place. Usually utf-8 is a safe bet but in some cases can be overkill. And then in you Python input/output (read/write) you may have to use a different encoding if the programs that you have to communicate with expect something different. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-03 Thread Piet van Oostrum
nd the issue and how to get over? How did you post the data? If you post binary data you should indicate this with a proper mime type, like application/octet-stream. Otherwise it might be interpreted as text which it isn't. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: Calendar yr-mnth-day data to day since data

2009-10-03 Thread Piet van Oostrum
be since 1969-12-31, or since 1970-1-1 but then starting with 1 instead of 0. And your 59 is wrong if the others are deemed to be correct. Depending on what you want you have to add 1 to the following solution import datetime startdate = datetime.date(1970, 1, 1) enddate = datetime.date(197

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread Piet van Oostrum
>>>>> greg (g) wrote: >g> MRAB wrote: >>> And when someone says "January 30", do they really mean the day before >>> the last day of the month? >g> No, no, that's January -2, a *completely* different thing! But for someone e

Re: Form Value Won't Post/Submit

2009-10-13 Thread Piet van Oostrum
x27;creator_badge_index': '1', 'token': '92dcd92a8bc16f73f330d118ae1ed891', 'do-grant': '1', 'grant-userid' : 'Guest_xLolKittyx', } params = urllib.parse.urlencode(paramdict) url = 'http://www.imvu.com/catalog/web_manage_badges.php' form = urllib.request.OpenerDirector.open(url, params) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-13 Thread Piet van Oostrum
>z> ... >z> Any ideas? CGI scripts return stuff by printing it, or more generally writing to stdout. So print message should do. The rest is not a Python question but a Javascript question. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-arrays python

2009-10-14 Thread Piet van Oostrum
ewline, or is it a backslash followed by 'n'? In the first case then every filename is on a separate line. So then you are mixing two concepts of line. Anyhow you would make your life easier by getting rid of the \n's. If all your filenames are numeric with the extension mp3 then the following gives you a list of the filenames from a line: In [31]: re.findall('[0-9]+\.mp3', line) Out[31]: ['100.mp3', '10008.mp3', '10005.mp3', '10001.mp3', '10006.mp3'] -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check the exists of a name?

2009-10-19 Thread Piet van Oostrum
use I solve my problem in another way :-) >D> locals().has_key(myname) >D> globals().has_key(myname) 1. This excludes builtins. The OP says: `no matter where is it', so that suggests also builins. 2. The more modern invocation would be "myname in locals()" or "mynam

Re: Ideas for creating processes

2010-03-13 Thread Piet van Oostrum
x27;t wait for them. You can only wait for the shell that starts the rsync, but that will be finished almost immediately. >>> import subprocess >>> p = subprocess.Popen('sleep 1000 &', shell=True) >>> p.wait() 0 >>> The wait() returns imm

Re: os.walk restart

2010-03-31 Thread Piet van Oostrum
ogram newlog.write(root) newlog.flush() -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] Nu Fair Trade woonwaar op http://www.zylja.com -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess only good for win32?

2010-04-01 Thread Piet van Oostrum
="win32". You can check that subprocess is working, e.g. with subprocess.call('dir', shell=True) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] Nu Fair Trade woonwaar op http://www.zylja.com -- http://mail.python.org/mailman/listinfo/python-list

Re: strange TypeError exception in function compiled from a string

2010-12-02 Thread Piet van Oostrum
nelson writes: > Hi all, > I have this function, defined in a string and ecetuted through ad > exec call > > def cell1(d): > > x=d.get('x') > print x > > import y > return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x)) > Wha

Re: string find/replace

2010-12-02 Thread Piet van Oostrum
Carlo writes: > On 2010-12-01, Peter Otten <__pete...@web.de> wrote: >>>>> import re >>>>> re.compile("([a-z])([A-Z])").sub(r"\1 \2", "camelCase") >> 'camel Case' > > Very simple if you know it. Thank you!

Re: Unicode thing that causes a traceback in 2.6 and 2.7 but not in 2.5, and only when writing to a pipe, not to the terminal

2010-12-02 Thread Piet van Oostrum
ep everything in byte strings your problem may disappear. In Python 3 you have to do this explicitely as the default is unicode. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] Nu Fair Trade woonartikelen op http://www.zylja.com -- http://mail.python.org/mailman/listinfo/python-list

Re: default behavior

2010-12-07 Thread Piet van Oostrum
Steven D'Aprano writes: > You don't need the space between strings and the attribute access: > "1".zfill(2) is fine. You only need it for numbers, due to the ambiguity > between the decimal point and dotted attribute access. Personally I prefer parentheses: (1).c

Re: Which non SQL Database ?

2011-02-13 Thread Piet van Oostrum
For non-SQL you could look into Kyoto Cabinet, which is Berkeley DB-like. Or ZODB which is a Python Object databes. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] Nu Fair Trade woonartikelen op http://www.zylja.com -- http://mail.python.org/mailman/listinfo

Re: return an object of a different class

2011-02-19 Thread Piet van Oostrum
return object.__new__(cls, n) But you have to be aware that the initializers are not called in this way. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] Nu Fair Trade woonartikelen op http://www.zylja.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Is reduce() foldl() or foldr()?

2009-06-07 Thread Piet van Oostrum
1.0, 2.0, 3.0]) >TN> 0.1 >TN> which looks like a left fold to me. Yes, see the Haskell result: Prelude> foldl (/) 1.0 [1.0, 2.0, 3.0] 0.1 Prelude> foldr (/) 1.0 [1.0, 2.0, 3.0] 1.5 -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142B

Re: multi-core software

2009-06-08 Thread Piet van Oostrum
n a way that retains scalability and avoids deadlock and data races. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: multi-core software

2009-06-08 Thread Piet van Oostrum
>>>>> Seamus MacRae (SM) wrote: >SM> Piet van Oostrum wrote: >>> By the way, there is a series of articles about concurrency on ACM Queue >>> which may be interesting for those participating in or just following >>> this discussion: >

Re: Unbound Method Error

2009-06-09 Thread Piet van Oostrum
o a staticmethod would be preferable: class Funcoes: @staticmethod def CifradorDeCesar(self, mensagem, chave, funcao): But as been mentioned in this thread before, there might be no reason to use the class anyway. The next thing you will run into is that you call CifradorDeCesar with an

Re: Unbound Method Error

2009-06-09 Thread Piet van Oostrum
>>>>> "Enrico" <4...@755189.45> (E) wrote: >E> "Piet van Oostrum" ha scritto nel messaggio >E> news:m2ljo1ajnx@cs.uu.nl... >>> The method doesn't need the class at all, so a staticmethod would be >>> preferable:

Re: How should I compare two txt files separately coming from windows/dos and linux/unix

2009-06-12 Thread Piet van Oostrum
can perfectly work, and I >h> think it is definitely to report this as a bug to Python.org as you >h> say. Filecmp does a binary compare, not a text compare. So it starts by comparing the sizes of the files and if they are different the files must be different. If equal it compares the bytes by reading large blocks. Comparing text files would be quite different especially when ignoring line separators. Maybe comparing text files should be added as a new feature. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How should I compare two txt files separately coming from windows/dos and linux/unix

2009-06-13 Thread Piet van Oostrum
just wanted to know whether two files were equal, not what the differences would be. In that case difflib is overkill. On the other hand `equal' has many meanings. Ignoring line endings is one option, ignoring trailing whitespace could be another one. Yet another one could be normalizing t

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-13 Thread Piet van Oostrum
NR> not help. The exact time of the destruction of objects is an implementation detail and should not be relied upon. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about None

2009-06-13 Thread Piet van Oostrum
n None and Nothing, except for the type system. Java, on the other hand does have static typing but does not have disjoint sums. So they have not much choice but to put null in every class-based type. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Piet van Oostrum
these the most idiomatically pythonic forms? Or am I missing >k> something better? Do it yourself: class MyList(list): def __getitem__(self, indx): if isinstance (indx, tuple): return [self[i] for i in indx] else: return list.__getitem__(self

Re: Question about None

2009-06-14 Thread Piet van Oostrum
>>>>> John Yeung (JY) wrote: >JY> I've never heard a mathematician use the term "bottom". It certainly >JY> could be that I just haven't talked to the right types of >JY> mathematicians. "Bottom" is a term from lattice theory, wh

Re: Input problem

2009-06-16 Thread Piet van Oostrum
eger in not entered,in that case how are they different? >>> z=eval(raw_input()) 3+4 >>> z 7 >>> z=int(raw_input()) 3+4 Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '3+4'

Re: PSP Text Editor

2009-06-16 Thread Piet van Oostrum
r. Therefore it should use client-side scripting (which probably means Javascript or flash (shudder!)) Including that in a PSP web page isn't so much different from its inclusion in any other framework. You must just choose one of the existing editors. -- Piet van Oostrum URL: http://pietvanoostrum.

Re: PSP Text Editor

2009-06-16 Thread Piet van Oostrum
Reading your question again I think I have probably misunderstood it. You want to an editor to edit Python Server Pages? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behavior with os.system

2009-06-16 Thread Piet van Oostrum
program? In that case you shouldn't call ./sort as it is in argv[0], but just sort (assuming '.' is not in your PATH) or the full path, like /usr/bin/sort. -- 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   >