Re: Simple and safe evaluator
On Jun 11, 1:25 pm, bvdp [EMAIL PROTECTED] wrote: Is there a simple/safe expression evaluator I can use in a python program. I just want to pass along a string in the form 1 + 44 / 3 or perhaps 1 + (-4.3*5) and get a numeric result. I can do this with eval() but I really don't want to subject my users to the problems with that method. In this use I don't need python to worry about complex numbers, variables or anything else. Just do the math on a set of values. Would eval() with some restricted list of permitted operators do the trick? I'm feeling too lazy to write/debug my own parser for this :) Thanks, Bob. Funny, I need exactly the same kind of parser myself right now. Fredrik Lundh has posted some code-and-explanation on an excellent simple parser that's easy to extend. http://effbot.org/zone/simple-iterator-parser.htm Just make it recognize the operator tokens you're interested in and if a string parsers w/o errors then you know it's safe to eval(). I probably won't get to writing this myself for a few days or a week, but if you do will you post it here (or send me a copy)? I'll do the same if I get to it sooner. Regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
[issue2517] Error when printing an exception containing a Unicode string
Simon Cross [EMAIL PROTECTED] added the comment: Attached a patch which implements Nick Coghlan's suggestion. All existing tests in test_exceptions.py and test_unicode.py pass as does the new unicode(Exception(u\xe1)) test. Added file: http://bugs.python.org/file10580/exception-unicode-with-type-fetch.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2517] Error when printing an exception containing a Unicode string
Simon Cross [EMAIL PROTECTED] added the comment: Re msg67974: Minor cleanup of Simon's patch attached - aside from a couple of unneeded whitespace changes, it all looks good to me. Not checking it in yet, since it isn't critical for this week's beta release - I'd prefer to leave it until after that has been dealt with. Thanks for the clean-up, Nick. The mixture of tabs and spaces in the current object.c was unpleasant :/. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2517] Error when printing an exception containing a Unicode string
Simon Cross [EMAIL PROTECTED] added the comment: One of the examples Christoph tried was unicode(Exception(u'\xe1')) which fails quite oddly with: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) The reason for this is Exception lacks an __unicode__ method implementation so that unicode(e) does something like unicode(str(e)) which attempts to convert the exception arguments to the default encoding (almost always ASCII) and fails. Fixing this seems quite important. It's common to want to raise errors with non-ASCII characters (e.g. when the data which caused the error contains such characters). Usually the code raising the error has no way of knowing how the characters should be encoded (exceptions can end up being written to log files, displayed in web interfaces, that sort of thing). This means raising exceptions with unicode messages. Using unicode(e.message) is unattractive since it won't work in 3.0 and also does not duplicate str(e)'s handling of the other exception __init__ arguments. I'm attaching a patch which implements __unicode__ for BaseException. Because of the lack of a tp_unicode slot to mirror tp_str slot, this breaks the test that calls unicode(Exception). The existing test for unicode(e) does unicode(Exception(uFoo)) which is a bit of a non-test. My patch adds a test of unicode(Exception(u'\xe1')) which fails without the patch. A quick look through trunk suggests implementing tp_unicode actually wouldn't be a huge job. My worry is that this would constitute a change to the C API for PyObjects and has little chance of acceptance into 2.6 (and in 3.0 all these issues disappear anyway). If there is some chance of acceptance, I'm willing to write a patch that adds tp_unicode. -- nosy: +hodgestar Added file: http://bugs.python.org/file10559/exception-unicode.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2517] Error when printing an exception containing a Unicode string
Simon Cross [EMAIL PROTECTED] added the comment: Concerning http://bugs.python.org/issue1551432: I'd much rather have working unicode(e) than working unicode(Exception). Calling unicode(C) on any class C which overrides __unicode__ is broken without tp_unicode anyway. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2517] Error when printing an exception containing a Unicode string
Simon Cross [EMAIL PROTECTED] added the comment: Benjamin Peterson wrote: What version are you using? In Py3k, str is unicode so __str__ can return a unicode string. I'm sorry it wasn't clear. I'm aware that this issue doesn't apply to Python 3.0. I'm testing on both Python 2.5 and Python 2.6 for the purposes of the bug. Code I'm developing that hits these issues are database exceptions with unicode messages raised inside MySQLdb on Python 2.5. The patch I submitted is against trunk. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Books for learning how to write big programs
On Thu, May 22, 2008 at 4:55 PM, duli [EMAIL PROTECTED] wrote: Hi: I would like recommendations for books (in any language, not necessarily C++, C, python) which have walkthroughs for developing a big software project ? So starting from inception, problem definition, design, coding and final delivery on a single theme or application. With regard to the arcitecture of systems rather than process, there are some good boos liked to from here: http://martinfowler.com/articles/enterprisePatterns.html. Patterns of Enterprise Application Architecture in particular is a bit of a classic. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues | Twitter: brunns -- http://mail.python.org/mailman/listinfo/python-list
Re: Misuse of list comprehensions?
On May 21, 4:36 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Simon Forman a écrit : On May 20, 8:58 am, Paul McGuire [EMAIL PROTECTED] wrote: On May 20, 10:50 am, [EMAIL PROTECTED] wrote: You don't need all those conditionals. A set differs from a list precisely in the fact that each element is unique. And since the function is expecting s to be an iterable object, it can be constructed even without a for loop: def compress(s): return list(set(s)) That does the trick. Only if order does not need to be maintained. list(set(s)) will not necessarily keep the unique characters in the order they are seen. We'll have to check with the OP to see if this is important (I just assumed that it was because of the use of list comps). -- Paul If order is important, you can use sorted() instead of list() like so: def compress(s): new = sorted(set(s), key=s.index) return return ''.join(new) This won't still preserve the *original* order. I don't understand. new will contain each unique item in s, sorted in order of the items' first occurance in s, right? There are other ways to do it (other functions that could be passed to sorted() as the key arg) of course, but this seems like a good value of original order, no? :) Regards, ~S -- http://mail.python.org/mailman/listinfo/python-list
Re: Misuse of list comprehensions?
On May 20, 8:58 am, Paul McGuire [EMAIL PROTECTED] wrote: On May 20, 10:50 am, [EMAIL PROTECTED] wrote: You don't need all those conditionals. A set differs from a list precisely in the fact that each element is unique. And since the function is expecting s to be an iterable object, it can be constructed even without a for loop: def compress(s): return list(set(s)) That does the trick. Only if order does not need to be maintained. list(set(s)) will not necessarily keep the unique characters in the order they are seen. We'll have to check with the OP to see if this is important (I just assumed that it was because of the use of list comps). -- Paul If order is important, you can use sorted() instead of list() like so: def compress(s): new = sorted(set(s), key=s.index) return return ''.join(new) ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: feature proposal, debug on exception
On May 20, 5:59 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: There's an occasional question here about how to get python to launch pdb on encountering an uncaught exception. The answer is to look in some ASPN recipe and do some weird magic. I guess that works, but it's another thing to remember or keep looking up when the occasion arises (some program crashes unexpectedly). I find myself manually adding tracing instead, finding out that I did it wrong and having to re-launch a long-running program, etc. I'd like to propose that debug-on-exception be made into a standard feature that is easy to enable, e.g. with a command line option or with a simple pdb call immediately after the import: import pdb pdb.debug_on_exception(True) ... Would there be big obstacles to this? It would have saved me considerable hassle on a number of occasions. I'm constantly processing large data sets that will munch along happily for hours and hours before hitting some unanticipated condition in the data, and it would be great to trap immediately rather than have to analyze the resulting stack dump and restart. This is not exactly an answer to your proposal, I know, but FWIW Ipython has exactly this capability. Regards, ~S -- http://mail.python.org/mailman/listinfo/python-list
[issue2844] int() lies about base parameter
Simon Cross [EMAIL PROTECTED] added the comment: Some quick digging in the code on trunk has revealed that by the time the base reaches PyInt_FromString in intobject.c, -909 has become 10. Surrounding numbers seem to come through fine. -- nosy: +hodgestar __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2844 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2844] int() lies about base parameter
Simon Cross [EMAIL PROTECTED] added the comment: In int_new in intobject.c the base -909 is used to indicate that no base has been passed through (presumably because NULL / 0 is a more common pitfall that -909). Thus -909 is equivalent to base 10. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2844 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1491] BaseHTTPServer incorrectly implements response code 100
Changes by Simon Cross [EMAIL PROTECTED]: -- nosy: +hodgestar __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1491 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2742] example code does not work
Simon Cross [EMAIL PROTECTED] added the comment: This also affects Python 2.4 and 2.6 on Linux systems. Bug http://bugs.python.org/issue2763 is a duplicate of this one. The issue is that socketmodule.c doesn't convert empty strings to NULLs before passing hptr through to the underlying system getaddrinfo(...). The question is whether to fix the documentation and examples or the socketmodule.c code. -- nosy: +hodgestar versions: +Python 2.4, Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2742 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2742] example code does not work
Simon Cross [EMAIL PROTECTED] added the comment: Attached a patch to correct the getaddrinfo(...) documentation and the code example in socket.rst. -- keywords: +patch Added file: http://bugs.python.org/file10237/getaddrinfo-doesnt-treat-empty-string-as-none.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2742 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2746] ElementTree ProcessingInstruction uses character entities in content
Simon Cross [EMAIL PROTECTED] added the comment: cElementTree.ElementTree is a copy of ElementTree.ElementTree with the .parse(...) method replaced, so the original patch for ElementTree should fix cElementTree too. The copying of the ElementTree class into cElementTree happens in the call to boostrap in the init_elementtree() function at the bottom of _elementtree.c. -- nosy: +hodgestar __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2746 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2736] datetime needs and epoch method
Simon Cross [EMAIL PROTECTED] added the comment: Attached a patch which adds a .totimetuple(...) method to datetime.datetime and tests for it. The intention is that the dt.totimetuple(...) method is equivalent to: mktime(dt.timetuple()) + (dt.microsecond / 100.0) -- keywords: +patch nosy: +hodgestar Added file: http://bugs.python.org/file10251/add-datetime-totimestamp-method.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2736 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2736] datetime needs and epoch method
Simon Cross [EMAIL PROTECTED] added the comment: Patch adding documentation for datetime.totimestamp(...). Added file: http://bugs.python.org/file10256/add-datetime-totimestamp-method-docs.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2736 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
How to convert unicode string to unsigned char *
Hi! I have a C module for which I created a wrapper with swig. The function def is: C: int some_thing(unsigned char * the_str); eg: Python: some_module.some_thing (the_str) Now I would like to feed it with a UTF-8 formatted string: test = u'Make \u0633\u0644\u0627\u0645, not war.' If I try: some_module.some_thing (test) I get: TypeError with message: in method 'some_thing', argument 1 of type 'unsigned char *' I also tried to pack the string into array or struct but I can not get it to work. What would be the best solution for this problem? [I am working on Windows] Regards Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert unicode string to unsigned char *
On Mon, May 5, 2008 at 4:16 PM, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Mon, 5 May 2008 16:05:08 +0200, Simon Posnjak [EMAIL PROTECTED] wrote: On Mon, May 5, 2008 at 3:48 PM, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Mon, 5 May 2008 15:41:08 +0200, Simon Posnjak [EMAIL PROTECTED] wrote: Hi! I have a C module for which I created a wrapper with swig. The function def is: C: int some_thing(unsigned char * the_str); eg: Python: some_module.some_thing (the_str) Now I would like to feed it with a UTF-8 formatted string: test = u'Make \u0633\u0644\u0627\u0645, not war.' `test´ is not a UTF-8 encoded string. It's a unicode string. To get a UTF-8 encoded string from a unicode string, use the `encode´ method: some_module.some_thing(test.encode('utf-8')) Yes you are correct. It is unicode string. But still if I use encode I get the same error: TypeError with message: in method 'some_thing', argument 1 of type 'unsigned char *' So I am looking for a way to cast unicode string to unsigned char *. You need to provide some more information about `some_module.some_thing´. How is it implemented? What Python type does it expect? If it doesn't take a unicode string and it doesn't take a byte string, I don't know what kind of string it does take. some_module.some_thing(the_string) function is a swig generated function from a C lib. The C lib function expects unsigned char *. The generated function is: SWIGINTERN PyObject *_wrap_some_thing(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; unsigned char *arg1 = (unsigned char *) 0 ; unsigned char result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; if (!PyArg_ParseTuple(args,(char *)O:cpot_printer_simple_printf,obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), in method ' some_thing ', argument 1 of type ' unsigned char *'); } arg1 = (unsigned char *)(argp1); result = (unsigned char)some_thing(arg1); resultobj = SWIG_From_unsigned_SS_char((unsigned char)(result)); return resultobj; fail: return NULL; } -- http://mail.python.org/mailman/listinfo/python-list
Writing elapsed time as a string
Hello. I'm sorry if this has been asked a thousand (million) times. Is there a nifty pythonesque way to produce a string representing an elapsed time period, in terms of years, months, days, hours, mins, seconds? I am storing times in a MySQL db, and would love to be able to write the time elapsed between accesses of certain data. These are in seconds since the epoch, as produced by time.time() It is probable right in front of me in the docs but I am spinning off into outer space (mentally!) Thanks for the temporary loan of your clarity and experience. Simon -- http://www.squirtual-reality.com Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
Writing elapsed time as a string
Hello. I'm sorry if this has been asked a thousand (million) times. Is there a nifty pythonesque way to produce a string representing an elapsed time period, in terms of years, months, days, hours, mins, seconds? I am storing times in a MySQL db, and would love to be able to write the time elapsed between accesses of certain data. These are in seconds since the epoch, as produced by time.time() It is probable right in front of me in the docs but I am spinning off into outer space (mentally!) Thanks for the temporary loan of your clarity and experience. Simon -- http://www.squirtual-reality.com Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
problem with dictionaries
Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The value frq[key] is different from the value that key has in the file 'my_frqlist.txt'. I am using Python 2.5.1 Any hints? Simon #!/usr/bin/python import sys frqlist = open('my_frqlist.txt', 'r') # my_frqlist looks like this: # 787560608|the # 434879575|of # 413442185|and # 395209748|to # 284833918|a # 249111541|in # 169988976|is frq = {} for line in frqlist: line = line.rstrip() frequency, word = line.split('|') frq[word] = int(frequency) for key in frq.keys(): print key, frq[key] -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with dictionaries
flippancyYou musts have missed the memo. The rules of the universe changed at 0834 UST yesterday, and all functioning Python programs stopped working./flippancy As always, the rules of the universe have not changed. (Or, at least, I do hope so.) It seems that the cause of my problem was my switching too fast between too many and too seldom saved emacs buffers. Thanks to all for your hints. Simon -- http://mail.python.org/mailman/listinfo/python-list
London Python Meetup, Tuesday May the 6th
It's doubly good time for a Python meet-up. Firstly, Django's Jacob Kaplan-Moss is in town. If I can coax him into speaking, I will. Secondly, what with the release of the Google App Engine, I expect a big increase in interest in Python in general. Details here: http://tinyurl.com/3snu66 -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
python-gammu for Python 2.4 on Windows
Hi everyone, I am looking for binaries (.exe) of python-gammu (any version) for Python 2.4. What I'm getting from the download website is only for Python 2.5. Does anyone know where I can get what I'm looking for? Google isn't really helping :-C Regards, Simon Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008?
On Tue, Apr 8, 2008 at 10:10 AM, Simone Brunozzi [EMAIL PROTECTED] wrote: Greetings! I'm looking for conferences or events about Python, Django, Dabatases, Mysql, PHP, Ruby in Europe (or nearby locations like north africa and middle east) in 2008. Do you have any suggestions? PyCon UK 2008 - 12th to 14th September 2008 - http://www.pyconuk.org/. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning curve for new database program with Python?
On Mon, Apr 7, 2008 at 7:19 PM, Gary Duzan [EMAIL PROTECTED] wrote: It seems to me that ORM can work if your database isn't too complex and it is the only way your database is going to be accessed. I'm working on a big, complex system using an ORM at the moment - http://gu.com. It's a Java/Hibernate/Spring system rather than anything Python based, but the principle is the same. We find that the ORM works great for 99% of our DB interaction, and saves a lot of tedious fiddling around. *But*, the 1% is crucial. Using an ORM doesn't mean you don't have to understand what's going on underneath. When you need to hand craft a performance critical query, or when you are chasing down a bug, you need to know SQL, and know it well. C.F. The Law of Leaky Abstractions - http://tinyurl.com/bmvn. It's not either SQL or ORM. It's both. But SQL should come first. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning curve for new database program with Python?
On Sun, Apr 6, 2008 at 2:31 AM, John Nagle [EMAIL PROTECTED] wrote: Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, UPDATE, and DELETE syntax. That's enough for most simple applications. Agreed. What's more, I've found SQL to be the single most transferable skill in IT.. No matter what language and platform you find yourself working on, you'll find an SQL driven relational database somewhere in the mix. Learning SQL isn't a waste of time, I guarantee it. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic code problem
On Thu, Mar 27, 2008 at 4:13 PM, [EMAIL PROTECTED] wrote: My dynamic code failed at this site http://playwide1.extra.hu/, need some help thank you. http://catb.org/~esr/faqs/smart-questions.html -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Do any of you recommend Python as a first programming language?
On Sun, Mar 23, 2008 at 4:29 AM, Steven D'Aprano [EMAIL PROTECTED] wrote: Python is a programming language. It can be used for scripting, but that's not all it can do. Describing it as a scripting language is like describing a fully-equipped professional kitchen as a left-over warming room. +1 QOTW. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: if __name__ == '__main__':
On Thu, Mar 20, 2008 at 4:12 PM, Bhagwat Kolde [EMAIL PROTECTED] wrote: Hi, I am new to the python and not getting meaning of following line, if __name__ == '__main__': main() http://www.python.org/doc/faq/programming/#how-do-i-find-the-current-module-name -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Removal of tkinter from python 3.0? [was: Fate of the repr module in Py3.0]
On Mar 19, 11:39 pm, Daniel Fetchinson [EMAIL PROTECTED] wrote: Was looking at PEP 3108,http://www.python.org/dev/peps/pep-3108/, and saw that the repr module was slated for vaporization. I've only used the module a few times ever. I'm curious if the community wants it kept around or whether it is considered clutter. The PEP is going to be finalized soon, so if you have issues with it, they should be sent to the PEP author or brought up on the list, http://mail.python.org/mailman/listinfo/stdlib-sig. Is it just me or others also think that it would be a major loss to remove tkinter from the python core? PEP 3108 starts off with: Each module to be removed needs to have a justification as to why it should no longer be distributed with Python. then goes on with, With so many other GUI options out there that are considered better than Tkinter, it might be best to remove Tkinter from the stdlib and make it an externally maintained package. I don't get it. There are many [insert your favorite software component] options outside of the python core that are considered better than the one coming with python, yet they don't get removed. All network servers for example could be thrown out because twisted is considered better. This just doesn't make sense to me. Tkinter is great for its purpose, typical use cases are creating a simple GUI composed of a couple of components only. You can nicely do this with tkinter and the large user base shows that it's a real need real people have. Sure, for fancy GUI stuff there are better options but for quick and simple things tkinter is just great. And last time I checked python comes with batteries included so why sould I need to search and download a third party package for such a common use case? Thoughts anyone? Cheers, Daniel I've been thinking of volunteering to port Tkinter to Python 3.0, I hadn't noticed that there was any discussion of removing it. It would be a shame IMHO. Sure it has warts, but it /works/ and good for quick and dirty GUIs as well as elaborate (even totally visually customized) fancy applications. ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: PODCasts
On Wed, Mar 19, 2008 at 9:06 AM, Mike D [EMAIL PROTECTED] wrote: I really should say net cast as I think it's a better term ;) Since I'm working at The Guardian, I'm bound to stand up for the term 'podcast'. ;-) Besides, it's very established now - too late to fight it. Does anyone have any recommended net casts on Python, or programming in general? Whats everyone listening to? Python411: http://www.awaretek.com/python/index.xml This Week in Django: http://media.djangonetcasts.com/twid_mp3.xml Plus a bunch of non-Python related stuff. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Using threads in python is safe ?
On Wed, Mar 19, 2008 at 7:43 AM, Deepak Rokade [EMAIL PROTECTED] wrote: If jobs to be processed by threds is I/O bound would multithreading help python to improve speed of application ? Probably, yes. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: changing names of items in a list
On Wed, Mar 19, 2008 at 2:21 PM, royG [EMAIL PROTECTED] wrote: hi i am trying to rename extension of files in a directory..as an initial step i made a method in class ConvertFiles: def __init__(self,infldr,outfldr): self.infldr=infldr self.outfldr=outfldr self.origlist=os.listdir(infldr) def renamefiles(self,extn): for x in self.origlist: x=x+.+extn ... later when i print self.origlist i find that the elements of list are unchanged..even tho a print x inside the renamefiles() shows that extn is appended to x .. why does this happen? Your 'x=' line is building a brand new string, and rebinding the name 'x' to it. It's not doing anything to the original list. See http://effbot.org/zone/python-objects.htm. I'd rewrite that as (untested): def renamefiles(self, extn): self.origlist = list((x + . + extn) for x in self.origlist) or def renamefiles(self, extn): self.origlist = list((%s.%s % (z, extn)) for x in self.origlist) Better still, take a look at the os.path module... -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
finding items that occur more than once in a list
Is there a more efficient way to do this? def f(L): '''Return a set of the items that occur more than once in L.''' L = list(L) for item in set(L): L.remove(item) return set(L) | f([0, 0, 1, 1, 2, 2, 3]) set([0, 1, 2]) -- http://mail.python.org/mailman/listinfo/python-list
Re: finding items that occur more than once in a list
I love you guys, thanks! ;-) ~Simon -- http://mail.python.org/mailman/listinfo/python-list
[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation
Simon Percivall [EMAIL PROTECTED] added the comment: It's still a problem, as the test case demonstrates. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2074 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Big file
On Mar 12, 5:42 pm, Andrew Rekdal [EMAIL PROTECTED] wrote: I am working in the class constructor defining elements of an application. The problem is the file is getting unmanageble and I am wanting to extend the contructor __init__ to another file. Is it possible to import directly into the contructor the contents of another module file? If so how would this be done? Thanks -- andrew First, you should consider breaking your __init__() method into smaller pieces (methods) and calling those from within __init__(). That said, you can add attributes to an instance by means of its __dict__ dict attribute: | class foo: | def __init__(self): | self.__dict__['hi'] = ['An object'] | print self.__dict__ | | f = foo() {'hi': ['An object']} | f.hi ['An object'] You might try: | exec 'from sys import *' in f.__dict__ Now everything in sys appears in f: | f.copyright 'Copyright (c) 2001-2006 Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 BeOpen.com.\nAll Rights Reserved.\n \nCopyright (c) 1995-2001 Corporation for National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved.' HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Check For SELF Variable Existance
On Tue, Mar 11, 2008 at 11:00 AM, Robert Rawlins [EMAIL PROTECTED] wrote: I want to be able to check if a class has a certain property in its 'self' scope, what's the best way to do this? class Spam(object): ... def egg(self): ... if hasattr(self, 'chips'): print 'got chips!' ... spam = Spam() spam.egg() spam.chips = 'beans' spam.egg() got chips! -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: lowercase u before string in python for windows
On Mon, Mar 10, 2008 at 5:20 PM, davidj411 [EMAIL PROTECTED] wrote: why does this occur when using the python windows extensions? There's nothing Windows specific about this - it just means that you have unicode strings. See http://effbot.org/zone/unicode-objects.htm, -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Regarding coding style
On Fri, Mar 7, 2008 at 4:31 PM, K Viltersten [EMAIL PROTECTED] wrote: 1. When writing English, Strunk and White apply. I apply Fowler, PEP 8 be damned. ;-) -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: List all files using FTP
On Thu, Mar 6, 2008 at 6:11 PM, jay graves [EMAIL PROTECTED] wrote: On Mar 6, 10:46 am, Anders Eriksson [EMAIL PROTECTED] wrote: I need to list all the files on my FTP account (multiple subdirectories). I don't have shell access to the account. anyone that has a program that will do this? Not offhand, but you can look at the ftpmirror.py script for inspiration. It should be in your Tools/scripts/ subdirectory of your Python installation. This might be of use: http://ftputil.sschwarzer.net/trac -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
How to make rainbow RGB values?
Hey all, I want to map an int to a color on a rainbow spectrum, i.e. for an int n in the range 0..N, low values (near 0) should map to the red end, and high values (near N) to the blue/violet end. The return values should be R, G, B tuples (well, #xx color codes, but that's not the hard part.) The trouble I'm having is in coming up with a good way to generate color values that approximates the ROY G BIV rainbow spectrum. This is just a simple, non-scientific, non-photographic application, nothing fancy. I've tried a simple scheme of overlapping sines, but this resulted in too much red and blue, and no indigo/violet. Any suggestions? I'm searching on the web now but not coming up with much, so I thought I'd ask here. TIA, ~Simon Here's the sinecode I tried: def g(n): ''' map sine [-1.0 .. 1.0] = color byte [0 .. 255] ''' return 255 * (n + 1) / 2.0 def f(start, stop, N): interval = (stop - start) / N for n in range(N): coefficient = start + interval * n yield g(sin(coefficient * pi)) n = 150 RED = f(0.5, 1.5, n) GREEN = f(1.5, 3.5, n) BLUE = f(1.5, 2.5, n) RGBs = [('#%02x%02x%02x' % rgb) for rgb in zip(RED, GREEN, BLUE)] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make rainbow RGB values?
On Feb 24, 5:09 pm, Andrew McNamara [EMAIL PROTECTED] wrote: I want to map an int to a color on a rainbow spectrum, i.e. for an int n in the range 0..N, low values (near 0) should map to the red end, and high values (near N) to the blue/violet end. [...] I've tried a simple scheme of overlapping sines, but this resulted in too much red and blue, and no indigo/violet. Consider using an HSV-RGB conversion function. Saturation (S) and value (V) should remain constant, while Hue (H) varies to get your rainbow effect. -- Andrew McNamara, Senior Developer, Object Crafthttp://www.object-craft.com.au/ Hey thank you very much, that worked like a charm! :] There's even a library function in the colorsys module (http:// docs.python.org/lib/module-colorsys.html) Cheers, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: Missing the last piece of the puzzle
On Feb 23, 9:00 am, [EMAIL PROTECTED] wrote: I have a simple editor built into my visual parser. It has a File menu with typical New, Open, Save, Save As ... options. I now know how to set the options [en/dis]abled and how to check the Text widget's modified flag. Now I want to [en/dis]able those options. Can I ask the text to notify me when the modified flag changes? yes! check out http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/464635 HTH, ~Simon Can I set the statuses when the user clicks File, before the options are displayed? Do I need to create a checker on an independent thread that looks at the flag every few millis? (Tkinter deserves more respect. I've got a good-looking application growing quickly.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Sending key-presses to other programs on Windows, and settings of controls?
On Thu, Feb 21, 2008 at 1:20 PM, Tim van der Leeuw [EMAIL PROTECTED] wrote: I'm looking for ways to send keypresses to another application on Windows XP, and to set values of Windows Controls (all of them text-boxes). Try http://pywinauto.openqa.org/. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Garbage collection
Ken wrote: What is your __del__ method doing? Actually, nothing but printing a message when the object is deleted, just morbid curiosity. I've yet to see one of the destructor messages, tho from sys import getrefcount print getrefcount(x) Perfect, thanks Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Fate of itertools.dropwhile() and itertools.takewhile()
On Dec 29, 2007 11:10 PM, Raymond Hettinger [EMAIL PROTECTED] wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. Personally, I'd rather you kept them around. I have no FP background, and I found them easy enough to understand. These thoughts reflect my own experience with the itertools module. It may be that your experience with them has been different. Please let me know what you think. FWIW, I used them only today: http://tinyurl.com/22q6cb Not sure if something that ugly counts as a reason for keeping them around, though! -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Garbage collection
Hi, I'm building a server with python, but coming from a c++ background, garbage collection seems strange. For instance, I have a manager looking after many objects in a dict. When those objects are no longer needed, I use del manager[objectid], hoping to force the garbage collector to perform the delete. However, this doesn't trigger my overloaded __del__ destructor. Can I simply rely on the python garbage collector to take it from here? Is there a way to find how many references exist for an object? Thanks Simon -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation
New submission from Simon Percivall: _safe_repr() tries to handle the case where two objects are unorderable by ordering on (str(type(key)), key, value), but this fails when str(type(key)) is equal for two objects, but key is different and unorderable. Easy fix: order just on the string representation. -- components: Library (Lib) files: pprint.diff messages: 62303 nosy: percivall severity: normal status: open title: pprint._safe_repr() unsafe on ordering differently types objects with same str represenation versions: Python 3.0 Added file: http://bugs.python.org/file9413/pprint.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2074 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Sudden pyexpat error with ElementTree
Hi, I've been using ElementTree for a few weeks without problem, with Stackless Python. Suddenly I have an error importing expat, in both application and console: [EMAIL PROTECTED]:~$ python Python 2.5.2a0 Stackless 3.1b3 060516 (release25-maint:60694M, Feb 9 2008, 13:21:41) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type help, copyright, credits or license for more information. from xml.parsers import expat Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.5/site-packages/_xmlplus/parsers/expat.py, line 4, in module from pyexpat import * ImportError: /usr/lib/python2.5/site-packages/_xmlplus/parsers/pyexpat.so: undefined symbol: PyUnicodeUCS4_Decode Google shows a few other sufferers, but reveals no answers. I have just rebuilt python to see if I had messed it up somehow, but the problem persists. Thanks for your advice. Simon -- http://mail.python.org/mailman/listinfo/python-list
Events in Python
Hi, I have a stackless python app, using twisted in parts (.internet and .adbapi). I need a little help getting pythonic after years of c++ hell. I'd like to use a system of events and observers, like c++ boost.signal. I'd like to be able to subscribe multiple callbacks to a single function and cal them all using something like: event.invoke(some data to send with invocation) I'm thinking twisted callbacks do this: def observe(self, f); self.event.addcallback(f) Are there other ways? Thanks Si -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
refcount
Hi, Is is possible to access the refcount for an object? Ideally, I am looking to see if I have a refcount of 1 before calling del Thanks Simon -- Linux Counter: User# 424693 -- http://mail.python.org/mailman/listinfo/python-list
REALLY simple xml reader
Hi Can anyone suggest a really simple XML reader for python? I just want to be able to do something like this: xmlDoc = xml.open(file.xml) element = xmlDoc.GetElement(foo/bar) ... to read the value of: foo bar42/bar /foo Thanks Simon -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
Hashable
Hi, The term 'hashable'. Am I right in thinking it means it can be indexed? like a string or a dict? Thanks Si -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
del self?
Hi, Just curious... What are the implications of a class member calling: del self is that what the __del__ method calls anyway? Thanks Simon -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
Pythonland documentation
Hi I am new to python (fairly) but can't stop pythonning. c++ seems so far away now from here it looks like a horrid scribble :) Anyway my question is really about doc tools. I've been used to doxygen in c++ land, and although it makes a reasonable stab with a python project in java mode, the output is a bit messy. Can any one suggest a more tailored tool? or do I risk a flamewar? :) Thanks SiPi -- Linux user #458601 - http://counter.li.org. -- http://mail.python.org/mailman/listinfo/python-list
Treating a unicode string as latin-1
Hello, I'm using ElementTree to parse an XML file which includes some data encoded as cp1252, for example: nameBob\x92s Breakfast/name If this was a regular bytestring, I would convert it to utf8 using the following: print 'Bob\x92s Breakfast'.decode('cp1252').encode('utf8') Bob's Breakfast But ElementTree gives me back a unicode string, so I get the following error: print u'Bob\x92s Breakfast'.decode('cp1252').encode('utf8') Traceback (most recent call last): File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/encodings/cp1252.py, line 15, in decode return codecs.charmap_decode(input,errors,decoding_table) UnicodeEncodeError: 'ascii' codec can't encode character u'\x92' in position 3: ordinal not in range(128) How can I tell Python I know this says it's a unicode string, but I need you to treat it like a bytestring? Thanks, Simon Willison -- http://mail.python.org/mailman/listinfo/python-list
Re: Odd behavior in Python/Tkinter?
On Dec 21, 12:30 pm, Lie [EMAIL PROTECTED] wrote: Inspect the following code: --- start of code --- import Tkinter as Tk from Tkconstants import * root = Tk.Tk() e1 = Tk.Entry(root, text = 'Hello World') e2 = Tk.Entry(root, text = 'Hello World') e1.grid(row = 1, column = 1) e2.grid(row = 2, column = 1) e1.insert(END, 'Hello Python') root.mainloop() --- end of code --- What do you expect the result should be? a. Two textboxes: One contains 'Hello Python', the other 'Hello World' b. Two textboxes: Both containing 'Hello World' c. Two textboxes: Both containing 'Hello Python' d. Two textboxes: Both empty e. Don't know Check your guess with your Python 2.5.1 (AFAIK, the latest version at the moment of writing) Huh. I got C (using python 2.4.3 on Ubuntu Linux..) That ain't right. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie edit/compile/run cycle question
On Dec 8, 6:45 pm, Jeremy C B Nicoll [EMAIL PROTECTED] wrote: Steve Howell [EMAIL PROTECTED] wrote: --- Jeremy C B Nicoll [EMAIL PROTECTED] wrote: What command (in XP) does one need to issue to syntaxcheck a saved python script without running it? Perhaps oversimplifying a bit, running python does a syntaxcheck, and if it passes, moves on the next steps of interpretation/execution. Ah, I've been using IDLE so far (but would probably prefer to write Python in my normal text editor). In IDLE Alt-X syntax checks the saved copy of the file being edited (at least it seems to), and I was wondering how to replicate that elsewhere. I don't know of a command line tool to do that, but I hasten to point out that you have the source code of IDLE available so you could just figure out what it's doing and encapsulate that in a script. Regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Job Offer: Python Ninja or Pirate!
On Dec 10, 6:10 am, Nikos Vergas [EMAIL PROTECTED] wrote: Challenge: A valid response will be either a solution to the problem below, or a link to some code of which you are particularly proud. Problem: In the dynamic language of your choice, write a short program that will: 1. define a list of the following user ids 42346, 77290, 729 (you can hardcode these, but it should still work with more or less ids) 2. retrieve an xml document related to each user at this url http:// api.etsy.com/feeds/xml_user_details.php?id= 3. retrieve the data contained in the city element from each xml document 4. keep a running total of how many users are found in each city 5. display the total count of users living in each city You can assume user ids are valid and that the url is available. The output should look something like: Charlotte: 1 New York: 2 i wanted to make it a one liner, but i had to import modules :( import sys, xml, urllib dummy = [sys.stdout.write(city + ': ' + str(num) + '\n') for city, num in set([[(a, o.count(a)) for a in p] for o, p in [2*tuple([[city for city in ((xml.dom.minidom.parseString(urllib.urlopen('http://api.etsy.com/feeds/xml_user_details.php?id=' + str(id)).read()).getElementsByTagName('city')[0].childNodes + [(lambda t: (setattr(t, 'data', 'no city'), t))(xml.dom.minidom.Text())[1]])[0].data.lower().replace(' ', ' ') for id in [71234, 71234, 71234, 71234, 71234, 71234, 42792])]])]][0])] Cute, now can you make it readable? ;-) ~S -- http://mail.python.org/mailman/listinfo/python-list
[issue1084] ''.find() gives wrong result in Python built with ICC
Simon Anders added the comment: Update to the story: After I submitted the bug report to Intel, they investigated and quickly confirmed it to be a compiler bug, whcih they then managed to fix. I have just got an e-mail from Intel that the newest available version of ICC, namely version l_cc_c_10.1.008, contains the fix. In principle the problem should vanish now, but I have not found the time to verify that. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1084 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to Teach Python Variables
On Nov 25, 2007 6:19 PM, @bag.python.org none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Perhaps you mean: http://effbot.org/zone/python-objects.htm -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: creating color gradients using PIL
On 21 Nov, 06:30, Ramdas [EMAIL PROTECTED] wrote: Any ideas how we can create a color gradient using Python Imaging Library. Has any got some sample code that can give me some idea. I need to create a horizontal and vertical color gradient for a college project Thanks I use these functions for building PIL images from numpy arrays # Convert a 2-d array with typecode 'b' to an image with mode 'P' def numpy2pil(arr): rows = arr.shape[0] cols = arr.shape[1] m = arr.tostring() out = Image.new('L', (cols, rows), 999 ) #out.fromstring(m) out.fromstring(m, 'raw', 'L', 0, -1) return out def pil2numpy(im, typecode='b'): # tostring does something funny with '1' images (packs em tight). # For 'P' images, the image data is not pased through the palette. if im.mode != 'L' and im.mode != 'P': print 'im.mode must be L or P' raise 'terminate' xsize = im.size[0] ysize = im.size[1] m = im.tostring() t = fromstring(m, 'b') tt = asarray(t, typecode) # Note that ysize is first: return reshape(tt, (ysize, xsize)) im = numpy2pil(myarray) im.putpalette(palette_list) im.save('myimage.png') You'll need to import numpy and Image. You'll need to generate the palette (juust a list) and image array (a numpy array) of course. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
Re: python safe scripting
2007/11/21, Vladimir Rusinov [EMAIL PROTECTED]: Yes, but apache, nginx and others does not uses logger. I wanna write an application which would handle all my (Linux) logs: rotating, compressing, analysing and so on (logrotate replacement), it would require some nontrivial configuration, something like If size of this log bigger then 2Mb or today is sunday. If size of this log bigger then 30 Mb, and today is not sunday, then rotate it, and make alert. Is there any module to parse such configuration files? I don't think there's a module for this. Those kinds of tests are fairly easy though. import datetime, os filename = 'myfile.log' if (datetime.date.today().weekday() == 0) or (os.stat(filename)[6] 200): do.whatever() The individual tests would be better wrapped in utility functions of course. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
[issue1358] Compile error on OS X 10.5
Simon Percivall added the comment: It has to do with the MACOSX_DEPLOYMENT_TARGET. If it's set to 10.4, the legacy version of setpgrp is used (with args), it it's 10.5, setpgrp expects no arguments. It seems configure won't detect the difference. -- nosy: +percivall __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1358 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: which Python ? asks beginner
On Nov 17, 2007 6:20 PM, [EMAIL PROTECTED] wrote: Have given up Java. Want to switch to Python. Welcome! But _which_ ? There is ver : 2.5 out now 2.6 in beta , final expected Apr 2008 You should go for 2.5.1 unless you have a reason to stick to an older version. (Such reasons might include your hosting company's Python version, your employer's preferred version, and so on.) 2.6 isn't even in beta yet AFAIK. When it is, you should be able to upgrade to it with nothing more than a few warning messages at worst. At least, that's always been my experience. 3.0 ? in alpha or beta 3.0 final expected Sep 2008 ? Py3k is still in fairly early alpha, and is strictly for Python developers at the moment. Even when it goes final, I wouldn't want to use it in production for a while. So, unless you just want something to play with, steer clear. It'll be an exception to the just-works upgrade that we've been used to in the past, but plans are afoot to make upgrading possible. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Excellent sci-fi novel featuring Python
On Nov 17, 2007 4:25 PM, Paul McGuire [EMAIL PROTECTED] wrote: On Nov 17, 9:37 am, Wade Leftwich [EMAIL PROTECTED] wrote: I'm about halfway through Charles Stross' excellent new novel, Halting State. It's set in Edinburgh in the year 2018, and one of the main characters is a game programmer whose primary language is something called Python 3000. I should hope that by 2018, Python 4000 would be more cutting-edge. Or is the protagonist struggling with backward-compatibility with a Python version that would be nearly 10 years old already? If the whole 3.n series is called Python 3000, then it's very plausible. I can see Python 3.7 or 3.8 being the latest version in 2018. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a good Python environment
Well, I am recent Windows escapee, and was dismayed by lack of Pyscripter for Linux. Hold on... there is hope! Pyscripter works great using WINE. search http://groups.google.com/group/PyScripter?hl=en for Linux Enjoy! Paul Rudin wrote: jwelby [EMAIL PROTECTED] writes: This is a fair question. I didn't phrase my post too well. I find PyScripter does pretty much everything I need in terms of doing actual development for Python. My use of 'lightweight' is by no means a criticism of PyScripter - it's more of a compliment, as it refers to the relatively modest demands that it makes on my system compared with Eclipse, which can be hog. The main reason I have used Eclipse for larger, team based, projects is for the source control plug-ins. Eclipse has plug-in support for cvs and svn. PyScripter may have this too - perhaps I've missed it. (I'm away from my Windows box at the moment, otherwise I would check). Of course, there are other ways to implement source control without it needing to be integrated in the IDE, so even this need not put off anyone who wants to use PyScripter with source control. Summary - unless you need the added flexibility offered by Eclipse plug-ins, PyScripter is a great tool for developing with Python on Windows. I'm not sure if you count emacs as lightweight but it's certainly less resource hungry than eclipse/pydev, and does have integrated cvs/svn functionality. -- http://mail.python.org/mailman/listinfo/python-list
London Python meetup, Wednesday, December the 5th
Details here: http://tinyurl.com/2cvtlq -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Arrays
On Nov 13, 2007 6:58 AM, John Machin [EMAIL PROTECTED] wrote: Hey Bernard, read Gordon's message carefully; he's asking about arrays, not lists. Chances are a list is exactly what the OP wants. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Rothschilds own half the worlds wealth directly and indirectly thru zionist proxies Re: Bill Gates was never the Richest man on earth
On 2007-11-12 18:57:07 +0100, [EMAIL PROTECTED] said: On Nov 11, 5:48 am, GOH, Kheng-Swee [EMAIL PROTECTED] wrote: On Tue, 06 Nov 2007 17:53:01 -, [EMAIL PROTECTED] wrote: ... Using an innovative system of pigeons for communication and encoded letters, ... I didn't believe you until I read that part. It all makes sense now! You would learn a lot MORE if you listened to the videos whose links are provided. Ah, good, we don't have to actually *watch* them ... simon -- http://mail.python.org/mailman/listinfo/python-list
Re: 911 operation by evil JEWS and Mossad
On 2007-11-08 04:21:48 +0100, [EMAIL PROTECTED] said: 911 carried out by evil jews and mossad http://www.guba.com/watch/2000991770 I'm glad it was carried out by evil jews and not by nice ones. That rules me out. simon -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent to heckle
On 11/6/07, rustom [EMAIL PROTECTED] wrote: heckle in ruby is inspired by jester for java. I quote: Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests don't notice, either that code isn't being covered or it doesn't do anything. from http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle Is there anything similar for python?? Pester - http://jester.sourceforge.net/. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Python IDE
Hi, I have recently moved from Windows XP to Ubuntu Gutsy. I need a Python IDE and debugger, but have yet to find one as good as Pyscripter for Windows. Can anyone recommend anything? What are you all using? Coming from a Visual Studio background, editing text files and using the terminal to execute them offends my sensibilities :) Thanks Si -- http://mail.python.org/mailman/listinfo/python-list
[issue1651995] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.5
Simon added the comment: The 255 - 127 change works for me. Let me know if I can help with unit tests or whatever to get this patched. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1651995 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
On 10/31/07, jelle [EMAIL PROTECTED] wrote: the subject pretty much says it all. if I check a string for for a substring, and this substring isn't found, should't the .find method return 0 rather than -1? this breaks the if check.find('something'): do(somethingElse) print 'ughughugh'.find('ugh') ;-) -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
[issue1651995] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.
Changes by Simon: -- nosy: +bind _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1651995 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Monitoring external processes
On 10/23/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there a way to track external processes launched by python on the Mac? I am using subprocess module to launch the process. Depending on how much detail you are looking for, PSI might be worth a look. http://www.psychofx.com/psi/ -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: New module for method level access modifiers
On 10/23/07, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Specifically, I have created 3 decorators named public, private and protected. Lord have mercy. +1 QOTW. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Running another python interpreter
This is very nearly perfect. I have a second console window. Unfortunately, the first is waiting for the second to close. Is there anyway to specify the equivalent of os.P_NOWAIT? Gabriel Genellina wrote: --- Simon Pickles [EMAIL PROTECTED] escribió: os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, gateway.py) ... works but both process output to the same interpreter window. Is there a way to run another interpreter window containing gateway.py? Use the subprocess module, passing CREATE_NEW_CONSOLE into creationflags: subprocess.call([sys.executable, gateway.py, other, arguments], creationflags = subprocess.CREATE_NEW_CONSOLE) -- http://mail.python.org/mailman/listinfo/python-list
Running another python interpreter
Hello, I have several servers which link to each other (and of course, to clients). At present, I am starting them in turn manually. Is there a way with python to say, open gateway.py in a new interpreter window? I looked at execv, etc, but they seem to replace the current process. Ah, maybe I need spawnv(). I am on windows i386, python 2.5 Thanks si -- http://mail.python.org/mailman/listinfo/python-list
Re: Running another python interpreter
Well, I tried: os.spawnv(os.P_NOWAIT, gateway.py, ()) and got: OSError: [Errno 8] Exec format Simon Pickles wrote: Hello, I have several servers which link to each other (and of course, to clients). At present, I am starting them in turn manually. Is there a way with python to say, open gateway.py in a new interpreter window? I looked at execv, etc, but they seem to replace the current process. Ah, maybe I need spawnv(). I am on windows i386, python 2.5 Thanks si -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbi Q: What is a rational for strings not being lists in Python?
On 10/16/07, Benjamin [EMAIL PROTECTED] wrote: Good explanation, but basically strings are immutable so they can be used in dicts. Nope. Value types should always be immutable. http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbi Q: What is a rational for strings not being lists in Python?
On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote: To clarify my point: reverse() is a lucky one - Python has variants of *this particular* function both for lists and strings. Yet what about other list functions? How in general, can I write a function that works both on list and string types? Both are sequences, right? Why string is not a subtype of a list then? Lists are mutable, strings are not, so so strings can't support all a list's methods. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: EasyMock for python ?
On 10/12/07, Ben Finney [EMAIL PROTECTED] wrote: BlueBird [EMAIL PROTECTED] writes: This means that the Mock object automatically supports any number of attributes and methods by any reasonable names; the only setup needed beyond creating the instance is to seed it with anything you *don't* want returned as a Mock. Now *that* is what the OP was talking about - that's not a Mock, that's a Stub. See http://tinyurl.com/26hfjd. . -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: EasyMock for python ?
On 10/10/07, BlueBird [EMAIL PROTECTED] wrote: Does anybody know where to find a library like EasyMock for python ? I searched quickly but could not find anything. I found python-mocks on sourceforge but form quickly reading the docs, it is not an EasyMock style mock. Actually, according to http://martinfowler.com/articles/mocksArentStubs.html I don't think it is even a mock library. More a stub. python-mock is more jMock than EasyMock in style, it's true, and the fact that you define expectations *after* the test invocation rather than before does feel a bit odd. But it does indeed check against the defined expectations, so that makes it a mock library in my book. A record-playback EasyMock style mock library would be nice, it's true... -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter text widget
On Oct 6, 11:18 pm, goldtech [EMAIL PROTECTED] wrote: I thought the DISABLED made it so I could not edit it. But it also makes it so I can not scroll down. If you make the window smaller than the content then try to put a cursor in there to use up/down arrow you can't. What I want is not to be able to change text content, but no other action is disabled. Is this complicated to do? Thanks. from Tkinter import * root = Tk() text = Text(root, font=(Courier)) text.pack() i='123456789abcdefghijklmnopqrstuvwxyz\n' for x in range(30): text.insert(END, i) text.config(state=DISABLED) mainloop() I just tried this script. You can select text and if you drap the selection outside the window then scrolling occurs, also Tk's default behavior of scrolling with the middle button still works (i.e. click- and-drag with the middle button to scroll.) The arrow keys don't scroll the window, but that's because either A. the Text widget won't take 'focus' while disabled -or- B. the arrow keys et. al. work through the cursor which isn't there in disabled mode. I'm guessing and I'm not sure which is right, or if it's something else entirely. Try adding a scrollbar widget and tying it to the Text (there are webpages out there that describe how to do this), I think this widget would still get focus (since it's NOT disabled) and therefore be able to scroll the Text. Or try explicitly binding the arrow keys to scroll commands. ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Emailing the attachment created with the Quick Screenshots Script(Python + PIL)
On 9/28/07, Mark Bratcher [EMAIL PROTECTED] wrote: I tried the suggestion at the other end of this link without any luck. Does anyone have a working script which will send the screenshot file created by the Quick Screenshots Script (Python + PIL)? I receive errors like access denied errors and not defined errors. Could you show us the code you are running, and the exact error messages that you get? This might be worth a look: http://tinyurl.com/anel . -- Cheers, Simon B. [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: True of False
On 9/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I tried writing a true and false If statement and didn't get anything? I read some previous posts, but I must be missing something. I just tried something easy: a = [a, b, c, d, e, f] if c in a == True: Print Yes When I run this, it runs, but nothing prints. What am I doing wrong? Just use if c in a: and all will be well. The True object isn't the only truthy value in Python - see http://docs.python.org/lib/truth.html. -- Cheers, Simon B. [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
cute use of lambda
class FakeQueue(list): put = list.append get = lambda self: self.pop(0) ;] -- http://mail.python.org/mailman/listinfo/python-list
Matplotlib TkAgg WindowsXP ImportError
Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg Traceback (most recent call last): File stdin, line 1, in module File C:\Python25\Lib\site-packages\matplotlib\backends \backend_tkagg.py, line 8, in module import tkagg # Paint image to Tk photo blitter extension File C:\Python25\lib\site-packages\matplotlib\backends\tkagg.py, line 1, in module import _tkagg ImportError: DLL load failed: The specified module could not be found. I found one old (2004) post http://mail.python.org/pipermail/python-list/2004-April/258963.html that seems to indicate that some sort version mismatch of the Tk/Tcl libraries may be to blame. But I don't know how to diagnose that or what to do about it. FWIW, I installed using matplotlib-0.90.1.win32-py2.5.exe and numpy-1.0.3.1.win32-py2.5.exe. Thanks in advance for any help. Sincerely, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: An Editor that Skips to the End of a Def
On 9/26/07, Bjoern Schliessmann [EMAIL PROTECTED] You definitely used the wrong languages :) http://worsethanfailure.com/Articles/The-Other-Kind-of-RPG.aspx Ah, but one edits RPG with SEU[1], Undo - who needs it? -- Cheers, Simon B. [EMAIL PROTECTED] [1] http://tinyurl.com/yvra7l -- http://mail.python.org/mailman/listinfo/python-list
Re: Matplotlib TkAgg WindowsXP ImportError
On 9/26/07, Simon Forman [EMAIL PROTECTED] wrote: Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg Traceback (most recent call last): File stdin, line 1, in module File C:\Python25\Lib\site-packages\matplotlib\backends \backend_tkagg.py, line 8, in module import tkagg # Paint image to Tk photo blitter extension File C:\Python25\lib\site-packages\matplotlib\backends\tkagg.py, line 1, in module import _tkagg ImportError: DLL load failed: The specified module could not be found. I found one old (2004) post http://mail.python.org/pipermail/python-list/2004-April/258963.html that seems to indicate that some sort version mismatch of the Tk/Tcl libraries may be to blame. But I don't know how to diagnose that or what to do about it. FWIW, I installed using matplotlib-0.90.1.win32-py2.5.exe and numpy-1.0.3.1.win32-py2.5.exe. Thanks in advance for any help. Sincerely, ~Simon -- http://mail.python.org/mailman/listinfo/python-list Please disregard. I was missing MSVCP71.dll. Sorry for the 'noise', Sincerely, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Matplotlib TkAgg WindowsXP ImportError
On Sep 26, 1:19 pm, Simon Forman [EMAIL PROTECTED] wrote: Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg Traceback (most recent call last): File stdin, line 1, in module File C:\Python25\Lib\site-packages\matplotlib\backends \backend_tkagg.py, line 8, in module import tkagg # Paint image to Tk photo blitter extension File C:\Python25\lib\site-packages\matplotlib\backends\tkagg.py, line 1, in module import _tkagg ImportError: DLL load failed: The specified module could not be found. I found one old (2004) posthttp://mail.python.org/pipermail/python-list/2004-April/258963.html that seems to indicate that some sort version mismatch of the Tk/Tcl libraries may be to blame. But I don't know how to diagnose that or what to do about it. FWIW, I installed using matplotlib-0.90.1.win32-py2.5.exe and numpy-1.0.3.1.win32-py2.5.exe. Thanks in advance for any help. Sincerely, ~Simon Ah, nevermind. I was missing MSVCP71.dll. Once I included that in the system folder matplotlib ran fine. Sorry for the noise. ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python to create windows apps that everyone can use?
On 9/18/07, Thomas Harding [EMAIL PROTECTED] wrote: Hi guys, sorry to post another topic on this, as I am aware that it has already been posted a few times, but not with specifically what I am looking for. I want an app that makes a gui interface for python (similar to Microsoft visual studio or qt designer, not a code based one) and/ or an app that can make this into a .exe that can be opened by any person on any computer without python installed. For windows only, there's always Iron Python. This allows you to use Visual Studio, the commercial or the express version, to create the GUI in VB or C# and from that call Python code that does all the heavy lifting. I'd second the recommendation for QtDesigner if you want cross- platform capability. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
London Python meetup, Wednesday, October the 10th
ThoughtWorks UK (my employer) have given us the use of a room this time, so I'm looking for volunteer speakers, too. Details here: http://announce.londonpython.org.uk/2007/09/18/london-python-meetup-wednesday-october-the-10th/. -- Cheers, Simon B. [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Tkinter pack difficulty
Thanks everyone for the incredibly helpful replies! I got the effect I wanted, no problem. I don't know why I didn't think to remove the expand option. I thought the sticky option would constrain the expansion. Thanks again, ~Simon -- http://mail.python.org/mailman/listinfo/python-list