Colorado Python seminar in November
Just a reminder that the Fall 2006 Colorado Python seminar is now less than 2 months away. Space is limited, so plan now to come join us for a week of in-depth Python training in the Colorado Rockies. For details, please see the original announcement below. Mark Lutz's Python Training Services is pleased to announce that our Fall 2006 public Colorado seminar is now open. This 5-day Python training event will be held November 6 through November 10. This year, our Fall seminar will be held at Historic Crag's Lodge, a resort in Estes Park, Colorado. Estes Park is a mountain town 80 miles from Denver's airport, and gateway to Rocky Mountain National Park. This in an all-inclusive event. Come spend 5 days mastering Python in the beautiful Colorado Rockies, and let us handle the details of your visit. We will be providing students with rooms at the resort, three full meals per day, a guided sightseeing tour, shuttle service to and from the Denver airport, and our new Snake Charmers T-shirt. Besides the included amenities, the extended format of this session will allow for in-depth coverage of class topics. Like all our public classes, this seminar will be taught by best-selling Python author and trainer Mark Lutz, and is open to individual enrollments. For more details, please see our web page: http://home.earthlink.net/~python-training/public.html --Python Training Services -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
lxml 1.1 and 1.0.4 released
Hi all, I'm proud to announce the release of lxml 1.1, right after lxml 1.0.4. http://codespeak.net/lxml/ Download: http://cheeseshop.python.org/pypi/lxml/1.1 http://cheeseshop.python.org/pypi/lxml/1.0.4 lxml 1.1 is a major new release that introduces many new features compared to the 1.0 series. lxml 1.0.4 is a maintenance release for the stable 1.0 series. For a quick introduction: lxml is a Pythonic binding for the libxml2 and libxslt libraries. It provides safe and convenient access to these libraries using the ElementTree API. It extends the ElementTree API significantly to offer support for XPath, RelaxNG, XML Schema, XSLT, C14N and much, much more. Its goals are: * Pythonic API. * Documented. http://codespeak.net/lxml/#documentation http://codespeak.net/lxml/FAQ.html * FAST! http://codespeak.net/lxml/performance.html * Use Python unicode strings in API. * Safe (no segfaults). * No manual memory management! (as opposed to the official libxml2 Python bindings) The main improvements in the 1.1 series are: * threading support * XPath axis iteration * iterparse() and iterwalk() * configurable Element class lookup methods * lxml.objectify - a data binding API on top of lxml.etree The complete changelog is below. lxml 1.1 has been tested in an alpha and beta version and received various bug fixes before the final release. It is currently considered stable and ready for production use, whereas the 1.0 series are considered rock-stable and may still be the right thing to choose for more conservative environments. Bug-fix releases and minor improvements to the 1.1 and 1.0 series will continue to become available at need. That way, 1.1 will soon be considered as stable as 1.0 to become its the main line successor. Given the many helpful egg contributions we received for past releases, I hope that 1.1 (and 1.0.4) will be as well supported in that regard to help in further increasing our community. Thanks to everyone who helped in getting 1.1 done, in getting bugs fixed and helping others in using it. Have fun, Stefan *** Changes in 1.0.4: 1.0.4 (2006-09-09) Features added * List-like Element.extend() method Bugs fixed * Crash in tail handling in Element.replace() *** Changes in 1.1: 1.1 (2006-09-13) Features added -- * Comments and processing instructions return '!-- coment --' and '?pi-target content?' for repr() * Parsers are now the preferred (and default) place where element class lookup schemes should be registered. Namespace lookup is no longer supported by default. Bugs fixed -- * filenames with local 8-bit encoding were not supported * 1.1beta did not compile under Python 2.3 * ignore unknown 'pyval' attribute values in objectify * objectify.ObjectifiedElement.addattr() failed to accept Elements and Lists * objectify.ObjectPath.setattr() failed to accept Elements and Lists 1.1beta (2006-08-08) Features added -- * Support for Python 2.5 beta * Unlock the GIL for deep copying documents and for XPath() * New ``compact`` keyword argument for parsing read-only documents * Support for parser options in iterparse() * The ``namespace`` axis is supported in XPath and returns (prefix, URI) tuples * The XPath expression / now returns an empty list instead of raising an exception * XML-Object API on top of lxml (lxml.objectify) * Customizable Element class lookup: * different pre-implemented lookup mechanisms * support for externally provided lookup functions * Support for processing instructions (ET-like, not compatible) * Public C-level API for independent extension modules Bugs fixed -- * XPathSyntaxError now inherits from XPathError * Threading race conditions in RelaxNG and XMLSchema * Crash when mixing elements from XSLT results into other trees, concurrent XSLT is only allowed when the stylesheet was parsed in the main thread * The EXSLT ``regexp:match`` function now works as defined (except for some differences in the regular expression syntax) * Setting element.text to '' returned None on request, not the empty string * ``iterparse()`` could crash on long XML files * Creating documents no longer copies the parser for later URL resolving. For performance reasons, only a reference is kept. Resolver updates on the parser will now be reflected by documents that were parsed before the change. Although this should rarely become visible, it is a behavioral change from 1.0. 1.1alpha (2006-06-27) = Features added -- * Module level ``iterwalk()`` function as 'iterparse' for trees * Module level ``iterparse()`` function similar to ElementTree (see documentation for differences) * Element.nsmap property returns a mapping of all namespace prefixes known at the Element to their namespace URI * Reentrant threading support in RelaxNG, XMLSchema and XSLT *
Re: [IronPython] [ANN] IronPython Community Edition 1.0r1
http://www.oreillynet.com/windows/blog/2006/09/seo_sanghyeonipce_ironpython_c.htmlSeo, do you have a blog I can point people to? Either way, Thanks! This will make things TONS easier in regards to running IronPython on Mono. :)On 9/13/06, Sanghyeon Seo [EMAIL PROTECTED] wrote:I am happy to announce IronPython Community Edition (IPCE for short) 1.0 revision 1, based on IronPython 1.0, to the world.Get it here:http://sparcs.kaist.ac.kr/~tinuviel/download/IPCE-1.0r1.zip Binary is built with Mono 1.1.17.1.Benefits of this edition:1. You don't need to fight Mono with non-working line editing orwhite-on-white blind console on Linux or Mac. A fix for this issue and fixed binary is already included.2. You don't need to edit makefile to build from the source on Mono.3. Various bugfixes are included: patches are available here: http://sparcs.kaist.ac.kr/~tinuviel/fepy/patches/1.0/patch-ironpython-mono-consolepatch-ironpython-mono-makefileDiscussed above.patch-ironpython-co-flagsThis patch fixes an issue that co_flags reports **-argument only function to have *-argument as well.patch-ironpython-codedom-empty-returnThis patch fixes an issue that CodeDom generator doesn't handle emptyreturn statements.patch-ironpython-oldstyle-setattr This patch fixes an issue that __setattr__ wasn't called for old-style classes.patch-ironpython-os-utimeThis patch fixes an issue that os.utime didn't set modified time andset access time wrong. patch-ironpython-re-backslash-escapeThis patch fixes an issue that backslash escape \\ wasn't properlyhandled in regular _expression_.--Seo Sanghyeon___ users mailing listusers@lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- /M:DM. David Petersonhttp://mdavid.name | http://www.oreillynet.com/pub/au/2354 -- http://mail.python.org/mailman/listinfo/python-list
Re: Refactor a buffered class...
thanks a lot to all, i help me to learn a lot ! (i finally use the generator trick, it is great...) best regards. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
Michael top-posted [again]: John Machin wrote: Michael top-posted [corrected]: John Machin wrote: Michael wrote: Hi All, I've received (via UDP) a null terminated string and need to convert it into a Python string. Can anyone tell me how this is done? If it helps, I know the number of characters in the string. I think you mean NUL, not null. What have you received it into, if it's not a Python string? You probably need/want this: if strg[-1] == \0: strg = strg[:-1] alternatively: strg = strg.rstrip(\0) # requires Python 2.2.2 or later It's possible you may be talking about a fixed length string which contains useful_stuff + \0 + padding -- in that case you need strg = strg.split(\0)[0] # grab upto (but not including) the first NUL (if any) If you're not sure what you've got, print repr(the_input_string) HTH, John Thank you very much for your responses. To answer some of the questions... Yes, I am in Python receiving a C language 0 terminated string that was sent to my Python program in a UDP packet (which is how I know the count). Are your responses still correct given this clarification? My responses are correct. Your clarification indicates to me that you are going by what you are told, not by inspection of (several instances of) the packet contents, using repr(). It's up to you whether you want to be skeptical about the packet contents or not. I certainly wouldn't be throwing the last byte away without checking that it was in fact a NUL. Cheers, John John, Thanks for your reply. Just wondering... how are Python strings formatted? Evidently they're not 0 terminated. A Python string is an object. The details of the internal storage may vary between implementations. CPython has 8-bit str objects and 16-bit or 32-bit Unicode objects. In IronPython, (str is Unicode) is true, and they are 16 bits. In any case the object knows its own length without having to scan for a terminator. Thus, a string can contain NULs. Having said all that, the CPython str implementation does have an additional byte at the end; this is set to zero and is not counted in the length. However you never see that and don't really need to know unless you are writing an extension module in C -- it's handy to know that you don't have to append a NUL if you want to call a C library function. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
Tim Williams wrote: On 07/09/06, Sybren Stuvel [EMAIL PROTECTED] wrote: sridhar enlightened us with: iam having user account on an exchangeserver. with that can i send an email using python? if iam using the following code iam getting error Traceback (most recent call last): File C:\sridhar\Beginning_Python\Beginning_Python\Chapter16\tryitout\InitialMailExample.py, line 5, in ? server = smtplib.SMTP(hstmsg002,25) File C:\Python24\lib\smtplib.py, line 244, in __init__ (code, msg) = self.connect(host, port) File C:\Python24\lib\smtplib.py, line 307, in connect (code, msg) = self.getreply() File C:\Python24\lib\smtplib.py, line 351, in getreply raise SMTPServerDisconnected(Connection unexpectedly closed) SMTPServerDisconnected: Connection unexpectedly closed Well that's useless. You could install a network sniffer (http://www.ethereal.com/) and find out what's actually sent over the network connection, and where things go wrong. Have you verified that you are allowed to use SMTP on this server ? Can you send email via it using outlook express or a similar POP3/IMAP mail client? :) yes , because iam having account on that server -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
Blair P. Houghton wrote: Mmmm, no. I'm saying that the change from Oracle 9 to Oracle 10 is like changing from ffs to fat32. well, I'm quite sure that the people I know who's spending a lot of their time moving stuff from Oracle N to Oracle N+1 (and sometimes getting stuck, due to incompatibilities between SQL and SQL and a lack of infinite resources) would say you're completely and utterly nuts. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
Brendon Towle wrote: On Sep 7, 2006, at 3:50 AM, sridhar [EMAIL PROTECTED]wrote: iam having user account on an exchangeserver. with that can i send an email using python? if iam using the following code iam getting error fromAddress = '[EMAIL PROTECTED]' toAddress = '[EMAIL PROTECTED]' msg = Subject: Hello\n\nThis is the body of the message. import smtplib server = smtplib.SMTP(hstmsg002,25) server.sendmail(fromAddress, toAddress, msg) error: Traceback (most recent call last): File C:\sridhar\Beginning_Python\Beginning_Python\Chapter16\tryitout \InitialMailExample.py, line 5, in ? server = smtplib.SMTP(hstmsg002,25) File C:\Python24\lib\smtplib.py, line 244, in __init__ (code, msg) = self.connect(host, port) File C:\Python24\lib\smtplib.py, line 307, in connect (code, msg) = self.getreply() File C:\Python24\lib\smtplib.py, line 351, in getreply raise SMTPServerDisconnected(Connection unexpectedly closed) SMTPServerDisconnected: Connection unexpectedly closed I saw a similar error when I was not following the server's authentication protocol -- either failing to authenticate when it wanted it, or authenticating when it didn't want it. Here's the code I use -- tested on both an Exchange server and on Comcast's SMTP servers. It assumes some globals (in all caps) which you need to set first. def emailGivenString(host=SMTP_HOST, fromAddr=FROM_ADDR, toAddr=TO_ADDR, subject='', body='', auth=False): server = smtplib.SMTP(host) if auth: server.login('username', 'password') outMessage = 'From: %s\rTo: %s\rSubject: %s\r%s' % (FROM_HEADER, TO_HEADER, subject, body) server.sendmail(fromAddr, toAddr, outMessage) If this doesn't work, I second the previous suggestion of talking to the server admin. B. -- Brendon Towle, Ph.D. [EMAIL PROTECTED] +1-412-362-1530 Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. - Brian W. Kernighan well, this type of authentication might work.Because the same process of sending mail with authentication worked when i used java mail application so iam confident of the same thing works in python also. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
Michael wrote: Thanks for your reply. Just wondering... how are Python strings formatted? Evidently they're not 0 terminated. have you tried *printing* the thing you got via UDP? to get a programmer-friendly representation of an arbitrary object, use print repr(obj) (where obj is your string, in this case). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: When is it a pointer (aka reference) - when is it a copy?
Dennis Lee Bieber wrote: References to lists, dictionaries, and class instances (which are, in a way, just an expanded dictionary) are mutable careful: it's not the *reference* that's mutable, it's the object. the *only* difference between mutable and immutable objects is that the latter don't provide any methods that you could use to modify their contents. plain assignment (name=) *never* modifies objects, and *never* copies objects. this article http://effbot.org/zone/python-objects.htm may be useful for those who haven't already seen it. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: stock quotes
Larry Bates wrote: If the HTML on the page(s) you want to process is clean and well formed it can be pretty easy. Download elementree from: http://effbot.org/zone/element-index.htm and if it turns out to be messy, but you still want to use the same API, see: http://effbot.org/zone/element-soup.htm /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - ? get IDLE going on cygwin
David J. Braden wrote: Worked great. This exercise has also raised my comfort level with the whole endeavor. To get rebaseall going, I was told to install the *entire* cygwin package. Good time to paint a couple of rooms, clean the gutters, ... or get a more convenient distribution. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
Cliff Wells wrote: patch here: http://mail.python.org/pipermail/python-list/2001-June/047996.html Did you happen to remember this post or is Google *really* your friend? Have you taken The Oath? If not, I'm afraid I cannot tell you. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Linear regression in 3 dimensions
Hi Dave! snip Hi Bernhard, I am just starting to learn Python; could you plz tell me specifically the introduction(s) you have in mind? TIA, DaveB Take a look at the documenation section on www.scipy.org. Especially the old NumPy documentation (follow link to NumPy tutorial) and the scipy tutorial (there's an 'old' version as pdf) were helpfull. There is also a fee based e-book on NumPy which I should buy to support the development, because the package is so great :-) For matplotlib take a look at http://matplotlib.sourceforge.net/ and get the user's guide. Enjoy! Bernhard -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.6.5 released
On Tue, 12 Sep 2006 20:15:58 GMT, Nemesis [EMAIL PROTECTED] wrote: XPN (X Python Newsreader) is a multi-platform newsreader with Unicode support. It is written with Python+GTK. It has features like scoring/actions, X-Face and Face decoding, muting of quoted text, newsrc import/export, find article and search in the body, spoiler char/rot13, random taglines and configurable attribution lines. Hello Nemesis, that is a great program, thank you. I will try to use it and also attempt to customize it, so that it works like forte agent. ironicEven better would it be to have it in wxPython/ironic Some little points: There is no progress bar or other info, if I subscribe one list. There is a little in the lower left corner, but if a lot of headers and bodies are received, the program seems to hang. I actually killed it, because I thought that hanging. It would be nice, if I click on the groups pane another group, the messages appear immediatly, without needing to double click the group. When composing messages, the tab size is 8. It would be nice to have the possibility to adjust this size. Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: time-based point system
Jay wrote: That function is absolutely no good for this situation. 1. Take a small number. 5.4348809719085693 2. Put it in the function. f(5.4348809719085693) = 1/5.4348809719085693 3. Get a large number??? 0.18399666987533483 That number is even smaller. I want a large one coming out. Not satisfied with with the shrink-wrapped functions available at your local math-mart? Make your own from only a few data points: from __future__ import division import bisect def make_function(*points): Finest built-to-order maths since Archimedes points = sorted(points) xvalues = [p[0] for p in points] def f(x): i = bisect.bisect(xvalues, x) if i == 0: i = 1 if i = len(xvalues): i = len(xvalues) - 1 x0, y0 = points[i-1] x1, y1 = points[i] return (y1-y0)/(x1-x0)*(x-x0) + y0 return f if __name__ == __main__: f = make_function((0, 10), (1, 100), (2, 10), (3, 1)) for i in range(-1, 21): x = i / 10 print x, --, f(x) Peter -- http://mail.python.org/mailman/listinfo/python-list
lxml Windows binaries
I'm trying to find Windows binaries for lxml. The cheeseshop is supposed to have such binaries, but I can't find them. Does anyone know where I might find such binaries? Thanks, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build extensions on Windows?
Martin v. Löwis wrote: Fuzzyman schrieb: More interestingly, someone reported on Python-dev recently a speed improvement of around 30% (from memory) by compiling with VC 8. I know the grumble (almost certainly correctly) about Microsoft's 'odd' interpretation of the C standards in VC 8, but it looks like there are major benefits to switching... You may or may not know that it is futile arguing about compiler switching for released versions of Python, i.e. 2.3, 2.4, and 2.5. Whether or not it might be a good idea: it can't be done, for compatibility with prior releases. Of course, but Python development continues... Into the future.. Fuzzyma http://www.voidspace.org.uk/python/index.shtml Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Why not event-driven packages in other than the main thread?
Hi, I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. I experienced similar problems with Twisted. Both of these tools are event-based, so I guess that is the root of the problem... But could anyone tell me why running these in a thread other than the main one doesn't work? regards -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython Community Edition 1.0r1
Sanghyeon Seo wrote: I am happy to announce IronPython Community Edition (IPCE for short) 1.0 revision 1, based on IronPython 1.0, to the world. Is there any word on ctypes for IronPython? The last I can find out on the tubes is a promising message dated back in June: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-June/002500.html All messages since then seem to refer just to that one post. Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
Fredrik Lundh wrote: Michael wrote: Thanks for your reply. Just wondering... how are Python strings formatted? Evidently they're not 0 terminated. have you tried *printing* the thing you got via UDP? to get a programmer-friendly representation of an arbitrary object, use print repr(obj) (where obj is your string, in this case). Probably not; there was no indication after the two messages where I mentioned repr :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
Hi Stu und Willie, Willie? Thats new. ;) I will be running it under (sigh) Windows. So? Apart from Microsoft being evil and spying on you all the time, I find much satisfaction in the fact that Windows Just Works(tm). Linux on the other hand Just Barely Works(tm). Hello flamewar :). I don't yet know what jython is about, or for, but I'm up for trying jedit for python. jython is an implementation of python in java (hence the name ;)). That means it's a python interpreter inside a java virtual machine (groan). It basically lets you write java apps in python syntax. It's currently at python 2.1 I believe. jEdit is extensible though java, and with the jython plugin also through python. Which plugins give me a good start for scientific stuff? Er ... I don't know. What do you mean by 'scientific stuff'? You might want to look at python packages such as scipy (?) or numpy (for numerical calculations) or whatever those are called. I think you can hook up python to Matlab, Scilab or Mathematica, but don't take my word for it. I don't use any of this, so I cannot really tell you more. None of this is jEdit specific though. Can you clarify? I am not interested in Web/html apps. Too bad, that's the future ;). And is there an IDE out there that lets us create GUI dialogs along the lines of what MS provides with Excel and, I assume, VB? Stani's Python Editor (SPE) and Boa Constructor, I think. I've tried SPE a few years back and liked it a lot. If you only ever write python code you might want to forget about jEdit and use one of the two above. jEdit is dubbed 'Programmer's Text Editor', and as such provides a 'unified' framework for many languages (so you don't have to learn a new editor for every damn language you write in once in a blue moon). It is for that reason a /tad/ less specialized (though highly configurable). If you still want to use jEdit, there is wxGlade for wxPython out there and Glade (not wxGlade!) works for pyGTK, I believe. Hope that helps you deciding. Willie ;) -- http://mail.python.org/mailman/listinfo/python-list
descriptor problems
I want to define a class-level attribute that will be shared by all subclasses. That is, I want this class, every subclass of this class, every instance of this class and every instance of every subclass to be able to read and write to the _same_ slot/variable. But I can't figure out how to do it. My attempts so far have led me to using a descriptor as follow, but it doesn't get me where I want to be: class sharedClassVar(object): def __init__(self,x=None): print creating self.value = x def __get__(self,ob,cls): print getting return self.value def __set__(self,ob,x): print setting self.value = x class A( object ): # install it like this I guess: cls2 = sharedClassVar(5) class B( A ): pass print A.cls2 # so far so good o = A() o2 = B() print o.cls2 # ok print o2.cls2 # ok o.cls2 = 2 print B.cls2 # perfect print o2.cls2 # o2.cls2 = 3 print A.cls2 # print o.cls2 # # but I need to be able to update the value through the class # how do I do it? A.cls2 = 4 # whoops - we just overwrote the descriptor with an integer A.cls2.__set__(None,4) # AttributeError: 'int' object has no attribute '__set__' -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml Windows binaries
Jan Dries wrote: I'm trying to find Windows binaries for lxml. The cheeseshop is supposed to have such binaries, but I can't find them. Does anyone know where I might find such binaries? The lxml install docs point to the following link for Windows binaries : http://www.zlatkovic.com/libxml.en.html Which in turn points to : http://www.zlatkovic.com/pub/libxml/ The latest binaries on this page are from July. Fuzzyman http://www.voidspace.org.uk/python/index.shtml Thanks, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml Windows binaries
Fuzzyman wrote: Jan Dries wrote: I'm trying to find Windows binaries for lxml. The cheeseshop is supposed to have such binaries, but I can't find them. Does anyone know where I might find such binaries? The lxml install docs point to the following link for Windows binaries : http://www.zlatkovic.com/libxml.en.html Which in turn points to : http://www.zlatkovic.com/pub/libxml/ Yes, but these are binaries for libxml. I found those already. What I need now is a binary version of the python extension module lxml (http://codespeak.net/lxml/). The docs there refer to http://cheeseshop.python.org/pypi/lxml, but that page only has a binary egg for Linux. Regards, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need tobe?
On Wed, 13 Sep 2006 07:45:02 +, Antoon Pardon wrote: This is just an idea of mine, nothing I expect python to adapt. But just suppose the language allowed for words in bold. A word in bold would be considered a reserved word, a word in non bold would be an identifier. [snip] Shrug, Different options are possible, in a file the keywords could just be prefixed with a Ctrl-K, and depending on the editor or its setting, this could be shown bold or blue or whatever. I don't care about the specifics at this point. I just wanted to make clear there is the option to make/show the distiction between identifiers and keywords more explicitly. But surely all you are doing is changing the reserved word from (say) return to \x0breturn. Once you do that, you can bet that people will complain that they want to have identifiers in bold too, why can't they create a name \x0breturn, and somebody will come up with an even more complicated scheme for accommodating them... wash, rinse, repeat. -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
What about IDLE? I really apreciate it but a big broblem is that it doesn't support tabs: for every source you edit you have to open a new IDLE window. :-\ -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Tor Erik wrote: But could anyone tell me why running these in a thread other than the main one doesn't work? Just for personal interest: Why would you want to run the GUI in another thread? It's common to leave the GUI in the main thread and let worker threads handle heavy time-consuming stuff. Regards, Björn -- BOFH excuse #170: popper unable to process jumbo kernel -- http://mail.python.org/mailman/listinfo/python-list
Re: descriptor problems
Gary Stephenson wrote: I want to define a class-level attribute that will be shared by all subclasses. That is, I want this class, every subclass of this class, every instance of this class and every instance of every subclass to be able to read and write to the _same_ slot/variable. But I can't figure out how to do it. class A: class __metaclass__(type): _shared = 42 def get_shared(self): return self.__class__._shared def set_shared(self, value): print %r -- %r % (self._shared, value) self.__class__._shared = value shared = property(get_shared, set_shared) def get_shared(self): return self.__class__.shared def set_shared(self, value): self.__class__.shared = value shared = property(get_shared, set_shared) Does that what you want? Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: descriptor problems
Gary Stephenson wrote: # but I need to be able to update the value through the class # how do I do it? A.cls2 = 4 # whoops - we just overwrote the descriptor with an integer A.cls2.__set__(None,4) # AttributeError: 'int' object has no attribute '__set__' You need to define the descriptor at the metaclass level too. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
On 14 Sep 2006 00:11:05 -0700, sridhar [EMAIL PROTECTED] wrote: Tim Williams wrote: Have you verified that you are allowed to use SMTP on this server ? Can you send email via it using outlook express or a similar POP3/IMAP mail client? :) yes , because iam having account on that server Having an account on an Exchange server doesn't automatically mean you have SMTP access to that server.Some exchange servers don't have SMTP running at all, and others will not allow SMTP access from local IP addresses - even with authentication. Can you telnet to your Exchange server on port 25 and start an SMTP conversation, using the EHLO or HELO, MAIL and RCPT commands, but quitting before the DATA command? If you can successfully specify a recipient, then your script should work, if not you will need your script to work around the problem based on what you do or don't get back from the server. HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python blogging software
On Wed, 2006-09-13 at 19:28 +0200, Irmen de Jong wrote: Cliff Wells wrote: I'm currently using Frog, and it's decent, but lacks some fundamental features (tags for one). Since Irmen is probably going to scrap it anyway, I'm kind of fishing about for something new. That is not really true. I won't scrap Frog. One of the reasons would be that I'm using it myself ;-) Perhaps you confused it with the possible scrapping of the Snakelets appserver it runs on? I'm thinking about rebuilding Frog on one of the more established servers such as Turbogears. But haven't had the time to start this. Yes, I saw that and took it to mean you were scrapping Frog as well (of course, if you scrap Snakelets, I suspect any new Frog would have little in common with the existing one except perhaps the moniker). BTW, I still like Frog (it's still near the top of the Python blog heap IMO), I just needed some things it didn't have. Regards, Cliff -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
On Thu, 2006-09-14 at 11:13 +0200, Tor Erik wrote: Hi, I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. I experienced similar problems with Twisted. Both of these tools are event-based, so I guess that is the root of the problem... But could anyone tell me why running these in a thread other than the main one doesn't work? They probably use signals (Twisted I'm sure does) and it's documented that signals don't work with threads: http://docs.python.org/lib/module-signal.html Regards, Cliff -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
On Thu, 2006-09-14 at 03:22 -0700, Cliff Wells wrote: They probably use signals (Twisted I'm sure does) and it's documented that signals don't work with threads: http://docs.python.org/lib/module-signal.html Er, specifically, they only work with the main thread. Cliff -- -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il Wed, 13 Sep 2006 07:34:45 +0100, Steve Holden ha scritto: What do you need this name for, just as a materr of interest? There are ways of manipulating the stack frames, but they'll be slow and possibly unreliable. I am writing a big (for me) program and it would be helpful to have a dummy function like this: def function_A_subfunction_B(self, ) dummy() that display a standard message like this: Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet regards David -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il 13 Sep 2006 00:31:47 -0700, John Machin ha scritto: David wrote: Inside a function I need to get the function's caller's name. How can I get it? Check out the thread __LINE__ and __FILE__ functionality in Python? (messages posted 2006-0813). I'll check thankyou! Traffic in this NG is so high that is difficult to stay uptodate. David. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Tor Erik [EMAIL PROTECTED] wrote: I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. That's because Tkinter is not thread safe AFAIK. I experienced similar problems with Twisted. Neither Twisted is thread-aware. It uses thread for a couple of things (twisted.row and address resolution). You can call stuff in a separate thread with deferToThread or callInThread but avoid threads is best. But could anyone tell me why running these in a thread other than the main one doesn't work? Because neither Twisted nor Tkinter are meant to work with threads. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Bjoern Schliessmann wrote: Tor Erik wrote: But could anyone tell me why running these in a thread other than the main one doesn't work? Just for personal interest: Why would you want to run the GUI in another thread? It's common to leave the GUI in the main thread and let worker threads handle heavy time-consuming stuff. Regards, Björn If you have two event-based frameworks, both needing to run in the main thread, such as Tkinter and Twisted, you have a problem -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Tor Erik [EMAIL PROTECTED] wrote: If you have two event-based frameworks, both needing to run in the main thread, such as Tkinter and Twisted, you have a problem Twisted supports Tkinter: http://twistedmatrix.com/projects/core/documentation/howto/choosing-reac tor.html#auto14 It's better to use GUI with a real reactor available like GTK2 anyway... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: how are dictionary literals handled by the interpreter?
[EMAIL PROTECTED] wrote: I wrote up a quick little set of tests, I was acutally comparing ways of doing case behavior just to get some performance information. Now two of my test cases had almost identical results which was not at all what I expected. Ultimately I realized I don't really know how literals are treated within the interpreter. The two implementations I was looking at were: class caseFunction(object): def __init__(self): self.caseDict = {'a':retval = 'a', 'b':retval='b',c:retval='c',d:retval='d', e:retval='e',f:retval='f',g:retval='g',h:retval='h', i:retval='i'} def doIt(self,a): exec(self.caseDict.get(a)) return retval Err... Why would you want to exec anything here ? Remember that Python's functions are objects too: def funcA(*args, **kw): return funcA called with %s %s % (str(args), kw) def funcB(*args, **kw): return funcB called with %s %s % (str(args), kw) def funcC(*args, **kw): return funcC called with %s %s % (str(args), kw) def defaultFunc(*args, **kw): return defaultFunc called with %s %s % (str(args), kw) class SwitchFunc(object): def __init__(self, default, **kw): self._default = default self._switch = kw # makes the object callable. def __call__(self, case, *args, **kw): func = self._switch.get(case, self._default) return func(*args, **kw) switch = SwitchFunc(defaultFunc, a=funcA, b=funcB, c=funcC) for case in abcX: print switch(case, foo, q=42) HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Force sleep to ignore interrupts
I've written a simple Timer class that allows you to extend it and then implement onMinuteChange, onHourChange etc methods which will be executed on each new minute/hour respectively. It works as I want when used in the main application thread. That is, when you hit Ctr + C, it stops running. However, if the class that subclasses it, also subclasses Thread, it breaks in that hitting Ctrl + C interrupts the call to sleep which puts the event loop out of sync with real time. How can I force the sleep to stay asleep for a whole second? The source code is below. from threading import Thread from datetime import datetime from time import sleep new_minute = lambda t: t.second == 0 new_hour = lambda t: t.minute == 0 and new_minute(t) new_day = lambda t: t.hour == 0 and new_hour(t) new_week = lambda t: t.weekday() == 0 and new_day(t) new_month = lambda t: t.day == 0 and new_day(t) class Timer: def run(self): t = datetime.now() diff = t.microsecond delay = 1.00 - (0.01 * diff) sleep(delay) self.onSecondChange() while True: sleep(1) t = datetime.now() self.onSecondChange() if new_minute(t): self.onMinuteChange() if new_hour(t): self.onHourChange() if new_day(t): self.onDayChange() if new_week(t): self.onWeekChange() if new_month(t): self.onMonthChange() def onSecondChange(self): pass def onMinuteChange(self): pass def onHourChange(self): pass def onDayChange(self): pass def onWeekChange(self): pass def onMonthChange(self): pass def onYearChange(self): pass if __name__ == '__main__': class TestTimer(Timer, Thread): def onSecondChange(self): print second elapse: %s % datetime.now() def onMinuteChange(self): print minute elapse : %s % datetime.now() def onHourChange(self): print hour elapse : %s % datetime.now() t = TestTimer() t.start() -- http://mail.python.org/mailman/listinfo/python-list
Re: Force sleep to ignore interrupts
[EMAIL PROTECTED] wrote: It works as I want when used in the main application thread. That is, when you hit Ctr + C, it stops running. However, if the class that subclasses it, also subclasses Thread, it breaks in that hitting Ctrl + C interrupts the call to sleep which puts the event loop out of sync with real time. Maybe you could install a signal handler to ignore ctrl+c, when required import signal signal.signal(signal.SIGINT, signal.SIG_IGN) -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
David wrote: Il Wed, 13 Sep 2006 07:34:45 +0100, Steve Holden ha scritto: What do you need this name for, just as a materr of interest? There are ways of manipulating the stack frames, but they'll be slow and possibly unreliable. I am writing a big (for me) program and it would be helpful to have a dummy function like this: def function_A_subfunction_B(self, ) dummy() that display a standard message like this: Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet regards David Check also the warnings module (it will give you also line number information for free). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Paul Boddie wrote: Well, if the client is free not to bother signalling anything about erroneous value types, one has to wonder why there's so much of a specification. If you read it, I think you'll notice that the committee has managed to produce a lot of text without spending too much ink on error handling. I'm not completely up to date with the latest standards, but last time I looked, a lot of things that are essential parts of all serious implementations were missing from the standards. I'm pretty certain it would overwhelm the SQL standards committee if they had to specify how error conditions are handled. It would certainly be useful though. E.g. is PostgreSQL SQL compliant in forcing a rollback as soon as an operation fails. E.g. in Oracle, you can have a transaction with a loop where you try to insert values, and fall back to updating instead if you get a duplicate key on insert error. In PostgreSQL you need to set a savepoint before the the insert and rollback to that. Does the standard say whether this is kosher? I think not. -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml Windows binaries
http://puggy.symonds.net/~ashish/downloads/ HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
Wildemar Wildenburger wrote: Hi Stu und Willie, [...] Which plugins give me a good start for scientific stuff? Er ... I don't know. What do you mean by 'scientific stuff'? You know, stitching body parts together from different corpses and trying to animate them with lightning, inventing potions that completely cjange the personailty, that kind of thing. People have been doing it for hundreds of years ... regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
David wrote: Il Wed, 13 Sep 2006 07:34:45 +0100, Steve Holden ha scritto: What do you need this name for, just as a materr of interest? There are ways of manipulating the stack frames, but they'll be slow and possibly unreliable. I am writing a big (for me) program and it would be helpful to have a dummy function like this: def function_A_subfunction_B(self, ) dummy() that display a standard message like this: Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet One way would be to have dummy() raise an exception, which it catches. Then use the traceback information to provide the information you want. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Force sleep to ignore interrupts
Jeremy Sanders wrote: [EMAIL PROTECTED] wrote: It works as I want when used in the main application thread. That is, when you hit Ctr + C, it stops running. However, if the class that subclasses it, also subclasses Thread, it breaks in that hitting Ctrl + C interrupts the call to sleep which puts the event loop out of sync with real time. Maybe you could install a signal handler to ignore ctrl+c, when required import signal signal.signal(signal.SIGINT, signal.SIG_IGN) That worked nicely. Thanks Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
David wrote: I am writing a big (for me) program and it would be helpful to have a dummy function like this: def function_A_subfunction_B(self, ) dummy() that display a standard message like this: Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet that's spelled def function_A_subfunction_B(self, ) raise NotImplementedError in Python. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: stock quotes
Donlingerfelt wrote: I would like to download stock quotes from the web, store them, do calculations and sort the results. However I am fairly new and don't have a clue how to parse the results of a web page download. I can get to the site, but do not know how to request the certain data need. Does anyone know how to do this? I would really appreciate it. Thanks. Hi, Heres's example 8.4 from the SE manual: -- def get_current_stock_quotes (symbols): import urllib url = 'http://finance.yahoo.com/q/cq?d=v1s=' + '+'.join (symbols) htm_page = urllib.urlopen (url) import SE keep = '~[A-Z]+ [JFMAJSOND].+?%~==(10) ~[A-Z]+ [0-9][0-2]?:[0-5][0-9][AP]M.+?%~==(10)' Data_Extractor = SE.SE ('EAT ' + keep) Tag_Stripper = SE.SE ('~(.|\n)*?~= se/htm2iso.se | ~\n[ \t\n]*~=(10) ~ +~= ') data = Data_Extractor (Tag_Stripper (htm_page.read ())) htm_page.close () return data print get_current_stock_quotes (('GE','IBM','AAPL', 'MSFT', 'AA', 'MER')) GE 3:17PM ET 33.15 0.30 0.90% IBM 3:17PM ET 76.20 0.47 0.61% AAPL 3:22PM ET 55.66 0.66 1.20% MSFT 3:22PM ET 23.13 0.37 1.57% AA 3:17PM ET 31.80 1.61 4.82% MER 3:17PM ET 70.24 0.82 1.15% - If this meets your requirements you'll find SE here: http://cheeseshop.python.org/pypi/SE/2.2%20beta Regards Frederic -- http://mail.python.org/mailman/listinfo/python-list
BIOS Changes (enable WOL)
I was wondering if it is possible to access the BIOS settings on a system using Python. I would like to be able to write a script that would enable WOL on a specified system. For the most part, it would be Win32 systems, but could be just about any flavor of UNIX as well. Thanks for any help that can be provided, - DF -- http://mail.python.org/mailman/listinfo/python-list
socket and threading ... bad file descriptor
Hi, I have two classes, one listens and accepts connections, gets the socket, reads the first byte from the opened socket then launches a thread (threading) and gives it the socket identifier. The first time the thread attempts to read from the given socket, socket.py raises a bad file descriptor in _dummy. I tried using plain threads with the same problem. Any clue ? Thanks, hg -- http://mail.python.org/mailman/listinfo/python-list
Re: When is it a pointer (aka reference) - when is it a copy?
John Henry a écrit : Hi list, Just to make sure I understand this. Since there is no pointer type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list... some_huge_list[0]=1 aref = some_huge_list aref[0]=0 print some_huge_list[0] we know that the answere will be 0. In this case, aref is really a reference. But what if the right hand side is a simple variable (say an int)? Can I reference it somehow? Should I assume that: aref = _any_type_other_than_simple_one be a reference, and not a copy? Thanks, That's easy. In Python, every variable is a depth one pointer. Every variable is of the type (PyObject*) Of course, since numbers and strings are immutable, that pointer is useless to push back the modifications you've done. You need a PyObject** ? Use a one element list instead and manipulate it like that : number_ref[0] = new_value instead of that : number_ref = [new_value] -- http://mail.python.org/mailman/listinfo/python-list
Limitate speed of a socket-based data transferring
Hi all. I'm writing a TCP-based application that I will use to trasfer binary files through the network. This piece of code represents how do I get a file from a remote peer and save it on my local hard drive: file_obj = open('downloaded.ext', 'wb') while 1: buf = sock.recv(2048) if len(buf) == 0: break file_obj.write(buf) file_obj.close() sock.close() I would like to know how could be possible to limit the file transfer speed (for example: don't write more than 50 Kb/sec). Some ideas? Best regards -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
Jay wrote: I, too, am a hardcore fan of jEdit. It's nice to finally see some user support on this forum. :-) I quite often throw in jEdits name in these discussions. It's the most powerful and extensible editor I know of outside of the emacs/vi world (and far more accessible than those). -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
David Isaac wrote: I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? You haven't provided enough requirements for us to make any intelligent suggestions. Perhaps you might learn something from reading through my old EuroPython presentation. http://www.thinkware.se/cgi-bin/thinki.cgi/DatabaseProgrammingWithPython Relational databases with SQL syntax provides a convenient way to store data with an appropriate structure. You can always force a tool into handling things it wasn't designed for, but SQL database work best when you have strict, well defined structures, such as in accounting systems, booking systems etc. It gives you a declarative query language, transaction handling, typically multi user support and varying degrees of scalability and high availability features. For you, it's probably overkill, and if you have files to start with, keeping them in the file system is the natural thing to do. That means that you can use a lot of standard tools to access, manipulate, backup and search through them. Perhaps you rather need a search engine for the file system? Do you intend to store information concerning how these files relate to each other? Perhaps it's better in that case to just keep that relationship information in some small database system, and to keep the actual files in the file system. Perhaps it's enough to keep an XML file with the structure, and to use something like ElementTree to manipulate that XML structure. You gain a lot of power, robustness and flexibility by using some kind of plain text format. Simple files play well with configuration management systems, backup systems, editors, standard search tools, etc. If you use XML, it's also easier to transform your structural information to some presentable layout through standard techniques such as XSL. -- http://mail.python.org/mailman/listinfo/python-list
Re: question about including something like sqlite in python
John Salerno wrote: I was just thinking, since Python 3.0 is supposed to clean up a lot of the unnecessary or redundant features of Python and make other things more streamlined, does it seem to anyone that including SQLite goes against this goal? Not to me. I don't see the redundancy. The DB-API spec has been around for years. I think it's great that one implementation comes with Python. This is just me thinking out loud, mind you, but it seems like including a database module (especially one that many people won't use in favor of MySQL or PostgreSQL, etc.) is weighing down the standard library. I suppose the sqlite module might still be removed in 3.0, but the inclusion of it at all seems a little strange (and also sort of like an endorsement for using it). Sure, but primarily it's endorsement for using the the DB-API. Including SQLite lowers the barrier for getting started in writing applications in a domain where Python fits well. A domain where Visual Basic and tools like FoxPro have dominated. Libraries such as datetime and decimal also goes in the same direction. One could argue that a simple to use GUI building tool is another requisite in this domain, but maybe a web tool kit is more appropriaet these days... In short I think it helps making Python into a VB-killer, or if you prefer (yuk!) the new COBOL! ;^) -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me use my Dual Core CPU!
I use D-Bus (Python). I recommend it. I don't know how cross platform it is. However, it supports message passing of most built-in (strings, ints, lists, dictionaries etc) Python objects accross processes. You can mimick clean Erlang-like concurrency with it. It is the future of IPC on Desktop Unix. Given Python's crippled threading implementation, it can play a role in making your Python applications scalable, with regards to concurrency. I am recommending D-Bus because I have used it, and I know it works. I didn't read this of a newsgroup or mailing list. http://www.freedesktop.org/wiki/Software/dbus Simon Wittber wrote: I've just bought a new notebook, which has a dual core CPU. I write cross platform games in Python, and I'd really like to be able to use this second core (on my machine, and on user's machines) for any new games I might write. I know threads won't help (in CPython at least) so I'm investigating other types of concurrency which I might be able to use. I really like the PyLinda approach, however I need to be able to pass around all the simple python types, which PyLinda won't help me with. Also, PyLinda is more focused on distributing computing; I really only want to have 2 processes cooperating (or 4, if I had 4 CPUs/cores etc). Is there any cross platform way to share python objects across processes? (I've found POSH, but it's old, and doesn't appear to be maintained). I could implement my own object space using shared memory, but from what I can see, this is not available on Win32. Are there any other concurrency options I've not discovered yet? -Sw. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
David wrote: Il 13 Sep 2006 00:31:47 -0700, John Machin ha scritto: David wrote: Inside a function I need to get the function's caller's name. How can I get it? Check out the thread __LINE__ and __FILE__ functionality in Python? (messages posted 2006-0813). I'll check thankyou! Traffic in this NG is so high that is difficult to stay uptodate. You don't need to. Google is your friend. Google caller name in this NG; it's that simple :-) Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Invitation: Kamaelia Open Space, Brussels, Sept 22 2006
Hello, I'd like to invite you to our first Kamaelia Open Space event. Our theme is Making Software like Lego through intuitive useful concurrency. Perhaps you want to learn to use Kamaelia, or you're already using it, or you're simply interested in code reuse or concurrency being actually useful in everyday code rather than theory. If these match your interests, please come along. WHEN The day after Euro OSCON, and just before Bar Camp Brussels: * Friday 22nd September 2006 - 11am - 5pm WHERE * FOAM Offices, Brussels, Belgium * Koolmijnenkaai 30-34, 1080 Brussels, Belgium * http://fo.am/contact.html * http://tinyurl.com/hsarl (link showing location on multimap) WHAT http://kamaelia.sourceforge.net/Home Kamaelia started as an applied research project, at BBC Research, and has an underlying goal of making software systems easier to maintain and create through the use of intuitive and safe concurrency, in the form of components, whilst maintaining performance. It's being fleshed out by creating systems useful in the real world. This approach turns software into systems similar to a number of systems people may be familiar with : Unix pipes (except non-linear is practical), CSP, hardware (especially HDL's), Occam, K'nex and Lego. Components send messages out via outboxes, receive messages on inbox, have zero copy delivery and messages may be any python object including a component. Practical systems using Kamaelia developed to-date include time-shifting digital TV and a variety of network systems, however components exist simplifying the use of audio, video, pygame Open GL. PURPOSE The purpose of the event is similar to a python sprint. Our aims for this event are to spread what we've learnt with the wider community - for the simple reason we're finding it works for us, and hope it does for you too. This includes - but not exclusively: * To assist people to get started using Kamaelia :-) * Help you copy or tailor our approach to your systems. (eg making our system or approach usable in twisted). * To investigate areas where we can flesh Kamaelia out (eg we have a webserver than can run in a similar manner to seaside, how would you like that fleshed out) * We'd like to assist others using other languages take the lessons we've learnt and apply them in their preferred language. (especially Ruby and C++) * Help attendees integrate their projects with Kamaelia encouraging reuse between projects, bosting the system for everyone (eg integrate pygtk, wxwidgets, pyqt, or other projects you may use or contribute to, building on experience from integrating tk, pygame and open gl) * To share the work done by students during Google's Summer of Code * How to apply this to teaching children to create these systems effectively. (We've noticed that pre-university users of Kamaelia tend to achieve the most using it) * Use of Kamaelia for art and entertainment At the other extreme, we could also like to use the time to share information (if people are interested) on how some of the practical systems we use work since they are likely to be useful to others. Two interesting areas: * Distributed whiteboarding including audio. This is served in an effectively peer to peer manner - extending this to include grid setup (and/or DHT search) would be useful. This is potentially interesting beyond simple whiteboarding since this really forms a simple distributed events backplane * Practical flexible timeshifting either entire channels, and multiplexes or based on programme names Nascent areas perhaps of interest which are include in Kamaelia include a handwriting recogniser (currently at stroke/letter recognition level), graphical systems creation, and a basic open GL toolkit. FORMAT The above list of suggestions for discussion is just that, suggestions. The specific agenda for the event will be decided on the day by those who attend. Since much of what's to be discussed will be new, this will be a cross between a python sprint and open space in format. THANKS TO Finally, many thanks to the very kind people at FOAM - http://fo.am/ for hosting this event, it is very much appreciated. WHAT NEXT If you're interested in coming, please email your interest either to me at: [EMAIL PROTECTED] Or to the kamaelia mailing list: [EMAIL PROTECTED] If you know someone who you think is interested in the theme, could benefit from coming - for example someone interested in making practical concurrency safer and easier to use in future - please don't hesitate to forward this invitation to them. Hope to see you there! Michael -- Michael Sparks, Senior Research Engineer, BBC Research, Technology Group [EMAIL PROTECTED], Kamaelia Project Lead, http://kamaelia.sf.net/ This message may contain personal views which are not the views of the BBC --
Re: Limitate speed of a socket-based data transferring
billie schrieb: Hi all. I'm writing a TCP-based application that I will use to trasfer binary files through the network. This piece of code represents how do I get a file from a remote peer and save it on my local hard drive: file_obj = open('downloaded.ext', 'wb') while 1: buf = sock.recv(2048) if len(buf) == 0: break file_obj.write(buf) file_obj.close() sock.close() I would like to know how could be possible to limit the file transfer speed (for example: don't write more than 50 Kb/sec). Some ideas? If you are on unix, use trickle. If you must limit it from within your own code, I can only assume that computing the transfer rate so far and introducing timeouts might help - but I never did such a thing, nor do I know what that means for example for the network stack. But maybe even then trickle may help you to get an idea, as it is a user-space program AFAIK. So they might have some information (at least the code... ) out there that could be of use. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need?tobe?
Delaney, Timothy (Tim) wrote: Antoon Pardon wrote: This is just an idea of mine, nothing I expect python to adapt. But just suppose the language allowed for words in bold. A word in bold would be considered a reserved word, a word in non bold would be an identifier. Exactly how am I supposed to use my text editor to make words bold? Is every text editor supposed to understand a python format for code? That's easy: bpass/b, breturn/b, ... Hmm, that's too verbose, maybe it would be better to do it just by appending a underscore to the word: pass_, return_, ... wink_ -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list
Re: socket and threading ... bad file descriptor
hg wrote: Hi, I have two classes, one listens and accepts connections, gets the socket, reads the first byte from the opened socket then launches a thread (threading) and gives it the socket identifier. The first time the thread attempts to read from the given socket, socket.py raises a bad file descriptor in _dummy. I tried using plain threads with the same problem. Any clue ? Thanks, hg Bug discovered, sorry -- http://mail.python.org/mailman/listinfo/python-list
Outbound port on sockets
Is it possible to specify which port to use as the outbound port on a connection? I have the IP address and port number for the computer I'm trying to connect to (not listening for), but it's expecting my connection on a certain port. Specifically, I'm trying to write an FTP host, and I'm trying to implement the PORT command. From everything I've read, the client supplies the IP address and port number for where I'm supposed to connect to send it data (like a LISTing), and it's expecting me to connect over port 20. If anyone is familiar with FTP and can tell me whether this is true or not, whether I really need to go out on port 20, I'd appreciate it, as well. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
memory
Hi all,Is there any module to limit the memory usage of the python program ?regards,KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
On 7 Sep 2006 13:18:22 -0700, Omar [EMAIL PROTECTED] wrote: I'd love the perfect editor that would be: a) free DrPython and spe; both written in Python and wxPython using SciTe's control scintilla) and SciTE. DrPython on: http://sourceforge.net/projects/drpython/ (Projectpage) http://drpython.sourceforge.net/ (Homepage) b) enable me to drag and drop code snippets from a sort of browser into the code DrPython Codemarks plugin. c) can run programs right from within DrPython = Program = Run (default F5) d) can edit - PYTHON DrPython, spe, SciTE. - Javascript no definite support. - HTML DrPython (the others, I don't know) - actionscript (since I'm also learning flash) Sepy on Sourceforge (also written in Python with wxPython) http://sourceforge.net/projects/sepy/ e) easy to learn SciTE especially. suggestions? -- http://mail.python.org/mailman/listinfo/python-list
Re: memory
km [EMAIL PROTECTED] wrote: Is there any module to limit the memory usage of the python program ? http://docs.python.org/lib/module-resource.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
On Thu, 14 Sep 2006 11:13:59 +0200, Tor Erik [EMAIL PROTECTED] wrote: Hi, I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. I experienced similar problems with Twisted. Both of these tools are event-based, so I guess that is the root of the problem... But could anyone tell me why running these in a thread other than the main one doesn't work? I don't know about Tkinter, but Twisted can be run in a thread other than the main thread. Several projects make use of this feature extensively, so while I wouldn't recommend it, it should certainly work. Perhaps you did something wrong in setting it up, or perhaps you have found a bug. Can you post a minimal example to reproduce this to Twisted's bug tracker? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: When is it a pointer (aka reference) - when is it a copy?
John Henry wrote: Hi list, Just to make sure I understand this. Since there is no pointer type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list... some_huge_list[0]=1 aref = some_huge_list aref[0]=0 print some_huge_list[0] we know that the answere will be 0. In this case, aref is really a reference. But what if the right hand side is a simple variable (say an int)? Can I reference it somehow? Should I assume that: aref = _any_type_other_than_simple_one be a reference, and not a copy? short answer : Python won't copy anything until explicitely asked to. Longer answer: First, there's nothing like simple type or var in Python. All that you have are names and objects. The statement 'some_name = some_obj' binds together 'some_name' and 'some_obj' - IOW, once this statement is executed, 'some_name' refers to ('points to') 'some_obj' (think of it as an equivalent of 'globals['some_name'] = some_obj', and you won't be far from truth). This is how it works for all and any type. What you really need to understand is that in Python, a 'variable' is *only* a name. It's *not* the object itself. Now we have mutable and immutable types. Immutable types are (mainly) numerics, strings and tuples. As the qualificative implies, one cannot change the state (ie value) of an object of immutable type. Also, note that mutating (modifying the state of an object) and assignment (binding a name to an object) are two very different things. Rebinding a name just make it points to another object, it doesn't impact the object previously bound to that name (not directly at least, cf memory management). To come back to your code snippet: # binds name some_huge_list to an empty list some_huge_list = [] # mutate the list object bound to name 'some_huge_list' some_huge_list[0]=1 # binds name aref to the list object # already bound to name 'some_huge_list' aref = some_huge_list # you can verify that they are the same object: assert aref is some_huge_list # nb : in CPython, id(obj) returns the memory address of obj # FWIW, identity test (obj1 is obj2) is the same as # equality test on objects id (ie id(obj1) == id(obj2)) print id(aref) print id(some_huge_list) # mutate the list object bound to names 'aref' and 'some_huge_list' aref[0]=0 # Now lets go a bit further and see what happens when we rebind # some_huge_list: some_huge_list = [] # does this impact aref ? print aref aref is some_huge_list # well, obviously not. # name 'aref' is still pointing to the same object: print id(aref) # but name 'some_huge_list' now points to another object: print id(some_huge_list) To answer your question : it works *exactly* the same way for immutable objects: a = 333 b = a print b is a # True b = 333 print b is a # False The only difference here is that you can not alter the value of (IOW mutate) an immutable object. So having a reference to it won't buy you much... If you want to share an immutable object, you have to embed it into a mutable container and share this container: a = [333] b = a b[0] = 3330001 assert a is b assert a[0] is b[0] print a[0] As a side note : when passing arguments to a function, the arguments themselves are (references to) the original objects, but the names are local to the function, so mutating an object passed as argument will effectively impact the object (if it's mutable of course !-), but rebinding the name inside the function won't change anything outside the function : def test(arg) # really mutates the object passed in arg[0] = 42 print in test : arg is %s (%s) % (arg, id(arg)) # only rebinds the local name 'arg' arg = [] print in test : now arg is %s (%s) % (arg, id(arg)) def runtest(): obj = [Life, universe and everything] print in runtest : obj is %s (%s) % (obj, id(obj)) print calling test with obj: test(obj) print in runtest: now obj is %s (%s) % (obj, id(obj)) Here again, if you want your function to alter the value of an immutable object passed as argument, you have to embed it in a mutable container. *But* this is usually useless - it's perfectly legal for a Python function to return multiple values : def multi(x): return x+1, x*2 y, z = multi(42) print y : %s - z : %s % (y, z) HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
bmearns wrote: Specifically, I'm trying to write an FTP host, and I'm trying to implement the PORT command. From everything I've read, the client supplies the IP address and port number for where I'm supposed to connect to send it data (like a LISTing), and it's expecting me to connect over port 20. If anyone is familiar with FTP and can tell me whether this is true or not, whether I really need to go out on port 20, I'd appreciate it, as well. PORT means that the client is asking the server to connect to the given IP/port combination; see: http://cr.yp.to/ftp/retr.html the port number used by the server for this connection is irrelevant. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
On 9/14/06, Franz Steinhaeusler [EMAIL PROTECTED] wrote: On 7 Sep 2006 13:18:22 -0700, Omar [EMAIL PROTECTED] wrote: I'd love the perfect editor that would be: a) free DrPython and spe; both written in Python and wxPython using SciTe's control scintilla) and SciTE. DrPython on: http://sourceforge.net/projects/drpython/ (Projectpage) http://drpython.sourceforge.net/ (Homepage) b) enable me to drag and drop code snippets from a sort of browser into the code DrPython Codemarks plugin. c) can run programs right from within DrPython = Program = Run (default F5) d) can edit - PYTHON DrPython, spe, SciTE. - Javascript no definite support. - HTML DrPython (the others, I don't know) - actionscript (since I'm also learning flash) Sepy on Sourceforge (also written in Python with wxPython) http://sourceforge.net/projects/sepy/ e) easy to learn SciTE especially. suggestions? These things UliPad also can do. And it also support html, javascript, css, java, etc syntax highlight. UliPad also support Input Assistant, even include custom calltips and auto-complete, and many features, you can find in http://wiki.woodpecker.org.cn/moin/UliPad It also has a directory browser, wizard, plugins-system, code snippets manage. Just using it, you'll find out what it's. -- I like python! My Blog: http://www.donews.net/limodou UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad UliPad Maillist: http://groups.google.com/group/ulipad -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
bmearns schrieb: Is it possible to specify which port to use as the outbound port on a connection? I have the IP address and port number for the computer I'm trying to connect to (not listening for), but it's expecting my connection on a certain port. Specifically, I'm trying to write an FTP host, and I'm trying to implement the PORT command. From everything I've read, the client supplies the IP address and port number for where I'm supposed to connect to send it data (like a LISTing), and it's expecting me to connect over port 20. If anyone is familiar with FTP and can tell me whether this is true or not, whether I really need to go out on port 20, I'd appreciate it, as well. AFAIK you neither can't do that nor need it. The PORT commands purpose is to tell where the server can connect to - but the client makes no assumptions over the source port of that connection. Let alone NAT and other things could come into your way. If firewalls are a problem, use PASV. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
bmearns wrote Is it possible to specify which port to use as the outbound port on a connection? I have the IP address and port number for the computer I'm trying to connect to (not listening for), but it's expecting my connection on a certain port. Specifically, I'm trying to write an FTP host, and I'm trying to implement the PORT command. From everything I've read, the client supplies the IP address and port number for where I'm supposed to connect to send it data (like a LISTing), and it's expecting me to connect over port 20. If anyone is familiar with FTP and can tell me whether this is true or not, whether I really need to go out on port 20, I'd appreciate it, as well. Thanks. This isn't correct. If you send a PORT command you're telling server to establish a connection with you, not the contrary. In this case, even if you are an FTP client, you temporary ACCEPT an outbound connection from the FTP server. The right format of a FTP PORT command is: PORT x,x,x,x,y,z ...where x(s) represents your IP address in dotted form and (x * y) the TCP port you bind. For further informations you can check RFC959 or take a look at ftplib in standard module library. Also in twisted you can find a lot of useful code in the module protocols.ftp. -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
The right format of a FTP PORT command is: PORT x,x,x,x,y,z ...where x(s) represents your IP address in dotted form and (x * y) the TCP port you bind. Sorry, I wanted to say: (y * z) -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
On Thu, 14 Sep 2006 20:45:11 +0800, limodou [EMAIL PROTECTED] wrote: These things UliPad also can do. And it also support html, javascript, css, java, etc syntax highlight. UliPad also support Input Assistant, even include custom calltips and auto-complete, and many features, you can find in http://wiki.woodpecker.org.cn/moin/UliPad It also has a directory browser, wizard, plugins-system, code snippets manage. Just using it, you'll find out what it's. Of course, I took only randomly three programs for easier comparing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Jean-Paul Calderone wrote: On Thu, 14 Sep 2006 11:13:59 +0200, Tor Erik [EMAIL PROTECTED] wrote: Hi, I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. I experienced similar problems with Twisted. Both of these tools are event-based, so I guess that is the root of the problem... But could anyone tell me why running these in a thread other than the main one doesn't work? I don't know about Tkinter, but Twisted can be run in a thread other than the main thread. Several projects make use of this feature extensively, so while I wouldn't recommend it, it should certainly work. Perhaps you did something wrong in setting it up, or perhaps you have found a bug. Can you post a minimal example to reproduce this to Twisted's bug tracker? Jean-Paul Oh... I've re-coded that part of my app. now, so it doesn't contain any references to Twisted anymore. However, I was aiming to build a scalable HTTP server, and tried using Twisted for the task. Whenever I started the thing from the main thread (as a separate thread), nothing happened. That is, I received no exceptions, but the HTTP server was not running... When executing the HTTP server as a separate app., things worked perfectly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
Thanks for all the responses. I understood what the PORT command was for, but I've been seeing alot of doc online that only mentions going outbound on port 20 for data connections, so I thought maybe that was my problem. Sorry if this is the wrong spot to follow up on this not-so-much-python matter. Does anyone know of an appropriate news group? I'm trying to get through a router and Norton Internet security, using my homebrewed python FTP server and Internet Explorer as my client (I've also tried microsoft's FTP command line client). I'm able to go back and forth on the command socket, no problem, but after the client issues a PORT, I try to connect to it, and time out. I'm becoming increasingly convinced that it's a firewall/router issue because if I connect to my server as localhost, instead of my outside IP address, I can connect fine. I've tried disabling Internet security, but that doesn't help. I suspect the problem is port forwarding from the router, but I don't know what the port numbers will be, so how can I set up forwarding? Any help is greatly appreciated. I've been banging my head against the wall for hours. -Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
Quick follow up, I'm able to connect to other external FTP sites behind my firewall and router, no problem. -Brian bmearns wrote: Thanks for all the responses. I understood what the PORT command was for, but I've been seeing alot of doc online that only mentions going outbound on port 20 for data connections, so I thought maybe that was my problem. Sorry if this is the wrong spot to follow up on this not-so-much-python matter. Does anyone know of an appropriate news group? I'm trying to get through a router and Norton Internet security, using my homebrewed python FTP server and Internet Explorer as my client (I've also tried microsoft's FTP command line client). I'm able to go back and forth on the command socket, no problem, but after the client issues a PORT, I try to connect to it, and time out. I'm becoming increasingly convinced that it's a firewall/router issue because if I connect to my server as localhost, instead of my outside IP address, I can connect fine. I've tried disabling Internet security, but that doesn't help. I suspect the problem is port forwarding from the router, but I don't know what the port numbers will be, so how can I set up forwarding? Any help is greatly appreciated. I've been banging my head against the wall for hours. -Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Unit balancing
Thanks, all. We will investigate Unum. Abraham -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
bmearns [EMAIL PROTECTED] writes: Quick follow up, I'm able to connect to other external FTP sites behind my firewall and router, no problem. You've been told already to implement PASV command in your server (then client will be able to use so called passive mode). -- Sergei. -- http://mail.python.org/mailman/listinfo/python-list
Re: Limitate speed of a socket-based data transferring
On 14/09/06, Diez B. Roggisch [EMAIL PROTECTED] wrote: billie schrieb: Hi all. I'm writing a TCP-based application that I will use to trasfer binary files through the network. This piece of code represents how do I get a file from a remote peer and save it on my local hard drive: file_obj = open('downloaded.ext', 'wb') while 1: buf = sock.recv(2048) if len(buf) == 0: break file_obj.write(buf) file_obj.close() sock.close() I would like to know how could be possible to limit the file transfer speed (for example: don't write more than 50 Kb/sec). Some ideas? If you are on unix, use trickle. If you must limit it from within your own code, I can only assume that computing the transfer rate so far and introducing timeouts might help - but I never did such a thing, nor do I know what that means for example for the network stack. But maybe even then trickle may help you to get an idea, as it is a user-space program AFAIK. So they might have some information (at least the code... ) out there that could be of use. You could wrap buf = sock.recv(xxx) in a data counter and sleep loop so that you burst to no more than 50KB/s average. Completely untestest and for illustration only :) file_obj = open('downloaded.ext', 'wb') interval = 1.0 # seconds eg. 0.5 or 2.0 # smaller the interval, the less bursty and smoother the throughput max_speed = 51200 # 50k * 1024 = bytes data_count = 0 # keep track of the amount of data transferred time_next = time.time() + interval while 1: buf = sock.recv(512) # smaller chunks = smoother, more accurate if len(buf) == 0: break data_count += len(buf) if data_count = max_speed * interval: data_count = 0 sleep_for = time_next - time.time() if sleep_for 0: time.sleep(sleep_for) time_next = time.time() + interval file_obj.write(buf) file_obj.close() sock.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: xinclude and pathnames
Tim Arnold [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm using ElementTree to access some xml configuration files, and using the module's xinclude capability. I've got lines like this in the parent xml file (which lives in the same directory as the included xml file): xi:include href=/dept/app/doc/current/en/xml/asdf/asdf_syntaxterms.xml/ When I started the project it was Unix-only; this worked fine. Now I have users who want to use the system on Windows and of course that directory path doesn't exist on Windows, but it is available on the network using a name like \\ladida\current\en\xml\asdf\asdf_syntaxterms.xml if relative paths worked, I could imagine xi:include href=asdf_syntaxterms.xml / would work. Also,the file can be read via an http server. My question: is there a way to make xinclude work with relative paths or perhaps urls? Any ideas welcome--to me it looks like I'll have to restructure this part of the system since I've basically programmed myself into a corner. Replying to my own post. With no replies I assume that means either (a) I didn't explain the problem very well, or (b) I really have programmed myself into a corner and there's no other way to happiness except to rethink the problem. That is, is there really no way to share xinclude'd files between *nix and Windows platforms. Anyone been down this road before? thanks, --Tim Arnold -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
One place where I would use such a feature is in a unittest package. I think being able to write self.assert or self.raise looks better than having to append an underscore. Maybe that is a good argumment for Py.Test ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
Passive mode is implemented, the client isn't trying to use it. Besides, that doesn't really help me anyway, all it means is that I have to resolve port forwarding for the server, instead of for the client. I think what this basically comes down to is that either with PASV or PORT, there's a relatively arbitrary port number being specified, and I can't figure out how to get my router to forward it since I don't know what it will be in advance, short of forwarding all the 64 thousand some odd valid ports. The thing that gets me is that I can connect to the other FTP servers, and (according to the responses echoed by the command line FTP client), they're using PORT, not PASV. So somehow, my client is specifying some arbitrary port for the server to connect to, and that port is actually being forwarded through my router. -Brian Sergei Organov wrote: bmearns [EMAIL PROTECTED] writes: Quick follow up, I'm able to connect to other external FTP sites behind my firewall and router, no problem. You've been told already to implement PASV command in your server (then client will be able to use so called passive mode). -- Sergei. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
At 08:54 PM 9/13/2006, Jay wrote: I, too, am a hardcore fan of jEdit. It's nice to finally see some user support on this forum. :-) I'm trying out jEdit and UliPad. I got UliPad going right away and I'm very pleased with it, but could I jump in here with a basic jEdit question? How do you run a script? And one more. On the menus, the font is clear and large, but the equivalent key combinations are written so small they are very difficult for me to read. Is there a way to configure them to be slightly larger? (I'd ask on the jEdit support forum, but it doesn't seem to be very active.) Thanks, Dick Moores -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
It's actually 256*y + z billie wrote: The right format of a FTP PORT command is: PORT x,x,x,x,y,z ...where x(s) represents your IP address in dotted form and (x * y) the TCP port you bind. Sorry, I wanted to say: (y * z) -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
billie wrote: [...] The right format of a FTP PORT command is: PORT x,x,x,x,y,z where x(s) represents your IP address in dotted form and (x * y) the TCP port you bind. That's actually x*256 + y - tou're makling a 16-bit unsigned integer from two bytes. For further informations you can check RFC959 or take a look at ftplib in standard module library. Also in twisted you can find a lot of useful code in the module protocols.ftp. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me use my Dual Core CPU!
Are there any other concurrency options I've not discovered yet? PyMPI? Ironpython? Sincerely, Wolfgang Keller -- My email-address is correct. Do NOT remove .nospam to reply. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il Thu, 14 Sep 2006 13:37:24 +0200, Fredrik Lundh ha scritto: [...] in Python. Thanks to all of you! David -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need tobe?
On 2006-09-14, Steven D'Aprano [EMAIL PROTECTED] wrote: On Wed, 13 Sep 2006 07:45:02 +, Antoon Pardon wrote: This is just an idea of mine, nothing I expect python to adapt. But just suppose the language allowed for words in bold. A word in bold would be considered a reserved word, a word in non bold would be an identifier. [snip] Shrug, Different options are possible, in a file the keywords could just be prefixed with a Ctrl-K, and depending on the editor or its setting, this could be shown bold or blue or whatever. I don't care about the specifics at this point. I just wanted to make clear there is the option to make/show the distiction between identifiers and keywords more explicitly. But surely all you are doing is changing the reserved word from (say) return to \x0breturn. Once you do that, you can bet that people will complain that they want to have identifiers in bold too, why can't they create a name \x0breturn, and somebody will come up with an even more complicated scheme for accommodating them... wash, rinse, repeat. Do you really think this is a serious possibility? As far as I can see, that \x0b that will be prepended to differentiate keywords from identifiers is a technique called stropping, that has been used with some algol languages. Have you any knowledge of people programming algol who asked for the use of stropped identifiers? I think I really would be amazed to find out there were such people, but then I have been amazed before. So I really would like to know. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: how are dictionary literals handled by the interpreter?
Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: I wrote up a quick little set of tests, I was acutally comparing ways of doing case behavior just to get some performance information. Now two of my test cases had almost identical results which was not at all what I expected. Ultimately I realized I don't really know how literals are treated within the interpreter. The two implementations I was looking at were: class caseFunction(object): def __init__(self): self.caseDict = {'a':retval = 'a', 'b':retval='b',c:retval='c',d:retval='d', e:retval='e',f:retval='f',g:retval='g',h:retval='h', i:retval='i'} def doIt(self,a): exec(self.caseDict.get(a)) return retval Err... Why would you want to exec anything here ? Remember that Python's functions are objects too: Largely because it was immaterial to what I am asking about here, which is dictionary literals. I was also curious about how much overhead exec had - even on simple statements, and it's about as bad as I would have guessed. Finally - it's a little quicker to write out the exec dictionary than all of the functions ;) def funcA(*args, **kw): return funcA called with %s %s % (str(args), kw) def funcB(*args, **kw): return funcB called with %s %s % (str(args), kw) def funcC(*args, **kw): return funcC called with %s %s % (str(args), kw) def defaultFunc(*args, **kw): return defaultFunc called with %s %s % (str(args), kw) class SwitchFunc(object): def __init__(self, default, **kw): self._default = default self._switch = kw # makes the object callable. def __call__(self, case, *args, **kw): func = self._switch.get(case, self._default) return func(*args, **kw) switch = SwitchFunc(defaultFunc, a=funcA, b=funcB, c=funcC) for case in abcX: print switch(case, foo, q=42) Now I'm not sure what the value of semi abstraction is here. If we are going to make the class semi generic, might as well have it use exec, then the function determined by the switch statement could be dynamically changed at runtime(and run like a pig). Otherwise, we need to have those functions implemented so what do we gain? I was also going to say, why not make the functions instance methods, but -- surprise surprise - when I timed it out, the lookup was ever so slightly slower for the instance methods. I had to do about 100,000 loops of it for the speed difference to be definitive, but oddly enough lookup to the module function was faster than looking up an instance method. HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: xinclude and pathnames
Tim Arnold wrote in news:[EMAIL PROTECTED] in comp.lang.python: Tim Arnold [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm using ElementTree to access some xml configuration files, and using the module's xinclude capability. I've got lines like this in the parent xml file (which lives in the same directory as the included xml file): xi:include href=/dept/app/doc/current/en/xml/asdf/asdf_syntaxterms.xml/ When I started the project it was Unix-only; this worked fine. Now I have users who want to use the system on Windows and of course that directory path doesn't exist on Windows, but it is available on the network using a name like \\ladida\current\en\xml\asdf\asdf_syntaxterms.xml if relative paths worked, I could imagine xi:include href=asdf_syntaxterms.xml / would work. Also,the file can be read via an http server. My question: is there a way to make xinclude work with relative paths or perhaps urls? Any ideas welcome--to me it looks like I'll have to restructure this part of the system since I've basically programmed myself into a corner. According to the docs: http://effbot.org/zone/element-xinclude.htm The default handler just sees the href value as a filename, so you should be able to use a relative path if you os.chdir() to the working directory before processing you xml file. I just ran a 3 line sample to make sure os.chdir() works with network paths, which it did. Rob. -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
Carl Banks wrote: metaperl wrote: -- python -i class = algebra File stdin, line 1 class = algebra ^ SyntaxError: invalid syntax Why isn' t the parser smart enough to see that class followed by an identifier is used for class definition but class followed by equals is a simple assignment? Hmm. Someone called metaPERL is asking why Python doesn't have a more complicated grammar. Why does this not surprise me? :) Yeah. But elimination of all keywords and replacement by punctuation is clearly an alternative. One might just start with: @class X(object): @def __init__(self): @print an X and move on to: @% X(object): @_ _init__(self): an X That's all still LL(1) parsable. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
John, Since I'm new to Python, I'm having trouble understanding what this means (see below). Would appreciate any help. if strg[-1] == \0: strg = strg[:-1] Thanks, MDM John Machin wrote: Fredrik Lundh wrote: Michael wrote: Thanks for your reply. Just wondering... how are Python strings formatted? Evidently they're not 0 terminated. have you tried *printing* the thing you got via UDP? to get a programmer-friendly representation of an arbitrary object, use print repr(obj) (where obj is your string, in this case). Probably not; there was no indication after the two messages where I mentioned repr :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter on Python 2.4 on Mac OS X?
Bill Williams wrote: Ben Kovitz [EMAIL PROTECTED] wrote: ...I finally got the Hello World program at http://docs.python.org/lib/node718.html to work, but only under Python 2.3. Has anyone gotten Tkinter running with Python 2.4 on a Mac? The Hello World example works for me. You have to save as applet, though. Thanks for the suggestion, Bill! I would never have guessed that it would make a difference if you make your script an applet (that seems very strange). Now, here's a stupid question: how do you save as an applet? I know IDLE can do that, but my 2.4 IDLE is failing because...Tkinter isn't working with Python 2.4 (same spinning beachball forever as Hello World). If you know a quick way to do it, that would be great, before I go digging into the source code of IDLE. Maybe this is a better question for me to ask: *How* did you get Python 2.4 running with Tkinter on OS X? Ben Kovitz -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
Michael wrote: John, Since I'm new to Python, I'm having trouble understanding what this means (see below). Would appreciate any help. if strg[-1] == \0: If the last (i.e index -1) byte in the string equals ASCII NUL: strg = strg[:-1] then take a slice of the string from the start up to but not including the last byte and assign that to strg In other words, if the last byte of strg is NUL, throw it away. The truly paranoid would code that as if strg and strg[-1] etc etc so that it wouldn't blow up if strg is empty -- strange things can happen when you are reading other people's data :-) Perhaps you should work through the tutorial; all the above concepts are treated in this section: http://docs.python.org/tut/node5.html#SECTION00512 HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
In [EMAIL PROTECTED], John Machin wrote: In other words, if the last byte of strg is NUL, throw it away. The truly paranoid would code that as if strg and strg[-1] etc etc so that it wouldn't blow up if strg is empty -- strange things can happen when you are reading other people's data :-) I would spell it: if strg.endswith('\0'): strg = strg[:-1] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to JavaScript Compiler? Anyone written such a beast?
Helpfull link to JS specific docs in pypy: http://codespeak.net/pypy/dist/pypy/doc/js/using.html -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I would spell it: if strg.endswith('\0'): strg = strg[:-1] I would just go with: strg = strg.rstrip('\0') -- http://mail.python.org/mailman/listinfo/python-list
Re: Outbound port on sockets
bmearns schrieb: Passive mode is implemented, the client isn't trying to use it. Besides, that doesn't really help me anyway, all it means is that I have to resolve port forwarding for the server, instead of for the client. I think what this basically comes down to is that either with PASV or PORT, there's a relatively arbitrary port number being specified, and I can't figure out how to get my router to forward it since I don't know what it will be in advance, short of forwarding all the 64 thousand some odd valid ports. But you can restrict the numbers of ports the server will use to a certain range! It's common for ftp to allow only for so many connections at the same time, so reserve a port-range of 20 or so for your server and configure the router to forward them. The thing that gets me is that I can connect to the other FTP servers, and (according to the responses echoed by the command line FTP client), they're using PORT, not PASV. So somehow, my client is specifying some arbitrary port for the server to connect to, and that port is actually being forwarded through my router. No idea how that happens, but there are protocol aware fire walls. Diez -- http://mail.python.org/mailman/listinfo/python-list