Re: import hooks
En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson [EMAIL PROTECTED] escribió: What's the current way to install an import hook? I've got an embedded app that has a few scripts that I want to import each other, but that are not in sys.modules. I intentionally keep them out of sys.modules because their names will not be unique across the app. They will, however, be unique between scripts that I (do* want to see each other). Basically, I want to return a certain module from a name-based filter. I've already written a type in C with find_module and load_module, but it doesn't seem to work when I add the type to sys.path_hooks. I wrote a simple one that worked just fine from a pure script file run through python.exe. From that description alone I can't say what's happening; you should post some code. Also, if your importer isn't disk-based, perhaps using sys.meta_path is better. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode chr(150) en dash
C:\Python24\Lib\site-packages\MySQLdb\cursors.py, line 149, in execute query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2013' in position 52: ordinal not in range(256) Here it complains that it deals with the character U+2013, which is EN DASH; it complains that the encoding called latin-1 does not support that character. That is a fact - Latin-1 does not support EN DASH. When I type 'print chr(150)' into a python command line window I get a LATIN SMALL LETTER U WITH CIRCUMFLEX (http://www.fileformat.info/info/unicode/char/00fb/index.htm), That's because your console uses the code page 437: py chr(150).decode(cp437) u'\xfb' py unicodedata.name(_) 'LATIN SMALL LETTER U WITH CIRCUMFLEX' Code page 437, on your system, is the OEM code page. but when I do so into a IDLE window I get a hypen (chr(45). That's because IDLE uses the ANSI code page of your system, which is windows code page 1252. py chr(150).decode(windows-1252) u'\u2013' py unicodedata.name(_) 'EN DASH' You actually *don't* get the character U+002D, HYPHEN-MINUS, displayed - just a character that has, in your font, a glyph which looks similar to the glyph for HYPHEN-MINUS. However, HYPHEN-MINUS and EN DASH are different characters, and IDLE displays the latter, not the former. I tried searching en dash or even dash into the encodings folder of python Lib, but I couldn't find anything. You didn't ask a specific question, so I assume you are primarily after an explanation. HTH, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling Python 2.5.2 on AIX 5.2
What is Py_UNICODE_SIZE and why was it not defined? There are current questions I have. Py_UNICODE_SIZE is the number of bytes that a Py_UNICODE value should have in the interpreter. With --enable-unicode=ucs2, it should be 2. I cannot guess why it is not defined; check pyconfig.h to find out whether there is a definition. If not, look in your configure output for the line checking what type to use for unicode... and perhaps edit configure to print out additional messages around the place where it deals with Py_UNICODE. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Interesting timing issue I noticed
En Tue, 15 Apr 2008 23:24:01 -0300, Jonathan Shao [EMAIL PROTECTED] escribió: I've written up a stripped down version of the code. I apologize for the bad coding; I am in a bit of a hurry. First things first: I think you will gain inmensely using NumPy: http://numpy.scipy.org/ My timings were 62 and 47ms with your code; after I modified it slightly, 39 and 48ms (for the on3 and two functions). The changes: - instead of a list of lists, I used a defaultdict with (x,y) as the keys. That is, instead of matrix[x][y], I use matrix[x,y] - I converted all range - xrange Some lines showing the changes: # generates a zero matrix def generate_zero(): import collections matrix = collections.defaultdict(int) return matrix def back_diff_one(back_array, fore_array, box): diff_array = generate_zero() start = time.time() for x in xrange(sizeX): for y in xrange(borderY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange((sizeY - borderY), sizeY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange(borderY, (sizeY - borderY)): for x in xrange(borderX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for x in xrange((sizeX - borderX), sizeX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] Probably most of the time was spent on creating that many range objects in the inner loops. xrange objects are rather cheap, but you may try pre-creating them in advance before entering the loops. Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderXsizeX and borderYsizeY it may be better to swap the inner and outer loops above. (I assume the above code is just a simplified example, because all the loops do the same thing and cover the whole picture...) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
Hallöchen! Joe P. Cool writes: On 12 Apr., 03:34, baalbek [EMAIL PROTECTED] wrote: Delphi/Object Pascal simply sucks big time! I disagree. Delphi/Object Pascal with the VCL (Visual Component Library) is one of the most sophisticated IDEs ever, even better than Qt IMO. [...] I was somewhat disappointed with Delphi. I had used Turbo Pascal 15 years ago, which was one of the best IDEs at that time. It was really good. Now, we use Delphi in our institute for measurement and automation applications with GUI. It is probably possible to work equally well with Delphi, however, none of us have found the right IDE settings for this yet. Especially the behaviour after runtime errors seems to be unpredictable to us, and it is mostly sub-optimal. After having tested most of the dozens of checkboxes I could improve the situation slightly but not more. As far as the GUI composing is concerned, this is great with Delphi, especially for beginners. However, I still prefer the text-only programming in e.g. wxPython (and I'm equally fast with it) but this is a matter of taste. It's like the Word vs LaTeX or Gnuplot vs Origin thing I suppose. All of us were utterly disappointed with the new help system. This used to be a stronghold in Borland products but now, you get explanations à la Method 'foo': do foo with the object. Super. [...] Wrong. It does have a GUI builder - a very good one - and you can do point and click creation of GUIs (nothing wrong with that) but you can also do pure text editor code only programming with it. This shows another disadvantage of such IDEs, namely the editor question. The editor is a very personal piece of software, and I ended up using Emacs for a lot of my Delphi work. I don't consider myself a religious Emacs user -- I was really faster this way. However, this throws away a lot of the IDE's advantages. Thus, having everything in one system is only a good idea if you do Delpi-only. (did anyone mention waste of one's life?), and don't get me started on that primitive, complete utter waste of language called Object Pascal! I'm no big Pascal fan either but Object Pascal has a decent string library and better container literals than C/C++ and Java. The language itself is a matter of taste and I don't waste my time discussing it. Well, there also are objective issues with it that *can* be discussed. You mentioned the string library. This is what caused a lot of headaches here. There is a *lot* of doubled functionality there because there seems to be a transition in Delphi from old to new string functions. The difference between Wide Strings and AnsiStrings is still obscure to me. In .NET Delphi, this seems to have been cleaned up, but I haven't used it. Python/wxPython/Glade == real programmer's toolkit Object Pascal/Delphi == the hobbyist/beginner's toolkit I'm pretty sure that there are more professional software products written in Delphi than in wxPython. Certainly. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
subplot function in matplotlib
Does anyone know a workaround to plotting beyond 9 subplots in matplotlib? It would be nice to have 20 plots under the subplot function for example (poster). Cheers, Eli -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
Thanks for your well-formulated article Providing the Python infrastructure with my program doesn't apply since I am providing a program/library that is intended to be general. So it doesn't help. All that py3k does to me, it seems, is some extra work. To be frank, no innovation. Just changes, no progress. And yes, I am pd. Somebody compared it with MS stuff. Yes. Nothing personal, I appreciate Your comment. And all others. Sverker On Apr 15, 7:09 pm, Donn Cave [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Sverker Nilsson [EMAIL PROTECTED] wrote: No one forces me, but sooner or later they will want a Python 3.0 and then a 3.1 whatever. I don't want that fuzz. As about the C versions, I am not that worried. What's your point? I just like want to write a program that will stay working. And maybe I can go on with something else hopefully than just compatibility fixes. They take some work afterall. It seems hard with Python. Esp. 2 - 3 Welcome to the world of Python. There was a period of relative stability in the '90s, culminating with version 1.5.2, which just happens to be about the time that people started taking Python seriously. It turns out that this stability was only due to lack of resources, though. I think most of us are working under two imperatives here that really boil down to the same thing: we want a programming language that lets us focus on the goal of the program. On one hand, that means things like automatic memory management that are brought to us by newer languages (i.e., less than 30 years old.) On the other hand it means stability that allows our deployed code to go on working without constant intervention, which usually we find in languages that have become utterly boring and out of fashion (i.e., more than 30 years old.) It's hard to find a good compromise between these two, in an interpreted language. I don't know what the current party line may be on this matter, but some years back it was that you should consider the interpreter part of your application. That is, each application should deploy with its own dedicated Python interpreter, complete with libraries and everything. This naturally relieves some of the maintenance issues, since at least you can upgrade on your own schedule, but of course it has its costs too. Anyone who might be thinking about using Python for an application should seriously think about this. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Mailing list question
Hello, Just curious; can I post a basic programming question to this mailing list? Thanks in advance. Pete - Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.-- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter, event.widget, what do i get?
On 16 Apr, 01:45, [EMAIL PROTECTED] wrote: On 16 Apr, 00:24, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 15 Apr 2008 17:45:08 -0300, [EMAIL PROTECTED] escribió: when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget then the bitmap? can i get info about the bitmap then? like color of the pixel i clicked. if so, how? w.bind(Key, key) w.bind(Button-1, hmm) def hmm(event): return event.widget Why don't you try by yourself? You can use: print repr(something) -- Gabriel Genellina i get Tkinter.Canvas instance at 0x01B9B6E8 thing is i get that even though i click outside the image. and what can i do with this number anyway?- Nascondi testo tra virgolette - - Mostra testo tra virgolette - If your image is a canvas item (i.e. created with canvas create_image method), then you can use the method tag_bind to handle events specific of that item. In that case, the callback argument is a Tkinter.Event instance. Ciao - FB -- http://mail.python.org/mailman/listinfo/python-list
Re: Mailing list question
python newbie wrote: Hello, Just curious; can I post a basic programming question to this mailing list? You just did. :-) (Real answer: Yes. We're pretty newbie friendly here.) Gary Herron Thanks in advance. Pete Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20 -- http://mail.python.org/mailman/listinfo/python-list
python beginer
hi, can anyone tell me hw to start with webapplication scripting(e.g login page..etc) if anyone has soln for this or simple e.g that mention above please send me by and have a nice day -- http://mail.python.org/mailman/listinfo/python-list
Can't see variables declared as global in a function
Hi. I have a hundred lines of code in a module that declare some global variables inside a function so that those variables can be used by other functions. I want to import this module so that I can more easily debug by looking at the value of individual variables. But when I try to reach these variables, I get a warning that they are not defined. I am on an Intel Mac running Leopard 10.5.2, Python 2.5 Here is an example of some code that has the same problem: #!/usr/bin/env python global isglobal isglobal=200 def somefunc(): global from_somefunc from_somefunc=5 def anotherfunc(): return from_somefunc+30 So during debugging I want to look at the variable from_somefunc here is my terminal output. I start by looking at dir(), then run somefunc(), then run anotherfunc(), then I want to look at from_somefunc but I get a warning: Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type help, copyright, credits or license for more information. from test_vars import * dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] somefunc() anotherfunc() 35 isglobal 200 from_somefunc Traceback (most recent call last): File stdin, line 1, in module NameError: name 'from_somefunc' is not defined dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] Is there a way that I can view from_somefunc? Thanks, Jake -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
On 11 Apr, 20:19, Rune Strand [EMAIL PROTECTED] wrote: On Apr 10, 3:54 am, Chris Stewart [EMAIL PROTECTED] wrote: ... Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. GUI-programming in Python is a neanderthal experience. What one may love with console scripts is turned upside-down. Projects like Boa Constructor seemed to be a remedy, but is not developed. The Iron- Pythonistas has a very promising RAD GUI-tool in the IronPython - Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- Iron, only sorrow is left - unless you fancy creating GUI in a text- editor. Something I consider waste of life. If you refer to lack of GUI designer, every toolkit usable by python - barring Tkinter - has a GUI designer wich can be used: pygtk - Glade pywx - wxDesigner, rxced, ... pyqt - QDesigner, ... All can generate python code and/or generate files that can be used by python program to create the whole GUI with a few function calls (e.g. libglade ). If you refer to the lack of visual programming ala visualstudio or JBorland, you might be right, but I personally found that visual programming makes for very unmaintenable code, especially if you have to fix something and you don't have the IDE with you (and this has happened many times to me). Therefore I now prefer a clean separation between the GUI (described in someting like glade files or .xrc files) and my code. BTW, once learned to use the right layout managers, even building a GUI from scratch is not such a PITA, since you don't have to manually place each widget anymore, but only define the structure of packers and grids and then adjust borders and such with some -limited IME - experimentation. I know people that prefer this approach to any GUI builder, having developed their own little library to help reducing the boilerplate (and in Python you can do nice things with decorators ans such ... ). So maybe yes, in python you might not have the fancy world of visual programming, but neither are deprived of tools that make your work easier. Ciao - FB -- http://mail.python.org/mailman/listinfo/python-list
Re: webcam (usb) access under Ubuntu
On Apr 15, 11:45 pm, Berco Beute [EMAIL PROTECTED] wrote: I've tried reinstalling gstreamer (for windows): http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... but that didn't help. I get some complaints about 'libgstinterfaces' as well... To be more precise, when doing an 'import gst' Python shell pops up an error dialog saying: This application has failed to start because libgstinterfaces-0.10.dll was not found. 2B -- http://mail.python.org/mailman/listinfo/python-list
insert python script in current script
I was wondering is there any way to do this: I have written a class in python and __init__ goes like this: def __init__(self): self.name = 'jack' self.age = 50 import data now here there is data.py in the same directory and contents are like: self.address = 'your address' self.status = 'single' The problem is 'self' is giving some error here. I need to know if somehow I can do this. It's like inserting the script as it's part of the file itself. Cheers -- http://mail.python.org/mailman/listinfo/python-list
how tirbo gears work?
hi everone, 1:- i want to know, how to turbo gears code works. 2:- i want to write code on html with the help of turbo gears -- http://mail.python.org/mailman/listinfo/python-list
Python crashes consistently
Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. It appears that python crashes consistently during installation. I'm not sure if this is related to python itself, but I just thought I'd ask here, just in case anyone else was aware of this problem. I did have a few problems during the installation, so perhaps it might be related to them? Is there anyway to check that my installation of python is valid? I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error messages from the terminal and the mac pop-up window from the crash. Any help would be very much appreciated! Cheers, Pete. The terminal says: Error: Target org.macports.build returned: shell command cd /opt/ local/var/macports/build/ _opt_local_var_macports_sources_rsync.macports.org_release_ports_pytho n_py25-numpy/work/numpy-1.0.4 /opt/local/bin/python2.5 setup.py config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / opt/local/bin/g95 build returned error 139 Command output: Running from numpy source directory. Error: The following dependencies failed to build: py25-gtk py25- cairo py25-numpy Error: Status 1 encountered during processing. The crash window that pops up says: Date/Time: 2008-03-30 11:30:33.545 +1100 OS Version: 10.4.11 (Build 8S165) Report Version: 4 Command: python2.5 Path:/opt/local/bin/python2.5 Parent: sh [247] Version: ??? (???) PID:248 Thread: 0 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 Thread 0 Crashed: 0 _random.so0x00571334 random_seed + 644 (_randommodule.c:297) 1 _random.so0x0057131c random_seed + 620 (_randommodule.c:292) 2 libpython2.5.dylib0x002b1788 PyEval_EvalFrameEx + 17604 (ceval.c:3573) 3 libpython2.5.dylib0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 4 libpython2.5.dylib0x002b19ac PyEval_EvalFrameEx + 18152 (ceval.c:3669) 5 libpython2.5.dylib0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 6 libpython2.5.dylib0x0023969c function_call + 332 (funcobject.c:524) 7 libpython2.5.dylib0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 8 libpython2.5.dylib0x0021960c instancemethod_call + 764 (classobject.c:2520) 9 libpython2.5.dylib0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 10 libpython2.5.dylib0x0026e81c slot_tp_init + 72 (typeobject.c: 4944) 11 libpython2.5.dylib0x00273f88 type_call + 664 (typeobject.c:436) 12 libpython2.5.dylib0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 13 libpython2.5.dylib0x002b2fc8 PyEval_EvalFrameEx + 23812 (ceval.c:3786) 14 libpython2.5.dylib0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 15 libpython2.5.dylib0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) 16 libpython2.5.dylib0x002cbea0 PyImport_ExecCodeModuleEx + 292 (import.c:676) 17 libpython2.5.dylib0x002cc3a0 load_source_module + 1032 (import.c:960) 18 libpython2.5.dylib0x002cd564 import_submodule + 392 (import.c: 2401) 19 libpython2.5.dylib0x002cd7d4 load_next + 300 (import.c:2221) 20 libpython2.5.dylib0x002cde8c import_module_level + 624 (import.c:2002) 21 libpython2.5.dylib0x002cefc0 PyImport_ImportModuleLevel + 228 (import.c:2072) 22 libpython2.5.dylib0x002a68a0 builtin___import__ + 132 (bltinmodule.c:49) 23 libpython2.5.dylib0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 24 libpython2.5.dylib0x002abf38 PyEval_CallObjectWithKeywords + 276 (ceval.c:3443) 25 libpython2.5.dylib0x002b09cc PyEval_EvalFrameEx + 14088 (ceval.c:2067) 26 libpython2.5.dylib0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 27 libpython2.5.dylib0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) 28 libpython2.5.dylib0x002cbea0 PyImport_ExecCodeModuleEx + 292 (import.c:676) 29 libpython2.5.dylib0x002cc3a0 load_source_module + 1032 (import.c:960) 30 libpython2.5.dylib0x002cd564 import_submodule + 392 (import.c: 2401) 31 libpython2.5.dylib0x002cd828 load_next + 384 (import.c:2225) 32 libpython2.5.dylib0x002cde8c import_module_level + 624 (import.c:2002) 33 libpython2.5.dylib0x002cefc0 PyImport_ImportModuleLevel + 228 (import.c:2072) 34 libpython2.5.dylib0x002a68a0 builtin___import__ + 132 (bltinmodule.c:49) 35 libpython2.5.dylib0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 36 libpython2.5.dylib0x002abf38 PyEval_CallObjectWithKeywords + 276 (ceval.c:3443) 37 libpython2.5.dylib0x002b09cc PyEval_EvalFrameEx + 14088 (ceval.c:2067) 38 libpython2.5.dylib0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 39 libpython2.5.dylib
Re: How is GUI programming in Python?
So many gui toolkits, designers none of them makes up half of Delphi... unfortunately... i try to use Boa now, easiest of all others on linux/python, but it is far away from Delphi- delphi like... Why dont those toolkits/designers come together and build a single, powerfull ide ? 2008/4/16, [EMAIL PROTECTED] [EMAIL PROTECTED]: On 11 Apr, 20:19, Rune Strand [EMAIL PROTECTED] wrote: On Apr 10, 3:54 am, Chris Stewart [EMAIL PROTECTED] wrote: ... Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. GUI-programming in Python is a neanderthal experience. What one may love with console scripts is turned upside-down. Projects like Boa Constructor seemed to be a remedy, but is not developed. The Iron- Pythonistas has a very promising RAD GUI-tool in the IronPython - Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- Iron, only sorrow is left - unless you fancy creating GUI in a text- editor. Something I consider waste of life. If you refer to lack of GUI designer, every toolkit usable by python - barring Tkinter - has a GUI designer wich can be used: pygtk - Glade pywx - wxDesigner, rxced, ... pyqt - QDesigner, ... All can generate python code and/or generate files that can be used by python program to create the whole GUI with a few function calls (e.g. libglade ). If you refer to the lack of visual programming ala visualstudio or JBorland, you might be right, but I personally found that visual programming makes for very unmaintenable code, especially if you have to fix something and you don't have the IDE with you (and this has happened many times to me). Therefore I now prefer a clean separation between the GUI (described in someting like glade files or .xrc files) and my code. BTW, once learned to use the right layout managers, even building a GUI from scratch is not such a PITA, since you don't have to manually place each widget anymore, but only define the structure of packers and grids and then adjust borders and such with some -limited IME - experimentation. I know people that prefer this approach to any GUI builder, having developed their own little library to help reducing the boilerplate (and in Python you can do nice things with decorators ans such ... ). So maybe yes, in python you might not have the fancy world of visual programming, but neither are deprived of tools that make your work easier. Ciao - FB -- http://mail.python.org/mailman/listinfo/python-list -- İ.Bahattin Vidinli Elk-Elektronik Müh. --- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: [EMAIL PROTECTED] yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- http://mail.python.org/mailman/listinfo/python-list
how turbo geras code works
hi. actually i have developed one small project but now i want to develope a project with the help of html.. please help me out -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't see variables declared as global in a function
Jacob Davis wrote: Hi. I have a hundred lines of code in a module that declare some global variables inside a function so that those variables can be used by other functions. I want to import this module so that I can more easily debug by looking at the value of individual variables. But when I try to reach these variables, I get a warning that they are not defined. I am on an Intel Mac running Leopard 10.5.2, Python 2.5 Here is an example of some code that has the same problem: #!/usr/bin/env python global isglobal isglobal=200 def somefunc(): global from_somefunc from_somefunc=5 def anotherfunc(): return from_somefunc+30 So during debugging I want to look at the variable from_somefunc here is my terminal output. I start by looking at dir(), then run somefunc(), then run anotherfunc(), then I want to look at from_somefunc but I get a warning: Yuck, YUCK, YUCK! You are breaking *so* many good-programming-practices, I hardly know where to start. First off: A python global is not what you think. There are *no* program wide globals. There are only module wide globals. Also, the global isglobal is absolutely meaningless as anything declared there is a (module level) global by definition. SO... Your from_somefunc is a global variable in module test_vars, but you are trying to access it from your main module (the interactive session). The fact that you did from test_vars import * isn't going to fix this, because at the time you did the import, from_somefunc was not defined ad so was not imported by the *. You could just import test_vars, and then after calling your function test_vars.somefunc(), you would find that test_vars.from_somefunc would be defined. BUT... DON'T DO THAT! A better way: (It is still slightly dubious, but it is much more straightforward, and does not use the global statement.) Define your vars.py module: isglobal=200 # and nothing else And from your main program, import vars print vars.isglobal # will print 200 vars.from_somefunc = 5# will define and set a global in vars print vars.from_somefunc+30 # retrieves a global value from vars As I said above this is still slightly dubious. Better solutions would probably involve creating a class with each of your huindred variables as attributes of the class, or a class, each instance of which has the hundred variables, or ... whatever. To give you better advice, we'd have to know more about what problem you are trying to solve. If you really getters and setters (that's what we might call somefucn and anotherfunc) then you really should be using a class to contain all the hundred variables, and define getter/setter methods for them. Gary Herron Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type help, copyright, credits or license for more information. from test_vars import * dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] somefunc() anotherfunc() 35 isglobal 200 from_somefunc Traceback (most recent call last): File stdin, line 1, in module NameError: name 'from_somefunc' is not defined dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] Is there a way that I can view from_somefunc? Thanks, Jake -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Vellum 0.13: Simple Python Build Tool (usable now)
Hello Everyone, Insomnia has blessed me with the ability to make another release of Vellum for all to play with and try using. Features in this release: * The ability to make your own commands for your build specs in plain old Python as a Python module. * The docstring comments on your vellum commands become dynamic documentation for vellum via: vellum -C. * Lots of documentation, comments, cleaned up code, and a more complete test suite. * Importing other build specs as recipes and importing python modules are all unified and cleaned up. * Still only 620 lines of Python code which is damn amazing. DOCUMENTATION I wrote a bunch of documentation tonight, and will be doing a more complete manual soon: http://zedshaw.com/projects/vellum/ This page is cleaned up and lays out how to use vellum, write a build.vel file, and write your own commands. DOWNLOADS First, you should grab Zapps and install that: http://zedshaw.com/projects/zapps/ Then you can grab Vellum with easy_install: $ sudo easy_install vellum Or, get it from http://launchpad.net/vellum/ ANNOUNCMENTS You can subscribe to Vellum's RSS feed at: https://launchpad.net/vellum/+announcements FEEDBACK Let me know if you run into anything, and if you like it or hate it. Otherwise, enjoy the gear. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
To be frank, no innovation. Just changes, no progress. And yes, I am pd. anger leads to hate, hate leads to suffering Somebody compared it with MS stuff. Yes. It's not similar at all. MS will first force all your customers/users to upgrade to their newest software, at the same time suffocating the old software, and denying anyone the oportunity to maintain that old software (part because it's closed-source, part because MS will sue you if try anything close to that). -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Image handling - stupid question
I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at http://www.pythonware.com/products/pil/ and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. -- http://mail.python.org/mailman/listinfo/python-list
Re: how turbo geras code works
reetesh nigam wrote: hi. actually i have developed one small project but now i want to develope a project with the help of html.. please help me out Try and work through the turbogears.org website, especially the tutorial. Subscribe to the TG mailing list, and post *concrete* questions. Questions of the type I want to fly to the moon, please help me do it are hard to answer. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: webcam (usb) access under Ubuntu
Berco Beute wrote: On Apr 15, 11:45 pm, Berco Beute [EMAIL PROTECTED] wrote: I've tried reinstalling gstreamer (for windows): http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... but that didn't help. I get some complaints about 'libgstinterfaces' as well... To be more precise, when doing an 'import gst' Python shell pops up an error dialog saying: This application has failed to start because libgstinterfaces-0.10.dll was not found. I'm sorry, but I really can't comment on gst-installion issues - that all worked for me because of ubuntu. Maybe if you are now using windows, there are better options - but I'm a *nix-boy :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: insert python script in current script
On 16 avr, 09:42, Prashant [EMAIL PROTECTED] wrote: I was wondering is there any way to do this: I have written a class in python and __init__ goes like this: def __init__(self): self.name = 'jack' self.age = 50 import data now here there is data.py in the same directory and contents are like: self.address = 'your address' self.status = 'single' The problem is 'self' is giving some error here. I need to know if somehow I can do this. It's like inserting the script as it's part of the file itself. The purpose of import is to build a module object, which implies executing the module file but in a new context. If you simply want to execute some code in a file, you can try execfile(filename): In [243]: class A(object): .: def __init__(self): .: execfile(test.py) .: In [244]: a=A() In [245]: a.a Out[245]: 1 In [246]: open(test.py).read() Out[246]: 'self.a = 1\n' But do you really want to execute some arbitrary code or to initialize values with some kind of configuration file? Cheers -- http://mail.python.org/mailman/listinfo/python-list
Change the output font color
Hello, I am developing a program that searches for a word in a piece of text. I need to be able to change the color of the searched for word when found in the output text. Is that possible in Python? So, for example: The input text could be: I like banans and apples The output should be: I like banans and apples Thank you very much, Nora. ___ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/-- http://mail.python.org/mailman/listinfo/python-list
Re: Image handling - stupid question
Jumping Arne a écrit : I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at http://www.pythonware.com/products/pil/ and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned I doubt it is. or that it's very good and stable. My own experience is that it's indeed a pretty good and AFAICT stable library. -- http://mail.python.org/mailman/listinfo/python-list
Re: Image handling - stupid question
Jumping Arne wrote: I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at http://www.pythonware.com/products/pil/ and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. Certainly the latter. Diez -- http://mail.python.org/mailman/listinfo/python-list
Compilation problem of Python2.5.1 on AIX5.2 (with --enable-shared option)
Dear All, I encountered a problem when compiling Python2.5.1 as shared library on AIX5.2. Your help are greatly appreciated. In order to embed python into our product, we want to compile python as shared library. It works for Solaris and Linux. Unfortunately, It is for AIX and I could not find solution from Web. Could you help answer the following questions: Is it feasible to compile python2.5.1 as shared library for AIX5.2? or where can I find relevant documentation/info for this? So far, the only documents I have are the README and Misc/AIX-NOTES in the source distribution The step I tried to compile python as shared library is to follow README, section Building a shared libpython, which suggests to add --enable-shared during configuration. My problem is that with --enable-shared, the make step could not complete (the error message shows it tries to refer to -lpython2.5 in a wrong directory). Then if I refer it to the correct directory (which is compiled in source root), some warning messages show duplicated symbols. And finally I just remove -lpython2.5, the make could finish but the resulting python interpreter is a statically-linked binary. (The detail is shown below). The detail of my compilation 1. CC=cc_r ./configure --prefix=/src/new/python2/install --without-gcc --disable-ipv6 --enable-shared 2. make CC=cc_r OPT=-O -qmaxmem=4000 An error occurred when compiling python extensions. ... running build running build_ext INFO: Can't locate Tcl/Tk libs and/or headers building '_struct' extension creating build ... cc_r -DNDEBUG -O -I. -I/vega5/prod/src/new/python2/Python-2.5.1/./Include -I./In clude -I. -I/usr/local/include -I/vega5/prod/src/new/python2/Python-2.5.1/Includ e -I/vega5/prod/src/new/python2/Python-2.5.1 -c /vega5/prod/src/new/python2/Pyth on-2.5.1/Modules/_struct.c -o build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/ Python-2.5.1/Modules/_struct.o creating build/lib.aix-5.2-2.5 ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/pro d/src/new/python2/Python-2.5.1/Modules/_struct.o -L/usr/local/lib -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so ld: 0706-006 Cannot find or open library file: -l python2.5 ld:open(): No such file or directory *** WARNING: renaming _struct since importing it failed: No such file or directory error: No such file or directory make: The error code from the last command is 1. The highlighted command tries to locate the pyhton2.5 lib in /usr/local/lib, which obviously does not contain this lib. A library, libpython2.5.a, has already been compiled in the root build directory. 1) First, I try to add -L. to the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -L/usr/local/lib -L. -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so It could find but with a lot of warning messages like: ld: 0711-224 WARNING: Duplicate symbol: PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: .PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: ._Py_ReadyTypes ... 2) Second, I try to remove -L/usr/local/lib -lpython2.5 from the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -o build/lib.aix-5.2-2.5/_struct.so It complete without any warning message. As a result, I filter out all -lpython2.5 passed to ./Modules/ld_so_aix for the rest commands. In this way, the python interpreter was generated. However, it is a big executable and ldd python does not show it depends on any python shared library (It seems no shared python library generated). It has no difference from the one compiled without --enable-shared. Note that if the configuration is run without --enable-shared option, the corresponding commands will not contain -lpython2.5. Best regards, Yin Ming This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crashes consistently
which python ? from macports or macpython ? -- http://mail.python.org/mailman/listinfo/python-list
Re: webcam (usb) access under Ubuntu
On Apr 16, 12:19 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Maybe if you are now using windows, there are better options - but I'm a *nix-boy :) Diez So am I :), but the application I'm writing has to run on *that other operating system from the 90's*. I'm trying hard not to implement the application in C#/.Net, but I'm running out of open source alternatives. VideoCapture *almost* worked and now I'm stranded at the gstreamer road as well... 2B -- http://mail.python.org/mailman/listinfo/python-list
Re: Image handling - stupid question
On Apr 16, 12:21 pm, Jumping Arne [EMAIL PROTECTED] wrote: I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? Depends on your requirements, but it's certainly the first library I would check out. It offers lots of functionality, it is easy to use, well documented and rock solid. I looked at http://www.pythonware.com/products/pil/ and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. The latter (what else would you expect from /F? :) 2B -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crashes consistently
On 16/04/2008, at 9:38 PM, [EMAIL PROTECTED] wrote: which python ? from macports or macpython ? -- http://mail.python.org/mailman/listinfo/python-list MacPorts. It automatically downloaded 2.5.2. My original message is reproduced below. On 16/04/2008, at 5:50 PM, Pete Crite wrote: Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. It appears that python crashes consistently during installation. I'm not sure if this is related to python itself, but I just thought I'd ask here, just in case anyone else was aware of this problem. I did have a few problems during the installation, so perhaps it might be related to them? Is there anyway to check that my installation of python is valid? I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error messages from the terminal and the mac pop-up window from the crash. Any help would be very much appreciated! Cheers, Pete. The terminal says: Error: Target org.macports.build returned: shell command cd /opt/ local/var/macports/build/ _opt_local_var_macports_sources_rsync.macports.org_release_ports_pyth o n_py25-numpy/work/numpy-1.0.4 /opt/local/bin/python2.5 setup.py config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / opt/local/bin/g95 build returned error 139 Command output: Running from numpy source directory. Error: The following dependencies failed to build: py25-gtk py25- cairo py25-numpy Error: Status 1 encountered during processing. The crash window that pops up says: Date/Time: 2008-03-30 11:30:33.545 +1100 OS Version: 10.4.11 (Build 8S165) Report Version: 4 Command: python2.5 Path:/opt/local/bin/python2.5 Parent: sh [247] Version: ??? (???) PID:248 Thread: 0 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 Thread 0 Crashed: 0 _random.so 0x00571334 random_seed + 644 (_randommodule.c:297) 1 _random.so 0x0057131c random_seed + 620 (_randommodule.c:292) 2 libpython2.5.dylib 0x002b1788 PyEval_EvalFrameEx + 17604 (ceval.c:3573) 3 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 4 libpython2.5.dylib 0x002b19ac PyEval_EvalFrameEx + 18152 (ceval.c:3669) 5 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 6 libpython2.5.dylib 0x0023969c function_call + 332 (funcobject.c:524) 7 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 8 libpython2.5.dylib 0x0021960c instancemethod_call + 764 (classobject.c:2520) 9 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 10 libpython2.5.dylib 0x0026e81c slot_tp_init + 72 (typeobject.c: 4944) 11 libpython2.5.dylib 0x00273f88 type_call + 664 (typeobject.c:436) 12 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 13 libpython2.5.dylib 0x002b2fc8 PyEval_EvalFrameEx + 23812 (ceval.c:3786) 14 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 15 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) 16 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 (import.c:676) 17 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 (import.c:960) 18 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: 2401) 19 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) 20 libpython2.5.dylib 0x002cde8c import_module_level + 624 (import.c:2002) 21 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 (import.c:2072) 22 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 (bltinmodule.c:49) 23 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 24 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + 276 (ceval.c:3443) 25 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 (ceval.c:2067) 26 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 (ceval.c:2836) 27 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) 28 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 (import.c:676) 29 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 (import.c:960) 30 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: 2401) 31 libpython2.5.dylib 0x002cd828 load_next + 384 (import.c:2225) 32 libpython2.5.dylib 0x002cde8c import_module_level + 624 (import.c:2002) 33 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 (import.c:2072) 34 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 (bltinmodule.c:49) 35 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: 1862) 36 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + 276 (ceval.c:3443)
Re: Python crashes consistently
Pete Crite wrote: Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. You are using the wrong python version. Don't use MacPorts for this, because it will install a local, non-framework version of python - which will do you no good if you e.g. want to use any OSX-specific stuff. Use the official 2.5 framework version. And then install Numpy yourself (which is a bit annoying I admit, as you need to install e.g. a fortran compiler, but it is pretty well documented) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: import hooks
I am defining a simple finder/loader object and adding it to sys.meta_path like this: PyRun_SimpleString(import sys; import ousiainternal; sys.meta_path = [ousiainternal.OusiaImporter]); The following C code defines the loader object: static void MyImporter_dealloc(PyObject *self) { self-ob_type-tp_free(self); } static int MyImporter_init(MyImporter *self, PyObject *args, PyObject *kwds) { return 0; } static PyObject * MyImporter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { MyOutput *self; self = (MyOutput *)type-tp_alloc(type, 0); return (PyObject *)self; } /* Check whether we can satisfy the import of the module named by 'fullname'. Return self if we can, None if we can't. FYI: MyImporter imports modules from the local instrument. */ static PyObject * MyImporter_find_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *path = NULL; char *fullname; if (!PyArg_ParseTuple(args, s|O, fullname, path)) return NULL; mod = lookup_module_in_my_app(name); //borrowed ref if(mod == NULL); { Py_INCREF(Py_None); return Py_None; } Py_INCREF(self); return (PyObject *)self; } /* Load and return the module named by 'fullname'. */ static PyObject * MyImporter_load_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *mod = NULL; char *fullname; if (!PyArg_ParseTuple(args, s, fullname)) return NULL; mod = lookup_module_in_my_app(name); // borrowed ref if(mod) Py_INCREF(mod); return mod; } static PyMethodDef MyImporter_methods[] = { {find_module, MyImporter_find_module, METH_VARARGS, find a module}, {load_module, MyImporter_load_module, METH_VARARGS, load a module}, {NULL, NULL} /* sentinel */ }; static PyTypeObject MyImporterType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ Myinternal.MyImporter, /*tp_name*/ sizeof( MyImporter), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) MyImporter_dealloc,/*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ import hook for loading embedded modules, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ MyImporter_methods, /* tp_methods */ 0, //MyImporter_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc) MyImporter_init, /* tp_init */ 0, /* tp_alloc */ MyImporter_new, /* tp_new */ }; A simpler example that yields the same results would be this: static const char *importer_source = import sys\n class Importer:\n def __init__(self, path):\n print \'Import.__init__\', path\n def find_module(self, fullname, path=None):\n print self\n if fullname == \'bleh\':\n return self\n def load_module(self, fullname):\n print self\n if fullname == \'bleh\':\n return sys\n sys.meta_path.append(Importer)\n; PyRun_SimpleString(importer_source); For both examples none of the methods are called (I set breakpoints for the C functions) but a statement like import os or PyImport_ImportModule(traceback) don't work. Thanks for your help On Wed, Apr 16, 2008 at 12:02 AM, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson [EMAIL PROTECTED] escribió: What's the current way to install an import hook? I've got an embedded app that has a few scripts that I want to import each other, but that are not in sys.modules. I intentionally keep them out of sys.modules because their names will not be unique across the app. They will, however, be unique between scripts that I (do* want to see each other). Basically, I want to return a certain module from a name-based
taylor swift in concert
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift height
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift hair
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift drew
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift concert tickets
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift concert schedule
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift concert dates
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift come in with the rain
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift birthday
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift biography
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift bio
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift age
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift a place in this world lyrics
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
taylor swift a place in this world
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
songs by taylor swift
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
Re: webcam (usb) access under Ubuntu
Berco Beute wrote: On Apr 16, 12:19 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Maybe if you are now using windows, there are better options - but I'm a *nix-boy :) Diez So am I :), but the application I'm writing has to run on *that other operating system from the 90's*. I'm trying hard not to implement the application in C#/.Net, but I'm running out of open source alternatives. VideoCapture *almost* worked and now I'm stranded at the gstreamer road as well... How's that saying? If your in Rom, do as the Romans do. Don't fight Windows. And take IronPython to mitigate the pain of using it :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
Who cares? Everyone does their GUI in a browser these days - keep up, Dad. What we need is a pythonic front end. /troll -- http://mail.python.org/mailman/listinfo/python-list
Re: webcam (usb) access under Ubuntu
Berco Beute wrote: I've been trying to access my webcam using Python, but I failed miserably. The camera works fine under Ubuntu (using camora and skype), but I am unable to get WebCamSpy or libfg to access my webcam. First I tried webcamspy (http://webcamspy.sourceforge.net/). That requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy results in: Exception exceptions.AttributeError: Parallel instance has no attribute '_fd' in bound method Parallel.__del__ of parallel.parallelppdev.Parallel instance at 0x83326ac ignored This seems to come from importing I2C. The application window opens, but there's an error message: NO VIDEO SOURCE FOUND Next I tried libfg (http://antonym.org/libfg). I built it, made the Python bindings and installed it. Unfortunately the following: import fg grabber = fg.Grabber() results in: fg_open(): open video device failed: No such file or directory Since the camera works fine in Ubuntu itself my guess is that the problem is with the python libraries (or even likelier, my usage of them). Is there anybody here that was successful in accessing their webcam on linux using Python? Else I have to reside to Windows and VideoCapture (which relies on the win32 api and thus is Windows-only), something I'd rather not do. Thanks for any help, 2B === I am uUsing: WebCam: Logitech QuickCam Pro 400 Ubuntu Python 2.5 Some time ago I was playing with writing a webcam server under Linux using V4L - I found this bit of code which may help (it works for me). Obviously it needs X running to work and the associated libs installed. Note this is not my code but it was a good starting point for me to work from. I can't find a link to the original article but credit to the author. import pygame import Image from pygame.locals import * import sys import opencv #this is important for capturing/displaying images from opencv import highgui camera = highgui.cvCreateCameraCapture(0) def get_image(): im = highgui.cvQueryFrame(camera) #convert Ipl image to PIL image return opencv.adaptors.Ipl2PIL(im) fps = 30.0 pygame.init() window = pygame.display.set_mode((320,240)) pygame.display.set_caption(WebCam Demo) screen = pygame.display.get_surface() while True: events = pygame.event.get() for event in events: if event.type == QUIT or event.type == KEYDOWN: sys.exit(0) im = get_image() pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode) screen.blit(pg_img, (0,0)) pygame.display.flip() pygame.time.delay(int(1000 * 1.0/fps)) Best of Luck Bgeddy -- http://mail.python.org/mailman/listinfo/python-list
Re: Preferred method for Assignment by value
On Apr 15, 3:51 pm, sturlamolden [EMAIL PROTECTED] wrote: On Apr 15, 8:19 pm, [EMAIL PROTECTED] wrote: Coming from VBA I have a tendency to think of everything as an array... Coding to much in Visual Basic, like Fortran 77, is bad for your mind. The distinction you're looking for is: VB: set a= collection a= collection Every assignment is a 'set'. -- http://mail.python.org/mailman/listinfo/python-list
Re: subplot function in matplotlib
eli wrote: Does anyone know a workaround to plotting beyond 9 subplots in matplotlib? It would be nice to have 20 plots under the subplot function for example (poster). Is there such a limitation? I thought that was only for the condensed sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crashes consistently
I agree, use the official python http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg I'm also using OS X 10.4.11 and I have no problem for installing numpy http://www.scipy.org/Installing_SciPy/Mac_OS_X or you can download Pre-built binaries from http://pythonmac.org/packages/py25-fat/index.html or http://trichech.us/?page_id=5 -- http://mail.python.org/mailman/listinfo/python-list
Learning Tkinter
I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc was published in 1999 and I wonder if there is a more recent version. I've googled a bit and this version is the one I keep finding. I like how this document is organized and also how it provides the code with visuals of what should appear on the screen. If there are other docs I should read, please let me know. Second, I am trying to work through a couple of the examples and make some small tweaks as I go to see how new things can work. In the first case, I have copied the code in the book to see how the menu works and are created as in the example menu.py below. I see how menus are created and how the command option is used to call the function callback. # menu.py from Tkinter import * def callback(): print called the callback! root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label=File, menu=filemenu) filemenu.add_command(label=New, command=harold) filemenu.add_command(label=Open..., command=callback) filemenu.add_separator() filemenu.add_command(label=Exit, command=callback) helpmenu = Menu(menu) menu.add_cascade(label=Help, menu=helpmenu) helpmenu.add_command(label=About..., command=callback) mainloop() However, I now want to incorporate a basic python program with a command. Say I have a simple program called test.py # test.py filename = raw_input(Please enter the file you want to open: ) new_file = raw_input(Save the output file as: ) f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print f, x[0],':', x[1] f.close() To make this example complete assume I have a text file like this # data.txt 1 one 2 two 3 three 4 four So, the user currently just follows directions on the screen, enters the file names, and I get what I want. I'd like to try experimenting with gui programming to see if the python programs I have written can be made even more user friendly. I currently use py2exe to create executables so that others in my organization can use these programs. In that spirit, say I want to have a menu option that allows the user to search their computer for this file, execute the python code and then save the result as a user-defined filename. So, I guess my questions are how do I associate the portion of code in menu.py filemenu.add_command(label=Open..., command=callback) with an operation that gives the user the ability to search the drives on their machine and then once they do let python execute the code in test.py? Many thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crashes consistently
Thanks for the quick reply, Just to clarify (sorry, I'm a bit of a command line newbie): Do you mean to install Python from the .dmg - i.e. into /usr/local/ bin? And then to install Numpy directly as well (manually, from source), then continue with the MacPorts installation of Gnumeric (i.e. into /opt/local/)? Thanks, Pete. On 16/04/2008, at 9:56 PM, Diez B. Roggisch wrote: Pete Crite wrote: Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. You are using the wrong python version. Don't use MacPorts for this, because it will install a local, non-framework version of python - which will do you no good if you e.g. want to use any OSX-specific stuff. Use the official 2.5 framework version. And then install Numpy yourself (which is a bit annoying I admit, as you need to install e.g. a fortran compiler, but it is pretty well documented) Diez -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
is file open in system ? - other than lsof
is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. -- İ.Bahattin Vidinli Elk-Elektronik Müh. --- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: [EMAIL PROTECTED] yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
On Apr 15, 12:30 am, Sverker Nilsson [EMAIL PROTECTED] wrote: No one forces me, but sooner or later they will want a Python 3.0 and then a 3.1 whatever. I don't want that fuzz. As about the C versions, I am not that worried. What's your point? I just like want to write a program that will stay working. Maybe I'll see the wisdom of py 3k eventually, if I don't die first, but I have to agree with Sverker's general comments. Just yesterday I had a conversation with someone who thinks maybe Ruby is better than Python -- the one really good argument Python has against nearly all contenders is all the stuff out there you can get so easily -- all the stuff that py3k will break -- most of which won't get ported -- and if it does can we be sure it will be tested properly? No, probably you will end up beta testing someone's quick port of what used to be rock solid code... This was quite rightly pointed out to me, and I had to agree that it was a pretty good point. In my opinion python's adherence to backwards compatibility has been a bit mythological anyway -- many new python versions have broken my old code for no good reason. This is an irritant when you have thousands of users out there who suddenly drop your code, blame you and python, and move on to use something else. Honestly, how hard would it have been to provide standard backwards support for the old regex module as a standard module which simply translated one regex string format to another, for example? I don't get it. It ain't broke. Don't fix it. At long last Python has a full head of steam and py3k is just confusing everyone. But I've been wrong before (twice). I also once thought generators were a mistake :) (but I still think full stackless would be much better, which python seems to be very slowly moving towards.) -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=nonsense -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe, program has stoped working!?
On 14 Apr, 14:11, John Machin [EMAIL PROTECTED] wrote: On Apr 14, 7:24 pm, [EMAIL PROTECTED] wrote: Is it a console program or a gui program? GUI What happens when you run it without py2exe? it works perfectly, both from within python and launching from windows Have you searched for has stopped working in (a) your source code yes no such message there (b) the py2exe source code? no, will do but doubt thats the problem Have you managed to get any py2exe-created program to run properly? no Well, perhaps you might like to look in the samples directory of the py2exe distribution and choose a simple example and try that. By the way, popup is what you get in a web browser. What did this popup look like: a panel from your GUI software? A Windows message box? Did it have a title across the top? What was the exact text in the popup/panel/box? Were there any options other than to close the window? Which version of Python? Which Windows, what service pack? What GUI, what version? Care to divulge the contents of your setup.py? Apart from your GUI, what 3rd party packages/modules are you importing? its a windows message as others have said. only option to close the window. 2.5python windows vista tkinter GUI im importing tkinter and from future import division -- http://mail.python.org/mailman/listinfo/python-list
Serving binary content (images, etc) using BasteHTTPServer
I'm writing a simple web server in python using the BaseHTTPServer library. I can serve text content (ie html pages) with ease, but im running into troubles when i try to serve images. The image gets corrupted in transit and when I manually download the image from the website and look at it using a hex editor it appears that the first 60 (or first 3C in hex if it makes a helps) characters are missing. My code looks like this: def do_GET(s): # code that determines that yes this is an image s.send_response(200) s.send_header(Content-type, image/jpeg) s.end_headers fileObj = open(1.jpg,rb) # file is harcoded until i get images being served correctly image = fileObj.read() s.wfile.write(image) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crashes consistently
Just to clarify (sorry, I'm a bit of a command line newbie): Do you mean to install Python from the .dmg - i.e. into /usr/local/ bin? Yes and No. Use the DMG - but it will install Python under /Library/Frameworks/Python.framework/... And then to install Numpy directly as well (manually, from source), then continue with the MacPorts installation of Gnumeric (i.e. into /opt/local/)? No MacPorts. The problem is that these will rely on their python available - which seems not to work properly. I had no problems installing e.g. matplotlib which requires Numpy. do everything by hand. I agree that MacPorts would be nice - but obviously you hit a road-block there. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: String Literal to Blob
The _keywords_ are _essential_. It is currently published at the end of a long and exhaustive thread. This is not good. It should be republished correctly, and with the kw people will use to search. For example, I would never have thought to search for a photo album. Victor On Tue, Apr 15, 2008 at 10:55 AM, J. Cliff Dyer [EMAIL PROTECTED] wrote: It is published. On comp.lang.python. Google groups has it, so google (search) will find it. Cheers, Cliff On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote: Gabriel; That's really nice code you wrote. I will rewrite my app accordingly, after I catch a breather! Say, would you please publish this somewhere? Why should I write a howto on this and credit you when all I would be doing is republishing (plagerizing) what you published? Please insert these keywords: mysql, image, python, mysqldb and maybe picture and photo (you already have photo). Call it something like MySQL/Python Tutorial for Posting and Retrieving Images / Photo Album. I ask you to do this because I scoured google looking for just what you've provided and it simply isn't out there. At all. There are nice howto's in php. Please post this for those interested in python, somewhere like the cookbook. Thanks, Victor On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden [EMAIL PROTECTED] escribió: Victor Subervi wrote: Thanks to all, especially Gabriel. [...] Steve, thank you for all your help, but do overcome your temper :)) I'm glad the penny finally dropped. You may have been treated to a modest display of exasperation, but please be assured you have not yet seen anything remotely like temper from me :-) And I'm glad to see that you finally got it, too! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list
Re: Serving binary content (images, etc) using BasteHTTPServer
[EMAIL PROTECTED] wrote: I'm writing a simple web server in python using the BaseHTTPServer library. I can serve text content (ie html pages) with ease, but im running into troubles when i try to serve images. The image gets corrupted in transit and when I manually download the image from the website and look at it using a hex editor it appears that the first 60 (or first 3C in hex if it makes a helps) characters are missing. My code looks like this: def do_GET(s): # code that determines that yes this is an image s.send_response(200) s.send_header(Content-type, image/jpeg) s.end_headers fileObj = open(1.jpg,rb) # file is harcoded until i get images being served correctly image = fileObj.read() s.wfile.write(image) Don't you miss a Content-Length header? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Tkinter
You might want to look at these: Thinking in Tkinter http://www.ferg.org/thinking_in_tkinter/index.html Easygui http://www.ferg.org/easygui/index.html -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
I'd like to build a really simple GUI app that will work across Mac, Windows, and Linux. You might look at easygui http://www.ferg.org/easygui/index.html That will give you something simple and workable. Then you can go on to more advanced stuff at your leisure. -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
Aaron Watters wrote: stuff out there you can get so easily -- all the stuff that py3k will break -- most of which won't get ported -- and if it does can we be sure it will be tested properly? No, probably you will end up beta testing someone's quick port of what used to be rock solid code... This was quite rightly pointed out to me, and I had to agree that it was a pretty good point. Do you mean Ruby's track in providing backward compatibility is better than Python's? Googling for that a bit, I would reckon otherwise. -- http://mail.python.org/mailman/listinfo/python-list
Re: is file open in system ? - other than lsof
On 2008-04-16, bvidinli [EMAIL PROTECTED] wrote: is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. This is not a Python question but an OS question. (Python is not going to deliver what the OS doesn't provide). Please first find an alternative way at OS level (ie ask this question at an appropiate OS news group). Once you have found that, you can think about Python support for that alternative. Sincerely, Albert -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Tkinter
On Apr 16, 7:46 am, Doran, Harold [EMAIL PROTECTED] wrote: I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc was published in 1999 and I wonder if there is a more recent version. I've googled a bit and this version is the one I keep finding. I like how this document is organized and also how it provides the code with visuals of what should appear on the screen. If there are other docs I should read, please let me know. There's some good Tkinter coverage in Lutz's tome, Programming Python 3rd Ed. and it also shows how to do a search for a file across your file system, iirc. Second, I am trying to work through a couple of the examples and make some small tweaks as I go to see how new things can work. In the first case, I have copied the code in the book to see how the menu works and are created as in the example menu.py below. I see how menus are created and how the command option is used to call the function callback. # menu.py from Tkinter import * def callback(): print called the callback! root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label=File, menu=filemenu) filemenu.add_command(label=New, command=harold) filemenu.add_command(label=Open..., command=callback) filemenu.add_separator() filemenu.add_command(label=Exit, command=callback) helpmenu = Menu(menu) menu.add_cascade(label=Help, menu=helpmenu) helpmenu.add_command(label=About..., command=callback) mainloop() However, I now want to incorporate a basic python program with a command. Say I have a simple program called test.py # test.py filename = raw_input(Please enter the file you want to open: ) new_file = raw_input(Save the output file as: ) f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print f, x[0],':', x[1] f.close() To make this example complete assume I have a text file like this # data.txt 1 one 2 two 3 three 4 four So, the user currently just follows directions on the screen, enters the file names, and I get what I want. I'd like to try experimenting with gui programming to see if the python programs I have written can be made even more user friendly. I currently use py2exe to create executables so that others in my organization can use these programs. In that spirit, say I want to have a menu option that allows the user to search their computer for this file, execute the python code and then save the result as a user-defined filename. So, I guess my questions are how do I associate the portion of code in menu.py filemenu.add_command(label=Open..., command=callback) with an operation that gives the user the ability to search the drives on their machine and then once they do let python execute the code in test.py? Many thanks, It sounds like you want to run code from within your own program. This would require embedding a Python interpreter, which is quite possible, although I do not know how to do it. I would suggest that you just use a Tkinter-created frame/window that allows the user to enter the information into text controls rather than a command line type interface. You could even use a Browse button and let the user search for the file using a file dialog. Check out the sample code for such a beast in the recipe linked below: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 If you do want to go the embedding route, you'll want to read the following information linked below: http://docs.python.org/api/embedding.html http://www.python.org/doc/ext/embedding.html http://www.ragestorm.net/tutorial?id=21 http://www.codeproject.com/KB/cpp/embedpython_1.aspx Hope that gets you going. Mike -- http://mail.python.org/mailman/listinfo/python-list
vary number of loops
Hi everyone, I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? For example, for n=2, I want the function to look something like: def foo(2) generate 2 sets of elements A, B # mix elements by: for a_elt in A for b_elt in B form all combinations of them If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. Any help is greatly appreciated, nullgraph -- http://mail.python.org/mailman/listinfo/python-list
Re: Image handling - stupid question
On Wed, 16 Apr 2008 12:21:13 +0200, Jumping Arne wrote (in article [EMAIL PROTECTED]): I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at http://www.pythonware.com/products/pil/ and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. Sounds like PIL is a safe option, thanks. -- http://mail.python.org/mailman/listinfo/python-list
Interesting timing issue I noticed
*Gabriel Genellina* gagsl-py2 at yahoo.com.ar python-list%40python.org?Subject=Interesting%20timing%20issue%20I%20noticedIn-Reply-To= *Wed Apr 16 08:44:10 CEST 2008* Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderXsizeX and borderYsizeY it may be better to swap the inner and outer loops above. Thank you for the tip on xrange. Even if I swap the inner and outer loops, I would still be doing the same number of computations, am I right (since I still need to go through the same number of elements)? I'm not seeing how a loop swap would lead to fewer computations, since I still need to calculate the outer rim of elements in the array (defined by borderX and borderY). ~ Jon -- Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return. ~ T.H.White -- http://mail.python.org/mailman/listinfo/python-list
Re: vary number of loops
On Wed, 16 Apr 2008 06:31:04 -0700, nullgraph wrote: I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? That has nothing to do with ``lambda``. If you don't think Hey, that's smells like a job for a function. then it's no job for ``lambda``, which is just a way to define a function without automatically binding it to a name like ``def`` does. One solution to your problem is recursion. Untested: def foo(xs): if xs: for elt in xs[0]: for ys in foo(xs[1:]): yield [elt] + ys else: yield [] Called as ``foo([A, B])``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: vary number of loops
I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? I'm not sure lambda is the tool to use here. Doable, perhaps, but improbable in my book. For example, for n=2, I want the function to look something like: def foo(2) generate 2 sets of elements A, B # mix elements by: for a_elt in A for b_elt in B form all combinations of them If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. You might be ineterested in this thread: http://mail.python.org/pipermail/python-list/2008-January/473650.html where various solutions were proposed and their various merits evaluated. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Python module for reading FilePro files?
Does anyone know of a Python package or module to read data files from the venerable old Filepro crossplatform database/IDE? -- http://mail.python.org/mailman/listinfo/python-list
Re: vary number of loops
On 16 avr, 15:31, [EMAIL PROTECTED] wrote: Hi everyone, I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? For example, for n=2, I want the function to look something like: def foo(2) generate 2 sets of elements A, B # mix elements by: for a_elt in A for b_elt in B form all combinations of them If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. Any help is greatly appreciated, nullgraph You can try recursion in a more classic manner: In [283]: def foo(n): .: def bar(n): .: my_elts = xrange(2) .: if n=0: .: raise StopIteration .: elif n=1: .: for elt in my_elts: .: yield (elt,) .: else: .: for elt in my_elts: .: for o_elt in bar(n-1): .: yield (elt,)+o_elt .: for elt in bar(n): .: print elt .: In [284]: foo(2) (0, 0) (0, 1) (1, 0) (1, 1) In [285]: foo(3) (0, 0, 0) (0, 0, 1) (0, 1, 0) (0, 1, 1) (1, 0, 0) (1, 0, 1) (1, 1, 0) (1, 1, 1) In this case, I have an inner function to generate the whole set of elements and then an outer loop to process them. Note that you can have the generation of my_elts depend on rank n of recursion (that is the index of the set in your list). -- http://mail.python.org/mailman/listinfo/python-list
Re: is file open in system ? - other than lsof
On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: On 2008-04-16, bvidinli [EMAIL PROTECTED] wrote: is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. This is not a Python question but an OS question. (Python is not going to deliver what the OS doesn't provide). Please first find an alternative way at OS level (ie ask this question at an appropiate OS news group). Once you have found that, you can think about Python support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the thousands of files individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree (man proc), as this is where lsof gets its information from on Linux machines. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: is file open in system ? - other than lsof
On Wed, Apr 16, 2008 at 10:00 AM, Chris McAloney [EMAIL PROTECTED] wrote: On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: On 2008-04-16, bvidinli [EMAIL PROTECTED] wrote: is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. This is not a Python question but an OS question. (Python is not going to deliver what the OS doesn't provide). Please first find an alternative way at OS level (ie ask this question at an appropiate OS news group). Once you have found that, you can think about Python support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the thousands of files individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree (man proc), as this is where lsof gets its information from on Linux machines. Chris -- I know this is a python list, but if speed is such an issue you might want to consider writing in C/C++. Both would be considerably faster than python. http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: vary number of loops
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Tim Chase Sent: Wednesday, April 16, 2008 9:53 AM To: [EMAIL PROTECTED] Cc: python-list@python.org Subject: Re: vary number of loops If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. You might be ineterested in this thread: http://mail.python.org/pipermail/python-list/2008-January/473650.html where various solutions were proposed and their various merits evaluated. I second that. The thread compared building loops on the fly, building comprehensions nested to arbitrarily levels, recursion (slw!), a slick cookbook recipe using iterators, etc. and provided timings for each method. Definitely worth bookmarking. * The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625 -- http://mail.python.org/mailman/listinfo/python-list
Finally had to plonk google gorups.
This morning almost half of c.l.p was spam. In order to try to not tar both the benign google group users and the malignant ones with the same brush, I've been trying to kill usenet spam with subject patterns. But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. AFAICT, if you're a google groups user your posts are not being seen by many/most experienced (read non-google-group) users. This is mainly the fault of google who has refused to do anything to stem the flood of span that's being sent via Google Groups. -- Grant Edwards grante Yow! I would like to at urinate in an OVULAR, visi.comporcelain pool -- -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
On Apr 16, 9:16 am, Marco Mariani [EMAIL PROTECTED] wrote: Do you mean Ruby's track in providing backward compatibility is better than Python's? Googling for that a bit, I would reckon otherwise. I can't comment on that. Ruby is a lot younger -- I'd expect it to still be stabilizing a bit. What I'm saying is that, for example, there are a lot of cool tools out there for using Python to manipulate postscript and latex and such. Most of those tools require no maintenance, and the authors are not paying any attention to them, and they aren't interested in messing with them anymore. My guess is that there are few such tools for Ruby. However, I wouldn't be too surprised if porting them to Ruby and testing them properly is not much more difficult than porting them to py3k and testing them properly... Especially since the basic treatment of strings is totally different in py3k, it seems. Maybe there is a secret desire in the Python community to remain a fringe minority underdog forever? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=reap+dead+child -- http://mail.python.org/mailman/listinfo/python-list
RotatingFileHandler - ShouldRollover error
I am using the RotatingFileHandler logger with Python 2.5 on Windows and I am getting an error on the rollover. When the log file gets close to the size where it needs to rollover, I start getting the following error for every log message. Does anyone have a solution to this problem? Traceback (most recent call last): File C:\Python25\Lib\logging\handlers.py, line 73, in emit if self.shouldRollover(record): File C:\Python25\Lib\logging\handlers.py, line 147, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file My configuration file is setup as such: [handler_file_detailed] class:handlers.RotatingFileHandler level:DEBUG formatter:detailed mode=a maxsize=400 backcount=5 args:('python.log','a',400,5) Thanks, Todd -- http://mail.python.org/mailman/listinfo/python-list
RE:Get oldest folder
Hi Tim, Thanks very much for your help! I'm still just learning Python and really appreciate seeing other peoples examples on how they work with Python. Thanks again for taking the time to share this. Jay I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. Is there a simple way to go about this? I'd like it to run on both OS X and Windows XP. I found this example but was curious if there's a better way to do this? Better: I don't know. Alternative, certainly: code import os, glob PATH = c:/python25/lib/site-packages print min ((f for f in glob.glob (os.path.join (PATH, *)) if os.path.isdir (f)), key=os.path.getctime) /code TJG -- http://mail.python.org/mailman/listinfo/python-list
matplotlib psd
Kudos to matplotlib in python, it's a real slick package. But I'd like to do several power spectrum density calls [ psd() ] and control the color of each. I don't see any obvious option for this. Any hints? -- http://mail.python.org/mailman/listinfo/python-list
Embedding Python in my C++ application
I am working on embedding Python 2.5 in my C++ application, and I have a few questions: 1) My application is multi-threaded; what problems should I be aware of if I create a separate interpreter in each working thread? The documentation is a bit vague (or perhaps I haven't found the right place). Calls into my application are already thread-safe. 2) Rather than implementing my own editor in C++, I would like to be able to use existing tools to some degree, such as a python editor, interactive interpreter and perhaps even debugger, without impacting the main (GUI) thread of my application. Is there an example application, or any hints from someone who has done this? 3) Because my program links statically with the C runtime (on Windows), and Python links with it dynamically, there are some things that cannot be passed back and forth, such as C file handles and FILE pointers. Is anyone aware of other issues this may cause? I will greatly appreciate help with these questions, or advice on embedding Python in general! Thanks, Sev -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
On Apr 16, 9:19 am, Grant Edwards [EMAIL PROTECTED] wrote: This morning almost half of c.l.p was spam. In order to try to not tar both the benign google group users and the malignant ones with the same brush, I've been trying to kill usenet spam with subject patterns. But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. AFAICT, if you're a google groups user your posts are not being seen by many/most experienced (read non-google-group) users. This is mainly the fault of google who has refused to do anything to stem the flood of span that's being sent via Google Groups. -- Grant Edwards grante Yow! I would like to at urinate in an OVULAR, visi.comporcelain pool -- Yeah, I noticed that Google Groups has really sucked this week. I'm using the Google Groups Killfile for Greasemonkey now and it helps a lot. I like Google, but my loyalty only goes to far. This is a complete lack of customer service. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: subplot function in matplotlib
On Apr 16, 8:27 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: eli wrote: Does anyone know a workaround to plotting beyond 9 subplots in matplotlib? It would be nice to have 20 plots under the subplot function for example (poster). Is there such a limitation? I thought that was only for the condensed sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) Diez Didn't see that part. Now it's fixed. Thanks! Eli -- http://mail.python.org/mailman/listinfo/python-list
Re: Serving binary content (images, etc) using BasteHTTPServer
[EMAIL PROTECTED] wrote in message news:556871d3-1fea-40f2-9cc6- s.end_headers A bare method name (without parentheses) won't get called. -- http://mail.python.org/mailman/listinfo/python-list
Default parameter for a method
I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def meth2(self, arg=meth1()): # The default `arg' should would take the return value of meth1() print 'arg is', arg This obviously doesn't work. I know I could do ... def meth2(self, arg=None): if arg is None: arg = self.meth1() but I'm looking for a more straightforward way. -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k s***s
On 16 abr, 09:56, Aaron Watters [EMAIL PROTECTED] wrote: In my opinion python's adherence to backwards compatibility has been a bit mythological anyway -- many new python versions have broken my old code for no good reason. This is an irritant when you have thousands of users out there who suddenly drop your code, blame you and python, and move on to use something else. Honestly, how hard would it have been to provide standard backwards support for the old regex module as a standard module which simply translated one regex string format to another, for example? Do you mean this? py import reconvert py help(reconvert) Help on module reconvert: NAME reconvert - Convert old (regex) regular expressions to new syntax (re). FILE c:\apps\python24\lib\reconvert.py DESCRIPTION When imported as a module, there are two functions, with their own strings: convert(s, syntax=None) -- convert a regex regular expression to re syntax quote(s) -- return a quoted string literal When used as a script, read a Python string literal (or any other expression evaluating to a string) from stdin, and write the translated expression to stdout as a string literal. Unless stdout is a tty, no trailing \n is written to stdout. This is done so that it can be used with Emacs C-U M-| (shell-command-on-region with argument which filters the region through the shell command). What I'm saying is that, for example, there are a lot of cool tools out there for using Python to manipulate postscript and latex and such. Most of those tools require no maintenance, and the authors are not paying any attention to them, and they aren't interested in messing with them anymore. And they will continue to work using the Python version for which they were designed, or even a later one; probably up to the last 2.x. Some scripts designed for Python 1.x still work. Really I don't feel the 3.0 incompatibilities are so big. My guess is that there are few such tools for Ruby. However, I wouldn't be too surprised if porting them to Ruby and testing them properly is not much more difficult than porting them to py3k and testing them properly... If you have to convert the code to 3.x, 2to3 does most of the dirty work. Of course you have to test properly - the same as with any new version. And you can't say seriously than porting to Ruby is easier than fixing the incompatibilities with 3.0 Especially since the basic treatment of strings is totally different in py3k, it seems. No. The new str type is the (renamed) old unicode type. Old strings are called bytes now. Both are immutable and mostly support the same old methods. Comparing (2.5) dir(u) with (3.0) dir(): decode() is not supported anymore; new: isidentifier(), maketrans(). Comparing (old) str with (new) bytes: encode() is not supported, nor format(); fromhex() added. So they look basically the same to me. Ok, when in 2.x you write uabc, it's spelled abc in 3.0; and when you write abc it will be spelled babc. But that change is easily done with the 2to3 tool, or using from __future__ import unicode_literals in Python 2.6. Again, not so terrible. It seems to me that the fear of the upcoming 3.0 is caused mostly by lack of information. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
kate hudson bathing suit
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
who is kate hudson dating
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
On 2008-04-16, Grant Edwards [EMAIL PROTECTED] wrote: But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. I did the same about an hour ago. -- http://mail.python.org/mailman/listinfo/python-list
kate hudson wallpapers
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
On Apr 16, 10:26 am, Mike Driscoll [EMAIL PROTECTED] wrote: Yeah, I noticed that Google Groups has really sucked this week. I'm using the Google Groups Killfile for Greasemonkey now and it helps a lot. I like Google, but my loyalty only goes to far. This is a complete lack of customer service. Mike Bless you. I just installed Greasemonkey and the Google Groups Killfile. Works like a charm. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
Mike Driscoll wrote: On Apr 16, 9:19 am, Grant Edwards [EMAIL PROTECTED] wrote: This morning almost half of c.l.p was spam. In order to try to not tar both the benign google group users and the malignant ones with the same brush, I've been trying to kill usenet spam with subject patterns. But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. AFAICT, if you're a google groups user your posts are not being seen by many/most experienced (read non-google-group) users. This is mainly the fault of google who has refused to do anything to stem the flood of span that's being sent via Google Groups. -- Grant Edwards grante Yow! I would like to at urinate in an OVULAR, visi.comporcelain pool -- Yeah, I noticed that Google Groups has really sucked this week. I'm using the Google Groups Killfile for Greasemonkey now and it helps a lot. I like Google, but my loyalty only goes to far. This is a complete lack of customer service. Unfortunately this means Google groups users are getting exactly the service they are paying for. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
kate hudson videos
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list
kate hudson thong
Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S -- http://mail.python.org/mailman/listinfo/python-list