[ANN] Zope 3.4.1 KGS released!
== Zope 3.4.1 Released! == June 22, 2010 - The Zope 3 development team announces the Zope 3.4.1 release. The 3.4.1 is the long awaited next bugfix version of 3.4.0. Major changes ~ - setuptools update to 0.6c11, so that it supports svn 1.6. - z3c.layer update to 0.2.4, which is a **SECURITY** fix. For details see the changelog. Packages and Eggs - Zope 3 is now fully converted to an egg-based system. While some work still remains, it integrates very well with the rest of the Python community. The conversion to egg-based packaging also enables other Python developers to only have to use small bits and pieces of the complete Zope software system. The conversion means that Zope 3 developers do not use the classic Zope 3 tar-ball release anymore. However, for your convenience, Zope 3 developers will provide the classic Zope 3 tar ball releases for at least the 3.4 series. So how are Zope 3 applications built using only eggs? The Known Good Set (KGS) The known good set -- or in short KGS -- is a configuration of packages and their versions that are known to work well together. The compatibility is frequently verified by running over twelve thousand tests on a daily basis [1]_. The KGS is tested against Python 2.4 and 2.5 on the 32- and 64-bit platforms. The list of controlled packages and their versions for Zope 3.4 can be found at the Zope 3 KGS site [2]_. The KGS can be used in several ways [3]_. The most common way is to nail the versions by downloading the version configuration file [4]_ and insert them as follows in your buildout configuration:: [buildout] versions = versions ... [versions] zope.interface = 3.4.0 ... ``zopeproject`` Project Builder ~~~ To start building a project using a common setup, a package called `zopeproject` can be used to quickly setup the boilerplate for the project. Ample documentation is provided at the `zopeproject` home page [5]_. `zopeproject` uses Paste or ZDaemon to create a working server. The following commands get you started:: $ easy_install zopeproject $ zopeproject HelloWorld $ cd HelloWorld $ bin/helloworld-ctl foreground Demo Packages ~ At this point, there is no demo package demonstrating a simple Zope 3 application setup. However, the ``z3c.formdemo`` package can be used as a fairly minimal setup. To get started with it, enter the following:: $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/tags/1.5.3 formdemo $ cd formdemo $ python bootstrap.py $ ./bin/buildout -v $ ./bin/demo fg .. [1] http://zope3.pov.lt/buildbot .. [2] http://download.zope.org/zope3.4/3.4.1/controlled-packages.cfg .. [3] http://download.zope.org/zope3.4/intro.html .. [4] http://download.zope.org/zope3.4/3.4.1/versions.cfg .. [5] http://pypi.python.org/pypi/zopeproject Downloads - - Zope 3.4 KGS: http://download.zope.org/zope3.4 - Zope 3.4 Controlled Packages: http://download.zope.org/zope3.4/3.4.1/controlled-packages.cfg - Zope 3.4 Versions: http://download.zope.org/zope3.4/3.4.1/versions.cfg - The classic Zope 3 source release will be made only on request. - The Windows .exe installer will be made only on request. Installation instructions for both Windows and Un*x/Linux are now available in the top level `README.txt` file of the distribution. The binary installer is recommended for Windows. Zope 3.4 requires Python 2.4 or 2.5 to run. You must also have zlib installed on your system. Resources - - Zope 3 Development Web Site: http://wiki.zope.org/zope3 - Zope 3 Developers Mailing List: http://mail.zope.org/mailman/listinfo/zope-dev Retired: http://mail.zope.org/mailman/listinfo/zope3-dev - Zope 3 Users Mailing List: http://mail.zope.org/mailman/listinfo/zope-users - Bug tracker at launchpad: https://launchpad.net/zope3 - IRC Channel: #zope3-dev at irc.freenode.net About Zope 3 Zope 3 is a web application server that continues to build on the heritage of Zope. It was rewritten from scratch based on the latest software design patterns and the experiences of Zope 2. The component architecture is the very core of Zope 3 that allows developers to create flexible and powerful web applications. Compatibility with Zope 2 ~ Zope 3 is not upwards compatible with Zope 2. This means you cannot run Zope 2 applications in Zope 3. We continue to work on the transition from Zope 2 to Zope 3 by making Zope 2 use more and more of the Zope 3 infrastructure. This means that new code written in Zope 2 can benefit from Zope 3 technology. Also, with care, code can be written that works in both Zope 3 and Zope 2. This allows a Zope 2 application to slowly evolve towards Zope 3. Unchanged Zope 2 applications are never expected to work in Zope 3, however. About the Zope Foundation - The
[ANN] pyparsing 1.5.3 released
I'm happy to announce that a new release of pyparsing is now available, version 1.5.3. It has been almost a year and a half since 1.5.2 was released, but pyparsing has remained pretty stable. I believe I have cleaned up the botch-job I made in version 1.5.2 of trying to support both Python 2.x and Python 3.x. This new release will handle it by: - providing version-specific binary installers for Windows users - use version-adaptive code in the source distribution to use the correct version of pyparsing.py for the current Python distribution This release also includes a number of small bug-fixes, plus some very interesting new examples. Here is the high-level summary of what's new in pyparsing 1.5.3: - === NOTE: API CHANGE!!! === With this release, and henceforward, the pyparsing module is imported as pyparsing on both Python 2.x and Python 3.x versions. - Fixed up setup.py to auto-detect Python version and install the correct version of pyparsing - suggested by Alex Martelli, thanks, Alex! (and my apologies to all those who struggled with those spurious installation errors caused by my earlier fumblings!) - Fixed bug on Python3 when using parseFile, getting bytes instead of a str from the input file. - Fixed subtle bug in originalTextFor, if followed by significant whitespace (like a newline) - discovered by Francis Vidal, thanks! - Fixed very sneaky bug in Each, in which Optional elements were not completely recognized as optional - found by Tal Weiss, thanks for your patience. - Fixed off-by-1 bug in line() method when the first line of the input text was an empty line. Thanks to John Krukoff for submitting a patch! - Fixed bug in transformString if grammar contains Group expressions, thanks to patch submitted by barnabas79, nice work! - Fixed bug in originalTextFor in which trailing comments or otherwised ignored text got slurped in with the matched expression. Thanks to michael_ramirez44 on the pyparsing wiki for reporting this just in time to get into this release! - Added better support for summing ParseResults, see the new example, parseResultsSumExample.py. - Added support for composing a Regex using a compiled RE object; thanks to my new colleague, Mike Thornton! - In version 1.5.2, I changed the way exceptions are raised in order to simplify the stacktraces reported during parsing. An anonymous user posted a bug report on SF that this behavior makes it difficult to debug some complex parsers, or parsers nested within parsers. In this release I've added a class attribute ParserElement.verbose_stacktrace, with a default value of False. If you set this to True, pyparsing will report stacktraces using the pre-1.5.2 behavior. - Some interesting new examples, including a number of parsers related to parsing C source code: . pymicko.py, a MicroC compiler submitted by Zarko Zivanov. (Note: this example is separately licensed under the GPLv3, and requires Python 2.6 or higher.) Thank you, Zarko! . oc.py, a subset C parser, using the BNF from the 1996 Obfuscated C Contest. . select_parser.py, a parser for reading SQLite SELECT statements, as specified at http://www.sqlite.org/lang_select.html; this goes into much more detail than the simple SQL parser included in pyparsing's source code . stateMachine2.py, a modified version of stateMachine.py submitted by Matt Anderson, that is compatible with Python versions 2.7 and above - thanks so much, Matt! . excelExpr.py, a *simplistic* first-cut at a parser for Excel expressions, which I originally posted on comp.lang.python in January, 2010; beware, this parser omits many common Excel cases (addition of numbers represented as strings, references to named ranges) . cpp_enum_parser.py, a nice little parser posted my Mark Tolonen on comp.lang.python in August, 2009 (redistributed here with Mark's permission). Thanks a bunch, Mark! . partial_gene_match.py, a sample I posted to Stackoverflow.com, implementing a special variation on Literal that does close matching, up to a given number of allowed mismatches. The application was to find matching gene sequences, with allowance for one or two mismatches. . tagCapture.py, a sample showing how to use a Forward placeholder to enforce matching of text parsed in a previous expression. . matchPreviousDemo.py, simple demo showing how the matchPreviousLiteral helper method is used to match a previously parsed token. Download pyparsing 1.5.3 at http://sourceforge.net/projects/pyparsing/. You can also access pyparsing's epydoc documentation online at http://packages.python.org/pyparsing/. The pyparsing Wiki is at http://pyparsing.wikispaces.com. -- Paul Pyparsing is a pure-Python class library for quickly developing recursive-descent parsers. Parser grammars are assembled directly in the
German 1-day course on XML/ElementTree/lxml in Leipzig, Germany - September 3rd, 2010
Hi everyone, [English version] I will be giving a 1-day beginners course on XML, ElementTree and lxml in September. It will be held in German (although sufficient interest may convince me to give it in English as well). It's called High-Performance XML with Python and will take place at the Python Academy in Leipzig/Germany on September 3rd, 2010. http://www.python-academy.de/Kurse/kurs_xml_python.html http://www.python-academy.com/courses/prices.html If you are interested, please contact me and/or Mike Müller of the PyA. http://www.python-academy.com/contact.html [German version] Am 3. September 2010 gebe ich einen eintägigen deutschsprachigen Einsteigerkurs zu XML, ElementTree und lxml. Der Kurstitel ist High-Performance XML mit Python, Veranstaltungsort ist die Python-Akademie in Leipzig. http://www.python-academy.de/Kurse/kurs_xml_python.html http://www.python-academy.de/Kurse/preise.html Bei Intresse bitte an mich und/oder Mike Müller von der PyA wenden. http://www.python-academy.de/kontakt.html Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN] RedNotebook 1.0
RedNotebook 1.0 has been released. You can get the tarball at http://sourceforge.net/projects/rednotebook/files/ For links to distribution packages head to the RedNotebook homepage http://rednotebook.sourceforge.net What is RedNotebook? RedNotebook is a **graphical journal** and diary helping you keep track of notes and thoughts. It includes a calendar navigation, customizable templates, export functionality and word clouds. You can also format, tag and search your entries. RedNotebook is available in the repositories of most common Linux distributions and a Windows installer is available. What's new? --- * Describe how to add latex math formulas and custom html tags in help * Fix crash on windows when data and program live on different drives in portable mode (LP:581646) * Fix display of italic text in edit mode * Fix inserting templates on Windows * New Translations: * Faroese Cheers, Jendrik -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: 'tsearchpath' Path Search Module, Version 1.08 Released
'tsearchpath' Version 1.108 is now released and available for download at: http://www.tundraware.com/Software/tsearchpath - What's New In This Release? --- This is the initial public release. A FreeBSD port has also been submitted. What Is 'tsearchpath'? --- 'tsearchpath' is a Python module for searching a list of paths for a particular file system 'filename'. This can be the name of a directory, file, or any other entity in the file system. This makes it easy to add things like include- or configuration file paths to your own programs. There is no fee for using 'tsearchpath' so long as the licensing terms found in 'tsearchpath-license.txt' are observed. Please take a moment to review this document. Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN]: newthreading - an approach to simplified thread usage, and a path to getting rid of the GIL
We have just released a proof-of-concept implementation of a new approach to thread management - newthreading. It is available for download at https://sourceforge.net/projects/newthreading/ The user's guide is at http://www.animats.com/papers/languages/newthreadingintro.html This is a pure Python implementation of synchronized objects, along with a set of restrictions which make programs race-condition free, even without a Global Interpreter Lock. The basic idea is that classes derived from SynchronizedObject are automatically locked at entry and unlocked at exit. They're also unlocked when a thread blocks within the class. So at no time can two threads be active in such a class at one time. In addition, only frozen objects can be passed in and out of synchronized objects. (This is somewhat like the multiprocessing module, where you can only pass objects that can be pickled. But it's not as restrictive; multiple threads can access the same synchronized object, one at a time. This pure Python implementation is usable, but does not improve performance. It's a proof of concept implementation so that programmers can try out synchronized classes and see what it's like to work within those restrictions. The semantics of Python don't change for single-thread programs. But when the program forks off the first new thread, the rules change, and some of the dynamic features of Python are disabled. Some of the ideas are borrowed from Java, and some are from safethreading. The point is to come up with a set of liveable restrictions which would allow getting rid of the GIL. This is becoming essential as Unladen Swallow starts to work and the number of processors per machine keeps climbing. This may in time become a Python Enhancement Proposal. We'd like to get some experience with it first. Try it out and report back. The SourceForge forum for the project is the best place to report problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
PyPy 1.3 released
=== PyPy 1.3: Stabilization === Hello. We're please to announce release of PyPy 1.3. This release has two major improvements. First of all, we stabilized the JIT compiler since 1.2 release, answered user issues, fixed bugs, and generally improved speed. We're also pleased to announce alpha support for loading CPython extension modules written in C. While the main purpose of this release is increased stability, this feature is in alpha stage and it is not yet suited for production environments. Highlights of this release == * We introduced support for CPython extension modules written in C. As of now, this support is in alpha, and it's very unlikely unaltered C extensions will work out of the box, due to missing functions or refcounting details. The support is disable by default, so you have to do:: import cpyext before trying to import any .so file. Also, libraries are source-compatible and not binary-compatible. That means you need to recompile binaries, using for example:: python setup.py build Details may vary, depending on your build system. Make sure you include the above line at the beginning of setup.py or put it in your PYTHONSTARTUP. This is alpha feature. It'll likely segfault. You have been warned! * JIT bugfixes. A lot of bugs reported for the JIT have been fixed, and its stability greatly improved since 1.2 release. * Various small improvements have been added to the JIT code, as well as a great speedup of compiling time. Cheers, Maciej Fijalkowski, Armin Rigo, Alex Gaynor, Amaury Forgeot d'Arc and the PyPy team -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Why Is Escaping Data Considered So Magical?
On 25Jun2010 15:54, I wrote: | The number of times I've had to | fix/remove insert-values-into-SQL-text code ... My point here is that with insert-escaped-values-into-sql-text, you only need to forget to do it once (or do it wrong). By using a parameterised form like that required by SQLalchemy the library does it and never forgets. I would also point out that if you use a library to _construct_ the SQL statements themselves eg via SQLA's .select() methods etc then you will never introduce a syntax error into the SQL either. I expect I could construct SQL syntax errors that cause havoc when inserted with correctly escaped parameter values if I tried, probably using quotes in the SQL typo part. Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ George, discussing a patent and prior art: Look, this publication has a date, the patent has a priority date, can't you just compare them? Paul Sutcliffe: Not unless you're a lawyer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
On Fri, 25 Jun 2010 12:25:56 +1200, Lawrence D'Oliveiro wrote: Just been reading this article ... which says that a lot of security holes are arising these days because everybody is concentrating on unit testing of their own particular components, with less attention being devoted to overall integration testing. Fair enough. But it’s disconcerting to see some of the advice being offered in the reader comments, like “force everyone to use stored procedures”, or “force everyone to use prepared/parametrized statements”, “never construct ad-hoc SQL queries” and the like. I construct ad-hoc queries all the time. It really isn’t that hard to do safely. Wrong. Even if you get the quoting absolutely correct (which is a very big if), you have to remember to perform it every time, without exception. And you need to perform it exactly once. As the program gets more complex, ensuring that it's done in the correct place, and only there, gets harder. More generally, as a program gets more complex, this will work so long as we do X every time without fail approaches this won't work. All you have to do is read the documentation—for example, http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html—and then write a routine that takes arbitrary data and turns it into a valid string literal, like this http://www.codecodex.com/wiki/Useful_MySQL_Routines#Quoting. That's okay. Provided the documentation is accurate. And provided that you update the escaping algorithm whenever the SQL dialect gets extended, or you switch to a different back-end, or modify the program. IOW, it's not even remotely okay. Unparsing data so that you get the correct answer out of a subsequent parsing step is objectively and obviously the wrong approach. The correct approach is to skip both the unparsing and parsing steps entirely. Formal grammars are a useful way to represent graph-like data structures in a human-readable and human-editable form. But for creation, modification and use by a computer, it is invariably preferable to operate upon the graph directly. Textual formats inherit all of the issues which apply to the underlying data structure, then add a few of their own for good measure. I've done this sort of thing for MySQL, for HTML and JavaScript (in both Python and JavaScript itself), and for Bash. And, of course, you're convinced that you got it right every time. That attitude alone should set alarm bells ringing for anyone who's worked in this industry for more than five minutes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Classes
On Thu, Jun 24, 2010 at 9:04 AM, Alf P. Steinbach /Usenet alf.p.steinbach+use...@gmail.com wrote: * Mag Gam, on 24.06.2010 13:58: I have been using python for about 1 year now and I really like the language. Obviously there was a learning curve but I have a programing background which made it an easy transition. I picked up some good habits such as automatic code indenting :-), and making my programs more modular by having functions. I know that Python is very OOP friendly, but I could not figure out why and when to use Classes in it. I mostly use it for simple text parsing I suppose when a program gets complicated I should start using Classes. Are there any tips or tricks people use to force them into the OOP mentality? I would like to force myself to learn the Python way but so far I could not figure out WHY I would need a class for this... Use whatever paradigm that yields code that you easily understand. g Having said that, the main use of a class is to model some data with an associated set of operations. For this a class is merely a convenience, but sometimes the convenience can be so great that any other approach would be impractical in comparision. In some cases a non-class approach ends up with a number of routines foo, bar, zlopf etc. that all take some argument of a general type and all internally has some if it's really a BRACHYKLURB, do A, assuming that it has BRACHYKLURB-specific data, but if it's really a KNETCHOFICHUS, then do B, assuming that it has KNETCHOFICHUS-specific data, and as default, if it's none of those, do C. If making up words is an art form, we are in the presence of a master. /applause Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Heuristic
Terry Reedy wrote: On 6/24/2010 9:13 PM, Marcos wrote: I have a store, so I want to maximize the profit. I have all the suppliers with diferent prices, some providers can send products to a client an others not, this has a plus price. Some providers has a discount over the tansport if a quantity is reached. Sometimes its better to me receive the order and resend to the client if I have a transport discount. Not all the suppliers has all products for a order. So I want to create a function which I can pass the data, and generates all the possibilities so I can find the maximum profit. Have I to use heuristics? Do you know some examples?. You would not use a heuristic to generate all possibilities. You might use one to *avoid* doing that, and still get a good, not necessarily optimal, answer. True. Basically there are two ways of approaching the problem. One is to try all the combinations, which will guarantee that you'll find the best solution, but if there are an enormous number of combinations then that could take a very long time. The other way is to use a heuristic to get an reasonable solution in an reasonable time. It's a trade-off. Wikipedia has an general entry on 'heuristic'. Algorithm books often specifically discuss heuristic algorithms. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
Nobody nob...@nowhere.com writes: More generally, as a program gets more complex, this will work so long as we do X every time without fail approaches this won't work. QOTW -- http://mail.python.org/mailman/listinfo/python-list
Re: GDAL-1.7.1 : vcvarsall.bat missing
On 24/06/2010 21:48, Christian Heimes wrote: I am attempting to install the GDAL bindings (GDAL-1.7.1) on a Windows XP Desktop with Python 2.6 and GDAL. During install, the script finishes with error: Unable to find vcvarsall.bat. What dependencies am I missing? Visual Studio 2008 Christian Not always, see my comment here. http://www.mail-archive.com/python-wi...@python.org/msg06755.html Kindest regards. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a non-standard IMAP command?
On Jun 24, 2:23 pm, Michael Torrie torr...@gmail.com wrote: On 06/24/2010 03:47 AM, Xianwen Chen wrote: , but I got error messages. Any hint please? Why not just use a proxy server: http://sourceforge.net/projects/imapidproxy/ Hi Michael Thanks a lot! Yes, it would be much more convenient. Actually, I have been using a modified version of Thunderbird [1] to access Yahoo! Mail IMAP server for months. The reason of using Python to access the mail server is to have less dependency on other software. Now I don't need Thunderbird anymore. Best regards, Xianwen [1] http://www.crasseux.com/linux/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send a non-standard IMAP command?
On Jun 24, 2:25 pm, Tim Chase python.l...@tim.thechases.com wrote: On 06/24/2010 04:47 AM, Xianwen Chen wrote: Thanks a lot for your reply! I thought it would be simpler if the problem was presented in a brief way. Unfortunately, not for this case. Here is the detail. Free Yahoo! mail accounts can be accsessed via IMAP protocal, however, a non-standard shake hand code is needed before log in [1]: ID (GUID 1) . This is what I'm now working for. I tried: IMAP4.xatom('','ID (GUID 1)','',) and dest_srv.xatom('ID (GUID 1)') , but I got error messages. Any hint please? In general, it would be helpful to include the error-message(s) you get. However, I tried it with a junk Yahoo account I set up: from imaplib import IMAP4 i = IMAP4(imap.mail.yahoo.com) USER = 'yourusern...@yahoo.com' PASS = 'your secret goes here' # per the Wikipedia page you gave # the ID has to happen before login i.xatom('ID (GUID 1)') i.login(USER, PASS) i.select() typ, data = i.search(None, 'ALL') for num in data[0].split(): typ, data = i.fetch(num, '(RFC822)') message = data[0][1].splitlines() subject = [line for line in message if line.lower().startswith('subject: ') ][0] print num, subject i.close() i.logout() and it worked. -tkc Hi Tim, The problem was the password. I was careless. Thanks for your advice. Next time I'll have error codes posted. And thanks a lot for your constructive example! I have a strange problem that M = imaplib.IMAP4_SSL(M_addr) M.debug = 2 doesn't work. No verbose output at all. Any hint please? Best regards, Xianwen -- http://mail.python.org/mailman/listinfo/python-list
web application in django
Hi I'm doing web application in django in which I have to make search option that will find on other web page some product(for example) and that product will have to been seen on my page.. now I don't know where to start with programming.. I know I must parse that other page but I don't have idea how to do that.. can someone help me with understanding what I have to do exactly?! Thanks! Tom Talim Email: melan...@gmail.com Site: http://psychologydegree-online.com/ -- http://mail.python.org/mailman/listinfo/python-list
Python 2.7, tkinter problem on OSX
Dear list, Last version of my software relies on ttk. Under windows and linux this is fine. But, OSX users are facing problems (I don't have access to a Mac myself for testing...). Those with OSX 10.6 can run the program. It seems that OSX 8.6 ships with Tk8.5. People with OSX 8.5 cannot run the app. I told them to install python 2.7 which seems to be the first version on OSX to ship with Tk8.5. However, the program still does not run. I asked a person to launch a python 2.7 interpreter and try to import tkinter. This is an excerpt of the output: from Tkinter import * File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py, line 39, in module import _tkinter # If this fails your Python may not be configured for Tk ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so: no matching architecture in universal wrapper Full log is there: http://pastebin.com/vky8FbrP I asked a person to simply open a python2.7 shell and import Tkinter. He got the same error. All of this is executed with Python 2.7rc1. Archives that are on the ftp of python.org. I have seen this bug http://bugs.python.org/issue9045, which is related, but deals with the specificities if OSX 64bit. Can this problem be solved by installing Active TK 8.5 for OSX ? Anybody knows what is the good combination of installer / libraries to install to run a ttk application on OSX 8.5 ? Ideally, I would like to document the setup procedure for 8.5 users. Cheers, Julien -- http://mail.python.org/mailman/listinfo/python-list
django csrf
When I add enctype=text/plain to a post form like form action=/auth method=post enctype=text/plain, there is a CSRF verification failed. error. But when I remove it, all is right. Who can tell me why? -- Li Hui http://www.lihui.org -- http://mail.python.org/mailman/listinfo/python-list
Re: django csrf
Li Hui a écrit : When I add enctype=text/plain to a post form like form action=/auth method=post enctype=text/plain, there is a CSRF verification failed. error. But when I remove it, all is right. Who can tell me why? http://groups.google.com/group/django-users http://catb.org/esr/faqs/smart-questions.html#forum HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: web application in django
I'm doing web application in django in which I have to make search option that will find on other web page some product(for example) and that product will have to been seen on my page.. now I don't know where to start with programming.. I know I must parse that other page but I don't have idea how to do that.. can someone help me with understanding what I have to do exactly?! First fetch the page using urllib2 [1] then parse it with elementtree [2] or beautiful soup [3] or something else [4]. Once you filtered out the data you want you can insert it where ever you need to insert it. Be sure to read this also [5]. HTH, Daniel [1] http://docs.python.org/library/urllib2.html [2] http://docs.python.org/library/xml.etree.elementtree.html [3] http://www.crummy.com/software/BeautifulSoup/ [4] http://wiki.python.org/moin/PythonXml [5] http://catb.org/esr/faqs/smart-questions.html -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: improving python performance by extension module (64bit)
On Thu, 2010-06-24 at 21:52 -0500, Peng Yu wrote: http://psyco.sourceforge.net/ The above package can improve python program on 32 bit library. But I need to run on 64 bit library. Is there any other module that can help improving the performance of python on 64 bit? As I understand it, Psycho isn't likely to get updated to 64-bit unless someone decides to supply a significant amount of funding to the developers. If you've on a platform where compiling C is easy then I'd highly recommending using Cython for objects that have to be high-performance: http://cython.org/ (It generates C from slightly modified python code - I use it on various 64-bit *nix platforms) Otherwise you could write a standard C extension. The major native-code generation projects that I know of are Pypy and Unladen Swallow, but neither of them are ready for use on 64-bit. Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: improving python performance by extension module (64bit)
On Fri, Jun 25, 2010 at 7:01 AM, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2010-06-24 at 21:52 -0500, Peng Yu wrote: http://psyco.sourceforge.net/ The above package can improve python program on 32 bit library. But I need to run on 64 bit library. Is there any other module that can help improving the performance of python on 64 bit? As I understand it, Psycho isn't likely to get updated to 64-bit unless someone decides to supply a significant amount of funding to the developers. If you've on a platform where compiling C is easy then I'd highly recommending using Cython for objects that have to be high-performance: http://cython.org/ (It generates C from slightly modified python code - I use it on various 64-bit *nix platforms) Otherwise you could write a standard C extension. The major native-code generation projects that I know of are Pypy and Unladen Swallow, but neither of them are ready for use on 64-bit. Tim Assuming you really need something like psyco, Cython's the way to go- but you may want to look into writing a C extension, too. I've found in some cases that it can actually be easier than using ctypes or Cython. Geremy Condra PS- a brief note, at some point this week the browser extension I use to swap the 'reply' and 'reply to all' buttons decided to die, so if you've gotten an offlist reply from me during that period, sorry about that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Heuristic
On 25 jun, 04:00, MRAB pyt...@mrabarnett.plus.com wrote: Terry Reedy wrote: On 6/24/2010 9:13 PM, Marcos wrote: I have a store, so I want to maximize the profit. I have all the suppliers with diferent prices, some providers can send products to a client an others not, this has a plus price. Some providers has a discount over the tansport if a quantity is reached. Sometimes its better to me receive the order and resend to the client if I have a transport discount. Not all the suppliers has all products for a order. So I want to create a function which I can pass the data, and generates all the possibilities so I can find the maximum profit. Have I to use heuristics? Do you know some examples?. You would not use a heuristic to generate all possibilities. You might use one to *avoid* doing that, and still get a good, not necessarily optimal, answer. True. Basically there are two ways of approaching the problem. One is to try all the combinations, which will guarantee that you'll find the best solution, but if there are an enormous number of combinations then that could take a very long time. The other way is to use a heuristic to get an reasonable solution in an reasonable time. It's a trade-off. Wikipedia has an general entry on 'heuristic'. Algorithm books often specifically discuss heuristic algorithms. Do you know it there is some way to generate all the scenario possibilities?. So I Can put an array an data an generate all. I have the lack of repeated elements that I cant solve. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
How to get the date format from the users locale?
I'm trying to get the locale-aware date format but it doesn't seem to be available through nl_langinfo in python 2.5.4 (windows vista). Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] onType help, copyright, credits or license for more information. import locale;locale.nl_langinfo Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'nl_langinfo' Is that what I should be using? Is there any other way for getting that info? Thanks, Fabio print '\n'.join(sorted(dir(locale))) CHAR_MAX Error LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME __all__ __builtins__ __doc__ __file__ __name__ _build_localename _group _parse_localename _percent_re _print_locale _setlocale _test atof atoi currency encodings format format_string getdefaultlocale getlocale getpreferredencoding locale_alias locale_encoding_alias localeconv normalize operator re resetlocale setlocale str strcoll strxfrm sys windows_locale -- http://mail.python.org/mailman/listinfo/python-list
reStructuredText format a part of a word
Hi there! Is it possible to format a word using reStructuredText in a way that only a part of it is formatted (e.g. in bold)? I would like to do something like this: my l****ng word where all the os are in bold but this doesn't work with rst2html Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: reStructuredText format a part of a word
On 06/25/2010 01:56 PM, Slafs wrote: Hi there! Is it possible to format a word using reStructuredText in a way that only a part of it is formatted (e.g. in bold)? I would like to do something like this: my l****ng word l\ ****\ nger word? where all the os are in bold but this doesn't work with rst2html Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: reStructuredText format a part of a word
On 25 Cze, 14:06, Thomas Jollans tho...@jollans.com wrote: On 06/25/2010 01:56 PM, Slafs wrote: Hi there! Is it possible to format a word using reStructuredText in a way that only a part of it is formatted (e.g. in bold)? I would like to do something like this: my l****ng word l\ ****\ nger word? where all the os are in bold but this doesn't work with rst2html Regards Yes, thanks, found it too ;] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
On Fri, 2010-06-25, Lawrence D'Oliveiro wrote: Just been reading this article http://www.theregister.co.uk/2010/06/23/xxs_sql_injection_attacks_testing_remedy/ which says that a lot of security holes are arising these days because everybody is concentrating on unit testing of their own particular components, with less attention being devoted to overall integration testing. I don't do SQL and I don't even understand the terminology properly ... but the discussion around it bothers me. Do those people really do this? - accept untrusted user data - try to sanitize the data (escaping certain characters etc) - turn this data into executable code (SQL) - executing it Like the example in the article SELECT * FROM hotels WHERE city = 'untrusted'; If so, its isomorphic with doing os.popen('zcat -f %s' % untrusted) in Python (at least on Unix, where 'zcat ...' is executed as a shell script). I thought it was well-known that the solution is *not* to try to sanitize the input -- it's to switch to an interface which doesn't involve generating an intermediate executable. In the Python example, that would be something like os.popen2(['zcat', '-f', '--', untrusted]). Am I missing something? If not, I can go back to sleep -- and keep avoiding SQL and web programming like the plague until that community has entered the 21st century. /Jorgen -- // Jorgen Grahn grahn@ Oo o. . . \X/ snipabacken.se O o . -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic Idiom For Searching An Include Path
On Thu, 2010-06-24, Nobody wrote: On Wed, 23 Jun 2010 17:27:16 -0500, Tim Daneliuk wrote: Given a program 'foo' that takes a command line argument '-I includefile', I want to be able to look for 'includefile' in a path specified in an environment variable, 'FOOPATH'. I'd like a semantic that says: If 'includefile' contains one or more path separator characters, ignore 'FOOPATH'. If it contains no path separators, look for it in the paths specified by 'FOOPATH', beginning with the leftmost path first. Is there a standard Pythonic idiom for doing this or do I need to cook up my own. There isn't an idiom. There are a surprising number of choices for such a simple task, e.g. whether the search path is used for relative paths containing a separator, whether you stop at the first file which exists or the first file which meets other criteria (e.g. suitable permissions), whether default locations come first or last, what happens if a default location is included in the search path, etc. Another favorite is whether relative paths are relative to your current directory, or to the location of whatever file this is to be included /into/. For an example where it mattered (to C compilers), google for the paper recursive make considered harmful. It took compiler writers decades to realize what the best choice was there. (By the way, -I commonly means search this directory for include files rather than include this file. You may want to avoid confusing people by choosing another letter, like -i.) /Jorgen -- // Jorgen Grahn grahn@ Oo o. . . \X/ snipabacken.se O o . -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic Idiom For Searching An Include Path
On 6/25/2010 7:25 AM, Jorgen Grahn wrote: On Thu, 2010-06-24, Nobody wrote: On Wed, 23 Jun 2010 17:27:16 -0500, Tim Daneliuk wrote: Given a program 'foo' that takes a command line argument '-I includefile', I want to be able to look for 'includefile' in a path specified in an environment variable, 'FOOPATH'. I'd like a semantic that says: If 'includefile' contains one or more path separator characters, ignore 'FOOPATH'. If it contains no path separators, look for it in the paths specified by 'FOOPATH', beginning with the leftmost path first. Is there a standard Pythonic idiom for doing this or do I need to cook up my own. There isn't an idiom. There are a surprising number of choices for such a simple task, e.g. whether the search path is used for relative paths containing a separator, whether you stop at the first file which exists or the first file which meets other criteria (e.g. suitable permissions), whether default locations come first or last, what happens if a default location is included in the search path, etc. Another favorite is whether relative paths are relative to your current directory, or to the location of whatever file this is to be included /into/. For an example where it mattered (to C compilers), google for the paper recursive make considered harmful. It took compiler writers decades to realize what the best choice was there. (By the way, -I commonly means search this directory for include files rather than include this file. You may want to avoid confusing people by choosing another letter, like -i.) /Jorgen I just went ahead and implemented my own. It will eventually find it's way to: http://www.tundraware.com/Software/tsearchpath/ I'll post on c.l.p.a when the thing is released into the wild. Thanks to all that took the time to respond... -- Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list
Python dynamic attribute creation
Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: 1) Modifying a class attribute is metaprogramming, and this is modifying a class, i.e. adding a new attribute to it, thus this should belong to metaprogramming. (I know, strictly speaking, maybe my definition of metaprogramming here is incorrect, I _do_ welcome someone could correct me if I am really wrong, but that is not the main point here, please don't go off-topic.) 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. 3) Thus, allowing dynamic attribute creation by assignment _by default_ is not a good design for me. It is not obvious at all to see if I am doing metaprogramming at a first glance. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. 5) This could hide errors silently, for example, when I do: test.typo = blah I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! I know someone will say you can change this by overriding the __set_attr__ function, like Recipe 6.3 in Python Cookbook. However, this is not default. In my points of view, a better design should be: 1) Disallow dynamic attribute creations by assignments _by default_, thus I expect an error when I do: foo.new_attr = blah AttributeError: by default. 2) For people who want to add a new attribute at runtime, but not to override __set_attr__, he/she should switch to: setattr(foo, new_attr, blah) This will be more like doing metaprogramming rather than non-meta programming, at least more obvious than using an assignment. 3) Allow users who don't like this to change by __set_attr__, of course. Someone argued with me that Python is a dynamic language, allowing this is natural. True, I do understand that attributes in Python are stored in an internal dictionary (__dict__), allowing assignments to an non-existing key is natural. However, this will be a little different when we talk about classes attributes, simple assignments could have side-effects, besides the traditional assignments effect, like in C, that is, creating a new attribute silently. So even from a view of beauty, this is not a good design. I hope someone could teach me more about why Python design it like it is. Any reply is more than welcome. Thanks for your time! -- Live like a child, think like the god. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help on finding word is valid as per English Dictionary through python
Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Do you have any package which can check English Dictionary Please help me. Thanks, Anu -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Jun 25, 2:15 pm, WANG Cong xiyou.wangc...@gmail.com wrote: Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: 1) Modifying a class attribute is metaprogramming, and this is modifying a class, i.e. adding a new attribute to it, thus this should belong to metaprogramming. (I know, strictly speaking, maybe my definition of metaprogramming here is incorrect, I _do_ welcome someone could correct me if I am really wrong, but that is not the main point here, please don't go off-topic.) 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. 3) Thus, allowing dynamic attribute creation by assignment _by default_ is not a good design for me. It is not obvious at all to see if I am doing metaprogramming at a first glance. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. 5) This could hide errors silently, for example, when I do: test.typo = blah I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! I know someone will say you can change this by overriding the __set_attr__ function, like Recipe 6.3 in Python Cookbook. However, this is not default. In my points of view, a better design should be: 1) Disallow dynamic attribute creations by assignments _by default_, thus I expect an error when I do: foo.new_attr = blah AttributeError: by default. 2) For people who want to add a new attribute at runtime, but not to override __set_attr__, he/she should switch to: setattr(foo, new_attr, blah) This will be more like doing metaprogramming rather than non-meta programming, at least more obvious than using an assignment. 3) Allow users who don't like this to change by __set_attr__, of course. Someone argued with me that Python is a dynamic language, allowing this is natural. True, I do understand that attributes in Python are stored in an internal dictionary (__dict__), allowing assignments to an non-existing key is natural. However, this will be a little different when we talk about classes attributes, simple assignments could have side-effects, besides the traditional assignments effect, like in C, that is, creating a new attribute silently. So even from a view of beauty, this is not a good design. I hope someone could teach me more about why Python design it like it is. Any reply is more than welcome. Thanks for your time! -- Live like a child, think like the god. If you desperately want to limit the attribute assignments that can be performed on an object you can set the __slots__ attribute of its type. However, the Python ethos has always been to restrict as little as necessary to provide the tools it needs. Performing additional checks every time an attribute assignment is performed is completely unnecessary. Remember that unlike C these checks would have to be performed at run-time. Richard. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.7, tkinter problem on OSX
There has been a lot of traffic on the MacPython list about this--see the list archives. -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help on finding word is valid as per English Dictionary through python
On 06/25/2010 03:30 PM, anu python wrote: Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Do you have any package which can check English Dictionary In a pinch, I might use open(/usr/share/dict/words, r) as a thesaurus, and check for words in there. Read the file and create a giant frozenset or something. For something a bit more civilized, I expect that there's a python package interfacing at least one of (ispell, aspell, hunspell, myspell) (and what they're all called. There is a multitude of English dictionaries. Some don't even include neighbour, imagine that! Please help me. Thanks, Anu -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
You are thinking like a C programmer Why do you want the language to tie your hands? I want a language to give me the tools I need and get out of the way. The more assumptions that are baked into a language the more opportunities it has to be wrong. Furthermore, object oriented design is a useful paradigm, but it is not the be-all and end-all of how computer programming is done. You should use it where it fits and ignore it where it doesn't. Focus more on doing things elegantly and less on conforming to the popular paradigm du jour. On Fri, Jun 25, 2010 at 9:15 AM, WANG Cong xiyou.wangc...@gmail.com wrote: Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: 1) Modifying a class attribute is metaprogramming, and this is modifying a class, i.e. adding a new attribute to it, thus this should belong to metaprogramming. (I know, strictly speaking, maybe my definition of metaprogramming here is incorrect, I _do_ welcome someone could correct me if I am really wrong, but that is not the main point here, please don't go off-topic.) 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. 3) Thus, allowing dynamic attribute creation by assignment _by default_ is not a good design for me. It is not obvious at all to see if I am doing metaprogramming at a first glance. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. 5) This could hide errors silently, for example, when I do: test.typo = blah I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! I know someone will say you can change this by overriding the __set_attr__ function, like Recipe 6.3 in Python Cookbook. However, this is not default. In my points of view, a better design should be: 1) Disallow dynamic attribute creations by assignments _by default_, thus I expect an error when I do: foo.new_attr = blah AttributeError: by default. 2) For people who want to add a new attribute at runtime, but not to override __set_attr__, he/she should switch to: setattr(foo, new_attr, blah) This will be more like doing metaprogramming rather than non-meta programming, at least more obvious than using an assignment. 3) Allow users who don't like this to change by __set_attr__, of course. Someone argued with me that Python is a dynamic language, allowing this is natural. True, I do understand that attributes in Python are stored in an internal dictionary (__dict__), allowing assignments to an non-existing key is natural. However, this will be a little different when we talk about classes attributes, simple assignments could have side-effects, besides the traditional assignments effect, like in C, that is, creating a new attribute silently. So even from a view of beauty, this is not a good design. I hope someone could teach me more about why Python design it like it is. Any reply is more than welcome. Thanks for your time! -- Live like a child, think like the god. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated string module issue
On Fri, 25 Jun 2010 01:29:22 +, Benjamin Peterson wrote: GrayShark howe.steven at gmail.com writes: Sorry, I meant from string import lowercase, uppercase Technically, you should use ascii_lowercase and ascii_uppercase, though I don't know if that's the cause of pylint's complaints. Thanks for the suggestion. I gave it a quick try. Same 'warning'. No, using the string module is the issue. Perhaps I'll just ignore it. sph -- http://mail.python.org/mailman/listinfo/python-list
Re: Heuristic
I solve optimization problems like this all the time using branch and bound. Just arrange the possible scenarios into a state space tree, (ideally ordered by lowest average cost supplier) then prune any branch where the best case scenario given supplier cost plus shipping cost summed over all remaining orders is greater than your current best total cost. You can make it pretty fast in python if you implement memoization of supplier fulfillment costs for orders. All you need to do is write a depth first search algorithm (stack based, not recursive), a best case predictor for a single order fulfillment (which is summed over all unfulfilled orders) and an actual cost for order fulfillment function. It's really easy to put together, and tends to work quite well. On Fri, Jun 25, 2010 at 7:24 AM, Marcos marcosruap...@gmail.com wrote: On 25 jun, 04:00, MRAB pyt...@mrabarnett.plus.com wrote: Terry Reedy wrote: On 6/24/2010 9:13 PM, Marcos wrote: I have a store, so I want to maximize the profit. I have all the suppliers with diferent prices, some providers can send products to a client an others not, this has a plus price. Some providers has a discount over the tansport if a quantity is reached. Sometimes its better to me receive the order and resend to the client if I have a transport discount. Not all the suppliers has all products for a order. So I want to create a function which I can pass the data, and generates all the possibilities so I can find the maximum profit. Have I to use heuristics? Do you know some examples?. You would not use a heuristic to generate all possibilities. You might use one to *avoid* doing that, and still get a good, not necessarily optimal, answer. True. Basically there are two ways of approaching the problem. One is to try all the combinations, which will guarantee that you'll find the best solution, but if there are an enormous number of combinations then that could take a very long time. The other way is to use a heuristic to get an reasonable solution in an reasonable time. It's a trade-off. Wikipedia has an general entry on 'heuristic'. Algorithm books often specifically discuss heuristic algorithms. Do you know it there is some way to generate all the scenario possibilities?. So I Can put an array an data an generate all. I have the lack of repeated elements that I cant solve. Thanks. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric variable in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. So var+=increment can't be used because Python would rebind the name var to a new object import Tkinter as tk class IntVar2(tk.IntVar): ... def __iadd__(self, val): ... self.set(self.get()+val) ... return self ... root = tk.Tk() myintvar2 = IntVar2() temp = myintvar2 myintvar2 += 5 print(myintvar2.get(),myintvar2 is temp) (5, True) Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Help on finding word is valid as per English Dictionary through python
why do you need that ? which platform are you onto ? On OSX you can use 'DictionaryServices' API eg., import sys import DictionaryServices word = .join(sys.argv[1:]) print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) Gives the meaning of the input word (works with python 2.5) You can use this script for Vi (~/.vimrc) if you want, control+a will do a spell check. Toggle Spell-Check set spell spelllang= function ToggleSpellCheck() if spelllang == en set spelllang= else set spelllang=en endif endfunction command! ToggleSpellChecking call ToggleSpellCheck() nmap c-a :ToggleSpellCheckingcr But again am not aware of your use case. On Fri, Jun 25, 2010 at 7:19 PM, Thomas Jollans tho...@jollans.com wrote: On 06/25/2010 03:30 PM, anu python wrote: Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Do you have any package which can check English Dictionary In a pinch, I might use open(/usr/share/dict/words, r) as a thesaurus, and check for words in there. Read the file and create a giant frozenset or something. For something a bit more civilized, I expect that there's a python package interfacing at least one of (ispell, aspell, hunspell, myspell) (and what they're all called. There is a multitude of English dictionaries. Some don't even include neighbour, imagine that! Please help me. Thanks, Anu -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
On Fri, Jun 25, 2010 at 5:15 AM, Jorgen Grahn grahn+n...@snipabacken.segrahn%2bn...@snipabacken.se wrote: Am I missing something? If not, I can go back to sleep -- and keep avoiding SQL and web programming like the plague until that community has entered the 21st century. You're not missing anything. Its been the accepted industry practice for years and years (and /years/), the taught industry practice, the advised industry practice, the constantly repeated practice on every even vaguely database related forum forever now. However: a) Some people are convinced of their own infallibility, and prefer a clever construct generating a string that has to be parsed due to the cleverness of said construct. b) Some people don't listen / understand. c) Some people don't care. And so, SQL injection attacks continue to persist. Then again, its not like anyone in the C-ish world doesn't know about bounds checking on arrays, do they? But buffer overflows persist. Probably for similar reasons as above (with slightly different 'and prefer' clause) --Stephen -- http://mail.python.org/mailman/listinfo/python-list
Re: GDAL-1.7.1 : vcvarsall.bat missing
On Jun 25, 1:26 am, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/06/2010 21:48, Christian Heimes wrote: I am attempting to install the GDAL bindings (GDAL-1.7.1) on a Windows XP Desktop with Python 2.6 and GDAL. During install, the script finishes with error: Unable to find vcvarsall.bat. What dependencies am I missing? Visual Studio 2008 Christian Not always, see my comment here. http://www.mail-archive.com/python-wi...@python.org/msg06755.html Kindest regards. Mark Lawrence Thanks for the tips, gentlemen. I'll try my luck with Cygwin's ggc before I look into another C/C++ compiler. Kelly Dean Fort Collins, CO -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: (snip) Python's classes are plain objects, and like any other object are created at runtime. Having to special-case them would break the simplicity and uniformity of Python for no good reason. Just like there's no good reason to make setattr() working differently for class and non-class objects. FWIW, what you call metaprogramming is just ordinary programming - at least in Python. All your fears and concerns about Python's dynamism are just a priori learned from the mainstream BD culture. From experience, these are non-issues - unless of course misused by some fool, but then there's no way to prevent stupids from doing stupid things. So, yes, Python rely quite a lot on programmer's common sense and discipline. Now the good news is that is JustWork(tm). -- http://mail.python.org/mailman/listinfo/python-list
python source code - win/dos executable (on linux)
hi. suppose i work in a linux environment, but i would like to ship a win/dos executable file from time to time, just for test purposes (my testers are windows users and don't want to go through the hassle of installing python on their win boxes). what is the best way to do that? (the application should be a simple console app, but my question applies to gui/tkinter apps too) hint: when i do the same in C, i usually do something like: http://www.youtube.com/watch?v=rhe6N7FB1D4 bye -- http://mail.python.org/mailman/listinfo/python-list
Re: GDAL-1.7.1 : vcvarsall.bat missing
I'll try my luck with Cygwin's ggc before I look into another C/C++ compiler. Better grab a recent build of MinGW32. Python's build system has native support for mingw32. IIRC Cygwin's GCC is only supported for Cygwin builds of Python. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: python source code - win/dos executable (on linux)
On 2010-06-25, superpollo ute...@esempio.net wrote: suppose i work in a linux environment, but i would like to ship a win/dos executable file from time to time, just for test purposes (my testers are windows users and don't want to go through the hassle of installing python on their win boxes). what is the best way to do that? (the application should be a simple console app, but my question applies to gui/tkinter apps too) http://www.google.com/search?q=python+windows+executable You're not going to be able to do it on linux. A virtual machine running win2k works fine, though. -- Grant Edwards grant.b.edwardsYow! I left my WALLET in at the BATHROOM!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
os.system: string encoding
How do I set the string encoding for os.system to anything other then UTF-8? (peter) ~ echo $LANG nl...@euro (peter) ~ python3 Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52) '\N{EURO SIGN}' '€' import os os.system('echo \N{EURO SIGN}') â?¬ 0 -- Peter Kleiweg -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated string module issue
On Fri, Jun 25, 2010 at 7:02 AM, GrayShark howe.ste...@gmail.com wrote: Thanks for the suggestion. I gave it a quick try. Same 'warning'. No, using the string module is the issue. Perhaps I'll just ignore it. Perhaps? Why perhaps? The warning is simply factually wrong-- therefore, there's no reason in the world not to ignore it. You can submit a bug to the pylint people though, that may be nice :) Remember that pylint is a third-party tool made by a group of people who have a certain understanding and set of expectations for what's good / bad / right / wrong. It isn't *really* an authoritative voice of what is supported by Python or what is good Python code -- and they even know that, which is why exactly what warnings and such it spits out are *very* configurable, so it can be adjusted to different peoples needs and standards. Its a very useful metric, but consider what it spits out advice and not necessarily errors or problems that need addressing. You have to decide that for yourself on a case-by-case basis. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: improving python performance by extension module (64bit)
On Thu, Jun 24, 2010 at 7:52 PM, Peng Yu pengyu...@gmail.com wrote: http://psyco.sourceforge.net/ The above package can improve python program on 32 bit library. But I need to run on 64 bit library. Is there any other module that can help improving the performance of python on 64 bit? This is a total aside as a response, and I mean no offense by it :) But are you sure you're ready to go there? Your questions have been pretty basic so far, and to go from basic to needing 64-bit performance boosts is a bit jarring. Have you profiled your code and located some bottlenecks where you've determined you need this? Python's slow, sure. But its in practice fast enough for an extremely broad range of activities. In my own personal, entirely anecdotal experience: those places where its not, I've actually often found Python wrappers for libraries that are. The lxml module for instance in some places where I do some crazy-intense xml processing. By using mature, established and fast libraries written in C(++) and wrapped in Python, I get all the benefits of their speed boosts, and don't have to even bother re-inventing the wheel myself and getting all the pesky details right. Now, true. Sometimes there isn't a square wheel already invented and you may find that place where Python's dynamic fluffy love is hiptastic and so its tripping over itself, at which point as others have noted-- Cython's what you're looking for. In my personal experience, that situation is actually really rare, though. Demonstrate you need it before you go out of your way to avoid it -- it'll save you time in the future, I think :) --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Heuristic
What do you suggest Terry? I think this problem its similar to traveler salesman. Some people solve it with Heuristic and some with Linear programming or Stochastic programming. On 25 jun, 03:28, Terry Reedy tjre...@udel.edu wrote: On 6/24/2010 9:13 PM, Marcos wrote: I have a store, so I want to maximize the profit. I have all the suppliers with diferent prices, some providers can send products to a client an others not, this has a plus price. Some providers has a discount over the tansport if a quantity is reached. Sometimes its better to me receive the order and resend to the client if I have a transport discount. Not all the suppliers has all products for a order. So I want to create a function which I can pass the data, and generates all the possibilities so I can find the maximum profit. Have I to use heuristics? Do you know some examples?. You would not use a heuristic to generate all possibilities. You might use one to *avoid* doing that, and still get a good, not necessarily optimal, answer. Wikipedia has an general entry on 'heuristic'. Algorithm books often specifically discuss heuristic algorithms. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Continuously running scripts question
Currently, I have some scripts (in particular, applescript 'stay-open' scripts) that run continuously on a Mac through the day. They look in a certain folder every 30 seconds and perform the necessary work needed. I was curious if anyone here on the list does anything similar with Python? If so, do you use launchd, cron, etc in order to start up your Python script at the appropriate time(s)? Or do you just let your Python code run continuously? I'm curious of the pros and cons with each of these. I'm assuming launchd (or something similar) is probably the better option since if a script broke it would start it back up again the next time around. Launchd also probably doesn't use as much processing power? Thanks. Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: GDAL-1.7.1 : vcvarsall.bat missing
kBob krd...@gmail.com wrote: On Jun 25, 1:26 am, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/06/2010 21:48, Christian Heimes wrote: I am attempting to install the GDAL bindings (GDAL-1.7.1) on a Windows XP Desktop with Python 2.6 and GDAL. During install, the If it suits your needs, you can wire the OSGEO installation of GDAL to a python.org python installation (rather than a bundled OSGEO python interpreter, which is another option): http://trac.osgeo.org/osgeo4w/ Setting the correct paths was enough to get the basic things I used to work (but I haven't used it extensively). Thanks for the tips, gentlemen. I'll try my luck with Cygwin's ggc before I look into another C/C++ compiler. Kelly Dean Fort Collins, CO Giovanni Bajo packages a version of MinGW GCC for use with Python: http://www.develer.com/oss/GccWinBinaries He does note on the page that the MinGW project isn't quite so sure that GCC 4.x is ready for release. Max -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuously running scripts question
On Fri, Jun 25, 2010 at 9:49 AM, jyoun...@kc.rr.com wrote: Currently, I have some scripts (in particular, applescript 'stay-open' scripts) that run continuously on a Mac through the day. They look in a certain folder every 30 seconds and perform the necessary work needed. I was curious if anyone here on the list does anything similar with Python? If so, do you use launchd, cron, etc in order to start up your Python script at the appropriate time(s)? Or do you just let your Python code run continuously? I'm curious of the pros and cons with each of these. I'm assuming launchd (or something similar) is probably the better option since if a script broke it would start it back up again the next time around. Launchd also probably doesn't use as much processing power? I use cron. Pro: You don't have to worry about an unusual exception crashing your script and requiring a restart. You fix the exception when you can, and in the meantime your script is still being run. Con: Most cron implementations have a maximum frequency of once per minute. Con: Starting a fresh Python interpreter is expensive, and doing it once or twice per minute could add significantly if the system is already under a heavy load. When I do this, my scripts generally run once every 15 minutes or thereabouts, so the cons don't really apply. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote: Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: 1) Modifying a class attribute is metaprogramming, and this is modifying a class, i.e. adding a new attribute to it, thus this should belong to metaprogramming. Yes, isn't it wonderful? In other languages, metaprogramming is deepest black magic, or even completely impossible. In Python it is so easy that anyone can do it, and it is something beginners learn. 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. Why should it be? 3) Thus, allowing dynamic attribute creation by assignment _by default_ is not a good design for me. It is not obvious at all to see if I am doing metaprogramming at a first glance. Why do you care if you are doing metaprogramming? Perhaps other languages make it seem difficult and scary, but in Python it is not. It is simple and easy. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Perhaps, and perhaps not. But Python has never pretended to slavishly follow OOP principles. Python does what works, not necessarily what is a pure design. Python has functional programming, procedural programming, and OO programming, and happily mixes them all together. 5) This could hide errors silently, for example, when I do: test.typo = blah Yes, that is one downside to Python's dynamicism. The solutions are: * Unit tests, unit tests, unit tests. Then more unit tests. (You're writing them anyway, aren't you?) * Run PyChecker or PyLint to check the source code for errors. * Don't make typos. *smiles* I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! Then don't do that. I know someone will say you can change this by overriding the __set_attr__ function, like Recipe 6.3 in Python Cookbook. However, this is not default. In my points of view, a better design should be: 1) Disallow dynamic attribute creations by assignments _by default_, There are many languages that do that. Python is not one of them. Python is *designed* to be a dynamic language. If you don't like dynamic languages, then you have many, many, many other choices. Perhaps such a language is better for *you*. Perhaps such non-dynamic languages are better for huge applications written by thousands of developers. But Python is designed to be a rapid prototyping language, and as such, dynamicism is a feature, not a bug. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuously running scripts question
On 2010-06-25, jyoun...@kc.rr.com jyoun...@kc.rr.com wrote: [order modified] I was curious if anyone here on the list does anything similar with Python? If so, do you use launchd, cron, etc in order to start up your Python script at the appropriate time(s)? Or do you just let your Python code run continuously? I'm curious of I do both. I use cron for large time intervals so that the script is not constantly memory resident and I run python continuously, either sleeping or pausing for a signal, when the time interval is small enough that the init overhead becomes significant. the pros and cons with each of these. I'm assuming launchd (or something similar) is probably the better option since if a script broke it would start it back up again the next time around. Launchd also probably doesn't use as much processing power? You can do the same thing by implementing a supervisor process that monitors your worker process so that the supervisor kills and restarts the worker process if it doesn't appear to be functioning properly or crashes. Currently, I have some scripts (in particular, applescript 'stay-open' scripts) that run continuously on a Mac through the day. They look in a certain folder every 30 seconds and perform the necessary work needed. It sounds to me, since your script is acting on an event, that it would benefit from using something like inotify, or whatever your system equivilant would be (FSEvents for Mac? FAM framework for general POSIX. There are python modules available.), so that your script can react when (and only when) it notices changes to the folder in question. -- http://mail.python.org/mailman/listinfo/python-list
followup links (Re: Continuously running scripts question)
On 2010-06-25, Tim Harig user...@ilthio.net wrote: It sounds to me, since your script is acting on an event, that it would benefit from using something like inotify, or whatever your system equivilant would be (FSEvents for Mac? FAM framework for general POSIX. There are python modules available.), so that your script can react when (and only when) it notices changes to the folder in question. pynotify (Linux inotify): http://trac.dbzteam.org/pyinotify FSEvents wrapper: http://pypi.python.org/pypi/pyobjc-framework-FSEvents/2.2b2 FAM: C libraries and daemon: http://savannah.nongnu.org/projects/fam/ Python wrapper: http://sourceforge.net/projects/python-fam/ Similar functionality is available for other platforms; but, you will need to look at the documentation for those platforms for information on how to access it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Fri, Jun 25, 2010 at 6:15 AM, WANG Cong xiyou.wangc...@gmail.com wrote: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Others have answered the rest fine, I just wanted to add: Who says we have to follow OOP principles, huh? If you want to follow OOP principles: Python will do absolutely nothing to stop you! All power to you. You're also free to break the principles if you choose to: this is the key point. Python lets you choose to. If you firmly believe in the principles, you can embrace them fully by simply never choosing to violate them in any way. Some languages force you to adopt the OOP paradigm and build its principles directly into the language. Python does not. A python object is not, necessarily, the same thing as an abstract Object in the OOP world. But you can use it as such an object if you want and do everything OOP needs, though some things (such as encapsulation) are done by convention more then a strict enforcement by the language. Or you can use it and abuse it and do some really interesting and slightly crazy things as you experiment with other paradigms (even some lesser known ones), perhaps inventing a new paradigm all together. :) Most of my code is pretty OOPish. But I have more then a few places where I dig out my metaclass dark magic and transform objects into some distinctly unique tool. Python's content with letting me do that. Not that I'd show anyone or admit to my vices publicly, though. :) --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuously running scripts question
- Original message - Currently, I have some scripts (in particular, applescript 'stay-open' scripts) that run continuously on a Mac through the day. They look in a certain folder every 30 seconds and perform the necessary work needed. Take a look at inotify. Maybe it fits your needs better. Not sure if it is available on mac os. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
Alan G Isaac wrote: div class=moz-text-flowed style=font-family: -moz-fixedOn 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric variable in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. So var+=increment can't be used because Python would rebind the name var to a new object import Tkinter as tk class IntVar2(tk.IntVar): ... def __iadd__(self, val): ... self.set(self.get()+val) ... return self ... root = tk.Tk() myintvar2 = IntVar2() temp = myintvar2 myintvar2 += 5 print(myintvar2.get(),myintvar2 is temp) (5, True) Alan Isaac A real Python integer is immutable. But for tkinter, you want something that can change. So they define an object that can be changed. But the default behavior of += is to assign a new object with the new value, rather than changing the previous object. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On Jun 25, 9:12 am, Alan G Isaac alan.is...@gmail.com wrote: On 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric variable in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. This is a good point. And i have always believed the IntVar should work this way. However it has not been changed because those who have the power to change it really don't use GUI's (much less Tkinter) or for that matter really care. I fear your laments will only fall on deaf ears as the many before you. However i find the control vars in most instances not really the best choice. For check buttons and radiobuttions they are essintial, however for labels, texts, listboxes, etc, just use w.config() As another example; IDLE is full of atrocities like using built-ins for variables, polluting namespaces with from Tkinter import * (not to mention that this slows load time to a crawl when you have load 30 namespaces with 500 or so names), the package is missing much needed comments and doc strings, and the most annoying and i would say *idiotic* of all is the if __name__ == '__main__' tests use root.quit instead of root.destroy! WTF! So after you run your test and try to press the little red X button to close the window guess what happens...yes the mainloop quits processing events but the GUI stays plopped right there on your monitor until you go and kill the process from task manager... WHAT F'N MORON WROTE THIS CODE?!?! But what is more amazing is how this atrocious code has lingered the stdlib for so long. People it's time to wake up, IDLE needs a complete re-write. But i wonder how many have called for changes and those changes have fallen on deaf ears. How many have submitted beautiful code only to be ignored because of childish rivalries? Why do i even waste my time posting to this group? There's a good question. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.7, tkinter problem on OSX
On Jun 25, 1:54 am, Julien Pauty julien.pa...@gmail.com wrote: Last version of my software relies on ttk. Under windows and linux this is fine. But, OSX users are facing problems (I don't have access to a Mac myself for testing...). Those with OSX 10.6 can run the program. It seems that OSX 8.6 ships with Tk8.5. People with OSX 8.5 cannot run the app. I told them to install python 2.7 which seems to be the first version on OSX to ship with Tk8.5. However, the program still does not run. I asked a person to launch a python 2.7 interpreter and try to import tkinter. This is an excerpt of the output: from Tkinter import * File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py, line 39, in module import _tkinter # If this fails your Python may not be configured for Tk ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so: no matching architecture in universal wrapper Full log is there:http://pastebin.com/vky8FbrP I asked a person to simply open a python2.7 shell and import Tkinter. He got the same error. All of this is executed with Python 2.7rc1. Archives that are on the ftp of python.org. I have seen this bughttp://bugs.python.org/issue9045, which is related, but deals with the specificities if OSX 64bit. Can this problem be solved by installing Active TK 8.5 for OSX ? Anybody knows what is the good combination of installer / libraries to install to run a ttk application on OSX 8.5 ? Ideally, I would like to document the setup procedure for 8.5 users. The OS X equation is confuzzulating due to version and API changes in Mac OS X. Let's review ... OS X 10.5 ships Tcl/Tk 8.4 built 32-bit only i386+ppc using Carbon. OS X 10.6 ships Tcl/Tk 8.5 built 32/64 i386+x86_64 using Cocoa. The Cocoa port of Tk was necessary for 64-bit support, as Apple never did supply the promised 64-bit Carbon. Tk 8.5 has Cocoa as an option, and it is default in Tk 8.6. ActiveTcl 8.5 still ships as 32-bit i386+ppc Carbon because going to Cocoa also means you have to drop OS X 10.4 support (out of curiousity - does anyone care about OS X 10.4 anymore that isn't stuck on what's already installed?). 8.5 plans to do so later this year (leaving behind our OS X 10.4 brethren to older versions). ActiveTcl 8.6 (Tcl/ Tk 8.6 is in beta) already ships i386+x86_64 Cocoa. Now there is the issue that Tkinter links to a specific version of Tcl/ Tk. I am currently working on a patch that will remove this limitation (making the binary Tk version independent). So what do you do? Well, it depends on what mix you are trying to make. The easiest is to just run arch -i386 python2.7 and then it will find the compatible i386 Tk. The next release of ActivePython 2.7 (which is building i386+x86_64) will have the Tk version independence, so it could work with core Tk or AT 8.6, or 8.5 in 32-bit mode. Less confuzzulated? Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/25/2010 10:24 AM rantingrick said... On Jun 25, 9:12 am, Alan G Isaacalan.is...@gmail.com wrote: On 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric variable in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. This is a good point. And i have always believed the IntVar should work this way. However it has not been changed because those who have the power to change it really don't use GUI's (much less Tkinter) or for that matter really care. I fear your laments will only fall on deaf ears as the many before you. However i find the control vars in most instances not really the best choice. For check buttons and radiobuttions they are essintial, however for labels, texts, listboxes, etc, just use w.config() As another example; IDLE is full of atrocities like using built-ins for variables, polluting namespaces with from Tkinter import * (not to mention that this slows load time to a crawl when you have load 30 namespaces with 500 or so names), the package is missing much needed comments and doc strings, and the most annoying and i would say *idiotic* of all is the if __name__ == '__main__' tests use root.quit instead of root.destroy! WTF! So after you run your test and try to press the little red X button to close the window guess what happens...yes the mainloop quits processing events but the GUI stays plopped right there on your monitor until you go and kill the process from task manager... WHAT F'N MORON WROTE THIS CODE?!?! But what is more amazing is how this atrocious code has lingered the stdlib for so long. People it's time to wake up, IDLE needs a complete re-write. But i wonder how many have called for changes and those changes have fallen on deaf ears. How many have submitted beautiful code only to be ignored because of childish rivalries? Why do i even waste my time posting to this group? There's a good question. IIRC, IDLE was written by Guido so that he could experience writing in python (which he also wrote). _You_ can either rewrite it or not, but realize no one else is going to do it, so stop wasting your time asking for it to be rewritten. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/25/2010 1:14 PM, Dave Angel wrote: the default behavior of += is to assign a new object with the new value, rather than changing the previous object. a = [] temp = a a += [2] temp [2] Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/25/2010 1:24 PM, rantingrick wrote: the if __name__ == '__main__' tests use root.quit instead of root.destroy! Did you open an issue? http://bugs.python.org/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 06/25/10 17:25, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote: Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: 1) Modifying a class attribute is metaprogramming, and this is modifying a class, i.e. adding a new attribute to it, thus this should belong to metaprogramming. (Thanks for your reply.) Yes, isn't it wonderful? In other languages, metaprogramming is deepest black magic, or even completely impossible. In Python it is so easy that anyone can do it, and it is something beginners learn. The point is why making metaprogramming easy is wonderful? AND, even if it were wonderful, why only this one, i.e. creating attributes by assignments, not other things? In my points of view, a programming language is wonderful only when it is designed so, there is no other things like this one in Python, AFAIK, are as simple as this one, thus making this one really odd to me. :-) 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. Why should it be? It is, if you consider other things of metaprogramming in Python. For example, deleting an attribute. 3) Thus, allowing dynamic attribute creation by assignment _by default_ is not a good design for me. It is not obvious at all to see if I am doing metaprogramming at a first glance. Why do you care if you are doing metaprogramming? Perhaps other languages make it seem difficult and scary, but in Python it is not. It is simple and easy. I do care, programming for a class is quite different from programming for a non-class, even from a historical reason. They sit in different levels of programming. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Perhaps, and perhaps not. But Python has never pretended to slavishly follow OOP principles. Python does what works, not necessarily what is a pure design. Python has functional programming, procedural programming, and OO programming, and happily mixes them all together. Happily mixes them all together doesn't mean it is elegant. :) 5) This could hide errors silently, for example, when I do: test.typo = blah Yes, that is one downside to Python's dynamicism. The solutions are: * Unit tests, unit tests, unit tests. Then more unit tests. (You're writing them anyway, aren't you?) * Run PyChecker or PyLint to check the source code for errors. * Don't make typos. *smiles* Well, I am talking in the language design level, if we could solve this problem in the language design level, why do we need to bother these things? I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! Then don't do that. Yeah, don't do that is one thing, Python allows to do that is another thing. I know someone will say you can change this by overriding the __set_attr__ function, like Recipe 6.3 in Python Cookbook. However, this is not default. In my points of view, a better design should be: 1) Disallow dynamic attribute creations by assignments _by default_, There are many languages that do that. Python is not one of them. Python is *designed* to be a dynamic language. If you don't like dynamic languages, then you have many, many, many other choices. Perhaps such a language is better for *you*. Perhaps such non-dynamic languages are better for huge applications written by thousands of developers. But Python is designed to be a rapid prototyping language, and as such, dynamicism is a feature, not a bug. Such as? As I said in the previous email, this is not so much related with dynamic programmin or not. Using 'setattr()' could also prove Python is a dynamic programming, but Python doesn't choose this by default. Thanks! -- Live like a child, think like the god. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 06/25/10 15:34, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: (snip) Python's classes are plain objects, and like any other object are created at runtime. Having to special-case them would break the simplicity and uniformity of Python for no good reason. Just like there's no good reason to make setattr() working differently for class and non-class objects. For implementaiton, perhaps, but not for the language design, how could a language design be perfect if we can use setattr() like assignments while use other things, e.g. delattr(), not? Is there any way to express delattr() as simple as expressing setattr() with assignments? I doubt... Using assignments to create an attribute hides metaprogramming behide, while using delattr() exposes it. Thanks! -- Live like a child, think like the god. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 06/25/10 14:31, Richard Thomas chards...@gmail.com wrote: snip If you desperately want to limit the attribute assignments that can be performed on an object you can set the __slots__ attribute of its type. However, the Python ethos has always been to restrict as little as necessary to provide the tools it needs. Performing additional checks every time an attribute assignment is performed is completely unnecessary. Remember that unlike C these checks would have to be performed at run-time. I don't care in which way I can limit this, I care why I should limit this by default, not vice versa? Yeah, I do understand this could be a performance issue, but comparing it with a language design issue, _I think_ the latter thing is much more important than the former one. -- Live like a child, think like the god. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
WANG Cong wrote: On 06/25/10 15:34, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still don't get the points why Python designs it like this. My points are: (snip) Python's classes are plain objects, and like any other object are created at runtime. Having to special-case them would break the simplicity and uniformity of Python for no good reason. Just like there's no good reason to make setattr() working differently for class and non-class objects. For implementaiton, perhaps, but not for the language design, how could a language design be perfect if we can use setattr() like assignments while use other things, e.g. delattr(), not? Is there any way to express delattr() as simple as expressing setattr() with assignments? I doubt... del test.a test.a Traceback (most recent call last): File stdin, line 1, in module AttributeError: class test has no attribute 'a' Looks pretty simple to me... ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Jew JUDGE shows off JEW POWER by BULLYING and BLACKMAILING a BLACK PRESIDENT OBAMA
On Jun 22, 8:30 pm, small Pox smallpox...@gmail.com wrote: Jew Judges NEVER came out against the CRIMES of BUSH and CHENEY and LARRY S I L V E R S T E I N - The main player in 911 Jews are coming out from the directions of Corporations, Mafias, Legislators, and now Judge to SUBVERT the UNITED STATES. Please listen to the Speech of Mr Benjamin H Freedman onhttp://iamthewitness.com to see how they BLACKMAILED President WOODROW WILSON to INSTALL a Jew Judge BRANDEIS in the SUPREME COURT - the FIRST one http://abcnews.go.com/Politics/gulf-oil-spill-disaster-judge-overrule... Judge Drills Hole in Deepwater Ban; Obama Promises Immediate Appeal Judge: Drilling Moratorium 'Cannot Justify' Effects on Local Economy 123 comments By ARIANE de VOGUE and JAKE TAPPER WASHINGTON, June 22, 2010 A federal judge ruled today that the Interior Department had acted arbitrarily when it issued a six-month moratorium on all pending, current or approved drilling plans for new deepwater wells in the Gulf of Mexico and Pacific Ocean and agreed to lift the ban. Scientists believe oil is depleting water of oxygen, driving predators to shore. Judge Martin L.C. Feldman granted a preliminary injunction to Hornbeck Offshore Services to lift the moratorium, saying that the government failed to cogently reflect the decision to issue a blanket, generic, indeed punitive, moratorium. The Administrative Procedure Act authorizes judges to review the actions of executive branch agencies only if the action is found to be arbitrary, capricious, and abuse of discretion, or not otherwise in accordance with the law. Feldman said a report by Secretary of the Interior Ken Salazar calling for the moratorium went too far and that he was unable to divine or fathom a relationship between the findings and the immense scope of the moratorium. Recent disclosure documents indicate that Feldman, who was appointed to the bench by President Ronald Reagan, has had financial holdings in energy companies. The Department of Justice said it would immediately appeal the decision. On Jun 22, 2:38 pm, nanothermite911fbibustards - Hide quoted text - - Show quoted text - nanothermite911fbibusta...@gmail.com wrote: The FASCINATING Secret Relationship Between PROFLIGATE WHITES and MISLEADER JEWS A fascinating relationship has existed between the PROFLIGATE WHITES of the European continent and the MISLEADING and MANIPULATING JEWS for more than a thousand years. The understanding of the world history can never commence without a focus on this historical point of view. We will slowly slowly reveal parts of this comprehensive treatise. US Senators Urge Obama To Stand By Israel By Ma'an News 25 June, 2010 Ma'an News Bethlehem – Ma’an – In a letter, 87 American senators told President Barack Obama that the US must continue to stand with Israel. In a senate of 100 members, the group of 87 represents a strong majority. Declaring that Israel faces multiple threats from Hamas in Gaza, Hezbollah in Lebanon, and the current regime in Iran, the senators outlined the importance of Israel as an ally to the US. The letter commended the Obama administration for preventing the adoption of a UN Security Council resolution calling for an international probe into Israel’s deadly raid on an aid boat last month which left nine civilians, including a US citizen, dead. The senators cited the aid mission as one of the clever diplomatic and tactical ploys employed by Israel’s opponents. The group suggested the Turkish Humanitarian Relief Foundation, which was involved in the attempt to send aid to Gaza, should be listed as a terrorist organization, and said it has additional questions about Turkey and any connections to Hamas. Further, the senators declared their opposition to the UN's main human rights organ, stating, We also deplore the actions of the United Nations Human Rights Council which, once again, singled out Israel. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the date format from the users locale?
On Fri, Jun 25, 2010 at 4:39 AM, Fabio Zadrozny fabi...@gmail.com wrote: I'm trying to get the locale-aware date format but it doesn't seem to be available through nl_langinfo in python 2.5.4 (windows vista). There is the %x format specifier in the time module, but it doesn't actually tell you the format, it merely parses/outputs data in that format; thus, it's rather opaque. http://docs.python.org/library/time.html#time.strftime Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Jew JUDGE shows off JEW POWER by BULLYING and BLACKMAILING a BLACK PRESIDENT OBAMA
US Senators Urge Obama To Stand By Israel By Ma'an News 25 June, 2010 Ma'an News Bethlehem – Ma’an – In a letter, 87 American senators told President Barack Obama that the US must continue to stand with Israel. In a senate of 100 members, the group of 87 represents a strong majority. Declaring that Israel faces multiple threats from Hamas in Gaza, Hezbollah in Lebanon, and the current regime in Iran, the senators outlined the importance of Israel as an ally to the US. The letter commended the Obama administration for preventing the adoption of a UN Security Council resolution calling for an international probe into Israel’s deadly raid on an aid boat last month which left nine civilians, including a US citizen, dead. The senators cited the aid mission as one of the clever diplomatic and tactical ploys employed by Israel’s opponents. The group suggested the Turkish Humanitarian Relief Foundation, which was involved in the attempt to send aid to Gaza, should be listed as a terrorist organization, and said it has additional questions about Turkey and any connections to Hamas. Further, the senators declared their opposition to the UN's main human rights organ, stating, We also deplore the actions of the United Nations Human Rights Council which, once again, singled out Israel. On Jun 22, 8:30 pm, small Pox smallpox...@gmail.com wrote: Jew Judges NEVER came out against the CRIMES of BUSH and CHENEY and LARRY S I L V E R S T E I N - The main player in 911 Jews are coming out from the directions of Corporations, Mafias, Legislators, and now Judge to SUBVERT the UNITED STATES. Please listen to the Speech of Mr Benjamin H Freedman onhttp://iamthewitness.com to see how they BLACKMAILED President WOODROW WILSON to INSTALL a Jew Judge BRANDEIS in the SUPREME COURT - the FIRST one http://abcnews.go.com/Politics/gulf-oil-spill-disaster-judge-overrule... Judge Drills Hole in Deepwater Ban; Obama Promises Immediate Appeal Judge: Drilling Moratorium 'Cannot Justify' Effects on Local Economy 123 comments By ARIANE de VOGUE and JAKE TAPPER WASHINGTON, June 22, 2010 A federal judge ruled today that the Interior Department had acted arbitrarily when it issued a six-month moratorium on all pending, current or approved drilling plans for new deepwater wells in the Gulf of Mexico and Pacific Ocean and agreed to lift the ban. Scientists believe oil is depleting water of oxygen, driving predators to shore. Judge Martin L.C. Feldman granted a preliminary injunction to Hornbeck Offshore Services to lift the moratorium, saying that the government failed to cogently reflect the decision to issue a blanket, generic, indeed punitive, moratorium. The Administrative Procedure Act authorizes judges to review the actions of executive branch agencies only if the action is found to be arbitrary, capricious, and abuse of discretion, or not otherwise in accordance with the law. Feldman said a report by Secretary of the Interior Ken Salazar calling for the moratorium went too far and that he was unable to divine or fathom a relationship between the findings and the immense scope of the moratorium. Recent disclosure documents indicate that Feldman, who was appointed to the bench by President Ronald Reagan, has had financial holdings in energy companies. The Department of Justice said it would immediately appeal the decision. On Jun 22, 2:38 pm, nanothermite911fbibustards - Hide quoted text - - Show quoted text - nanothermite911fbibusta...@gmail.com wrote: The FASCINATING Secret Relationship Between PROFLIGATE WHITES and MISLEADER JEWS A fascinating relationship has existed between the PROFLIGATE WHITES of the European continent and the MISLEADING and MANIPULATING JEWS for more than a thousand years. The understanding of the world history can never commence without a focus on this historical point of view. We will slowly slowly reveal parts of this comprehensive treatise. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Fri, Jun 25, 2010 at 11:03 AM, WANG Cong xiyou.wangc...@gmail.comwrote: On 06/25/10 17:25, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Yes, isn't it wonderful? In other languages, metaprogramming is deepest black magic, or even completely impossible. In Python it is so easy that anyone can do it, and it is something beginners learn. The point is why making metaprogramming easy is wonderful? AND, even if it were wonderful, why only this one, i.e. creating attributes by assignments, not other things? In my points of view, a programming language is wonderful only when it is designed so, there is no other things like this one in Python, AFAIK, are as simple as this one, thus making this one really odd to me. :-) What other things? That you define this as 'metaprogramming' is really strange to me. I have no idea what you're talking about when you decide to call adding an attribute to an object that. Classes and instances are not static. They are created at runtime: thus, they can be changed at runtime. Why would you expect anything else? They aren't concrete 'things' like in certain other languages. 2) Metaprogramming should be distinguished with non-meta programming, like templates in C++, it is obvious to see if you are using template metaprogramming in C++. Why should it be? It is, if you consider other things of metaprogramming in Python. For example, deleting an attribute. del obj.a works just fine. 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Perhaps, and perhaps not. But Python has never pretended to slavishly follow OOP principles. Python does what works, not necessarily what is a pure design. Python has functional programming, procedural programming, and OO programming, and happily mixes them all together. Happily mixes them all together doesn't mean it is elegant. :) Its quite elegant in fact. 5) This could hide errors silently, for example, when I do: test.typo = blah Yes, that is one downside to Python's dynamicism. The solutions are: * Unit tests, unit tests, unit tests. Then more unit tests. (You're writing them anyway, aren't you?) * Run PyChecker or PyLint to check the source code for errors. * Don't make typos. *smiles* Well, I am talking in the language design level, if we could solve this problem in the language design level, why do we need to bother these things? Why complicate the language when there's perfectly good ways to solve the problem elsewhere? Especially if those ways -also- have significant benefits of their own. I am expecting Python will compllain that Hey! You have a typo in the attribute name!. Also, this could make code worse to read, if I add a new attribute in one place, and add another one in the another place, and so on, what attributes the hell do I have finally?! Then don't do that. Yeah, don't do that is one thing, Python allows to do that is another thing. Why shouldn't it allow it? If you care about having a firm, set series of attributes that can not change, then you will never add an attribute on the fly. Therefore, you will never run into a situation where you're confused on what attributes are available. Therefore, this works perfectly well as-is. Using 'setattr()' could also prove Python is a dynamic programming, but Python doesn't choose this by default. I don't understand what you're saying here. On Fri, Jun 25, 2010 at 11:18 AM, WANG Cong xiyou.wangc...@gmail.com wrote: On 06/25/10 15:34, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Python's classes are plain objects, and like any other object are created at runtime. Having to special-case them would break the simplicity and uniformity of Python for no good reason. Just like there's no good reason to make setattr() working differently for class and non-class objects. For implementaiton, perhaps, but not for the language design, how could a language design be perfect if we can use setattr() like assignments while use other things, e.g. delattr(), not? Is there any way to express delattr() as simple as expressing setattr() with assignments? I doubt... Huh? Python 2.5.1 (r251:54863, Jun 17 2009, 20:37:34) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. delattr built-in function delattr del obj.x invokes obj.__delattr_(x) just like obj.x = 1 invokes obj.__setattr__(x, 1), and there are delattr() and setattr() convenience functions for both. There's also a getattr() function (which ultimately calls obj.__getattr__) for the 'reading' of said attribute. I'm not sure what you think is missing. The object protocol is fully documented (and customizable). Using assignments to create an attribute hides metaprogramming behide, while using delattr() exposes it. I don't understand what
Re: Why Is Escaping Data Considered So Magical?
On 6/25/2010 12:09 AM, Paul Rubin wrote: Nobodynob...@nowhere.com writes: More generally, as a program gets more complex, this will work so long as we do X every time without fail approaches this won't work. Yes. I was just looking at some of my own code. Out of about 100 SQL statements, I'd used manual escaping once, in code where the WHERE clause is built up depending on what information is available for the search. It's done properly, using MySQLdb.escape_string(s), which is what's used inside cursor.execute. Looking at the code, I now realize that it would have been better to add sections to the SQL string with standard escapes, and at the same time, append the key items to a list. Then the list can be converted to a tuple for submission to cursor.execute. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
(test - ignore)
Having posting problems - ignore -- http://mail.python.org/mailman/listinfo/python-list
[ANN]: newthreading - an approach to simplified thread usage, and a path to getting rid of the GIL
We have just released a proof-of-concept implementation of a new approach to thread management - newthreading. It is available for download at https://sourceforge.net/projects/newthreading/ The user's guide is at http://www.animats.com/papers/languages/newthreadingintro.html This is a pure Python implementation of synchronized objects, along with a set of restrictions which make programs race-condition free, even without a Global Interpreter Lock. The basic idea is that classes derived from SynchronizedObject are automatically locked at entry and unlocked at exit. They're also unlocked when a thread blocks within the class. So at no time can two threads be active in such a class at one time. In addition, only frozen objects can be passed in and out of synchronized objects. (This is somewhat like the multiprocessing module, where you can only pass objects that can be pickled. But it's not as restrictive; multiple threads can access the same synchronized object, one at a time. This pure Python implementation is usable, but does not improve performance. It's a proof of concept implementation so that programmers can try out synchronized classes and see what it's like to work within those restrictions. The semantics of Python don't change for single-thread programs. But when the program forks off the first new thread, the rules change, and some of the dynamic features of Python are disabled. Some of the ideas are borrowed from Java, and some are from safethreading. The point is to come up with a set of liveable restrictions which would allow getting rid of the GIL. This is becoming essential as Unladen Swallow starts to work and the number of processors per machine keeps climbing. This may in time become a Python Enhancement Proposal. We'd like to get some experience with it first. Try it out and report back. The SourceForge forum for the project is the best place to report problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Fri, Jun 25, 2010 at 12:51 PM, Stephen Hansen me+list/pyt...@ixokai.io wrote: Using assignments to create an attribute hides metaprogramming behide, while using delattr() exposes it. I don't understand what you're saying here either. I think he's saying that when an attribute exists in the class dictionary, assigning that attribute to an instance obscures it, and deleting that attribute from an instance exposes it. The point being, I guess, that when an assignment to an instance attribute is performed in the code, it's not immediately obvious whether that assignment is updating something already defined in the class or creating something entirely new. Whereas deleting an instance attribute always exposes whatever is already defined at the class level. I think the distinction is false, though, since deleting an instance attribute says nothing about whether that attribute is defined at the class level to begin with. -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
Alan G Isaac wrote: div class=moz-text-flowed style=font-family: -moz-fixedOn 6/25/2010 1:14 PM, Dave Angel wrote: the default behavior of += is to assign a new object with the new value, rather than changing the previous object. a = [] temp = a a += [2] temp [2] Alan Isaac I said default, not only behavior. I suspect list provides an __iadd__ method to provide this ability. Integers do not, and therefore neither does the object the OP was asking about. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/25/2010 10:12 AM, Alan G Isaac wrote: On 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric variable in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. tkinter was written long before newstyle classes and properties existed. For 3.x, all the classes had to be and were updated. I presume properties could now be used in 3.x to update the interface. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On Jun 25, 12:36 pm, Emile van Sebille em...@fenx.com wrote: IIRC, IDLE was written by Guido so that he could experience writing in python (which he also wrote). _You_ can either rewrite it or not, but realize no one else is going to do it, so stop wasting your time asking for it to be rewritten. I AM rewriting it, however i am heavily contemplating whether i will or will not share the code with such ungrateful heathens. -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated string module issue
On 6/25/2010 10:02 AM, GrayShark wrote: Thanks for the suggestion. I gave it a quick try. Same 'warning'. No, using the string module is the issue. Perhaps I'll just ignore it. And what about the next naive user of pylint? Submitting a bug report to the author of pylint would take much less time than you have *us* to spend helping you. Doing so would be a way of thanking us since then, if pylint were changed, we would not have to answer the same question again in a year. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Help on finding word is valid as per English Dictionary through python
On 6/25/2010 9:30 AM, anu python wrote: Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Cut and paste your code into anything that does spell checking. For instance, I am answering this with Mozilla Thunderbird, and 'lcose' above is underlined in red, though not here because of the single versus double quote. (So is 'txt', but one just has to ignore intended non-English words.) OpenOffice would do just as well, and that lets you add custom dictionaries. For instance, I have a Python dictionary to which I add things like 'def' as needed. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
hex question
Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On Jun 25, 12:46 pm, Alan G Isaac alan.is...@gmail.com wrote: On 6/25/2010 1:24 PM, rantingrick wrote: the if __name__ == '__main__' tests use root.quit instead of root.destroy! Did you open an issue?http://bugs.python.org/ If *I* open an issue it will be ignored or quickly dismissed because the people in charge of the Python community hate me. The reason for this hate is because I am very outspoken and will not allow myself to be brow beaten by some of the thugs within this group. Thats Ok, the only people they hurt in the end is themselves. Well not really... their actions filter out improvements that will benefit others. I have said it before and i'll say it again... IDLE IS BROKEN BEYOND REPAIR! WE MUST SALVAGE THE VERY FEW PARTS OF IT THAT CAN BE SALVAGED AND RE-WRITE THE REST FROM THE GROUND UP! YOU CANNOT KEEP MONKEY PATCHING BROKEN SOFTWARE!!! Until that statement sinks into the exceedingly thick skulls around here we will forever live in a state of stdlib hell. Yes IDLE was originally written by the great GvR. He had a vision and we failed to maintain that vision. The code sucks and is in a state not welcome in any stdlib, however i am sure at the time he wrote it he could not make as pretty as it should have been because he was also in the process of building Python itself. I don't blame GvR for the poor style of IDLE. I blame ALL OF YOU for not allowing new code to replace this rotten piece of crap that makes python look like some children's toy. You people should be ashamed of yourselves. You have fallen asleep at the wheel and now the Valdeez is spewing black crude into the word of programming covering all hope with a nasty black film of pollution. Some of you don't care about IDLE, well thats fine, but you should care about the stdlib being clean and up to date. -- http://mail.python.org/mailman/listinfo/python-list
[ANN]: newthreading - an approach to simplified thread usage, and a path to getting rid of the GIL
We have just released a proof-of-concept implementation of a new approach to thread management - newthreading. It is available for download at https://sourceforge.net/projects/newthreading/ The user's guide is at http://www.animats.com/papers/languages/newthreadingintro.html This is a pure Python implementation of synchronized objects, along with a set of restrictions which make programs race-condition free, even without a Global Interpreter Lock. The basic idea is that classes derived from SynchronizedObject are automatically locked at entry and unlocked at exit. They're also unlocked when a thread blocks within the class. So at no time can two threads be active in such a class at one time. In addition, only frozen objects can be passed in and out of synchronized objects. (This is somewhat like the multiprocessing module, where you can only pass objects that can be pickled. But it's not as restrictive; multiple threads can access the same synchronized object, one at a time. This pure Python implementation is usable, but does not improve performance. It's a proof of concept implementation so that programmers can try out synchronized classes and see what it's like to work within those restrictions. The semantics of Python don't change for single-thread programs. But when the program forks off the first new thread, the rules change, and some of the dynamic features of Python are disabled. Some of the ideas are borrowed from Java, and some are from safethreading. The point is to come up with a set of liveable restrictions which would allow getting rid of the GIL. This is becoming essential as Unladen Swallow starts to work and the number of processors per machine keeps climbing. This may in time become a Python Enhancement Proposal. We'd like to get some experience with it first. Try it out and report back. The SourceForge forum for the project is the best place to report problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs Form Feed (^L) Display Suggestion and Tips
On Jun 24, 11:12 am, Tassilo Horn tass...@member.fsf.org wrote: Xah Lee xah...@gmail.com writes: Hi Xah, also, besides emacs elisp, does anyone see the form feed char in other lang source code? It's quite often used in messages in newsgroups and mailing lists. The Gnus news- and mailreader creates nice Next/Previous page buttons from them and hides the next/previous part. Really good for posting fun questions, so that you don't see the answer directly. Why did the chicken cross the road? To show the raccoon it could be done!! Tassilo, i use google groups to read news, so i don't see any form feed. Don't think i can see them in any or most web based interface. Just checked gmane.org it also doesn't show. With google group, if you view the message raw, it's still there though... Xah -- http://mail.python.org/mailman/listinfo/python-list
Re: hex question
On 6/25/2010 1:20 PM Sneaky Wombat said... Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? It's not happening. What you're seeing is the representation of the four bytes, and \x0a _is_ \n and python displays the common form to assist interpretation. What you can do is write a display function to suit your needs if it makes a difference. \x48\x54\x48\x2c Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: hex question
Sneaky Wombat wrote: Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? '\x0a' == '\n' -- http://mail.python.org/mailman/listinfo/python-list
Re: Help on finding word is valid as per English Dictionary through python
Please don't top post! On 25/06/2010 15:20, Shashwat Anand wrote: why do you need that ? which platform are you onto ? On OSX you can use 'DictionaryServices' API eg., import sys import DictionaryServices word = .join(sys.argv[1:]) print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) Gives the meaning of the input word (works with python 2.5) You can use this script for Vi (~/.vimrc) if you want, control+a will do a spell check. Toggle Spell-Check set spell spelllang= function ToggleSpellCheck() ifspelllang == en set spelllang= else set spelllang=en endif endfunction command! ToggleSpellChecking call ToggleSpellCheck() nmapc-a :ToggleSpellCheckingcr But again am not aware of your use case. On Fri, Jun 25, 2010 at 7:19 PM, Thomas Jollanstho...@jollans.com wrote: On 06/25/2010 03:30 PM, anu python wrote: Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How do you discover the difference between e.g. use and sue, or are you not interested in that? How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Do you have any package which can check English Dictionary In a pinch, I might use open(/usr/share/dict/words, r) as a thesaurus, and check for words in there. Read the file and create a giant frozenset or something. For something a bit more civilized, I expect that there's a python package interfacing at least one of (ispell, aspell, hunspell, myspell) (and what they're all called. There is a multitude of English dictionaries. Some don't even include neighbour, imagine that! Please help me. Thanks, Anu -- http://mail.python.org/mailman/listinfo/python-list Are you talking about correct English, as in that from Angleland, or are you going for one of those silly foreign ones, like USA, South Africa, Australia, New Zealand or wherever? Kindest regards. Mark Lawrence. p.s. my mum was a Celt as in Welsh!!! -- http://mail.python.org/mailman/listinfo/python-list
value of: None is None is None
Surprising for a moment, if you don't immediatelyrecognize it as a chained comparison. (Just sharing.) Alan Isaac None is None is None True (None is None) is None False None is (None is None) False -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On 6/25/2010 3:52 PM, Dave Angel wrote: I said default, not only behavior. I suspect list provides an __iadd__ method to provide this ability. Integers do not, and therefore neither does the object the OP was asking about. I have no idea what default behavior is supposed to mean. Mutable objects like a list will generally modify in place. Immutable objects of course will not. An IntVar is mutable. You have given no reason for it not to handle ``+=`` in an unsurprising fashion. It is not an int. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: improving python performance by extension module (64bit)
On 25/06/2010 16:34, Stephen Hansen wrote: Python's slow, sure. But its in practice fast enough for an extremely broad range of activities. What? Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Heuristic
Please stop top posting!!! On 25/06/2010 15:14, Nathan Rice wrote: I solve optimization problems like this all the time using branch and bound. Just arrange the possible scenarios into a state space tree, (ideally ordered by lowest average cost supplier) then prune any branch where the best case scenario given supplier cost plus shipping cost summed over all remaining orders is greater than your current best total cost. You can make it pretty fast in python if you implement memoization of supplier fulfillment costs for orders. All you need to do is write a depth first search algorithm (stack based, not recursive), a best case predictor for a single order fulfillment (which is summed over all unfulfilled orders) and an actual cost for order fulfillment function. It's really easy to put together, and tends to work quite well. On Fri, Jun 25, 2010 at 7:24 AM, Marcosmarcosruap...@gmail.com wrote: On 25 jun, 04:00, MRABpyt...@mrabarnett.plus.com wrote: Terry Reedy wrote: On 6/24/2010 9:13 PM, Marcos wrote: I have a store, so I want to maximize the profit. I have all the suppliers with diferent prices, some providers can send products to a client an others not, this has a plus price. Some providers has a discount over the tansport if a quantity is reached. Sometimes its better to me receive the order and resend to the client if I have a transport discount. Not all the suppliers has all products for a order. So I want to create a function which I can pass the data, and generates all the possibilities so I can find the maximum profit. Have I to use heuristics? Do you know some examples?. You would not use a heuristic to generate all possibilities. You might use one to *avoid* doing that, and still get a good, not necessarily optimal, answer. True. Basically there are two ways of approaching the problem. One is to try all the combinations, which will guarantee that you'll find the best solution, but if there are an enormous number of combinations then that could take a very long time. The other way is to use a heuristic to get an reasonable solution in an reasonable time. It's a trade-off. Wikipedia has an general entry on 'heuristic'. Algorithm books often specifically discuss heuristic algorithms. Do you know it there is some way to generate all the scenario possibilities?. So I Can put an array an data an generate all. I have the lack of repeated elements that I cant solve. Thanks. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to increment an IntVar?
On Fri, Jun 25, 2010 at 1:26 PM, rantingrick rantingr...@gmail.com wrote: On Jun 25, 12:46 pm, Alan G Isaac alan.is...@gmail.com wrote: On 6/25/2010 1:24 PM, rantingrick wrote: the if __name__ == '__main__' tests use root.quit instead of root.destroy! Did you open an issue?http://bugs.python.org/ If *I* open an issue it will be ignored or quickly dismissed because the people in charge of the Python community hate me. Nonsense. Though an inflammatory, hyperbole-filled rant made up of nothing but charged declarations and rhetoric, and lacking actual reasoned and evidence supported arguments will certainly get deleted-- like I'm going to do with most of your message as I quote But! I think you're missing something: The reason for this hate is because I am very outspoken and will not allow myself to be brow beaten by some of the thugs within this group. Those of us who are brow beating you on this list -- aren't in charge of the Python community. They aren't the ones who close bug tickets. That'd be the folks over on python-dev. I rather suspect they largely don't bother reading your threads, and are utterly indifferent to you, for reasons I've explained previously that you ignore. That's not the same thing as hate. Okay, sure, there's obviously overlap between the groups, and I wouldn't be surprised if most of them skim interesting threads. But they have tended to (in my reading of your threads, at least) have the good sense I lack and not gotten into it with you :) --S -- http://mail.python.org/mailman/listinfo/python-list
Re: improving IDLE
On 6/25/2010 1:24 PM, rantingrick wrote: the if __name__ == '__main__' tests use root.quit instead of root.destroy! On Jun 25, 12:46 pm, Alan G Isaacalan.is...@gmail.com wrote: Did you open an issue?http://bugs.python.org/ On 6/25/2010 4:26 PM, rantingrick wrote: If *I* open an issue it will be ignored or quickly dismissed because the people in charge of the Python community hate me. I bet against that assessment. For this particular issue. ;-) As for the larger issue, I believe DreamPie is under active development? http://dreampie.sourceforge.net/ fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 25/06/2010 19:03, WANG Cong wrote: [lots of snips] Happily mixes them all together doesn't mean it is elegant. :) Bollocks springs to my mind. :) Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: hex question
Sneaky Wombat joe.hrbek at gmail.com writes: Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? 'h' is an ascii string. The ascii encoding for '\n' is the number(byte) 0x0A. When you type '\x0a' you are entering the ascii code directly. hex(ord('\n')) '0xa' Python doesn't know that you entered the values using the '\xXX' syntax, it just knows that the string contains a byte with that value. When it prints it back out, it will print out the corresponding symbol. Any character that has a reasonable ascii representation will show up as that symbol when it (or its repr) is printed. \x61\x62\x63\x64\x65\x66 'abcdef' If you are interested in printing the hex values, you could so something like this: h = '\x0a\xa8\x19\x0b' for c in h: ... print 0x%02x % ord(c), ... 0x0a 0xa8 0x19 0x0b Matt -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 25/06/2010 19:23, WANG Cong wrote: On 06/25/10 14:31, Richard Thomaschards...@gmail.com wrote: snip If you desperately want to limit the attribute assignments that can be performed on an object you can set the __slots__ attribute of its type. However, the Python ethos has always been to restrict as little as necessary to provide the tools it needs. Performing additional checks every time an attribute assignment is performed is completely unnecessary. Remember that unlike C these checks would have to be performed at run-time. I don't care in which way I can limit this, I care why I should limit this by default, not vice versa? Yeah, I do understand this could be a performance issue, but comparing it with a language design issue, _I think_ the latter thing is much more important than the former one. Blimey, one minute we're talking about Python dynamic attribute creation, the next it's a performance issue. What do you want, blood on it? Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
importing modules from higher level directory
Hi, Is it somehow possible to import modules from *.py files in a higher level directory? Intuitively I would do import ../module but that does not work. How does it work? Thanks! Nathan -- http://mail.python.org/mailman/listinfo/python-list
Re: improving python performance by extension module (64bit)
On Fri, Jun 25, 2010 at 1:51 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 25/06/2010 16:34, Stephen Hansen wrote: Python's slow, sure. But its in practice fast enough for an extremely broad range of activities. What? What, what? --S -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated string module issue
Why the rudness Terry Jan Reedy? Get up on the wrong side of the bed? Or worse luck, no one on the other side to create a wrong side? As to your comment about Logilab's pylint. I'v seen a ticket similar to this from three months back. I assume they're not fixing it because if you review 'string' via pydoc you'd read this: --- Help on module string: NAME string - A collection of string operations (most are no longer used). FILE /usr/lib64/python2.6/string.py DESCRIPTION Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as methods on the standard string object. They used to be implemented by a built-in module called strop, but strop is now obsolete itself. --- Not the 1.6. Seems some serious work went into putting the 'string's functionality into _builtin_. I've seen many 'deprecated' warnings when programming in PyGTK, as modules get replaced or functionality changes. I've always assumed it means that the module will be removed at some future date. An advisory to programmers and users. -- You might note what 'deprecated' means. http://www.thefreedictionary.com/ deprecated tr.v. de·pre·cat·ed, de·pre·cat·ing, de·pre·cates 1. To express disapproval of; deplore. 2. To belittle; depreciate. 3. Computer Science To mark (a component of a software standard) as obsolete to warn against its use in the future so that it may be phased out. --- Not the third definition. It applies here. I was inquiring about what other module I should be using instead, having grep'ped my way through /usr/lib64/python2.6/*.py for a replacement. Nor a naive user here. Been programming/using python since 2000 (java, C++, C, APL, Fortan and Basic before that). Python's my favorite place to do math (since I don't have an APL environment anymore, where a cross or dot product is just a single operator away). I decided to ask a question about an issue that's been on my mind for years. Not really sorry if that bother's your incorrect belief of who can ask questions. There are subjects for each posting. Perhaps you should just ignore ones that aren't interesting to you? Or get a life and a girl/boy friend, so you'll have less time to make snipping remarks (check out: 'http://www.thefreedictionary.com/snipe' if you don't understand snipe). have a better day. GrayShark. On Fri, 25 Jun 2010 16:10:23 -0400, Terry Reedy wrote: On 6/25/2010 10:02 AM, GrayShark wrote: Thanks for the suggestion. I gave it a quick try. Same 'warning'. No, using the string module is the issue. Perhaps I'll just ignore it. And what about the next naive user of pylint? Submitting a bug report to the author of pylint would take much less time than you have *us* to spend helping you. Doing so would be a way of thanking us since then, if pylint were changed, we would not have to answer the same question again in a year. -- http://mail.python.org/mailman/listinfo/python-list