py.edit.js -- a simple python editor in javascript
I thought people here might be interested in a simple, lightweight Python editor written in Javascript. Something to use when blogging or replying to comments. Its just a proof-of-concept -- something I've had rolling in my head for a while. http://py-edit-js.appspot.com/ Features: - simplistic auto indent/dedent of lines - can output as html, text - bookmarklet mode - opens a mini-editor within the current page - spaces at the beginning of a line, dedents the next line by that many blocks -- an easy way to close blocks. Bugs: - sometimes the Javascript Bookmarklet doesn't close, when the user tries to close it I've tested it with Safari Firefox under OS X. -sri -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Ironclad v0.7 released (compiled CPython extensions on IronPython)
Hi all I'm delighted to announce the release of Ironclad v0.7, which is now available from http://code.google.com/p/ironclad/downloads/list . This release is a major step forward: * Runs transparently on vanilla IronPython 2.0RC2, without creating extra PythonEngines or breaking .NET namespace imports * Many numpy 1.2 tests (from the core, fft, lib, linalg and random subpackages) now reliably pass (run ipy numpytests.py from the build directory) * Significant performance improvements (by several orders of magnitude in some places :D) So... if you want to use numpy (or other C extension modules) with IronPython on Win32, please download it and try it out; I'm very keen to hear your experiences, and to know which neglected features will be most useful to you. Cheers William -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANNOUNCE python-mode.el 5.0.0 (Molluscs)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 It's been ages since we did a formal python-mode.el release, so I took the opportunity to embrace my tryptophan induced hallucinations and release a new version. Skip was suggesting we try to include better triple quoted string support, but my motto for today is JFDI. So here it is for better or worse, and I hope we'll be making further improvements over time. I have no idea what's new since whatever version you have. RTSL and enjoy. Download from: https://launchpad.net/python-mode/+download Bugs and patches: https://launchpad.net/python-mode Cheers, - -Barry P.S. Please note that while we still have lots of artifacts sitting on the SourceForge project, and there's no way to disable them, we've requested an import of those issues into Launchpad. For all new patches and bugs, you must submit them to Launchpad or we'll probably ignore them. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Darwin) iQCVAwUBSTAiMXEjvBPtnXfVAQJl7gQAj4uiD9xQrn530f/riOG9bRBKZt4mhre4 5wcWsYX3JWeI/gWF3lk6ckjfHTYriJNN/rFtzRL3/YPGs5ftRD2kw1matDPF8uhs Vv+pNwNatnoiVl3RzBx4uGNsaEe04LVNf8DocwheYdVCo321VSllcsC02cqXzMSZ hNpE63kAZJs= =hyn9 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Is there any project whose patches are all available?
ZelluX [EMAIL PROTECTED] writes: For example, by comparing two versions of a program, may be we can generate some scripts to direct the virtual machine update a running python program. I'm still confused. Are you talking about self-modifying programs here? Perhaps if you could say more detail about what the overall goal is we can understand and discuss it better. -- \ “My girlfriend has a queen sized bed; I have a court jester | `\ sized bed. It's red and green and has bells on it, and the ends | _o__) curl up.” —Steven Wright | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
Terry Reedy: The problem is that inner functions do not exist until the outer function is called and the inner def is executed. And they cease to exist when the outer function returns unless returned or associated with a global name or collection. OK. A 'function' only needs to be nested if it is intended to be different (different default or closure) for each execution of its def. Or maybe because you want to denote a logical nesting, or maybe because you want to keep the outer namespace cleaner, etc etc. --- Benjamin: Of course, you could resort to terrible evil like this: My point was of course to ask about possible changes to CPython, so you don't need evil hacks anymore. --- Steven D'Aprano: For this to change wouldn't be a little change, it would be a large change. I see, then my proposal has little hope, I presume. I'll have to keep moving functions outside to test them and move them inside again when I want to run them. However you can get the same result (and arguably this is the Right Way to do it) with a class: Of course, that's the Right Way only for languages that support only a strict form of the Object Oriented paradigm, like for example Java. Thank you to all the people that have answered. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter and asyncronous socket
Eric Brunel [EMAIL PROTECTED] wrote You don't need to in fact: from the secondary thread, it seems to be safe to post a user-defined event in the GUI event loop on which you can set a binding in the GUI thread. This allows a thread switch without having to do a periodical check. 8 example - The custom event 'heartbeat' is posted in the event loop from the secondary thread. Note the when='tail' option, which is absolutely necessary or the binding might be called immediatly without even an actual event posting. The binding on this event will then be executed in the thread that launched the mainloop. Cunning stuff - I was not aware of this either. I hope we are not confusing the newbie - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: functions
You could pass it as an argument: c:\script1.py foo(whatever_arguments_you_need, caller=None): c:\script2.py import script1 script1.foo(blabla, caller=__file__) Other than that I would not know. Maybe the inspect module can help you but as far as I can see, it doesn't. I'm also not sure if it would be a nice way to solve your problem (what is your problem?), if it is even possible. Additionally, the function could be called from the command line rather than from a file. Almar 2008/11/28 Girish [EMAIL PROTECTED] Hello, Is ter any way to identify the file name and the path in which the function is called. for example: if the function definition is in the file c:\script1.py and if I call this function in a script: c:\script2.py than in the function definition part(script1.py) some how I need to know that its called in c:\script2.py. Thanks, Giri -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: what's so difficult about namespace?
From: Kaz Kylheku [EMAIL PROTECTED] Scheme hasn't officially supported breaking a program into multiple files until R6RS. If the language is defined in terms of one translation unit, it doesn't make sense to have a namespace feature. Good point. Note that any language that uses optionally-loadable libraries automatically has more than one translation unit, namely the application itself and at least one loaded library. More on this later. Javascript programs are scanned at the character level by the browser as part of loading a page. So there are severe practical limitations on how large Javascript programs can be. That's only half the reason. The other half is that JavaScript doesn't support requiring additional libraries to be downloaded from another site to be added to the main JavaScript application, right? Namespaces are useful only in very large programs. Or in medium sized programs that require loading libraries written by other people, of the total set of all such libraries is too large to globally manage well enough to avoid name clashes. The main program might not use namespaces internally, but the various libraries *must* use namespaces internally, and then the main program must arrange for external functions to be propertly called with namespace+localname. The essence of a true namespace or package system or whatever is that you can establish situations in which you use the unqualified names. Correct. You can emulate namespaces by adding prefixes to identifiers, which is how people get by in C. With the pain that you must always use the fully-qualified name, right? In C, you can even get the functionality of short names using the preprocessor. I hear Greenspun there! :-) I have done this before (but only once). ... (Story of a Greenspun task. Yes, I agree what you did, after the fact, to avoid needing to manually edit all the files in your source to have fully-qualified names when porting for others to use, was a reasonable hack.) I recently read about a very useful theory which explains why technologies succeed or fail. See: http://arcfn.com/2008/07/why-your-favorite-programming-language-is-unpopular.html 404 not found. Otherwise this thread, and your article in it, are interesting and enlightening. BTW comp.lang.lisp is my favorite newsgroup for articles that give new insight I overlooked before. KentP and PascalB have the largest amount of good insight, but other posters contribute too. Thanks for posting Kaz et al. (I hope once in a while something I post provides enlightening insight to somebody.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
On Nov 27, 11:42 am, Viktor Kerkez [EMAIL PROTECTED] wrote: Here is the situation: $ ls test $ cd test $ ls __init__.py data.py $ cat __init__.py $ cat data.py DATA = {} $ cd .. $ python import os from test.data import DATA DATA['something'] = 33 os.chdir('test') from data import DATA as NEW_DATA DATA {'something': 33} NEW_DATA {} Is this a bug? No, because you've actually imported two different modules (even though it's the same file on disk, for the second inport statement Python imports the file again because it was done from a different absolute path, that is, the module data is always different from the module test.data even if they refer to the same file). However, I'm not so sure the effect of os.chdir() on the import path is a good idea. It would seem that among people who use os.chdir() in their programs, some will want the import path to change with it, some will not. You can't please everyone, so I would suggest that we should choose in favor of limiting context sensitivity. I like to think that import abc always does the same thing regardless of any seemingly unrelated state changes of my program, especially since, as the OP pointed out, import is used as a means to ensure singleness. Thus, if I were designing the language, I would have sys.path[0] be the current working directory at program start. To the OP: My first suggestion is to consider not using os.chdir() in your programs, and instead construct pathnames with the directory included. If you do use os.chdir(), then early in your script script, add a line such as sys.path[0] = os.getcwd(). Then, no matter where you are, always import the file relative to the starting directory. So always use from test.data import DATA, even after you os.chdir(). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: functions
Girish wrote: Is ter any way to identify the file name and the path in which the function is called. for example: if the function definition is in the file c:\script1.py and if I call this function in a script: c:\script2.py than in the function definition part(script1.py) some how I need to know that its called in c:\script2.py. You can inspect the stack: import sys import inspect def some_func(): print inspect.getfile(sys._getframe(1)) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any project whose patches are all available?
ZelluX schrieb: Hi, all I want to write a version-tracking tool for Python projects, and need some sample projects whose even smallest modifications can be downloaded from the internet. Could you recommend some to me? Well, most of them have ... TADA ... Versioncontrol systems they use. Which makes ti possible to fetch all the different revisions as single patches. So write yourself a script that exctracts these from e.g. a SVN repo, and you are done. If that serves your cause though, I'm not so sure. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with capturing error
tekion wrote: Hello, I am getting the following error and my script is bailing out because of it. I have tried capturing it but it does not seem to work. Below is the error: ValueError: I/O operation on closed file the above error is received when, the following code snippet is executed: try: 117 self.xml_file.close() 118 except ValueError: 119 print file, %s is already closed % self.seek_file Any idea why line 118, is not capturing the error? Thanks. It seems you didn't read the traceback carefully. Line 117 doesn't cause that error. You can close a file as often as you like, but you can't read/write to a closed file: f = open(tmp.txt, w) f.close() f.close() f.close() f.write(yadda) Traceback (most recent call last): File stdin, line 1, in module ValueError: I/O operation on closed file Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
Carl Banks [EMAIL PROTECTED] writes: I like to think that import abc always does the same thing regardless of any seemingly unrelated state changes of my program, especially since, as the OP pointed out, import is used as a means to ensure singleness. Thus, if I were designing the language, I would have sys.path[0] be the current working directory at program start. This is resolved in the Python 2.x series by implementing PEP 328 URL:http://www.python.org/dev/peps/pep-0328/, such that the search path for ‘import’ does *not* contain the current directory, and requiring relative-to-the-current-directory imports to be explicitly requested. -- \“If you go parachuting, and your parachute doesn't open, and | `\you friends are all watching you fall, I think a funny gag | _o__) would be to pretend you were swimming.” —Jack Handey | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading multiple versions of the same package at the same time
On 27 Nov, 21:34, Terry Reedy [EMAIL PROTECTED] wrote: But in the interpreters module dict, foo it is, and stays. But giving the modules different names on the disk should work, no? Yes, but -- for what I've understood -- that wouldn't solve my original problem with pickle, since I would need to carry around a module with the new name forever :) matteo -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
On Nov 28, 9:35 am, Carl Banks [EMAIL PROTECTED] wrote: However, I'm not so sure the effect of os.chdir() on the import path is a good idea. I'm not actually using os.chidir(), I just used it here to create a clearer example. Here is the simplest representation of the problem: http://www.ninjashare.com/904415 $ cd singleton_test $ export PYTHONPATH=. $ python application/main_script.py Creating class Singleton Creating class MySingleton Creating class Singleton Creating class MySingleton $ -- http://mail.python.org/mailman/listinfo/python-list
Re: functions
On Nov 28, 1:46 pm, Peter Otten [EMAIL PROTECTED] wrote: Girish wrote: Is ter any way to identify the file name and the path in which the function is called. for example: if the function definition is in the file c:\script1.py and if I call this function in a script: c:\script2.py than in the function definition part(script1.py) some how I need to know that its called in c:\script2.py. You can inspect the stack: import sys import inspect def some_func(): print inspect.getfile(sys._getframe(1)) Peter Thanks a lot Peter. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Thu, 27 Nov 2008 21:28:34 -0800, r wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! No, this is Sparta! (Somebody had to say it.) Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! Oh the damage! Won't anybody think of the damage?! I hope Guido's eyes never see this thread, for he may lose all hope in humanity. Probably, but not for the reason you think. Have you considered that as Guido works at Google, he probably knows all about Sketchup and doesn't care a flying fig about the scripting language it uses? He's got better things to do than run around like a headless chicken getting upset that there's a program out in the world that uses something other than Python. He only spent the last 18 years of his life pursuing this thing called Python. No, he has spent the last 18 years of his life having a life. Python is only a small part of it. He has a wife and child and a job, and no doubt he has hobbies. He even has a blog: http://neopythonic.blogspot.com/ Maybe 1,2,3, years from now someone will see this thread and post a vote for Python. Maybe as simple as I will fight for Python , I am not scared to go up against the status quo. For that day will be a glorious day. That day shall be Python Day! I will never give UP! Forgot to take your meds today? Earlier, at Thu, 27 Nov 2008 18:49:37 -0800, you wrote: Well... 3 for Ruby 1 for python. Not looking good so far. Any more votes? Are you trolling? Are you some sort of agent provocateur trying to put people *against* the idea of Python scripting for Sketchup? If not, you're sure doing an excellent imitation of one. You start off by spitting all over Ruby, then demonstrate spinelessness by turning around and saying you have nothing against Ruby when it is obvious that you do have many things against it. Then you gush about how wonderful Python is in an embarrassingly, and obnoxiously, saccharine way. And now you come up with this garbage about 3 for Ruby -- nobody here voted for Ruby. It's not that we don't want Python to be successful, and I for one resent you implication that just because we're not throwing ourselves at your pet project we're anti-Python. Python is already successful, and we're not throwing ourselves at your pet project because most of us don't give a monkey's toss about Sketchup. Why should we put our time and energy into a piece of software that we don't care about? You might not have anything better to do with your life, but we do. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Great exercise for python expert !
I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Really needs some help ... and it's a great exercise too ;-) (3 hours on that, and don't find a way to resolve that, because I can't find a way to terminate the recursivity in the getattr way) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
On Tue, 25 Nov 2008 18:07:22 -0500, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Jorgen Grahn [EMAIL PROTECTED] wrote: Hard to take a popularity index seriously when Logo is at #19 and Bourne shell at #32 ... and then they suggest that their readers can use it to make a strategic decision about what programming language should be adopted when starting to build a new software system. When you've seen some of the shell scripts I've seen, it's not hard to imagine that logo might be a better choice of programming language. I have seen them, too. But I have also written and maintained medium-sized shell scripts which are very successful. (I could get away with using Bash in these cases. It has functions, local variables and so on. Writing portable Bourne shell is not as much fun.) Not to mention how useful interactive shell scripting is. I use it more and more: pipelines which combine xargs, while, for, sort and perl oneliners. This is surely a kind of programming, too. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Install modules with no root privilegies
On Mon, 24 Nov 2008 20:11:42 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Philipp Pagel wrote: Alfons Nonell-Canals [EMAIL PROTECTED] wrote: Install python modules in a linux computer is really easy, it is because the module is a package of the distribution or because the python installation is really easy. But, in both situations, you need root privilegies. I would like to know how to install modules only for one user, with no root privilegies. Do you know if it is possible and easy. Yes, there is. You can choose among two strategies referred to as home scheme and prefix scheme in the Installing Python Modules documentation: http://docs.python.org/install/index.html Have a look at Section 3 Alternate installation. That's way much more than is actually needed, as thus each user would end up with a different installation. The home scheme, you mean. It seems to me that this is exactly what the poster wants -- mess with a bunch of modules without having to consider anyone else's needs. Setting the PYTHONPATH-env-variable to a user writable location allows e.g. easy_install and friends to install into that location. Yes, but the users have to trust everyone with write access to that place. Someone could replace a module with a trojan horse, or simply with a newer version which isn't compatible, and things would break. Sometimes this is OK, but sometimes you only trust root and yourself. And installing virtualenv globally, everybody can create a local site-packages-directory. Cannot comment -- I haven't used it. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading multiple versions of the same package at the same time
della wrote: On 27 Nov, 21:34, Terry Reedy [EMAIL PROTECTED] wrote: But in the interpreters module dict, foo it is, and stays. But giving the modules different names on the disk should work, no? Yes, but -- for what I've understood -- that wouldn't solve my original problem with pickle, since I would need to carry around a module with the new name forever :) You can rename the globals within the pickle. A starting point, not tested beyond running the demo script: $ cat fixpickle.py import pickle import pickletools def ops(d): prevpos = None previnfo = None for info, arg, pos in pickletools.genops(d): if prevpos is not None: yield d[prevpos:pos] prevpos = pos previnfo = info yield d[prevpos:] def tocode(dotted): parts = tuple(dotted.rsplit(., 1)) return c%s\n%s\n % parts def rename_globals(d, pairs): updates = dict((tocode(old), tocode(new)) for old, new in pairs) return .join(updates.get(o, o) for o in ops(d)) $ cat alpha.py class A(object): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return A(%s, %s) % (self.x, self.y) $ cat beta.py class B(object): def __str__(self): return B(%s, %s) % (self.x, self.y) $ cat demo.py import alpha import fixpickle import pickle if __name__ == __main__: a = alpha.A(1, 2) print a d = pickle.dumps(a) d = fixpickle.rename_globals(d, [(alpha.A, beta.B)]) b = pickle.loads(d) print b Peter -- http://mail.python.org/mailman/listinfo/python-list
setting path for python interpretor
Hi all, Can any body suggest me how to the set path for making python2.4 as the main interpretor instead of python 2.5. regards -- Beema Shafreen -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
Steven D'Aprano a écrit : (snip) Consequently, I almost always use single-underscore private by convention names, rather than double-underscore names. The name-mangling is, in my experience, just a nuisance. s/just/most often than not/ and we'll agree on this !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
r a écrit : (snip) Unfortunatly though SketchUp currently uses Ruby(sorry to use profanity) (snip) language for scripting on both the free and pro versions. IMHO...and you will probably agree... programming with Ruby is neither fun or efficient. Don't get me wrong i am not knocking Ruby. No ? Really ? Then I don't want to know what you could come with if you tried to. But i have tried to learn Rudy and i all i get is a headache... (snip more Ruby bashing). The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
r a écrit : On Nov 28, 12:52 am, [EMAIL PROTECTED] wrote: On Nov 27, 10:28 pm, r [EMAIL PROTECTED] wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may lose all hope in humanity. He only spent the last 18 years of his life pursuing this thing called Python. Maybe 1,2,3, years from now someone will see this thread and post a vote for Python. Maybe as simple as I will fight for Python , I am not scared to go up against the status quo. For that day will be a glorious day. That day shall be Python Day! I will never give UP! r, i am with you! i will back Python!!! we MUST spread Python throughout the world! sketchup is the first step, only the first step. it is really sad that the so-called Python supporters on this list don't really care about Python -- only money, and depravity. you and i and the other few, pure of heart, must fight for Python!! death to infidel ruby lovers!!! long live Guido! i pledge my life to Python and Guido!!! Ok finally! Thank you [EMAIL PROTECTED] the Python Gods have not forsaken me! I'm afraid you've been trolled. -- http://mail.python.org/mailman/listinfo/python-list
Windows Installer testing using python.
Hi, How can we test Windows Installer using python. Is there any module available for testing? Please mail to [EMAIL PROTECTED] Thanks, Kalyan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
On 27 Nov, 01:59, Steven D'Aprano [EMAIL PROTECTED] wrote: Oh please Steve. Did you read Xah's post or stop after the second paragraph? It was amazingly *non* vituperative, and I don't just mean for Xah. Agreed, although I had to look vituperative up first. Is the mere presence of Xah Lee's name now shocking in itself? I only counted two uses of the f-word and one of the a-word, none of which I personally would object to (we're grown-ups, naughty words shouldn't shock us). The only things which were even *close* to a vituperative rant were a short comment about Brian Harvey being unhappy with Scheme 6, and that Sun Microsystems use inferior versions of shell tools. Maybe half a dozen lines expressing strong opinions, out of a 300 line post. And I'd definitely want to express frustration with the latter situation if I had to use a Sun operating system without the GNU suite of programs installed. I haven't checked, but perhaps even the latest release of OpenSolaris still has the /usr/ucb, /usr/ccs and /usr/xpg5 directories (or whatever they're called), although these probably no longer provide the default tools. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Django Latex Permissions Problem
It was a very unlikely problem. Apparently although apache was configured, someone in the past had run some instances of manage.py Maybe they were stuck or they were running in the background. Once all python instances were killed and Apache was restarted, everything worked as a breeze. Thanks for the help though On Nov 25, 2:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote: I-T [EMAIL PROTECTED] wrote: I have a python/django webapp running with apache2. It executes system commands for getting a pdf generated by pdflatex from a .tex file and a couple of image files which it also generates. The permssions from ls-l for all the created files is:- -rw-r--r-- 1 www-data www-data The files are being created in /tmp/pdfscratch{id} created from the script and so is the directory. pdflatex fails with the following error message:- This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %-line parsing enabled. entering extended mode ! I can't write on file `uber.log'. Please type another transcript file name: ! Emergency stop ! == Fatal error occurred, no output PDF file produced! Its supposed to write to this directory. I have a feeling that pdflatex is trying to generate files using some weird access credentials that dont have access to /tmp/pdfscratch{id} Unlikely - it takes root to change user and I wouldn't have thought any of the files would be setuid. Try chdir to /tmp/pdfscratch{id} first would be my suggestion. -- Nick Craig-Wood [EMAIL PROTECTED] --http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
Roy Smith wrote: There's a well known theory in studies of the human brain which says people are capable of processing about 7 +/- 2 pieces of information at once. It's not about processing multiple taks, it's about the amount of things that can be held in working memory. n -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any project whose patches are all available?
zellux I want to write a version-tracking tool for Python projects, and zellux need some sample projects whose even smallest modifications can zellux be downloaded from the internet. Sure. Python itself. Do a checkout of the code from Subversion then for any given file just ask Subversion for a diff between it and the previous version. For example: % pwd /Users/skip/src/python/trunk % svn info Lib/os.py Path: Lib/os.py Name: os.py URL: svn+ssh://[EMAIL PROTECTED]/python/trunk/Lib/os.py Repository Root: svn+ssh://[EMAIL PROTECTED] Repository UUID: 6015fed2-1504-0410-9fe1-9d1591cc4771 Revision: 67276 ... % svn log Lib/os.py r66142 | gregory.p.smith | 2008-09-02 00:36:11 -0500 (Tue, 02 Sep 2008) | 3 lines Issue #3708: os.urandom no longer goes into an infinite loop when passed a non-integer floating point number. r65795 | brett.cannon | 2008-08-17 19:46:22 -0500 (Sun, 17 Aug 2008) | 3 lines Update __all__ for cookielib, csv, os, and urllib2 for objects imported into the module but exposed as part of the API. r63493 | georg.brandl | 2008-05-20 02:49:57 -0500 (Tue, 20 May 2008) | 2 lines Revert copy_reg - copyreg rename. r63158 | ronald.oussoren | 2008-05-12 06:24:33 -0500 (Mon, 12 May 2008) | 5 lines Remove references to platform 'mac' The 'mac' platform (that is, os.name == 'mac') was used for the MacOS 9 port, which is no longer supported (as of Python 2.4 IIRC). ... % svn diff -r66142:65795 Lib/os.py Index: Lib/os.py === --- Lib/os.py (revision 66142) +++ Lib/os.py (revision 65795) @@ -753,10 +753,8 @@ _urandomfd = open(/dev/urandom, O_RDONLY) except (OSError, IOError): raise NotImplementedError(/dev/urandom (or equivalent) not found) -try: -bs = b -while n - len(bs) = 1: -bs += read(_urandomfd, n - len(bs)) -finally: -close(_urandomfd) -return bs +bytes = +while len(bytes) n: +bytes += read(_urandomfd, n - len(bytes)) +close(_urandomfd) +return bytes % svn diff -r65795:63493 Lib/os.py Index: Lib/os.py === --- Lib/os.py (revision 65795) +++ Lib/os.py (revision 63493) @@ -28,7 +28,7 @@ _names = sys.builtin_module_names # Note: more names are added to __all__ later. -__all__ = [altsep, curdir, pardir, sep, extsep, pathsep, linesep, +__all__ = [altsep, curdir, pardir, sep, pathsep, linesep, defpath, name, path, devnull, SEEK_SET, SEEK_CUR, SEEK_END] And so on. In general, any open source project should be available in this fashion. The details for fetching diffs will depend on the specific source code control system being used. -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
In article [EMAIL PROTECTED], Nigel Rantor [EMAIL PROTECTED] wrote: Roy Smith wrote: There's a well known theory in studies of the human brain which says people are capable of processing about 7 +/- 2 pieces of information at once. It's not about processing multiple taks, it's about the amount of things that can be held in working memory. Yes, and that's what I'm talking about here. If there's N possible code paths, can you think about all of them at the same time while you look at your code and simultaneously understand them all? If I write: if foo: do_this() else: do_that() it's easy to get a good mental picture of all the consequences of foo being true or false. As the number of paths go up, it becomes harder to think of them all as a coherent piece of code and you have to resort to examining the paths sequentially. -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
On Fri, 28 Nov 2008 00:06:01 -0800, bearophileHUGS wrote: For this to change wouldn't be a little change, it would be a large change. I see, then my proposal has little hope, I presume. I'll have to keep moving functions outside to test them and move them inside again when I want to run them. Not so. You just need to prevent the nested functions from being garbage collected. def foo(x): if not hasattr(foo, 'bar'): def bar(y): return x+y def foobar(y): return 3*y-y**2 foo.bar = bar foo.foobar = foobar return foo.bar(3)+foo.foobar(3) However, note that there is a problem here: foo.bar will always use the value of x as it were when it was called the first time, *not* the value when you call it subsequently: foo(2) 5 foo(3000) 5 Because foo.foobar doesn't use x, it's safe to use; but foo.bar is a closure and will always use the value of x as it was first used. This could be a source of puzzling bugs. There are many ways of dealing with this. Here is one: def foo(x): def bar(y): return x+y def foobar(y): return 3*y-y**2 foo.bar = bar foo.foobar = foobar return bar(3)+foobar(3) I leave it as an exercise for the reader to determine how the behaviour of this is different to the first version. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On Nov 28, 5:36 am, manatlan [EMAIL PROTECTED] wrote: I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return Add:+j if __name__ == __main__: o = MyObject() s = o.js.kiki(12).kuku() print s HTH, George -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On 28 nov, 14:58, George Sakkis [EMAIL PROTECTED] wrote: On Nov 28, 5:36 am, manatlan [EMAIL PROTECTED] wrote: I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return Add:+j if __name__ == __main__: o = MyObject() s = o.js.kiki(12).kuku() print s HTH, George sure, it works like you said ... but it's not what I want. by doing that, you create an action ... when you will call print it will call the __str__ (__repr__ is better in that case), which will call the callback of myobject. In my preceding post, the action was called by the () trick at the end of line In fact, MyObject will handle a list of all js call If i do : o.js.toto() o.js.toto().titi(12,13) I'd like my MyObject contains a list like that [toto(),toto().titi (12,23)] another idea ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On 28 nov, 15:19, manatlan [EMAIL PROTECTED] wrote: On 28 nov, 14:58, George Sakkis [EMAIL PROTECTED] wrote: On Nov 28, 5:36 am, manatlan [EMAIL PROTECTED] wrote: I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return Add:+j if __name__ == __main__: o = MyObject() s = o.js.kiki(12).kuku() print s HTH, George sure, it works like you said ... but it's not what I want. by doing that, you create an action ... when you will call print it will call the __str__ (__repr__ is better in that case), which will call the callback of myobject. In my preceding post, the action was called by the () trick at the end of line In fact, MyObject will handle a list of all js call If i do : o.js.toto() o.js.toto().titi(12,13) I'd like my MyObject contains a list like that [toto(),toto().titi (12,23)] another idea ? To explain better, here is another code == class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(list): def __init__(self): list.__init__([]) js=property(lambda self:JQueryCaller(self.__add)) def __add(self,j): self.append(j) if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() o.js.kiki(12).kuku().roro(gfde)() assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] == here, it uses the __call__ of JQueryCaller by adding the () trick at the end ... I'd really like to have the same result, without the () trick, like this: o=MyObject() o.js.kiki(12).kuku() o.js.kiki(12).kuku().roro(gfde) assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On Nov 28, 9:19 am, manatlan [EMAIL PROTECTED] wrote: On 28 nov, 14:58, George Sakkis [EMAIL PROTECTED] wrote: On Nov 28, 5:36 am, manatlan [EMAIL PROTECTED] wrote: I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return Add:+j if __name__ == __main__: o = MyObject() s = o.js.kiki(12).kuku() print s HTH, George sure, it works like you said ... but it's not what I want. by doing that, you create an action ... when you will call print it will call the __str__ (__repr__ is better in that case), which will call the callback of myobject. In my preceding post, the action was called by the () trick at the end of line ... which you apparently don't like, and rightly so. __getattr__ and __call__ do totally different things in your example, why do you want to conflate them ? In fact, MyObject will handle a list of all js call If i do : o.js.toto() o.js.toto().titi(12,13) I'd like my MyObject contains a list like that [toto(),toto().titi (12,23)] Of course this still happens when you rename __call__ to __str__. another idea ? Yes, put a little more thought on your design and give a more realistic example of what you're really trying to do; so far it seems more like a pointless hack. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On Fri, 28 Nov 2008 02:36:28 -0800, manatlan wrote: I'd like to make a jquery python wrapper [...] here is my code : [...] What is the purpose of this code? As near as I can see, it would make an excellent entry to the Obfuscated Python Competition, except it isn't clear that it does anything useful. Frankly, this looks like an pointlessly overly-complicated design to me. Rather than getting rid of the extra parentheses, I suggest you rethink your design. Explicit is better that implicit: don't have the one method do both appending to the object *and* calling the object. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
On Nov 28, 3:15 am, Ben Finney [EMAIL PROTECTED] wrote: Carl Banks [EMAIL PROTECTED] writes: I like to think that import abc always does the same thing regardless of any seemingly unrelated state changes of my program, especially since, as the OP pointed out, import is used as a means to ensure singleness. Thus, if I were designing the language, I would have sys.path[0] be the current working directory at program start. This is resolved in the Python 2.x series by implementing PEP 328 URL:http://www.python.org/dev/peps/pep-0328/, such that the search path for ‘import’ does *not* contain the current directory, and requiring relative-to-the-current-directory imports to be explicitly requested. PEP 328 doesn't say anything about that. Using Python 2.5, which PEP 328 claims implements this change, I see the same behavior that Victor Kerkez sees. My sys.path[0] is still the empty string, meaning that Python does start its import search from the current directory. Perhaps you are confusing current directory with directory that the current module file is in, which PEP 328 does address? (It's ok, the PEP itself used current directory in this way.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On 28 nov, 15:49, George Sakkis [EMAIL PROTECTED] wrote: On Nov 28, 9:19 am, manatlan [EMAIL PROTECTED] wrote: On 28 nov, 14:58, George Sakkis [EMAIL PROTECTED] wrote: On Nov 28, 5:36 am, manatlan [EMAIL PROTECTED] wrote: I'd like to make a jquery python wrapper ... here is my code : === #!/usr/bin/env python # -*- coding: utf-8 -*- class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(object): def __init__(self): self.js = JQueryCaller(self.__add) def __add(self,j): print Add:+j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() === If i run the script : it will display : Add:kiki('12').kuku() Because the JQueryCaller caller is called, by the () trick at the end of the last line I'd like to display the same thing, but without the need to put the () at then end ! (by calling simply : o.js.kiki(12).kuku() not o.js.kiki(12).kuku() ()) (or how to call the MyObject._add (callback) without using the caller on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return Add:+j if __name__ == __main__: o = MyObject() s = o.js.kiki(12).kuku() print s HTH, George sure, it works like you said ... but it's not what I want. by doing that, you create an action ... when you will call print it will call the __str__ (__repr__ is better in that case), which will call the callback of myobject. In my preceding post, the action was called by the () trick at the end of line ... which you apparently don't like, and rightly so. __getattr__ and __call__ do totally different things in your example, why do you want to conflate them ? In fact, MyObject will handle a list of all js call If i do : o.js.toto() o.js.toto().titi(12,13) I'd like my MyObject contains a list like that [toto(),toto().titi (12,23)] Of course this still happens when you rename __call__ to __str__. another idea ? Yes, put a little more thought on your design and give a more realistic example of what you're really trying to do; so far it seems more like a pointless hack. George I just want to make a jquery wrapper, and let people use it to write jquery call on the server side in a python way ... o is a object, imagine a widget : like a textarea or input box js is a special attribut of o, which will let you write javascript for this object. o=MyObject() o.js.toggleClass(clean).hide() When I will render the object to a http/html output : it will generate something like (a javascript call): $(#idOfMyObject).toggleClass (clean).hide(); It's all what I want in the real world. I wouldn't do something like that (with the () tricks at the end on the chain, because I don't find it really readable/natural) o=MyObject() o.js.toggleClass(clean).hide()() The code I gave before (the JQueryCaller) was just my try to do what I want ... If there is another way : I take ;-) -- http://mail.python.org/mailman/listinfo/python-list
Help with regular expression patterns
Hi: i'm so newbie in python that i don't get the right idea about regular expressions. This is what i want to do: Extract using python some information and them replace this expresion for others, i use as a base the wikitext and this is what i do: code file=parse.py paragraphs = = Test '''wikitest'''= [[Image:image_link.jpg|rigth|thumbnail|200px|PREMIER]] [http://www.google.com.cu] ::''Note: This is just an example to test some regular expressions stuffs.'' The ''wikitext'' is a text format that helps a lot. In concept is a simple [[markup]] [[programming_language|language]]. That helps to make simple create documentations texts. ==Wikitext== Created by Warn as a ... nowiki[/nowiki this is a normal nowikisign]/nowiki .split('\n\n') import re wikipatterns = { 'a_nowiki' : re.compile(rnowiki(.\S+)/nowiki), # nowiki 'section' : re.compile(r\=(.*)\=),# section one tags 'sectiontwo' : re.compile(r\=\=(.*?)\=\=),# section two tags 'wikilink': re.compile(r\[\[(.*?)\]\]), # links tags 'link': re.compile(r\[(.*?)\]), # external links tags 'italic': re.compile(r\'\'(.*?)\'\'), # italic text tags 'bold' : re.compile(r\'\'\'(.*?)\'\'\'), # bold text tags } for pattern in wikipatterns: print === processing pattern :, pattern, == for paragraph in paragraphs: print wikipatterns[pattern].findall(paragraph) /code But When i run it the result is not what i want, it's something like: code [EMAIL PROTECTED]:/local/python$python parser.py === processing pattern : bold == ['braille'] [] [] [] [] [] === processing pattern : section == [ Test '''wikitest'''] [] [] ['=Wikitext='] [] [] === processing pattern : sectiontwo == [] [] [] ['Wikitext'] [] [] === processing pattern : link == ['[Image:image_link.jpg|rigth|thumbnail|200px|PREMIER'] ['http://www.google.com.cu'] ['[markup', '[programming_language|language'] [] [] ['/nowiki this is a normal nowikisign'] === processing pattern : italic == ['wikitest] ['Note: This is just an example to test some regular expressions stuffs.'] ['wikitext'] [] [] [] === processing pattern : wikilink == ['Image:image_link.jpg|rigth|thumbnail|200px|PREMIER'] [] ['markup', 'programming_language|language'] [] [] [] === processing pattern : a_nowiki == [] [] [] [] [] ['sign]'] /code In the first case the result it's Ok In the second the first it's Ok, but the second it's not because second result it's a level two section not a level one. In the third result things are Ok The fourth, the first and thrid result are wrong beacuse they are level two links, but the second it's Ok. The fifth it Ok The sixth shows only one result and it should show two. Please help. PS: am really sorry about my technical English. -- Michel Perez )\._.,--,'``. Ulrico Software Group/, _.. \ _\ ;`._ ,. Nihil est tam arduo et difficile human `._.-(,_..'--(,_..'`-.;.' mens vincat. Séneca. = --- Red Telematica de Salud - Cuba CNICM - Infomed -- http://mail.python.org/mailman/listinfo/python-list
Unicode regex and Hindi language
The regex below identifies words in all languages I tested, but not in Hindi: # -*- coding: utf-8 -*- import re pat = re.compile('^(\w+)$', re.U) langs = ('English', '中文', 'हिन्दी') for l in langs: m = pat.search(l.decode('utf-8')) print l, m and m.group(1) Output: English English 中文 中文 हिन्दी None From this is assumed that the Hindi text contains punctuation or other characters that prevent the word match. Now, even more alienating is this: pat = re.compile('^(\W+)$', re.U) # note: now \W for l in langs: m = pat.search(l.decode('utf-8')) print l, m and m.group(1) Output: English None 中文 None हिन्दी None How can the Hindi be both not a word and not not a word?? Any clue would be much appreciated! Best. -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
I just want to make a jquery wrapper, and let people use it to write jquery call on the server side in a python way ... o is a object, imagine a widget : like a textarea or input box js is a special attribut of o, which will let you write javascript for this object. o=MyObject() o.js.toggleClass(clean).hide() When I will render the object to a http/html output : it will generate something like (a javascript call): $(#idOfMyObject).toggleClass (clean).hide(); It's all what I want in the real world. I wouldn't do something like that (with the () tricks at the end on the chain, because I don't find it really readable/natural) o=MyObject() o.js.toggleClass(clean).hide()() The code I gave before (the JQueryCaller) was just my try to do what I want ... If there is another way : I take ;-) But there must be *something* on this end of the chain, because how is python otherwise to distinguish betwenn os.js.toggleClass().hide() os.js.toggleClass().hide().show() ? Now the question is if the action that is to take must be on the object itself. Maybe it works for you to make the assignment to some other object do the trick, or additon. Something like this: self.js_calls += os.js.toggleClass().hide() Then in the __iadd__-method of js_calls you can render the right side. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
Steven D'Aprano wrote: On Fri, 28 Nov 2008 02:36:28 -0800, manatlan wrote: I'd like to make a jquery python wrapper [...] here is my code : [...] What is the purpose of this code? As near as I can see, it would make an excellent entry to the Obfuscated Python Competition, except it isn't clear that it does anything useful. Frankly, this looks like an pointlessly overly-complicated design to me. Rather than getting rid of the extra parentheses, I suggest you rethink your design. Explicit is better that implicit: don't have the one method do both appending to the object *and* calling the object. The basic idea isn't so bad. The OP tries to create a syntactic look-alike to the way the javascript library jQuery works, which does these chained calls, with the purpose of making the writing of JS serverside (something you sometimes for dynamic JS) within the same DSL. If this is nicely integrated, it actually could be neat. OTOH, I go with -strings string interpolation - works good enough for me... Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
On Nov 28, 3:24 am, Viktor Kerkez [EMAIL PROTECTED] wrote: On Nov 28, 9:35 am, Carl Banks [EMAIL PROTECTED] wrote: However, I'm not so sure the effect of os.chdir() on the import path is a good idea. I'm not actually using os.chidir(), I just used it here to create a clearer example. Here is the simplest representation of the problem: http://www.ninjashare.com/904415 $ cd singleton_test $ export PYTHONPATH=. $ python application/main_script.py Creating class Singleton Creating class MySingleton Creating class Singleton Creating class MySingleton $ Ah ha. That's a slightly different issue. Here's the problem: when you type python application/main_script.py, Python doens't call the module it runs application,main_script like you'd expect. Instead it calls the module __main__. Thus, when you later import application.main_script, Python doesn't see any already-loaded modules called application.main_script, so it imports the file again (this time calling the module application.main_script). Try it this way: python -c 'import application.main_script' In this example, Python the string passed to -c is considered the __main__ module, so when you import application.main_script it calls the module it imports application.main_script, so you will get the behavior you expect. The thing you have to remember is, Never try to reimport the main script; it just won't work. If you find yourself doing that, create a tiny script whose sole job is to import the real main script (and maybe set up sys.path), and run that. (Also, some people consider reciprocal imports to be bad style. I'm not one of them per se but I find that it's worth the effort to avoid them if it's easy to do so.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
unicode and hashlib
hashlib.md5 does not appear to like unicode, UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in position 1650: ordinal not in range(128) After googling, I've found BDFL and others on Py3K talking about the problems of hashing non-bytes (i.e. buffers) http://www.mail-archive.com/[EMAIL PROTECTED]/msg09824.html So what is the canonical way to hash unicode? * convert unicode to local * hash in current local ??? but what if local has ordinals outside of 128? Is this just a problem for md5 hashes that I would not encounter using a different method? i.e. Should I just use the built-in hash function? -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
manatlan wrote: To explain better, here is another code class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(list): def __init__(self): list.__init__([]) js=property(lambda self:JQueryCaller(self.__add)) def __add(self,j): self.append(j) if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() o.js.kiki(12).kuku().roro(gfde)() assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] here, it uses the __call__ of JQueryCaller by adding the () trick at the end ... I'd really like to have the same result, without the () trick, like this: o=MyObject() o.js.kiki(12).kuku() o.js.kiki(12).kuku().roro(gfde) assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] You could preallocate slots in MyObject: from functools import partial class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) self.__callback(..join(self._s)) return self return _caller class MyObject(list): def __init__(self): list.__init__([]) @property def js(self): n = len(self) self.append(None) return JQueryCaller(partial(self._add, n)) def _add(self, i, j): self[i] = j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku() o.js.kiki(12).kuku().roro(gfde) assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] This will course fail if you try things like a = o.js.kiki a(1) a(2) Peter -- http://mail.python.org/mailman/listinfo/python-list
web services ssl client
Hi, should I build a client for web services that require authentication based on a ca (pem and crt), I'm trying to use soappy but not work... someone have any idea or can tell me where to find a tutorial? tnx a lot! Luca -- skype:luca.tebaldi bookmark: http://del.icio.us/lucatebaldi foto: http://www.flickr.com/photos/teba/tags/ linkedin: http://www.linkedin.com/in/lucatebaldi -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On 28 nov, 17:12, Peter Otten [EMAIL PROTECTED] wrote: manatlan wrote: To explain better, here is another code class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) return self return _caller def __call__(self): return self.__callback(..join(self._s)) class MyObject(list): def __init__(self): list.__init__([]) js=property(lambda self:JQueryCaller(self.__add)) def __add(self,j): self.append(j) if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku()() o.js.kiki(12).kuku().roro(gfde)() assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] here, it uses the __call__ of JQueryCaller by adding the () trick at the end ... I'd really like to have the same result, without the () trick, like this: o=MyObject() o.js.kiki(12).kuku() o.js.kiki(12).kuku().roro(gfde) assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] You could preallocate slots in MyObject: from functools import partial class JQueryCaller(object): def __init__(self,callback): self.__callback=callback self._s=[] def __getattr__(self,name): def _caller(*args): sargs=['%s'%i for i in args] self._s.append(%s(%s)%(name,,.join(sargs))) self.__callback(..join(self._s)) return self return _caller class MyObject(list): def __init__(self): list.__init__([]) @property def js(self): n = len(self) self.append(None) return JQueryCaller(partial(self._add, n)) def _add(self, i, j): self[i] = j if __name__ == __main__: o=MyObject() o.js.kiki(12).kuku() o.js.kiki(12).kuku().roro(gfde) assert o==[kiki('12').kuku(), kiki('12').kuku().roro('gfde')] This will course fail if you try things like a = o.js.kiki a(1) a(2) Peter great ! you've found the way ! I don't understant the trick for now, but i will study it ! But it works like expected ! great ! thanks a lot -- http://mail.python.org/mailman/listinfo/python-list
Re: Great exercise for python expert !
On 28 nov, 16:53, Diez B. Roggisch [EMAIL PROTECTED] wrote: I just want to make a jquery wrapper, and let people use it to write jquery call on the server side in a python way ... o is a object, imagine a widget : like a textarea or input box js is a special attribut of o, which will let you write javascript for this object. o=MyObject() o.js.toggleClass(clean).hide() When I will render the object to a http/html output : it will generate something like (a javascript call): $(#idOfMyObject).toggleClass (clean).hide(); It's all what I want in the real world. I wouldn't do something like that (with the () tricks at the end on the chain, because I don't find it really readable/natural) o=MyObject() o.js.toggleClass(clean).hide()() The code I gave before (the JQueryCaller) was just my try to do what I want ... If there is another way : I take ;-) But there must be *something* on this end of the chain, because how is python otherwise to distinguish betwenn os.js.toggleClass().hide() os.js.toggleClass().hide().show() ? Now the question is if the action that is to take must be on the object itself. Maybe it works for you to make the assignment to some other object do the trick, or additon. Something like this: self.js_calls += os.js.toggleClass().hide() Then in the __iadd__-method of js_calls you can render the right side. Diez nice idea ... but you use an action on the += and __add__ ... it makes sense. but peter has found the way ! -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
Shiao wrote: The regex below identifies words in all languages I tested, but not in Hindi: # -*- coding: utf-8 -*- import re pat = re.compile('^(\w+)$', re.U) langs = ('English', '中文', 'हिन्दी') for l in langs: m = pat.search(l.decode('utf-8')) print l, m and m.group(1) Output: English English 中文 中文 हिन्दी None From this is assumed that the Hindi text contains punctuation or other characters that prevent the word match. Now, even more alienating is this: pat = re.compile('^(\W+)$', re.U) # note: now \W for l in langs: m = pat.search(l.decode('utf-8')) print l, m and m.group(1) Output: English None 中文 None हिन्दी None How can the Hindi be both not a word and not not a word?? Any clue would be much appreciated! It's not a word, but that doesn't mean that it consists entirely of non-alpha characters either. Here's what Python gets to see: langs[2] u'\u0939\u093f\u0928\u094d\u0926\u0940' from unicodedata import name for c in langs[2]: ... print repr(c), name(c), [non-alpha, ALPHA][c.isalpha()] ... u'\u0939' DEVANAGARI LETTER HA ALPHA u'\u093f' DEVANAGARI VOWEL SIGN I non-alpha u'\u0928' DEVANAGARI LETTER NA ALPHA u'\u094d' DEVANAGARI SIGN VIRAMA non-alpha u'\u0926' DEVANAGARI LETTER DA ALPHA u'\u0940' DEVANAGARI VOWEL SIGN II non-alpha Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
On Fri, Nov 28, 2008 at 10:47 AM, Shiao [EMAIL PROTECTED] wrote: The regex below identifies words in all languages I tested, but not in Hindi: # -*- coding: utf-8 -*- import re pat = re.compile('^(\w+)$', re.U) langs = ('English', '中文', 'हिन्दी') I think the problem is that the Hindi Text contains both alphanumeric and non-alphanumeric characters. I'm not very familiar with Hindi, much less how it's held in unicode, but take a look at the output of this code: # -*- coding: utf-8 -*- import unicodedata as ucd langs = (u'English', u'中文', u'हिन्दी') for lang in langs: print lang for char in lang: print \t %s %s (%s) % (char, ucd.name(char), ucd.category(char)) Output: English E LATIN CAPITAL LETTER E (Lu) n LATIN SMALL LETTER N (Ll) g LATIN SMALL LETTER G (Ll) l LATIN SMALL LETTER L (Ll) i LATIN SMALL LETTER I (Ll) s LATIN SMALL LETTER S (Ll) h LATIN SMALL LETTER H (Ll) 中文 中 CJK UNIFIED IDEOGRAPH-4E2D (Lo) 文 CJK UNIFIED IDEOGRAPH-6587 (Lo) हिन्दी ह DEVANAGARI LETTER HA (Lo) ि DEVANAGARI VOWEL SIGN I (Mc) न DEVANAGARI LETTER NA (Lo) ् DEVANAGARI SIGN VIRAMA (Mn) द DEVANAGARI LETTER DA (Lo) ी DEVANAGARI VOWEL SIGN II (Mc) From that, we see that there are some characters in the Hindi string that aren't letters (they're not in unicode category L), but are instead marks (unicode category M). -- http://mail.python.org/mailman/listinfo/python-list
Re: setting path for python interpretor
On Nov 28, 2008, at 6:41 AM, Beema Shafreen wrote: Hi all, Can any body suggest me how to the set path for making python2.4 as the main interpretor instead of python 2.5. Hi Beema, This question is about your operating system, not about Python. On my system (OS X), having installed Python to /usr/local, it was sufficient to add this to my ~/.profile export PATH=~/bin:/usr/local/bin:$PATH In general, check out the documentation for the PATH statement for your operating system and make sure your preferred Python appears first in the path. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
and we're not throwing ourselves at your pet project because most of us don't give a monkey's toss about Sketchup. Why should we put our time and energy into a piece of software that we don't care about? AGAIN, I'm NOT asking you to support SKETCHUP I am asking for support for PYTHON! Did you even read my entire OP?? Or did you just jump on Chris's bandwagon? Do you think for yourself, or do you follow blindly like a SHEEPLE?? this is the last line from my OP! but what needs to happen is to get a list together of people that use SketchUp or people who want use SketchUp, or people who just think... (having python in SketchUp)...it is a damn good idea and submit it to the DEV TEAM. I think you are TOO lazy to read a post as long as mine to the end, and since I have no reputation like Chris or George here you would never support my idea simply for that reason! If you support python scripting in SketchUp you are supporting Python, SketchUp is just collateral damage. But you are too blind with pride to see that. I think you and everyone that has replied negativly to this post justs want to use Python and not put in an effort to further Python. Hey, it's a free world baby... But can you really live with yourself??? -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
[EMAIL PROTECTED] wrote: Terry Reedy: A 'function' only needs to be nested if it is intended to be different (different default or closure) for each execution of its def. Or maybe because you want to denote a logical nesting, or maybe because you want to keep the outer namespace cleaner, etc etc. I was already aware of those *wants*, but they are not *needs*, in the sense I meant. A single constant function does not *need* to be nested and regenerated with each call. A standard idiom, I think, is give the foo-associated function a private foo-derived name such as _foo or _foo_bar. This keeps the public namespace clean and denotes the logical nesting. I *really* would not move things around after testing. For the attribute approach, you could lobby for the so-far rejected def foo(x): return foo.bar(3*x) def foo.bar(x): return x*x In the meanwhile... def foo(x): return foo.bar(3*x) def _(x): return x*x foo.bar = _ Or write a decorator so you can write @funcattr(foo. 'bar') def _ (I don't see any way a function can delete a name in the namespace that is going to become the class namespace, so that @fucattr(foo) def bar... would work.) Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: time function problem
willie wrote: My code: from time import time def leibniz(terms): acc = 0.0 num = 4.0 # numerator value remains constant in the series den = 1 count = 0 start_time = 0.0 for aterm in range(terms): nextterm = num/den * (-1)**aterm # (-1) allows fractions to alternate #between a + and a - value acc = acc + nextterm den = den + 2 #denominator increments by 2 count = count + 1 #print(count,acc) print(Time elapsed: %f%( time()- start_time)) return acc The result I get is -- Time elapsed: 1227812482.39 but I want to know the real time this code needed to run. Using a term value of 1000 I can see from the begining to end the actual time lapse is a little over 6 seconds. How do I get that value (6 + secs approx) as my time lapse. time() gives you the current time in seconds since the Epoch (1 Jan 1970). You should set start_time to time() instead of 0.0 at the start. Note that this will give you the elapsed time, not the CPU time. If you want the CPU (processing) time then use clock(). -- http://mail.python.org/mailman/listinfo/python-list
Python Library to display detail hardware information
Is there any python library that display very detailed hardware information and it must run in linux environtment ? Example (skip xml tag) biosPhoenix Technologies NAPA0001.86C.0049.D.0612081421 12/08/06/bios cpuIntel(R) Core(TM) Duo CPU T2350 @ 1.86GHz/cpu cpu2Intel(R) Core(TM) Duo CPU T2350 @ 1.86GHz/cpu2 memory1GiB Max.Mem = 3GiB/memory harddiskSeagate ST9120822AS 111GiB (120GB)/harddisk opticalTSSTcorpCD/DVDW TS-L632D/optical displayMobile 945GM/GMS, 943/940GML Express Integrated Graphics /display audio82801G (ICH7 Family) High Definition Audio/audio ethernetRealtek RTL-8169 Gigabit Ethernet eth0/ethernet wlanIntel PRO/Wireless 3945ABG [Golan] Network Connection Mini PCI /wlan modemMotorola Si3054/modem sdcard5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)/sdcard firewireIEEE-1394 PCIxx12 OHCI Compliant IEEE 1394 Host Controller/firewire bluetooth /bluetooth cameraUSB2.0 Camera ALi Corp./camera fingerprint /fingerprint batteryLION, now 598 mAh max 4000 mAh/battery Etc... TIA-Hanny Wibisono Sorry my english.. :( -- http://mail.python.org/mailman/listinfo/python-list
Installing NumPy and SciPy in Python 2.6
Sorry if my question was already asked and answered, but I can't manage with this... I've installed Python 2.6 in my Windows XP. Actually, I've installed ActiveState's ActivePython 2.6. I would like to use NumPy and SciPy. Are those packages compatible with version 2.6 of Python? Are they already installed in ActivePython 2.6? If not, how can install them? I downloaded the Windows installers for NumPy and SciPy, but as they are prepared for Python 2.5, I can't make the installers run properly. Any piece of help will be appreciated. Thank you! -- Vicent -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. Thanks Bruno, I never said Ruby is a bad Language! do you what IMHO means?? For every question there is one answer. Do YOU BRUNO, think that learning Ruby is easier than learning Python(for non-programmers)?? Can you honestly answer a simple question like this? Or does pride get in the way. Or maybe you where born knowing all programming languages and that is why you honestly cannot answer. -food for thought- -- http://mail.python.org/mailman/listinfo/python-list
filter func chaining
I am trying to chain filter functions together so I created these 2 functions. def AndChain(*filters): return (lambda asset: reduce((lambda r, f: apply(f, asset) and r), filters)) def OrChain(*filters): return (lambda asset: reduce((lambda r, f: apply(f, asset) or r), filters)) Where filters are simply functions that take a single argument and return true or false. My intention is to use these functions like this: f = AndChain(AssetTypeFilter(), CurrencyFilter()) filteredCol = filter(f, col) I am receiving the following error (where Asset is the type of items in my collection) Traceback (most recent call last): File , line 0, in stdin##44 File c:\proj\ofts\com.oakwoodft.ofts.compliance\complianceframework\filters\assetfilters.py, line 5, in lambda File c:\proj\ofts\com.oakwoodft.ofts.compliance\complianceframework\filters\assetfilters.py, line 5, in lambda TypeError: Asset object at 0x002B is not enumerable Am I going about this totally wrong? Is there a better solution? Thanks. Drew Schaeffer -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 11:52 am, r [EMAIL PROTECTED] wrote: and we're not throwing ourselves at your pet project because most of us don't give a monkey's toss about Sketchup. Why should we put our time and energy into a piece of software that we don't care about? AGAIN, I'm NOT asking you to support SKETCHUP I am asking for support for PYTHON! Did you even read my entire OP?? Or did you just jump on Chris's bandwagon? Do you think for yourself, or do you follow blindly like a SHEEPLE?? this is the last line from my OP! but what needs to happen is to get a list together of people that use SketchUp or people who want use SketchUp, or people who just think... (having python in SketchUp)...it is a damn good idea and submit it to the DEV TEAM. I think you are TOO lazy to read a post as long as mine to the end, and since I have no reputation like Chris or George here you would never support my idea simply for that reason! If you support python scripting in SketchUp you are supporting Python, SketchUp is just collateral damage. But you are too blind with pride to see that. I think you and everyone that has replied negativly to this post justs want to use Python and not put in an effort to further Python. Hey, it's a free world baby... But can you really live with yourself??? I encourage everyone that have been offended by my remarks about Ruby to Post their feeling about how Ruby is better than Python. THE ONLY REASON I SAID PYTHON WAS BETTER WAS IT'S LEARNABILITY. Proove to me intellectually that Ruby is easier to learn, instead of getting offended an spiting hateful remarks. I am sure the same goals can be accomplished with both languages. Sometimes Ruby will be better, sometimes Python will be better. You know there can only be one winner to a contest. This everybody needs to win crap makes me sick. Take for example little league games where they let both teams win. What does this teach a child. Winning is WRONG?? Yes...competition brings out the best and worst in all of us, but without it, we would still be in the stone ages. Wake up, i thought intellectual people hung out here, not blind SHEEPLE who will jump on the bandwagon. This is the same madness that Hitler employed! Use your mind, think freely of other people, and ye shall be free. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Thanks again alex23, but did you not already post the exact same thing, can you not engage in intellectual conversation, or have you spent your last penny? -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing NumPy and SciPy in Python 2.6
On Fri, Nov 28, 2008 at 1:20 PM, Vicent Giner [EMAIL PROTECTED] wrote: Sorry if my question was already asked and answered, but I can't manage with this... I've installed Python 2.6 in my Windows XP. Actually, I've installed ActiveState's ActivePython 2.6. I would like to use NumPy and SciPy. Are those packages compatible with version 2.6 of Python? Are they already installed in ActivePython 2.6? If not, how can install them? I downloaded the Windows installers for NumPy and SciPy, but as they are prepared for Python 2.5, I can't make the installers run properly. Any piece of help will be appreciated. Thank you! -- Vicent As of right now, the precompiled binaries do not run on Python 2.6. You can always try building the packages from source because it usually takes a while for binaries to come out for the new version of python. -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
Jeff H wrote: hashlib.md5 does not appear to like unicode, UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in position 1650: ordinal not in range(128) After googling, I've found BDFL and others on Py3K talking about the problems of hashing non-bytes (i.e. buffers) ... Unicode is characters, not a character encoding. You could hash on a utf-8 encoding of the Unicode. So what is the canonical way to hash unicode? * convert unicode to local * hash in current local ??? There is no _the_ way to hash Unicode, any more than there is no _the_ way to hash vectors. You need to convert the abstract entity something concrete with a well-defined representation in bytes, and hash that. Is this just a problem for md5 hashes that I would not encounter using a different method? i.e. Should I just use the built-in hash function? No, it is a definitional problem. Perhaps you could explain how you want to use the hash. If the internal hash is acceptable (e.g. for grouping in dictionaries within a single run), use that. If you intend to store and compare on the same system, say that. If you want cross- platform execution of your code to produce the same hashes, say that. A hash is a means to an end, and it is hard to give advice without knowing the goal. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing NumPy and SciPy in Python 2.6
Vicent Giner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sorry if my question was already asked and answered, but I can't manage with this... I've installed Python 2.6 in my Windows XP. Actually, I've installed ActiveState's ActivePython 2.6. I would like to use NumPy and SciPy. Are those packages compatible with version 2.6 of Python? Are they already installed in ActivePython 2.6? If not, how can install them? I downloaded the Windows installers for NumPy and SciPy, but as they are prepared for Python 2.5, I can't make the installers run properly. Any piece of help will be appreciated. The current version of NumPy doesn't work with Python 2.6. I believe that support for Python 2.6 is planned for NumPy 1.3 and there is a hope that this can be released before the end of 2008. Brian Gladman -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
Jeff H wrote: hashlib.md5 does not appear to like unicode, UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in position 1650: ordinal not in range(128) After googling, I've found BDFL and others on Py3K talking about the problems of hashing non-bytes (i.e. buffers) http://www.mail-archive.com/[EMAIL PROTECTED]/msg09824.html So what is the canonical way to hash unicode? * convert unicode to local * hash in current local ??? but what if local has ordinals outside of 128? Is this just a problem for md5 hashes that I would not encounter using a different method? i.e. Should I just use the built-in hash function? It can handle bytestrings, but if you give it unicode it performs a default encoding to ASCII, but that fails if there's a codepoint = U+0080. Personally, I'd recommend encoding unicode to UTF-8. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
Jerry Hill wrote: On Fri, Nov 28, 2008 at 10:47 AM, Shiao [EMAIL PROTECTED] wrote: The regex below identifies words in all languages I tested, but not in Hindi: # -*- coding: utf-8 -*- import re pat = re.compile('^(\w+)$', re.U) langs = ('English', '中文', 'हिन्दी') I think the problem is that the Hindi Text contains both alphanumeric and non-alphanumeric characters. I'm not very familiar with Hindi, much less how it's held in unicode, but take a look at the output of this code: # -*- coding: utf-8 -*- import unicodedata as ucd langs = (u'English', u'中文', u'हिन्दी') for lang in langs: print lang for char in lang: print \t %s %s (%s) % (char, ucd.name(char), ucd.category(char)) Output: English E LATIN CAPITAL LETTER E (Lu) n LATIN SMALL LETTER N (Ll) g LATIN SMALL LETTER G (Ll) l LATIN SMALL LETTER L (Ll) i LATIN SMALL LETTER I (Ll) s LATIN SMALL LETTER S (Ll) h LATIN SMALL LETTER H (Ll) 中文 中 CJK UNIFIED IDEOGRAPH-4E2D (Lo) 文 CJK UNIFIED IDEOGRAPH-6587 (Lo) हिन्दी ह DEVANAGARI LETTER HA (Lo) ि DEVANAGARI VOWEL SIGN I (Mc) न DEVANAGARI LETTER NA (Lo) ् DEVANAGARI SIGN VIRAMA (Mn) द DEVANAGARI LETTER DA (Lo) ी DEVANAGARI VOWEL SIGN II (Mc) From that, we see that there are some characters in the Hindi string that aren't letters (they're not in unicode category L), but are instead marks (unicode category M). Python3.0 allows unicode identifiers. Mn and Mc characters are included in the set of allowed alphanumeric characters. 'Hindi' is a word in both its native characters and in latin tranliteration. http://docs.python.org/dev/3.0/reference/lexical_analysis.html#identifiers-and-keywords re is too restrictive in its definition of 'word'. I suggest that OP (original poster) Shiao file a bug report at http://bugs.python.org tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing NumPy and SciPy in Python 2.6
Vicent Giner wrote: I've installed Python 2.6 in my Windows XP. Actually, I've installed ActiveState's ActivePython 2.6. I would like to use NumPy and SciPy. Are those packages compatible with version 2.6 of Python? I believe there is more work to do on Scipy and Numpy before they will run on 2.6. Expect Numpy to come first (or at the same time). 2.6 is quite new, so a number of packages may tak a while to get there. I think Numpy, in particular, is changing to a new memory buffer protocol, and may take a while. My guess would be, if you need it this year, drop back to 2.5. If you can wait until early next year (and/or have the round tuits to help), go with 2.6. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
Terry Reedy wrote: Jerry Hill wrote: On Fri, Nov 28, 2008 at 10:47 AM, Shiao [EMAIL PROTECTED] wrote: The regex below identifies words in all languages I tested, but not in Hindi: # -*- coding: utf-8 -*- import re pat = re.compile('^(\w+)$', re.U) langs = ('English', '中文', 'हिन्दी') I think the problem is that the Hindi Text contains both alphanumeric and non-alphanumeric characters. I'm not very familiar with Hindi, much less how it's held in unicode, but take a look at the output of this code: # -*- coding: utf-8 -*- import unicodedata as ucd langs = (u'English', u'中文', u'हिन्दी') for lang in langs: print lang for char in lang: print \t %s %s (%s) % (char, ucd.name(char), ucd.category(char)) Output: English E LATIN CAPITAL LETTER E (Lu) n LATIN SMALL LETTER N (Ll) g LATIN SMALL LETTER G (Ll) l LATIN SMALL LETTER L (Ll) i LATIN SMALL LETTER I (Ll) s LATIN SMALL LETTER S (Ll) h LATIN SMALL LETTER H (Ll) 中文 中 CJK UNIFIED IDEOGRAPH-4E2D (Lo) 文 CJK UNIFIED IDEOGRAPH-6587 (Lo) हिन्दी ह DEVANAGARI LETTER HA (Lo) ि DEVANAGARI VOWEL SIGN I (Mc) न DEVANAGARI LETTER NA (Lo) ् DEVANAGARI SIGN VIRAMA (Mn) द DEVANAGARI LETTER DA (Lo) ी DEVANAGARI VOWEL SIGN II (Mc) From that, we see that there are some characters in the Hindi string that aren't letters (they're not in unicode category L), but are instead marks (unicode category M). Python3.0 allows unicode identifiers. Mn and Mc characters are included in the set of allowed alphanumeric characters. 'Hindi' is a word in both its native characters and in latin tranliteration. http://docs.python.org/dev/3.0/reference/lexical_analysis.html#identifiers-and-keywords re is too restrictive in its definition of 'word'. I suggest that OP (original poster) Shiao file a bug report at http://bugs.python.org Should the Mc and Mn codepoints match \w in the re module even though u'हिन्दी'.isalpha() returns False (in Python 2.x, haven't tried Python 3.x)? Issue 1693050 said no. Perhaps someone with knowledge of Hindi could suggest how Python should handle it. I wouldn't want the re module to say one thing and the rest of the language to say another! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
Jeff H wrote: hashlib.md5 does not appear to like unicode, UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in position 1650: ordinal not in range(128) It is the (default) ascii encoder that does not like non-ascii chars. I suspect that is you encode to bytes first with an encoder that does work (latin-???), md5 will be happy. Reports like this should include Python version. After googling, I've found BDFL and others on Py3K talking about the problems of hashing non-bytes (i.e. buffers) http://www.mail-archive.com/[EMAIL PROTECTED]/msg09824.html So what is the canonical way to hash unicode? * convert unicode to local * hash in current local ??? but what if local has ordinals outside of 128? Is this just a problem for md5 hashes that I would not encounter using a different method? i.e. Should I just use the built-in hash function? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 4:32 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Are you trolling? Are you some sort of agent provocateur trying to put people *against* the idea of Python scripting for Sketchup? If not, you're sure doing an excellent imitation of one. I am the only person here THAT IS FOR Python scripting in SketchUp! (remember, i AM the OP) I AM the one who came up with the idea in the first place! Only one other person here has agreed fully with me. When i said Well... 3 for Ruby 1 for python. Not looking good so far. Any more votes?...was my disgust at the lack of support for python here. It's really shameful :( -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
On 28 Nov, 21:03, Terry Reedy [EMAIL PROTECTED] wrote: It is the (default) ascii encoder that does not like non-ascii chars. I suspect that is you encode to bytes first with an encoder that does work (latin-???), md5 will be happy. I know that the Python roadmap answer to such questions might refer to Python 3.0 and its strings are Unicode features, and having seen this mentioned a lot recently, I'm surprised that no-one has done so at the time of writing, but I do wonder whether good old Python 2.x wouldn't benefit from a more explicit error message in these situations. Since the introduction of Unicode in Python 1.6/2.0, I've always tried to make the distinction between what I call plain strings or byte strings and Unicode objects or character strings, and perhaps the UnicodeEncodeError message should be enhanced to say what is actually going on: that an attempt is being made to convert characters into byte values and that the chosen way of doing so (which often involves the default, ASCII encoding) cannot manage the job. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 6:15 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: r a écrit : On Nov 28, 12:52 am, [EMAIL PROTECTED] wrote: On Nov 27, 10:28 pm, r [EMAIL PROTECTED] wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may lose all hope in humanity. He only spent the last 18 years of his life pursuing this thing called Python. Maybe 1,2,3, years from now someone will see this thread and post a vote for Python. Maybe as simple as I will fight for Python , I am not scared to go up against the status quo. For that day will be a glorious day. That day shall be Python Day! I will never give UP! r, i am with you! i will back Python!!! we MUST spread Python throughout the world! sketchup is the first step, only the first step. it is really sad that the so-called Python supporters on this list don't really care about Python -- only money, and depravity. you and i and the other few, pure of heart, must fight for Python!! death to infidel ruby lovers!!! long live Guido! i pledge my life to Python and Guido!!! Ok finally! Thank you [EMAIL PROTECTED] the Python Gods have not forsaken me! I'm afraid you've been trolled. r, don't believe him. he is a secret ruby lover and a tool of matz. the ruby lovers here will stop at nothing to gain their end! they will try to sow dissension and suspicion among us! to turn us against our own! we must fight united for Python. do not waver, do not hesitate. this group is a den of inequity, filled with ruby lovers, perl lovers, java lovers, and yes, even c++ lovers! you r, see the situation with clear eyes -- there can be only one victor in this language war to the death! it MUST be Python!! without Python there is nothing to live for! give me Python or give me death!!! for all that is holy, all that is sacred, long live Guido!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about class relationships
John O'Hagan [EMAIL PROTECTED] wrote: Apologies if this is a D.Q., I'm still learning to use classes, and this little problem has proved too specific to find in the tutorials. I have two classes with a relationship that I find confusing. One is called Engine, and it has a method (bar_builder) which generates instances of the other class, called Bar (not as in Foo but as in bar of music; inherits from list). Also, Bar takes the generating instance of Engine as an argument to its __init__ method: class Bar(list): def __init__(self, a_bar, args, engine): list.__init__ (self, a_bar) self[:] = a_bar self.args = args self.engine = engine #more instance attributes... #methods... class Engine: def __init__(self, args): self.args = args #more instance attributes... def bar_builder(self): #body of method generates lists... yield Bar([generated_list], args, self) #more methods... #(other stuff...) def main(args): engine = Engine(args) bars = engine.bar_builder() for a_bar in bars: #play the music!... While this works (to my surprise!) and solves the problem which motivated it (i.e. Engine instances need to pass some attributes to Bar instances ), it seems too convoluted. Should one class inherit the other? If so, which way around? Or is it fine as is? You need to put on a philosophical hat for this. Inheritance is used for an is-a relationship, where one thing is-a special type of another thing. Is Engine a special type of Bar? Is Bar a generic type of Engine? I think the answer is no, and because of that inheritance is not the right answer. I'm hoping this is a common trap I've fallen into; I just haven't been able to get my head around it. (I'm a musician...) Why do you think this is a trap? Engine creates Bars. Bars need to know about the Engine. I think you have expressed that relationship properly. When I have these kinds of philosophical debates over my own code, I always try to summarize them in the comments inside the module, just so others can get inside my head to understand the thinking that led to my design. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 2:24 pm, [EMAIL PROTECTED] wrote: On Nov 28, 6:15 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: r a écrit : On Nov 28, 12:52 am, [EMAIL PROTECTED] wrote: On Nov 27, 10:28 pm, r [EMAIL PROTECTED] wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may lose all hope in humanity. He only spent the last 18 years of his life pursuing this thing called Python. Maybe 1,2,3, years from now someone will see this thread and post a vote for Python. Maybe as simple as I will fight for Python , I am not scared to go up against the status quo. For that day will be a glorious day. That day shall be Python Day! I will never give UP! r, i am with you! i will back Python!!! we MUST spread Python throughout the world! sketchup is the first step, only the first step. it is really sad that the so-called Python supporters on this list don't really care about Python -- only money, and depravity. you and i and the other few, pure of heart, must fight for Python!! death to infidel ruby lovers!!! long live Guido! i pledge my life to Python and Guido!!! Ok finally! Thank you [EMAIL PROTECTED] the Python Gods have not forsaken me! I'm afraid you've been trolled. r, don't believe him. he is a secret ruby lover and a tool of matz. the ruby lovers here will stop at nothing to gain their end! they will try to sow dissension and suspicion among us! to turn us against our own! we must fight united for Python. do not waver, do not hesitate. this group is a den of inequity, filled with ruby lovers, perl lovers, java lovers, and yes, even c++ lovers! you r, see the situation with clear eyes -- there can be only one victor in this language war to the death! it MUST be Python!! without Python there is nothing to live for! give me Python or give me death!!! for all that is holy, all that is sacred, long live Guido!!! If only the others had 1/10 of one percent of your love for Python, we could do great things! But in the world today, most people would rather sit glued to the boob-tube waiting for that next wardrobe malfunction from Janet Jackson, or watch beaver shots of Brittney and Paris, than jump in the trenches and fight for a just cause. Sad... very sad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating classes and objects more than once?
Carl Banks [EMAIL PROTECTED] writes: On Nov 28, 3:15 am, Ben Finney [EMAIL PROTECTED] wrote: This is resolved in the Python 2.x series by implementing PEP 328 URL:http://www.python.org/dev/peps/pep-0328/, such that the search path for ‘import’ does *not* contain the current directory, and requiring relative-to-the-current-directory imports to be explicitly requested. PEP 328 doesn't say anything about that. Using Python 2.5, which PEP 328 claims implements this change, I see the same behavior that Victor Kerkez sees. My sys.path[0] is still the empty string, meaning that Python does start its import search from the current directory. In Python 2.5, the PEP is implemented to the point that the absolute import behaviour is available by adding a ‘from __future__ import absolute_import’. Without that, yes, you will see the same behaviour as reported by Victor. The schedule of implementing significant changes like this is standardised for Python (by PEP 5), and the timeline is explicitly documented in the relevant section of PEP 328: Timeline In Python 2.5, you must enable the new absolute import behavior with from __future__ import absolute_import You may use relative imports freely. In Python 2.6, any import statement that results in an intra-package import will raise DeprecationWarning (this also applies to from import that fails to use the relative import syntax). In Python 2.7, import will always be an absolute import (and the __future__ directive will no longer be needed). -- \ “Pinky, are you pondering what I'm pondering?” “I think so, | `\ Brain, but if it was only supposed to be a three hour tour, why | _o__) did the Howells bring all their money?” —_Pinky and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 2:43 pm, r [EMAIL PROTECTED] wrote: On Nov 28, 2:24 pm, [EMAIL PROTECTED] wrote: On Nov 28, 6:15 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: r a écrit : On Nov 28, 12:52 am, [EMAIL PROTECTED] wrote: On Nov 27, 10:28 pm, r [EMAIL PROTECTED] wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may lose all hope in humanity. He only spent the last 18 years of his life pursuing this thing called Python. Maybe 1,2,3, years from now someone will see this thread and post a vote for Python. Maybe as simple as I will fight for Python , I am not scared to go up against the status quo. For that day will be a glorious day. That day shall be Python Day! I will never give UP! r, i am with you! i will back Python!!! we MUST spread Python throughout the world! sketchup is the first step, only the first step. it is really sad that the so-called Python supporters on this list don't really care about Python -- only money, and depravity. you and i and the other few, pure of heart, must fight for Python!! death to infidel ruby lovers!!! long live Guido! i pledge my life to Python and Guido!!! Ok finally! Thank you [EMAIL PROTECTED] the Python Gods have not forsaken me! I'm afraid you've been trolled. r, don't believe him. he is a secret ruby lover and a tool of matz. the ruby lovers here will stop at nothing to gain their end! they will try to sow dissension and suspicion among us! to turn us against our own! we must fight united for Python. do not waver, do not hesitate. this group is a den of inequity, filled with ruby lovers, perl lovers, java lovers, and yes, even c++ lovers! you r, see the situation with clear eyes -- there can be only one victor in this language war to the death! it MUST be Python!! without Python there is nothing to live for! give me Python or give me death!!! for all that is holy, all that is sacred, long live Guido!!! If only the others had 1/10 of one percent of your love for Python, we could do great things! But in the world today, most people would rather sit glued to the boob-tube waiting for that next wardrobe malfunction from Janet Jackson, or watch beaver shots of Brittney and Paris, than jump in the trenches and fight for a just cause. Sad... very sad. Oh Python, where art thy faithful followers, try house is crumbling, try last breath spent. You have fought bravely for all that is good. But ye are encompassed on all sides by evil. Those who proclaim to love you are only the very same who seek your end! Weep oh lovers of Python...Weep. For your silence brings about the hideous end to a great awesome power. Never again shall the sun shine on calm waters. Never again shall the people be free. For the betrayers have thrush the knife of iniquity slowly into thou heart, and as you lay dying, they desacrate your body like the scoundrels they are. Weep, Weep, for yourself you vipers...for you have done a great injustice to the world. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing NumPy and SciPy in Python 2.6
On Sat, Nov 29, 2008 at 4:31 AM, Scott David Daniels [EMAIL PROTECTED] wrote: Vicent Giner wrote: I've installed Python 2.6 in my Windows XP. Actually, I've installed ActiveState's ActivePython 2.6. I would like to use NumPy and SciPy. Are those packages compatible with version 2.6 of Python? I believe there is more work to do on Scipy and Numpy before they will run on 2.6. Expect Numpy to come first (or at the same time). 2.6 is quite new, so a number of packages may tak a while to get there. I think Numpy, in particular, is changing to a new memory buffer protocol, and may take a while. AFAIK, numpy on 2.6 will not change to a new API in that regard. But note that python 2.6 does not bring much for scientific computation, so I think that if you canm you should stick to 2.5 before a release with official 2.6 support is available. We indeed hope to get a 2.6 compatible release of numpy within the end of the year (scipy should follow quite quickly). David -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
MRAB wrote: Should the Mc and Mn codepoints match \w in the re module even though u'हिन्दी'.isalpha() returns False (in Python 2.x, haven't tried Python 3.x)? Same. And to me, that is wrong. The condensation of vowel characters (which Hindi, etc, also have for words that begin with vowels) to 'vowel marks' attached to the previous consonant does change their nature as indications of speech sounds. The difference is purely graphical. Issue 1693050 said no. The full url http://bugs.python.org/issue1693050 would have been nice, but thank you for finding this. I search but obviously not with the right word. In any case, this issue is still open. MAL is wrong about at least Mc and Mn. I will explain there also. Perhaps someone with knowledge of Hindi could suggest how Python should handle it. Recognize that vowel are parts of words, as it already does for identifiers. I wouldn't want the re module to say one thing and the rest of the language to say another! :-) I will add a note about .isapha Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
r schrieb: The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. Thanks Bruno, I never said Ruby is a bad Language! snip nonsense/ -food for thought- Eat your own post: Unfortunatly though SketchUp currently uses Ruby(sorry to use profanity) language for scripting on both the free and pro versions. Now I don't see no IMHO there, do you? Instead, you seem to think saying Ruby is considered a swear word. As this isn't the case for this very open minded and friendly community, this idea must be in *your* head. Ergo, you don't like Ruby. So much for never said it's a bad language. Now, up up and away into my killfilter, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
r schrieb: The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. Thanks Bruno, I never said Ruby is a bad Language! snip nonsense/ -food for thought- Eat your own post: Unfortunatly though SketchUp currently uses Ruby(sorry to use profanity) language for scripting on both the free and pro versions. Now I don't see no IMHO there, do you? Instead, you seem to think saying Ruby is considered a swear word. As this isn't the case for this very open minded and friendly community, this idea must be in *your* head. Ergo, you don't like Ruby. So much for never said it's a bad language. Now, up up and away into my killfilter, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Oh Python, where art thy faithful followers, thy house is crumbling, thy last breath spent, thy season draweth nigh...Ye have fought bravely for all that is good. But ye are encompassed on all sides by evil. Those who proclaim to love you are only the very same who seek your end! Weep oh lovers of Python...Weep. For your silence brings about the hideous end to a great awesome power. Never again shall the sun shine on calm waters. Never again shall the people be free. For the betrayers have thrush the knife of iniquity slowly into thou heart, and as ye lay dying, desacrate your body like the scoundrels they are. Weep, Weep, for yourself you scondrels, you vipers...for you have done a great injustice to yourself and the world. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 4:16 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Now, up up and away into my killfilter, Ditto; apparently it's either a troll or an 8-year old. George -- http://mail.python.org/mailman/listinfo/python-list
Pycon 2009
http://lifeflowcharts.appspot.com/?num_visible_rows=20scroll_offsets=%5B0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+5%5Dtranslate_x_ff=74translate_x_ie=-69num_visible_cols=8translate_y_ie=374child_order=reverse_timetranslate_y_ff=-364scale_xy_ff=1.0002db_key=ag5saWZlZmxvd2NoYXJ0c3IKCxIDQm94GKsFDAlfc_action=loadscale_xy_display=100scale_xy_ie=100recenter=1zoom=100child_order_select=by_ratingsearch_text=search_button=Searchmysubmit=Logoutmyinfo=Infosearch_string=pyconsearch_db_key= -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
r wrote: On Nov 28, 4:32 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Are you trolling? Are you some sort of agent provocateur trying to put people *against* the idea of Python scripting for Sketchup? If not, you're sure doing an excellent imitation of one. I am the only person here THAT IS FOR Python scripting in SketchUp! Stop lying. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tools for using virtual environments and PEP 370
Python 2.6 implemented PEP 370: Per-user site-packages Directory Ok, you can completelly replace virtualenv with a) setting PYTHONUSERBASE=something b) Editing ~/.pydistutils.cfg to be like: [install] user=True After this, installing new packages go to $PYTHONUSERBASE/lib/python2.6/site-packages/. I've also tried pip.py and it mostly works fine with this setup except for one bug where it tries to write a install-record-%s.txt file in /usr/lib/.../ I've hacked it with this crude patch (which is not correct always). @@ -1388,7 +1389,8 @@ if sys.platform == 'win32': install_location = os.path.join(sys.prefix, 'Lib') else: -install_location = os.path.join(sys.prefix, 'lib', 'python%s' % sys.version[:3]) +import site +install_location = os.path.join(site.USER_BASE, 'lib', 'python%s' % sys.version[:3]) record_filename = os.path.join(install_location, 'install-record-%s.txt' % self.name) ## FIXME: I'm not sure if this is a reasonable location; probably not -- дамјан ( http://softver.org.mk/damjan/ ) A: Because it reverses the logical flow of converstion. Q: Why is top posting frowned upon? -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
OK people, where back to 2 for Python and i will not even mention the one's against. I thought Terry was 50% onboard but he has just made his choice known. I would have liked to have you on board Terry, and will forgive if you change your mind. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
You know i wonder how many people saw that the link to the OP had 30,40 replies and they said...WOW it looks like the community is getting behind a project to host Python, I had better check this out! Then when they opened the link and saw all the negative responses from well known posters...either jumped on the negative bandwagon...or were too afraid to post a reply that backs a n00b supporting Python. -just food for thought- I my self would never so viciously attack a poster for his ideas, if i were to reply at all i would simple say i do not think this is a good idea. Plain and simple, and to the point. I never attacked anybody. I only came here to share my support to further the advancement of Python and see if anybody shared the same feelings. Only one person out of 14,405 members agrees with me. I never thought i will convince everyone, but i sure did not think ONLY one person HERE would support Python. WOW...that is all i can say...WOW You know I said before that I hoped Guido never see's this thread...but i wonder if maybe he should see it...To see how far the great advocates have fallen. I am disappointed to say the least. I would not want to be in his shoes and see this! -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
On Nov 29, 2:47 am, Shiao [EMAIL PROTECTED] wrote: The regex below identifies words in all languages I tested, but not in Hindi: pat = re.compile('^(\w+)$', re.U) ... m = pat.search(l.decode('utf-8')) [example snipped] From this is assumed that the Hindi text contains punctuation or other characters that prevent the word match. This appears to be a bug in Python, as others have pointed out. Two points not covered so far: (1) Instead of search() with pattern ^blahblah, use match() with pattern blahblah -- unless it has been fixed fairly recently, search() doesn't notice that the ^ means that it can give up when failure occurs at the first try; it keeps on trying futilely at the 2nd, 3rd, positions. (2) identifies words: \w+ (when fixed) matches a sequence of one or more characters that could appear *anywhere* in a word in any language (including computer languages). So it not only matches words, it also matches non-words like '123' and '0x000' and '0123_' and 10 viramas -- in other words, you may need to filter out false positives. Also, in some languages (e.g. Chinese) a word consists of one or more characters and there is typically no spacing between words; \w+ will identify whole clauses or sentences. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
You know i wonder how many people saw that the link to the OP had 30,40 replies and they said...WOW it looks like the community is getting behind a project to host Python, I had better check this out! Then when they opened the link and saw all the negative responses from well known posters...either jumped on the negative bandwagon...or were too afraid to post a reply that backs a n00b supporting Python. -just food for thought- I my self would never so viciously attack a poster for his ideas, if i were to reply at all i would simple say i do not think this is a good idea. Plain and simple, and to the point. I never attacked anybody. I only came here to share my support to further the advancement of Python and see if anybody shared the same feelings. Only one person out of 14,405 members agrees with me. I never thought i will convince everyone, but i sure did not think ONLY one person HERE would support Python. WOW...that is all i can say...WOW You know I said before that I hoped Guido never see's this thread...but i wonder if maybe he should see it...To see how far the great advocates have fallen. I am disappointed to say the least. I would not want to be in his shoes and see this! Here is the definition of a troll for those whom seem not to comprehend. From Wikipedia, the free encyclopedia = An Internet troll, or simply troll in Internet slang, is someone who posts controversial, inflammatory, irrelevant or off-topic messages in an online community, such as an online discussion forum or chat room, with the intention of provoking other users into an emotional response [1] or to generally disrupt normal on-topic discussion.[2] Application of the term troll is highly subjective. Some readers may characterize a post as trolling, while others may regard the same post as a legitimate contribution to the discussion, even if controversial. The term is often used to discredit an opposing position, or its proponent, by argument fallacy ad hominem. Often, calling someone a troll makes assumptions about a writer's motives. Regardless of the circumstances, controversial posts may attract a particularly strong response from those unfamiliar with the robust dialogue found in some online, rather than physical, communities. How is someone that goes to the PYTHON group to SUPPORT PYTHON a troll?? -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Fri, Nov 28, 2008 at 6:22 PM, r [EMAIL PROTECTED] wrote: You know i wonder how many people saw that the link to the OP had 30,40 replies and they said...WOW it looks like the community is getting behind a project to host Python, I had better check this out! Then when they opened the link and saw all the negative responses from well known posters...either jumped on the negative bandwagon...or were too afraid to post a reply that backs a n00b supporting Python. -just food for thought- I my self would never so viciously attack a poster for his ideas, if i were to reply at all i would simple say i do not think this is a good idea. Plain and simple, and to the point. I never attacked anybody. I only came here to share my support to further the advancement of Python and see if anybody shared the same feelings. Only one person out of 14,405 members agrees with me. I never thought i will convince everyone, but i sure did not think ONLY one person HERE would support Python. WOW...that is all i can say...WOW You know I said before that I hoped Guido never see's this thread...but i wonder if maybe he should see it...To see how far the great advocates have fallen. I am disappointed to say the least. I would not want to be in his shoes and see this! Here is the definition of a troll for those whom seem not to comprehend. From Wikipedia, the free encyclopedia = An Internet troll, or simply troll in Internet slang, is someone who posts controversial, inflammatory, irrelevant or off-topic messages in an online community, such as an online discussion forum or chat room, with the intention of provoking other users into an emotional response [1] or to generally disrupt normal on-topic discussion.[2] Application of the term troll is highly subjective. Some readers may characterize a post as trolling, while others may regard the same post as a legitimate contribution to the discussion, even if controversial. The term is often used to discredit an opposing position, or its proponent, by argument fallacy ad hominem. Often, calling someone a troll makes assumptions about a writer's motives. Regardless of the circumstances, controversial posts may attract a particularly strong response from those unfamiliar with the robust dialogue found in some online, rather than physical, communities. How is someone that goes to the PYTHON group to SUPPORT PYTHON a troll?? Easily- this is a forum for people to obtain help with Python problems, not to plan Python's conquest of the world. Many of us use several programming languages for various tasks. You are making inflammatory remarks on this list and you are trying to incite a response- a Python mob to go pester Google to release Python APIs for everything they release. Therefore, you are a troll. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Terry, I in my haste I may have miss-read your post...Are you saying that there are people who WOULD support Python in SketchUp? Are you one of them? Can you tell me who else may be interested? How can i contact these people? -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Terry, In my haste I may have miss-read your post...Are you saying that there are people who WOULD support Python in SketchUp? Are you one of them? Can you tell me who else may be interested? How can i contact these people? -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode regex and Hindi language
John Machin wrote: On Nov 29, 2:47 am, Shiao [EMAIL PROTECTED] wrote: The regex below identifies words in all languages I tested, but not in Hindi: pat = re.compile('^(\w+)$', re.U) ... m = pat.search(l.decode('utf-8')) [example snipped] From this is assumed that the Hindi text contains punctuation or other characters that prevent the word match. This appears to be a bug in Python, as others have pointed out. Two points not covered so far: Well, not so much a bug as a lack of knowledge. (1) Instead of search() with pattern ^blahblah, use match() with pattern blahblah -- unless it has been fixed fairly recently, search() doesn't notice that the ^ means that it can give up when failure occurs at the first try; it keeps on trying futilely at the 2nd, 3rd, positions. (2) identifies words: \w+ (when fixed) matches a sequence of one or more characters that could appear *anywhere* in a word in any language (including computer languages). So it not only matches words, it also matches non-words like '123' and '0x000' and '0123_' and 10 viramas -- in other words, you may need to filter out false positives. Also, in some languages (e.g. Chinese) a word consists of one or more characters and there is typically no spacing between words; \w+ will identify whole clauses or sentences. This is down to the definition of word character. Should \w match Mc characters? Should \w match a single character or a non-combining character with any combining characters, ie just Lo or Lo, Lo+Mc, Lo+Mc+Mc, etc? -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Fri, 28 Nov 2008 15:22:58 -0800, r wrote: You know I said before that I hoped Guido never see's this thread...but i wonder if maybe he should see it...To see how far the great advocates have fallen. I am disappointed to say the least. I would not want to be in his shoes and see this! I am shocked! Shocked and dismayed and distraught and heart-borken by the vile, dastardly, spineless false-friend's who have BETRAYED Pyhton and STABBED ME IN TEH BACK like the cowardly FIENDS they ARE! Everybody except r on this thread is banned from using Ptyhon. No, EVERYBODY is banned from Pyhton. I'm going to stop all work on it immediatelty and delete it from my website. See what you have made me do, you RUBY LOVERS!!?!?!! -- Giudo -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
On Nov 27, 4:32 pm, Emanuele D'Arrigo [EMAIL PROTECTED] wrote: On Nov 27, 5:00 am, Steven D'Aprano [EMAIL PROTECTED] wrote: Refactor until your code is simple enough to unit-test effectively, then unit-test effectively. Ok, I've taken this wise suggestion on board and of course I found immediately ways to improve the method. -However- this generates another issue. I can fragment the code of the original method into one public method and a few private support methods. But this doesn't reduce the complexity of the testing because the number and complexity of the possible path stays more or less the same. The solution to this would be to test the individual methods separately, but is the only way to test private methods in python to make them (temporarily) non private? I guess ultimately this would only require the removal of the appropriate double-underscores followed by method testing and then adding the double-underscores back in place. There is no cleaner way, is there? Manu Your experiences are one of the reasons that writing the tests *first* can be so helpful. You think about the *behaviour* you want from your units and you test for that behaviour - *then* you write the code until the tests pass. This means that your code is testable, but which usually means simpler and better. By the way, to reduce the number of independent code paths you need to test you can use mocking. You only need to test the logic inside the methods you create (testing behaviour), and not every possible combination of paths. Michael Foord -- http://www.ironpythoninaction.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Dennis Lee Bieber wrote: On 29 Nov 2008 00:26:06 GMT, Giudo von Rossom [EMAIL PROTECTED] declaimed the following in comp.lang.python: Given three or four mis-spellings just in the from: header data... This doesn't even pass as an attempt at humor... It's not comparable to the Parrot Sketch. FYI, the header also contains: X-Read-This: This message is not from GvR the creator of Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 27, 9:45 pm, r [EMAIL PROTECTED] wrote: On Nov 27, 9:31 pm, alex23 [EMAIL PROTECTED] wrote: On Nov 28, 12:49 pm, r [EMAIL PROTECTED] wrote: Well... 3 for Ruby 1 for python. Not looking good so far. Any more votes? I don't see -any- of the responses in this thread voting for anything other than a more civil approach to your request. I am still flabbergasted by the solid resistance to promoting Python. I think the posters have mostly promoted Python rationally, and not promoted Python irrationally. Python is a good language, and Ruby is not a bad one. From what posters say, it's possible I'll end up using Ruby or Scheme in the future, especially if they're the better choice for the task, though not exclusively. It is sad that devotion is such a two-sided coin. If you devote your time, memory, and attention to a principle or idea, you exclude others. Rational devotion, though, unless a contradiction in terms, is merely allocation. Here of all places, NOT even one person(well Terry did kinda half agree with me =), wants to support Python. I am completely perplexed. I'm actually honored that the posters here reply to me sometimes. I'm just in my 20s so I shouldn't expect them to really. But one thing that comes with realism (as opposed to zealotry), is a solid examination of one's leader's advice, the alternatives, and other leaders' advice. And realism is good. You OWE your allegence to Python and the BDFL. I don't see how this follows from any of your premises. Can you start with concrete observations and draw the conclusion you want? I could see that taking this as a premise, you could conclude that one is devoted to Python and the BDFL. Your argument is: M: X reads c-l-python. C: X owes his allegiance to Python and the BDFL. You haven't made any observations much stronger than the major premise, M, and unless you're making stronger assumptions that it, you can't deduce C. In the general case, I take the meaning of 'owe' to participate in something like: M: X has paid Z to Y, not free. C: Y owes Z to X. Python and Guido have not paid me allegiance. So I don't owe them allegiance. If you intended to make an argument for follower-ship ('fellowship'?) and devotion, something like: M: Python is good. C: Yay for Python. Then you haven't even proven your major premise. Taking debt (what one owes) to also originate from a collective, i.e. the community, we also have: Lemma: The community has granted Z to Y, such that Z is good. ('The shirt on your back', 'your life', e.g.) Major: One can pay a community by paying a particular leader or emblem with relation T to the community. Minor: Y owes Z to the community. Conclusion: Y can pay by paying the leader. To conclude that '[the audience owes its] allegiance to Guido and Python', assuming that 'a community paid Z to Y' and 'Y paid Z to the community' are well-defined, you're missing: 1: Allegiance is good. 2: The community has given the audience good things. 3: Guido and Python have relation T to the community. They are yet to be shown. My assumption has been that you're using 'owe' in the sense of honor, not vendetta, which I leave. I think i know why nobody wants to get on-board. All the regulars can't have a n00b come in here and propose a grand Idea. Does it bother you that i am so ambitious, so FOR the advancement of Python! I think Python's best interests are better served by a fair and steady course, not impulse and hot decision. like to see python in more applications? Why do you even use Python. Do you feel you should give back or just take, take, take??? I have shared my feelings, let's hear yours. IIRC there have been some 'Why do you like Python?' threads every so often on the newsgroup. Hard to search for. On Nov 27, 11:28 pm, r [EMAIL PROTECTED] wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Man is mad. No question. Preach on. Not one vote for Python, not a care. Ask in a new thread, 'What do you like about Python?'. My favorites are functions' being first-class objects, and variable-length argument lists. +1 for Python. I think everyone here should look deep within their self and realize the damage that has been done today! We can't. Man is mad. (See above.) I hope Guido's eyes never see this thread, for he may lose all hope in humanity. Guido's just a man acting in what he perceives to be his own interests. He wrote some of and conceived Python. I doubt this thread would change many mens' opinions of humanity; optimism takes years and decades to crush. It would not be clearly best to hide it from his eyes, of course; it is not necessarily advisable to have hope in humanity. Why Guido? Do you hope that Barack Obama's eyes never see this thread? If only Guido because Python is his invention and we're not devoted to it, he may be better off for it than the alternatives, such as devotion. He can count on us to
Re: Using thread in an asyncronous application
On Nov 27, 9:03 am, Giampaolo Rodola' [EMAIL PROTECTED] wrote: Hi, I'm the maintainer of an asynchronous FTP server implementation based on asyncore. Some days ago I thought it would be interesting to add a class offering the possibility to run the asyncore loop into a thread so that a user can run the server without blocking the entire application. It could be useful, for example, in case someone wants to integrate a GUI. Since I'm not good with multi-threaded programming I'd like some opinions about the code I'm going to paste below. The FTPServer class that I inherited in my subclass is the dispatcher which listens on port 21 dispatching the incoming connection to an handler. The polling loop (FTPServer.serve_forever()) is wrapped in the run method. As you can see I acquire and release the lock (threading.Lock) every time I call the polling loop. My question is: is that really necessary? Should I expect some weird behavior by running the main loop into a thread like I did? Thanks in advance I found it hard to read through it. Do you have a smaller abstract example? -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting in to metaprogramming
On Nov 27, 9:28 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Aaron Brady [EMAIL PROTECTED] wrote: ... As you can see, the 'visit' method is mechanical for classes A and B. One might want to autogenerate those in some languages, but Python has introspection: class BaseAB: def visit( self, vis ): getattr( vis, 'visit_%s'% self.__class__.__name__ )( self ) And it's easier to modify the default behavior this way than in autogenerated code too. This is kind of the wrong way around - this is an example of OO jiggery pokery that will be difficult to do by generating the source code - are there things that can be done by generating the source code that cannot be done with OO? Yes, I was examining the special case of generating OO code. -- http://mail.python.org/mailman/listinfo/python-list
python.org coming back as unreachable in Dillo (IPv6 routing error?)
Though only semi-Python related, it impacts me because I (until recently) use Dillo at home for browsing docs.python.org. I'm trying to figure out if something network-related changed. Within the last week or two (time-frame is fuzzy), it seems that something changed and I now get Network unreachable errors. AFAIK, I haven't changed any settings on my local Debian box. The best of my google-fu has returned that this may have something to do with ipv6 routing. Firefox, Epiphany and Lynx all work fine (as does Safari on my Mac on the same internal home network). Likewise, browsing with Dillo to IPv4 address-space seems to work fine. Have any network changes taken place at python.org (particularly IPv6 or DNS related) recently? Some of the configuration details from my machine: [EMAIL PROTECTED]:~$ ip -f inet6 route fe80::/64 dev eth0 metric 256 expires 21252543sec mtu 1500 advmss 1440 hoplimit 4294967295 [EMAIL PROTECTED]:~$ /sbin/ifconfig -a eth0 | grep inet6 inet6 addr: fe80::2e0:b8ff:fe37:e150/64 Scope:Link [EMAIL PROTECTED]:~$ traceroute -6 docs.python.org traceroute to docs.python.org (2001:888:2000:d::a2), 30 hops max, 40 byte packets connect: Network is unreachable A traceroute -4 docs.python.org works fine. If output of other commands would be helpful, just ask as I don't know enough about IPv6 to troubleshoot the best solution to this. It may be possible to just disable IPv6, but it would be nice to allow IPv6 to remain enabled *and* configured correctly :) Thanks for any pointers you might be able to offer. -tkc -- http://mail.python.org/mailman/listinfo/python-list