Re: pydeflate
De: Atrant SG atrant...@gmail.com Para: gagsl-...@yahoo.com.ar Enviado: domingo 8 de marzo de 2009, 12:23:06 Asunto: pydeflate I've read the topic here http://www.gossamer-threads.com/lists/python/python/678374 and I'd like to download pydeflate module, but its official site seems not to be hosted. Do you have pydeflate? Could you send it to me? All the search engines always link to the official site and so I cant download that module myself =(( No, I don't have pydeflate. Why do you need it? urllib2 can handle it transparently, and you can even use zlib/gzip manually. -- Gabriel Genellina PS: Please reply to the list. Yahoo! Cocina Recetas prácticas y comida saludable http://ar.mujer.yahoo.com/cocina/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Help required to read and print lines based on the type of first character
De: abhinayaraj.r...@emulex.com abhinayaraj.r...@emulex.com I am sorry to that I am not able to fully grasp it. Could you help me with some more details? How can I identify each line and utilize the interactive interpreter? You really should read the tutorial at http://docs.python.org/tut (or any other introductory text; see http://wiki.python.org/moin/BeginnersGuide for more references) To open the interpreter, just type python (no quotes; ENTER to execute) on the command prompt. -- Gabriel Genellina Yahoo! Cocina Recetas prácticas y comida saludable http://ar.mujer.yahoo.com/cocina/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [Help] The pywinauto Can't select the MDI's menu using the MenuItems() which return [].
--- El vie 19-dic-08, 为爱而生 boyee...@gmail.com escribió: I use the WORD Only for my example. The application I test is similar to the WORD and It has't the COM. The code below opens the Choose Font dialog on my Spanish Windows version: py from pywinauto.application import Application py app = Application.start(Notepad.exe) py app[uSin título - Bloc de notas].MenuSelect(uFormato-Fuente) (using an English version, the last line would be app.UntitledNotepad.MenuSelect(Format-Font) I presume) There are many examples in the documentation, and some more info at http://pywinauto.seleniumhq.org/ I think there is a pywinauto users list. 2008/12/19 Gabriel Genellina gagsl-...@yahoo.com.ar En Thu, 18 Dec 2008 11:28:54 -0200, Simon Brunning si...@brunningonline.net escribió: 2008/12/18 为爱而生 boyee...@gmail.com: This problem also use the following discription: How to use pywinauto to open WORD and select its Menu. I can't do that and have no idea why! Looking forward your help,Thanks! Word can be automated with COM. My golden rule is that automation via GUI driving is always a last resort. -- Gabriel Genellina ¡Buscá desde tu celular! Yahoo! oneSEARCH ahora está en Claro http://ar.mobile.yahoo.com/onesearch -- http://mail.python.org/mailman/listinfo/python-list
Re: PP3E error
--- El mar 18-nov-08, ryan [EMAIL PROTECTED] escribió: I got it to work, just added the PP3E folder to Lib\site-packages. thanks very much I have been wanting to mke a text editor for some time. I also have another question, what is the book's software licensed under? can i make changes to the program and sell the program as my own or do I have to give credit to the book and mark lutz? Excerpt from the book Preface: Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product's documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Python Programming, Third Edition, by Mark Lutz. Copyright 2006 O'Reilly Media, Inc., 978-0-596-00925-0. So if you use a significant portion of the code you are required to ask O'Reilly for permission. IANAL, but in my opinion you'll have to do much more than make changes to the program in order to rightfully consider the final product your own creation instead of a derivative work. -- Gabriel Genellina Yahoo! Cocina Recetas prácticas y comida saludable http://ar.mujer.yahoo.com/cocina/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What happened with python? messed strings?
(top posting fixed; please keep discussion on this list) --- [EMAIL PROTECTED] escribió: In article [EMAIL PROTECTED] you wrote: En Sun, 20 Apr 2008 15:54:20 -0300, [EMAIL PROTECTED] escribi?: I used extensively python and now I find this mess with strings, I can't even reproduce tutorial examples: apfel.encode('utf-8') (it was with umlaut) File stdin, line 0 ^ SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: ordinal not in range(128) Is there any good guide to this mess of codecs and hell ? [two links to unicode introductory articles] ok, and how do you explain that even the tutorial example is broken ??? Which tutorial example? -- Gabriel Genellina Los referentes más importantes en compra/ venta de autos se juntaron: Demotores y Yahoo! Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: import hooks
--- Patrick Stinson [EMAIL PROTECTED] escribió: Right on, that seemed to work, thanks. This is different than sys.path_hooks though, which requires a callable or string subclass? Yes, it's different, meta_path is a generic mechanism that doesn't depend on sys.path and is tried before sys.path is traversed; the other is triggered by a special sys.path entry (like a .zip file). After some experimentation it looks like you can disallow an import by raising an import error from your meta_path hook. It seems a little weird that python will then raise a new ImportError from import.c:find_module(), but I guess the behavior is desirable.. I think you can't make an import fail completely; if your meta_path doesn't work, the next one is tried, and then the standard places (where the error is finally raised). Looks like the global name foo not defined error: sometimes it's not a global name at all, but that's where the search finally failed. -- Gabriel Genellina Gabriel Genellina Softlab SRL Tarjeta de crédito Yahoo! de Banco Supervielle. Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python UML Metamodel
--- sccs cscs [EMAIL PROTECTED] escribió: Gabriel Genellina [EMAIL PROTECTED] a écrit : En Tue, 29 Jan 2008 21:25:26 -0200, sccs cscs escribió: I find an OPEN SOURCE tool (http://bouml.free.fr/) that Recently generates Python code from UML model. Does it keep the model synchronized when you modify the Python code? =No, not for the moment because the Python code generator is brand new, but the tool's author and i are specifying the reverse tool for a next version. I do not have found another Open Source Tool that generates Python code from UML better like that. Ok, that's important. If the model cannot reflect changes in the code it becomes less and less useful. I like to model the Python language metamodel himself, with it, e.g the model of the language: I need that to better understand the language constraint of the language. [...] -a class class has 0..n attributes and 0..n method Just attributes. Methods are created on-the-fly when the corresponding function attribute is retrieved from the instance. And remember that instances are not restricted to what their class define. You can add or remove any attribute (even methods!) to any instance of a user-defined class at any time. (This doesn't apply to most builtin types, but *does* apply if you inherit from it) =You're Right but I will also model that dynamic aspect . However i think it is possible and the relevant to make a static metamodel of Python, as if there was no possibility of changing dynamic an instance. But Python *is* a dynamic language. You have to capture that into the model somehow. A lot of person do not understand nothing to Python on many aspects, because there is no graphical representation of the relation of concepts : may a module have more than on class definition ? a mix of class and global fonction? etc... A graphical representation may be useful, but it must be acurate too - else people may incorrectly deduce that something can't be done because it's not expressed in the graph. Does anyone know a document that describes it already, because I think it is complicated to find this information in the documentation of Python. See section 2 Data Model and section 3 Execution Model in the Python Language Reference http://docs.python.org/ref/ = Thank you, it's pretty standard but somewhat indigestible. However, by studying line by line, I would have to be filled into a UML model Yes, sure, it's hard to follow. As the subtitle says, it's for language lawyers :) - a class method can contains nested method, but what is the way to get a list of internal methods, without use ? Can i just write: myNestedMethodList = method.nestedMethodList Are you talking about nested functions? = Yes You can't enumerate them from outside the container function: Python is a dynamic language, those inner functions are created when the def statement is *executed*. If you have an if statement around the def, the function may not even exist. = OK, it is diffcult to model: but possible: for example, by using a composition (a method may have 0..n inner function). The dynamic aspect may be described into a UML note or constraints for example Anyway it doesn't look right. Inner functions are not attributes of the enclosing one, like local variables are not attributes of the enclosing function. -- Gabriel Genellina Los referentes más importantes en compra/ venta de autos se juntaron: Demotores y Yahoo! Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: paging in python shell
--- Alex K [EMAIL PROTECTED] escribió: Thank you for this interesting tip. However I'm not sure to know how to use it. It seems pydoc.pager('text') just pages the text passed in. How do I actually make the python shell use a different pager? I'm unsure of what you want. Do you want the print statement, inside the Python interpreter, to page its output? Write a function to page the output the way you like, and assign it to sys.displayhook (see http://docs.python.org/lib/module-sys.html#l2h-5124 ) -- Gabriel Genellina Tarjeta de crédito Yahoo! de Banco Supervielle. Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar -- http://mail.python.org/mailman/listinfo/python-list
Please help in creating Python function in C ++ program
Forwarded to python-list@python.org --- Borse, Ganesh [EMAIL PROTECTED] escribió: Hi, I am new to Python. I would like to use Python for the specialized purpose of dynamic expressions parsing evaluation in my C++ application. I would like to encapsulate the expressions to be evaluated in Python function compile that function at runtime, somewhat as below. Expression to eval put in Python function def isSizeSmall(size,vol,ADV,prod): if ( (size 1000) (vol (0.001 * ADV)) (prod==Stock)): print OK; return 10 else: print NOK; return 11 Then, I want to evaluate the PyObject returned by Py_CompileString multiple times in my program using the user input as the variables to the above function. This I tried using two different approaches - 1) PyEval_evalCode, 2) PyObject_CallObject. 1) When using PyEval_evalCode: The function call to PyEval_evalCode was ok, but it did not return any output. 2) Whereas, when I used this object with PyObject_CallObject, it failed with error as . Any help will be great. Many thanks in advance for your help. Warm Regards, Ganesh //***// Output of my test program: Expression to eval = [def isSizeSmall(size,vol,ADV,prod): if ( (size 1000) (vol (0.001 * ADV)) (prod==Stock)): print OK; return 10 else: print NOK; return 11 ] str compiled fine with stdin Py_file_input, calling PyEval_EvalCode None ok [0] size [-1] str compiled fine with stdin Py_file_input, calling PyFunction_New then PyObject_CallObject Getting PyFunction_New Calling PyObject_CallObject func is callable TypeError: ?() takes no arguments (4 given) My test program having both above approaches is as below: main(int argc, char **argv) { /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(argv[0]); /* Initialize the Python interpreter. Required. */ Py_Initialize(); PyRun_SimpleString(import sys\n); char szExpr[2048]; memset(szExpr,'\0',sizeof(szExpr)); sprintf(szExpr,def isSizeSmall(size,vol,ADV,prod):\n if ( (size 1000) (vol (0.001 * ADV)) (prod==\Stock\)): print \OK\; return 10\n else: print \NOK\; return 11\n\n\n); printf(Expression to eval = \n[%s]\n,szExpr); OrderValues ordval; ordval.size = 100; ordval.ADV = 10; ordval.vol = 1000; memset(ordval.prod,'\0',sizeof(ordval.prod)); sprintf(ordval.prod,Stock); PyObject *glb, *loc; glb = PyDict_New(); PyDict_SetItemString(glb, __builtins__, PyEval_GetBuiltins()); loc = PyDict_New(); PyObject* tuple = PyTuple_New(4); PyObject* val = 0; val = PyInt_FromLong(ordval.size); PyTuple_SetItem(tuple,0,val); PyDict_SetItemString(loc,size,val); val = PyInt_FromLong(ordval.vol); PyTuple_SetItem(tuple,1,val); PyDict_SetItemString(loc,vol,val); val = PyInt_FromLong(ordval.ADV); PyTuple_SetItem(tuple,2,val); PyDict_SetItemString(loc,ADV,val); val = PyString_FromString(ordval.prod); PyTuple_SetItem(tuple,3,val); PyDict_SetItemString(loc,prod,val); /*** with string Py_file_input ***/ PyObject* result = NULL; result = Py_CompileString(szExpr,string, Py_file_input); if(result!=NULL !PyErr_Occurred()){ printf(str compiled fine with stdin Py_file_input, calling PyEval_EvalCode\n); PyCodeObject *pyCo = (PyCodeObject *)result; PyObject* evalret = NULL; evalret = PyEval_EvalCode(pyCo,glb,loc); if(!evalret || PyErr_Occurred()) PyErr_Print(); else printf(ok [%d] size [%d]\n,PyObject_Print(evalret,stdout,0),PyObject_Size(evalret)); // Try to get function obj of this... printf(Getting PyFunction_New\n); PyObject* func = PyFunction_New(result,glb); if(!func || PyErr_Occurred()){ printf(Failed to get Function..\n); PyErr_Print(); } else { printf(Calling PyObject_CallObject\n); if(PyCallable_Check(func)) printf(func is callable\n); PyObject* ret = PyObject_CallObject(func, tuple); //PyObject* ret = PyObject_CallObject(func, NULL); if(!ret || PyErr_Occurred()) PyErr_Print(); else printf(PyObject_CallObject evaluated..\n); } } else { printf(Py_CompileString-1 returned NULL\n); PyErr_Print(); } exit(100); } Remember that when you execute the Python source code, you get the function *definition*; you are not executing the function itself. I travel until Dec. so unfortunately I can't provide more help now. See the docs for Extending and Embedding. -- Gabriel Genellina Gabriel Genellina Softlab SRL Compartí video en la ventana de tus mensajes (y también tus fotos de Flickr). Usá el nuevo Yahoo! Messenger versión Beta. http://ar.beta.messenger.yahoo.com/ --
Re: Can Readlines() go to next line after a Tab
(Please keep posting on this list) --- [EMAIL PROTECTED] escribió: Thanks, but this method still reads the whole line into memory. I would like to find a way for it to stop reading when it encounters a \t and then go to the next. This would be much faster. You can't avoid reading the whole line - how can you detect the end-of-line, unless you use fixed-length records? According to my tests, readlines with a regular expression is actually faster than the index method you mentioned. Here is the code testing a 25meg file with thousands of lines, Hard to believe, altough that depends on a lot of factors. Is the posted code all your testing code? If so, it doesn't look right. Write two separate functions, without side effects each (in this case, that means using a local variable for kwords). Let's call them f1 and f2, inside kw.py. Use the timeit module to measure performance instead of time.time(). Execute both functions *separately* on two *separate* Python invocations, like this: python -m timeit -s from kw import f1,f2 f1() python -m timeit -s from kw import f1,f2 f2() and see what happens. -- Gabriel Genellina __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Set timeout and kill external windows
At Saturday 16/06/2007 02:24, you wrote: Thanks for your reply. I am new to Python and I cannot seem to figure this out. I searched for examples based on your recommendation below but couldn't do it. I am not familiar with subprocess and WaitForSingleObject. And I want to do this in Windows. Could you please write me the few lines I need to do this? (Please keep posting on the list - other people may help too, and I don't read this email too often). Try this. (I had to use a private Popen attribute, _handle). import subprocess from win32event import WaitForSingleObject, WAIT_TIMEOUT from win32api import TerminateProcess def execute_and_wait(args, timeout=None): Execute a command and wait until termination. If timeout elapses and still not finished, kill it. args: list containing program and arguments, or a single string. timeout: maximum time to wait, in ms, or None. p = subprocess.Popen(args) if timeout: ret = WaitForSingleObject(p._handle, timeout) if ret==WAIT_TIMEOUT: TerminateProcess(p._handle, 1) return None return p.wait() ret = execute_and_wait([notepad, c:\\python\\LICENSE.txt], 5000) print ret=,ret -- Gabriel Genellina __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list