Python competition ROUND #1
Hello, (Competition language: English) First round of Python competition at Python Evaluator will be next Saturday at 17:00 ( UTC ). If you want to register: http://evaluator.vdekovic.net/index.php?select=register.php Rules: http://evaluator.vdekovic.net/index.php?select=rules.php http://evaluator.vdekovic.net/ Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Python evaluator
Hello, I have created a Python evaluator - system that evaluates python scripts.Better explanation (how does it work): 1.) You have to open task that you want to solve from evaluator task panel 2.) Solve task 3.) Send task on evaluator 4.) After few seconds you get your result Here are some Python evaluator screenshots: http://www.vdekovic.net/include/data/evaluator1screen.png (Croatian version of evaluator) http://www.vdekovic.net/include/data/evaluator2screen.png (Croatian version of evaluator) http://www.vdekovic.net/include/data/evaluator3screen.png (Croatian version of evaluator) With this evaluator I want to make a little python competition, if you want to participate, you have to be member of: Python evaluator mailing list, if you want to subscribe here is the address: http://www.vdekovic.net/mail_liste/mail.cgi (FREE!) For any other informations, contact me: vedran.deko...@vdekovic.net Sorry for my bad english! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython and Croatian characters
On 17 velj, 00:09, alejandro aleksanda...@brisiovonet.hr wrote: Provjeri da si nisi stavio ansii kada si instalirao wx.python. Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem Pozdrav / Hello, It works now, all post were very useful, but now i have same problem with python MySQLdb. I want data that I got from wxPython TextCtrl write to MySQL database, but I don't know how to configure it. Any examples? Regards, John -- http://mail.python.org/mailman/listinfo/python-list
wxPython and Croatian characters
Hello, I have problem with configuring my wxPython script to work with Croatian characters like: đ,š,ž,č,ć. Here is my simple script without wxPython (this script works): # -*- coding: utf-8 -*- s = hello normal string đšžćč print s ..here is my snippet with wxPython: text = wx.StaticText(self, -1,Matični broj,(0,100)) # in this example,we have character č ...when I run this text, it looks something like: Mati,some weird characters ,and ni Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Python time measure question (timeit)
Hello, When I run following code with os.popen (for this time measure I'm using python module timeit): for i in range(50): print i I get this result: 0.00246958761519 But when I run same code from IDLE i get this result: 6.4533341528e-005 now, I have two questions: 1) Which of this results is correct? 2) Are this results in micro seconds? Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Python time measure question (timeit)
On 1 velj, 17:42, Steve Holden st...@holdenweb.com wrote: vedrandeko...@yahoo.com wrote: Hello, When I run following code with os.popen (for this time measure I'm using python module timeit): for i in range(50): print i I get this result: 0.00246958761519 But when I run same code from IDLE i get this result: 6.4533341528e-005 now, I have two questions: 1) Which of this results is correct? Both are. What makes you think that printing in IDLE (to a GUI) should take the same amount of time as it does running with os.popen (whatever that means). The two environments are likely to be completely different, but you haven't show the exact code you ran so it's hard to be more exact. 2) Are this results in micro seconds? No, seconds, as it says in the documentation: This executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, measured in seconds as a float. Even a modern computer doesn't do much in .0024 microseconds. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Hello again, This is the code that I ran: a) Main code: This code is in .exe: t = Timer(import os;os.popen('python myscript.py arg1 2 3')) print t.timeit() b) myscript.py code: import sys print sys.argv[1] var1=int(sys.argv[2]) var2=int(sys.argv[3]) var3=var1+var2 Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and threads
On 18 sij, 21:27, Stefan Behnel stefan...@behnel.de wrote: vedrandeko...@yahoo.com wrote: and thanks for all previous help.I want to measure memory usage of executed python script.I'am working on windows XP. Could you qualify measure? Do you mean: a) debug (permanently high accuracy, potentially high runtime overhead) b) monitor (high accuracy, low/medium-resolution surveillance, no runtime overhead) c) find out (low accuracy or just max usage, no permanent observation) ? Stefan Hello, I want to find out , sorry for this measure. Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Python and threads
Hello again, Thanks for previous help on Start two threads in same time it was useful,but when I run this two threads, I think they don't start at the same time, here is my code snippet: import threading class ThreadedClass1(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): a=True while a==True: bm=my_module.MyClass() a=bm.get_Python_Process_Usage_Function() #Returns True or False class ThreadedClass2(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): os.popen(my_python_script.py) threaded_obj = ThreadedClass1() threaded_obj.start() threaded_obj2 = ThreadedClass2() threaded_obj2.start() Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and threads
On 18 sij, 17:48, Diez B. Roggisch de...@nospam.web.de wrote: vedrandeko...@yahoo.com schrieb: Hello again, Thanks for previous help on Start two threads in same time it was useful,but when I run this two threads, I think they don't start at the same time, here is my code snippet: import threading class ThreadedClass1(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): a=True while a==True: bm=my_module.MyClass() a=bm.get_Python_Process_Usage_Function() #Returns True or False class ThreadedClass2(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): os.popen(my_python_script.py) threaded_obj = ThreadedClass1() threaded_obj.start() threaded_obj2 = ThreadedClass2() threaded_obj2.start() If you want to synchronize two or more threads, you need to do so manually using objects like Locks, Events, Conditions and Semaphores. See the threading module. Even if you managed to get two threads started simultaneously (which the OS doesn't even offer IINM), the would soon run out of sync. How about you tell us what you *want*, and we tell you if and how it's possible to do that. Diez Hello, and thanks for all previous help.I want to measure memory usage of executed python script.I'am working on windows XP. Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Start two threads in same time
Hello, Does anybody know how can I start two threads in same time? Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Python stack and heap
Hello, Does anybody know how can I get usage of stack or/heap memory in Python on Windows XP? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 9 kol, 01:27, Carl Banks [EMAIL PROTECTED] wrote: On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. While you're at it, please post your setup.py Carl Banks Hi, Here is my setup.py script: setup(name=MyApp, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\ \boost'], ) ]) Regards, Veki -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 9 kol, 13:34, [EMAIL PROTECTED] wrote: On 9 kol, 01:27, Carl Banks [EMAIL PROTECTED] wrote: On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. While you're at it, please post your setup.py Carl Banks Hi, Here is my setup.py script: setup(name=MyApp, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\ \boost'], ) ]) Regards, Veki Hello, ...and here is the error: C:\Panda3D-1.5.2\python\Lib\site-packagespython setup.py build running build running build_ext building 'hello' extension D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c / nologo /Ox /MD /W3 /GX /DNDEBUG -ID:\Program Files\boost\boost_1_34_1\boost - IC:\Panda3D -1.5.2\python\include -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.cpp / Fobuild\t emp.win32-2.5\Release\hellomodule.obj hellomodule.cpp hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/ module.hpp': No such file or directory error: command 'D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe' failed with exit status 2 C:\Panda3D-1.5.2\python\Lib\site-packagespause Press any key to continue . . . -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 7 kol, 21:43, Carl Banks [EMAIL PROTECTED] wrote: On Aug 7, 3:25 am, [EMAIL PROTECTED] wrote: Hello, I want to build my C++ (.cpp) script to (.pyd) like this: http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B I have installed Microsoft Visual studio .NET 2003 and Boost Python and then after I run my setup script: python setup.py build I get this error: running build running build_ext building 'hello' extension D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c / nologo /Ox /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC: \Panda3D-1.5.2\pytho n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release \hellomodule.obj hellomodule.cpp hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/ module.hpp': No such file or directory error: command 'D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe' failed with exit status 2 I think that my MS visual studio cannot find boost python, if that's the problem then can you tell me how can I solve it. This is very begginer question,but I can't find answer nowhere, and I don't have any expirience with Microsoft products. Sorry for my bad english! Regards, Veki First, locate the boost header files. Suppose you find the file module.hpp in this location: C:\boost-whatever-version\include\boost\python\module.hpp The part that comes before boost\python\module.hpp is the required include directory. You can tell setup to use this directory by adding the following argument to the Extension call: include_dirs = ['C:\\boost-whatever-version\\include'] Notice the doubling of backslashes. Remember to add the directory where the boost header files lie on your system; don't add this line exactly. You should end up with a setup call that looks like this: setup(name=blah, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['C:\\boost-whatever-version\\include']) ]) Carl Banks Hi, Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. Regards, Veki -- http://mail.python.org/mailman/listinfo/python-list
.cpp to .pyd
Hello, I want to build my C++ (.cpp) script to (.pyd) like this: http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B I have installed Microsoft Visual studio .NET 2003 and Boost Python and then after I run my setup script: python setup.py build I get this error: running build running build_ext building 'hello' extension D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c / nologo /Ox /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC: \Panda3D-1.5.2\pytho n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release \hellomodule.obj hellomodule.cpp hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/ module.hpp': No such file or directory error: command 'D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe' failed with exit status 2 I think that my MS visual studio cannot find boost python, if that's the problem then can you tell me how can I solve it. This is very begginer question,but I can't find answer nowhere, and I don't have any expirience with Microsoft products. Sorry for my bad english! Regards, Veki -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 7 kol, 09:48, Matthieu Brucher [EMAIL PROTECTED] wrote: I think that my MS visual studio cannot find boost python, if that's the problem then can you tell me how can I solve it. This is very begginer question,but I can't find answer nowhere, and I don't have any expirience with Microsoft products. Hi, Put Boost in your include path (options of Visual Studio). Matthieu -- French PhD student Website :http://matthieu-brucher.developpez.com/ Blogs :http://matt.eifelle.comandhttp://blog.developpez.com/?blog=92 LinkedIn :http://www.linkedin.com/in/matthieubrucher Hello again, Thanks for your quick reply! Put Boost in your include path (options of Visual Studio). Look at my image: http://img225.imageshack.us/my.php?image=zaimghostfy1.png I still get the same error. Regards, Veki -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 7 kol, 11:37, Ulrich Eckhardt [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/module.hpp': No such file or directory You need to tell it where to find the Boost includes. I suggest you first try to get some header-only Boost library going as example, if you have that right, you also have the include paths right. In your second posting, you gave a link to a picture which had the exact right dialog for setting this as system setup. You can also set the path on a per-project base, then it's in the C++ settings. Note that for compiled libraries like Boost.Python you will first have to compile those (see Boost docs), put the DLLs into a place where they can be found (e.g. the windows dir or anything else on the path) and also have to set a path to the .LIBS in the linker settings. As an alternative to compiling libraries separately, you can also include the Boost sources into your project, just add BOOST_PYTHON_STATIC_LIB to the preprocessor defines and include the following files from one(!) translation unit: boost/../libs/python/src/module.cpp boost/../libs/python/src/dict.cpp boost/../libs/python/src/errors.cpp boost/../libs/python/src/list.cpp boost/../libs/python/src/object_operators.cpp boost/../libs/python/src/object_protocol.cpp boost/../libs/python/src/tuple.cpp boost/../libs/python/src/str.cpp boost/../libs/python/src/object/class.cpp boost/../libs/python/src/object/function.cpp boost/../libs/python/src/object/inheritance.cpp boost/../libs/python/src/object/pickle_support.cpp boost/../libs/python/src/converter/builtin_converters.cpp boost/../libs/python/src/converter/registry.cpp boost/../libs/python/src/converter/from_python.cpp Note: this is with Boost 1.33.1, newer versions likely differ. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 Hello again, This answer is probably exactly what I need, but as I said, I don't have any expirience with MS products! Is there any other easier way except boost python to make .pyd from .cpp? -- http://mail.python.org/mailman/listinfo/python-list
Create executable from executable with py2exe
Hello, Is there any example how can I create executable from executable with py2exe.For example if I create main executable with some TextEntry ( wxpython ) and then when i write this code into this entry: import os print os.getcwd() print ok ...to main executable convert this code into executable with py2exe. Sorry for my english! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe embed my modules to libary.zip
On 26 ožu, 20:11, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 26 Mar 2008 15:38:16 -0300, Tzury Bar Yochay [EMAIL PROTECTED] escribió: and then when my application execute code how can I set path to d3dx module to library.zip/d3dx.py. I'm not sure is this properly set question. use the module zipimport http://docs.python.org/lib/module-zipimport.html You don't have to do anything special to use zipimport; from http://docs.python.org/lib/module-zipimport.html : It is usually not needed to use the zipimport module explicitly; it is automatically used by the builtin import mechanism -- Gabriel Genellina Hello, I was add this into my application code: import sys import os my_dir=os.getcwd() sys.path.append(my_dir) sys.path.append(my_dir+\\libary.zip) sys.path.append(my_dir+\\libary.zip\\py2exe) # PY2EXE is folder f=open(path.txt,w) f.write(str(sys.path)) f.close() an the output in path.txt is : ['C:\\Users\\veki\\Desktop\\python\\PGS\\dist\\library.zip', 'C:\\Users \\veki\\Desktop\\python\\PGS\\dist', 'C:\\Users\\veki\\Desktop\\python\ \PGS\\dist\\libary.zip', 'C:\\Users\\veki\\Desktop\\python\\PGS\\dist\ \libary.zip\\py2exe'] But it still can't find module py2exe.What should I do now? Any examples? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe embed my modules to libary.zip
On 27 ožu, 10:44, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 27 Mar 2008 06:00:26 -0300, [EMAIL PROTECTED] escribió: I was add this into my application code: import sys import os my_dir=os.getcwd() sys.path.append(my_dir) sys.path.append(my_dir+\\libary.zip) sys.path.append(my_dir+\\libary.zip\\py2exe) # PY2EXE is folder f=open(path.txt,w) f.write(str(sys.path)) f.close() an the output in path.txt is : ['C:\\Users\\veki\\Desktop\\python\\PGS\\dist\\library.zip', 'C:\\Users \\veki\\Desktop\\python\\PGS\\dist', 'C:\\Users\\veki\\Desktop\\python\ \PGS\\dist\\libary.zip', 'C:\\Users\\veki\\Desktop\\python\\PGS\\dist\ \libary.zip\\py2exe'] But it still can't find module py2exe.What should I do now? Any examples? I assume you're talking about the py2exe package available from www.py2exe.org- so it's not a module, it's a package. py2exe usually is only relevant on your *development* machine, so why do you want to put it inside a .zip? What do you want to do? Anyway, I tried the following and could import py2exe successully (but I don't know if it actually works as a distutils extension...) - compressed the py2exe folder into py2exe.zip - deleted the original py2exe folder - moved py2exe.zip onto some temporary directory - tried to import py2exe, failed as expected - added py2exe.zip to sys.path - tried to import py2exe, this time OK py import py2exe Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named py2exe py import sys py sys.path.append(rC:\TEMP\pna\py2exe.zip) py import py2exe py py2exe.__path__ ['C:\\TEMP\\pna\\py2exe.zip\\py2exe'] -- Gabriel Genellina Hello again, Thanks for previous post, it was useful! So now I know what is a problem, but I don't know how to solve it.Under my application user can convert his python code to executable, I was created this with subprocess: retcode =subprocess.Popen([ython,setup.py,py2exe,-d,exe], shell=True, stdout=subprocess.PIPE,creationflags = win32process.CREATE_NO_WINDOW) stdout_value = retcode.communicate()[0] ...Py2exe exit from process here: running py2exe creating C:\Users\veki\Desktop\python\PGS\dist\build creating C:\Users\veki\Desktop\python\PGS\dist\build\bdist.win32 creating C:\Users\veki\Desktop\python\PGS\dist\build \bdist.win32\winexe creating C:\Users\veki\Desktop\python\PGS\dist\build\bdist.win32\winexe \collect-2.5 creating C:\Users\veki\Desktop\python\PGS\dist\build\bdist.win32\winexe \bundle-2.5 creating C:\Users\veki\Desktop\python\PGS\dist\build\bdist.win32\winexe \temp creating C:\Users\veki\Desktop\python\PGS\dist\exe *** searching for required modules *** ...it's trying to find d3d,d3dx,d3dc,d3dgui... modules but it can't cause these modules are in library.zip.How can I set target for finding path to library.zip , I'm running these py2exe compile process from my main excutable? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Py2exe embed my modules to libary.zip
Hello, Does anybody have any idea how can I embed my modules to libary.zip and use it from my application.For example if user write this code in my TextEntry ( or something like that, textentry is created with wxpython ) : import d3dx # directpython module frame=d3dx.Frame(uMy frame) # create frame frame.Mainloop() # run it and then when my application execute code how can I set path to d3dx module to library.zip/d3dx.py. I'm not sure is this properly set question. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
py2exe: python modules and applicaation
Hello again, I'am working a simple application with wxpython, py2exe and directpython.After I write python code in my wxpython textctrl, then my application must save that code and create ( pgssetup2.py script ), and then with py2exe create (.exe) of the code. ( my application is builded with py2exe too ). Here is example of code the converts from .py to .exe: try: process2=subprocess.Popen([python,pgssetup2.py,py2exe,- d,exe],shell=True, stdout=subprocess.PIPE) stdout_value = process2.communicate()[0] except NameError,e: print e When I run this code before converting to exe it works fine but in .exe there is no error but It wont work. I think it's problem with modules py2exe and directpython how can I append that modules to my application? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
make exe from application with py2exe
Hello, Is there any idea how can i create (.exe) from application (.exe ) with py2exe? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxpython application ( problem ? )
Hello, Here is sample of my simple script with wxpython and modules: subprocess,threading, directpython... Code sample: import wx import wx.aui app=wx.App() frame=wx.Frame(None,title=New project) #There is also part with wx.aui frame.Show() app.MainLoop() After a few minutes wx application does destroy. Any ides why? -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython application ( problem ? )
On 2 sij, 12:29, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote: Here is sample of my simple script with wxpython and modules: subprocess,threading, directpython... Are you accessing the GUI from threads? Ciao, Marc 'BlackJack' Rintsch Hi again, yes, so what's the problem? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxPython ListCtrl image configuring
Hello, Here is example of my ListCtrl items with image: ( filebox1 is ListCtrl ) il = wx.ImageList(16,16) images=[file1.png,folder.png] for i in images: il.Add(wx.Bitmap(i)) img_list=filebox1.SetImageList(il, wx.IMAGE_LIST_SMALL) j=1 unos1p=unos1.GetValue() unos2p=unos2.GetValue() unos3p=unos3.GetValue() newftp=FTPHost(unos1p,unos2p,unos3p) for item in newftp._dir('/'): if item.split()[2]==DIR: index=filebox1.InsertStringItem(j,item) filebox1.SetItemImage(index,2) else: index=filebox1.InsertStringItem(j,item) filebox1.SetItemImage(index,1) ..Then my program show all items and images with them, but the problem is when I click on item image of item disappere .Any idea? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxPython ListCtrl
Hello, How can I Insert image with string in ListCtrl with this example: # Import ftputil module - like ftplib from ftputil import FTPHost # Create connection ftp=FTPHost(ftp.someserver.com,user,password) # LIST ALL FILES/FOLDERS ON SERVER for item in ftp._dir(/): # Now check if item is file /folder if item is file insert this image: wx.ART_NORMAL_FILE and if the item is folder insert this image wx.ART_FOLDER ...how can I do the same on server with GenericDirCtrl? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
string replace shortcut
Hello, I am trying to replace some string with list objects: my_text1=function1 function2 from my_module_with_functions_1 import * from my_module_with_functions_2 import * # functions in module my_module_with_functions_1 : my_func1 it's value function1 my_func2 it's value function2 # functions in module my_module_with_functions_2 : my_func100 it's value bla bla 1 my_func200 it's value bla bla 2 now, we need find and replace functions from module my_module_with_functions_1 and replace them with functions from module my_module_with_functions_2 with: my_text1.replace(items1,items2) Result must be: print my_text1.replace(items1,items2) bla bla 1 bla bla 2 Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: redirect or cover .bat log
On 22 kol, 21:18, [EMAIL PROTECTED] wrote: On 22 kol, 16:01, Gabriel Genellina [EMAIL PROTECTED] wrote: On 22 ago, 10:04, [EMAIL PROTECTED] wrote: e.g I need run my my_scripts_setup.bat that contain: python myscript_setup.py py2exe Can I cover or redirect log of that process into my wx program? I'am using Windows XP SP2, and Python 2.5. Try the subprocess module. For the single line command you posted earlier, you don't even need the bat file: import subprocess p = subprocess.Popen([python, myscript_setup.py, py2exe], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() output_from_process = p.stdout.readlines() This would be fine if executing the script takes relatively a short time and doesn't generate so many output lines; there are other examples in the subprocess module documentation http:// docs.python.org/lib/module-subprocess.html -- Gabriel Genellina Hi, This works fine. Thanks! Hi, This,works fine except this last line: output_from_process = p.stdout.readlines() I get an error: p has not attribute stdout Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
redirect or cover .bat log
Hello, e.g I need run my my_scripts_setup.bat that contain: python myscript_setup.py py2exe Can I cover or redirect log of that process into my wx program? I'am using Windows XP SP2, and Python 2.5. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: redirect or cover .bat log
On 22 kol, 09:19, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: Hello, e.g I need run my my_scripts_setup.bat that contain: python myscript_setup.py py2exe Can I cover or redirect log of that process into my wx program? I'am using Windows XP SP2, and Python 2.5. Who's running the bat, and who's running the wx program? Diez Hi, First I convert my main wx program to exe with my py2exe setup,then under my main program (exe), I must run that .bat file and redirect or cover that process. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: redirect or cover .bat log
On 22 kol, 10:52, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 22 kol, 09:19, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: Hello, e.g I need run my my_scripts_setup.bat that contain: python myscript_setup.py py2exe Can I cover or redirect log of that process into my wx program? I'am using Windows XP SP2, and Python 2.5. Who's running the bat, and who's running the wx program? Diez Hi, First I convert my main wx program to exe with my py2exe setup,then under my main program (exe), I must run that .bat file and redirect or cover that process. Still not very clear. But running a bat-file should be possible with the subprocess module that also has facilities to grab stdout of the child process. Diez Hi, Can I execute one .bat file (without opening .bat window) just execute commands and log process redirect with sys.stdout or something in my wx window? Is this clear enough? Have you any other solutions for this? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: redirect or cover .bat log
On 22 kol, 16:01, Gabriel Genellina [EMAIL PROTECTED] wrote: On 22 ago, 10:04, [EMAIL PROTECTED] wrote: e.g I need run my my_scripts_setup.bat that contain: python myscript_setup.py py2exe Can I cover or redirect log of that process into my wx program? I'am using Windows XP SP2, and Python 2.5. Try the subprocess module. For the single line command you posted earlier, you don't even need the bat file: import subprocess p = subprocess.Popen([python, myscript_setup.py, py2exe], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() output_from_process = p.stdout.readlines() This would be fine if executing the script takes relatively a short time and doesn't generate so many output lines; there are other examples in the subprocess module documentation http:// docs.python.org/lib/module-subprocess.html -- Gabriel Genellina Hi, This works fine. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
building exe from script
Hello, Is there any solution for building exe file from python script something like bbfreeze.When user write some script in my program, it must compile script into exe without opening console ( cmd ).I'am working on Windows XP SP2 and Python 2.5. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: Latest models of Gibson guitars
On 19 kol, 19:34, [EMAIL PROTECTED] wrote: Reviews of latest models of best guitars, fender, gibson, yamaha, and many more, with pictures and prices. http://pro-guitars.blogspot.com/ And if you want to win a free guitar go here http://freeguitars.blogspot.com/ Hello, This is a newsgroup of programming language Python, stop with this! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxPython with directpython
Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: python video editing libs
On 18 kol, 05:01, math2life [EMAIL PROTECTED] wrote: On Aug 17, 5:55 pm, DavidM [EMAIL PROTECTED] wrote: Hi, Does anyone know of any python or python-wrapped libs for video editing? My requirements: - open video files in any of the popular containers (avi, mov, ogg, flv etc) and all the popular codecs (mpeg3, theora, mpeg2 etc) and audio codecs (raw, wav, mp3 etc) - get an abstract video clip object on opening such a file - query the clip object to determine stuff like length, framerate, size etc - iterate through all the frames, and get a frame object with each frame - with a frame object, be able to access individual pixels, add graphic images (eg, via PIL), export frame to graphics file (eg jpeg) - with video clip object, be able to change framerate, insert/remove frames etc, and render out with desired a-v codecs and container - good well-documented API, preferably some usage examples Does anything like this exist? Cheers David Python OpenCV wrapper will meet most of your need, but I am not sure , plz check it out. Hi, I'am not sure, try pymedia Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython with directpython
On 18 kol, 15:35, [EMAIL PROTECTED] wrote: On Aug 18, 8:08 am, [EMAIL PROTECTED] wrote: Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran You need to post some more code, preferably the function that calls the directx stuff. And how do you catch the close event? It sounds like you've got multiple objects bound to it which causes the entire program to close. You might consider running the directx stuff in a separate thread. Mike Hi, no,that's all code I've got,I mean it's all code that I run with my program for now. You might consider running the directx stuff in a separate thread. How? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxpython log redirect
Hello, Why this wx example don't return \nHELLO WORLD and other text in same window: import wx import logging import sys def nekaj(): print \nHELLO WORLD class WxLog(logging.Handler): def __init__(self, ctrl): logging.Handler.__init__(self) self.ctrl = ctrl def emit(self, record): self.ctrl.AppendText(self.format(record)+\n) class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title=logging test) sizer = wx.BoxSizer(wx.VERTICAL) log = wx.TextCtrl(self, style=wx.TE_MULTILINE) rootLogger = logging.getLogger('') rootLogger.setLevel(logging.DEBUG) hdlr = WxLog(log) hdlr.setFormatter(logging.Formatter('%(levelname)s | %(name)s | %(message)s [@ %(asctime)s in %(filename)s:%(lineno)d]')) rootLogger.addHandler(hdlr) rootLogger.debug(str(sys.stdout)) nekaj() # goes to the function nekaj if __name__ ==__main__: app = wx.App(0) frame = MainFrame() frame.Show() app.MainLoop() Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
python 2.5 bug
Hello, I was install Python 2.5 and uninstall Python 2.4 now I cannot run my scripts, only from idle What should I do? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 bug
On 11 kol, 11:59, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 11 Aug 2007 02:41:26 -0700, vedrandekovic wrote: I was install Python 2.5 and uninstall Python 2.4 now I cannot run my scripts, only from idle What should I do? Install 2.4 again. Both can be installed in parallel. Ciao, Marc 'BlackJack' Rintsch I need python 2.5 for work becose python 2.4 module tokenizer has no attribute untokenize Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 bug
On 11 kol, 20:58, Thorsten Kampe [EMAIL PROTECTED] wrote: * Laurent Pointal (Sat, 11 Aug 2007 20:09:03 +0200) [EMAIL PROTECTED] wrote: On 11 kol, 11:59, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 11 Aug 2007 02:41:26 -0700, vedrandekovic wrote: I was install Python 2.5 and uninstall Python 2.4 now I cannot run my scripts, only from idle IMHO Python 2.4 was registered for .py files, Python 2.5 take precedence when installed, but when Python 2.4 has been removed, it remove .py files association too (so break Python 2.5 association). * manually associate .py/.pyc/.pyo files to python.exe, .pyw files to pythonw.exe. * or reinstall Python 2.5 so that it re-setup ad-hoc associations. Yeah. Did the Original Poster mention any details about his problem. Like - for instance - that he's using Windows? Thorsten Hello, Now I was restart my windows and python 2.5 also.Now everything works fine except python and py2exe script install ( of course something must destroy my day ) now when I run: $ cd c:\Python25\Lib\site-packages\ $ python mysetup.py py2exe 'python' is not recognized as an internal or external command, operable program or batch file. why? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
py2exe with python 2.5
Hello, Now,I was install python 2.5 and remove python 2.4 completely.After I write: $ python mysetup.py py2exe ... import py2exe_ util ImportError: Module use of conflicts with this version of Python ...ok, I know what is a problem, I haven't remove python completely, in my computer is one more folder Panda3D-1.4.0 but when I remove it and all dll files include python24.dll, I cannot run python or make that setup. (That panda3d contain python) Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe with python 2.5
On 10 kol, 14:38, Ant [EMAIL PROTECTED] wrote: On Aug 10, 11:47 am, [EMAIL PROTECTED] wrote: On 10 kol, 11:02, Ant [EMAIL PROTECTED] wrote: ... yes,Python 2.5 is on the path, but how can I remove panda3d from that path? Hit Win - Break to bring up the System Properties dialog (you can also get here through the Control Panel). Go to the Advanced tab, and click the Environment Variables button. Find the PATH variable in one of the two lists, and edit it. Just remove the Panda3D entry. Note you'll have to restart your console to pick up any changes. -- Ant... http://antroy.blogspot.com/ Hi, Ok,I have done that. But how can I restart console now? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe with python 2.5
On 10 kol, 11:02, Ant [EMAIL PROTECTED] wrote: On Aug 10, 8:39 am, [EMAIL PROTECTED] wrote: Hello, Now,I was install python 2.5 and remove python 2.4 completely.After I write: $ python mysetup.py py2exe ... import py2exe_ util ImportError: Module use of conflicts with this version of Python ...ok, I know what is a problem, I haven't remove python completely, in my computer is one more folder Panda3D-1.4.0 but when I remove it and all dll files include python24.dll, I cannot run python or make that setup. (That panda3d contain python) Regards, Vedran Sounds like your path needs setting up properly. Try typing echo %PATH % into your console window to find out if Python2.5 is in the path. If you are using the default setup, then c:\Python25 should be on the path. -- Ant... http://antroy.blogspot.com/ Hi, yes,Python 2.5 is on the path, but how can I remove panda3d from that path? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
setuptools
Hello, If anybody have experiences with setuptools, I was download bbfreeze-0.95.2-py2.4-win32.egg and when I run installation with cmd: $ easy_install bbfreeze-0.95.2-py2.4-win32.egg Processing bbfreeze-0.95.2-py2.4-win32.egg Removing c:\Python24\lib\site-packages\bbfreeze-0.95.2-py2.4-win32.egg creating c:\Python24\lib\site-packages\bbfreeze-0.95.2-py2.4-win32.egg Extracting bbfreeze-0.95.2-py2.4-win32.egg to c:\Python24\lib\site- packages Adding bbfreeze 0.95.2 to easy_install.pth file Installed c:\Python24\lib\site-packages\bbfreeze-0.95.2-py2.4- win32.egg Processing dependencies for bbfreeze==0.95.2 error: None If this installation is successfully then where is installed module? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
tokenize module after installation
Hi, I have one more question about installation. After installation my program that uses tokenize module,when I run myprogram.exe (vgsveki.exe): Traceback (most recent call last): File vgsveki.py, line 307, in kompajlati File vgsveki.py, line 302, in kompajlati_proces File vgsveki.py, line 278, in __init__ File vgsveki.py, line 93, in kod AttributeError: 'module' object has no attribute 'untokenize' but before installation it works properly. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
setuptools bbfreeze install egg error
Hello, I was download egg file bbfreeze-0.95.2-py2.4-win32.egg ( for windows of course ),and I have setuptools version 0.6c6 after I try install this with setuptools: $ ez_setup bbfreeze-0.95.2-py2.4-win32.egg Traceback (most recent call last): File C:\Python24\Lib\site-packages\ez_setup.py, line 226, in ? main(sys.argv[1:]) File C:\Python24\Lib\site-packages\ez_setup.py, line 183, in main from setuptools.command.easy_install import main File C:\Python24\Lib\site-packages\setuptools\command \easy_install.py, line 16, in ? from distutils import log,dir_util ImportError: cannot import name log Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
distutils
Hello again, Is there any patch for python distutils, for this from distutils import log,dir_util ImportError: cannot import name log Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils
On 7 kol, 14:53, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello again, Is there any patch for python distutils, for this from distutils import log,dir_util ImportError: cannot import name log What version of Python are you running with? It looks as though there may be something wrong with your installation if it's recent: [EMAIL PROTECTED] ~/Projects/Python $ python Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type help, copyright, credits or license for more information. from distutils import log import distutils.log regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - Hello, My version of python is 2.4 and I'am running it with Windows XP -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils
On 7 kol, 18:00, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 7 kol, 14:53, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello again, Is there any patch for python distutils, for this from distutils import log,dir_util ImportError: cannot import name log What version of Python are you running with? It looks as though there may be something wrong with your installation if it's recent: [EMAIL PROTECTED] ~/Projects/Python $ python Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type help, copyright, credits or license for more information. from distutils import log import distutils.log Hello, My version of python is 2.4 and I'am running it with Windows XP Your installation must be corrupted, then: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Steve\python24\python Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from distutils import log regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - Hi, Is there any other solution I need this for script installing with setuptools,now I was install and Python 2.5 too,but same error again. PS: I was try your previously example also: cd c:\Python24\python then: from distutils import log - but same error again any other solution? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils
On 7 kol, 19:37, Irmen de Jong [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello again, Is there any patch for python distutils, for this from distutils import log,dir_util ImportError: cannot import name log Regards, Vedran Are you sure you haven't written a module yourself called distutils.py ? (that one will hide the standard distutils module) --irmen I was search for all distutils files and folders and I'am sure there is no distutils except c:\Python24\Lib\distutils Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
wxpython TreeCtrl with os.listdir
Hello, Does anybody know how can I insert os.listdir items in wx python TreeCtrl and every item assign adequately icon on this example import wx class TestFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title=simple tree with icons, size=(400,500)) il = wx.ImageList(16,16) # adequately icons self.fldridx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16,16))) # icon for os.listdir folder self.fldropenidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN,wx.ART_OTHER, (16,16))) # icon for os.listdir file self.fileidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, (16,16))) # icon for os.listdir open folder self.tree = wx.TreeCtrl(self) self.tree.AssignImageList(il) root = self.tree.AddRoot(wx.Object) self.tree.SetItemImage(root, self.fldridx,wx.TreeItemIcon_Normal) self.tree.SetItemImage(root, self.fldropenidx,wx.TreeItemIcon_Expanded) self.AddTreeNodes(root, data.tree) # There must be os.listdir items self.tree.Expand(root) def AddTreeNodes(self, parentItem, items): for item in items: if type(item) == str: newItem = self.tree.AppendItem(parentItem, item) self.tree.SetItemImage(newItem, self.fileidx,wx.TreeItemIcon_Normal) else: newItem = self.tree.AppendItem(parentItem, item[0]) self.tree.SetItemImage(newItem, self.fldridx,wx.TreeItemIcon_Normal) self.tree.SetItemImage(newItem, self.fldropenidx,wx.TreeItemIcon_Expanded) self.AddTreeNodes(newItem, item[1]) def GetItemText(self, item): if item: return self.tree.GetItemText(item) else: return app = wx.PySimpleApp(redirect=True) frame = TestFrame() frame.Show() app.MainLoop() Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
os.listdir path error
Hello Here is my simple listdir example: import os os.listdir(C:\Python24\) # This directory relly exists Here is my error: WindowsError: [Errno 3] The system cannot find the path specified: 'l/ *.*' Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
simple string backspace question
Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran Hi, If you mean on operating system then unfortunately Windows XP. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On 31 srp, 12:03, [EMAIL PROTECTED] (Lawrence Oluyede) wrote: [EMAIL PROTECTED] wrote: If you mean on operating system then unfortunately Windows XP. I don't know for sure but maybe it doesn't support all ASCII escapes codes. Why do you care about \b anyway :-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair Hi, I need this inevitable for my programming language, for code indentation. I don't know how to write script with module tokenize for code indentation. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple string question
On 28 srp, 07:05, Zentrader [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: NEW TEXT : Hello world;\nHello:\n\t\t\n\n\n\n\n\nHello2 If you are doing all of this to format the output into columns, Python's print() or write() will do this, and is easier as well. Some more info on what you want to do will clear things up. Hi, That is confusing me too, so now I will try explain it more.This is text before translation: Let me explain you with python code. I want to this function act code indentation Short_Text=n=90; if n==90:print 'ok' Then now I must write that function for detect ; and :, and if that function detect ; then it appends \n before ; but if detect : then it appends \n\t\t\t\t\t\t\t\t Short_text_after_translation=n=90;\nif n==90:\n\t\t\t\t\t\t\t\tprint 'ok ...And now when we run this code with exec this must look like: n=90; if n==90: print 'ok' I think this will be enough for help. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple string question
On 28 srp, 14:15, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 28 srp, 07:05, Zentrader [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: NEW TEXT : Hello world;\nHello:\n\t\t\n\n\n\n\n\nHello2 If you are doing all of this to format the output into columns, Python's print() or write() will do this, and is easier as well. Some more info on what you want to do will clear things up. Hi, That is confusing me too, so now I will try explain it more.This is text before translation: Let me explain you with python code. I want to this function act code indentation Short_Text=n=90; if n==90:print 'ok' Then now I must write that function for detect ; and :, and if that function detect ; then it appends \n before ; but if detect : then it appends \n\t\t\t\t\t\t\t\t Short_text_after_translation=n=90;\nif n==90:\n\t\t\t\t\t\t\t\tprint 'ok ...And now when we run this code with exec this must look like: n=90; if n==90: print 'ok' I think this will be enough for help. OK, but you don't want that many tab characters if you can the code to look like you show it. It's not, anyway, a good idea to use tabs to indent code. I suspect what you need is to split the code on semicolons first, then re-form lines with colons in them. Some simple code to do this would look *something* like what follows. This will handle a little more than you wanted. Short_Text=n=90; if n==90:print 'ok' compound_lines = Short_Text.split(;) for line in compound_lines: ... line = line.replace(:, :\n) ... print line ... n=90 if n==90: print 'ok' Note there are issues here that I haven't addressed. The first is that leading spaces on the second statement need to be removed, and the second is that this only works at the outermost level of indentation. For example, if you want to end up translating function definitions with if statements inside them correctly you will need to handle multiple levels of indentation. There are other problems, like semicolons and colons inside string constants should be ignored, but the only way to get over those will be to parse the program text according to some grammar rather than using ad-hoc methods such as the above. I hope I have finally been of some assistance ... please reply via the newsgroup, not in personal email. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - Thanks Steve! When first version of this software emerge (after competition) you will get your full version for free. Once again thanks! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
a simple string question
Hello, I have one question about string.I am trying to make an function to analyze line of some text, this is my example: HELLO;HELLO2:WORLD:, if that function in this text find ; and : ( in this example will find both) e.g that function must return this: HELLO;\nHELLO2:\n\t\t\t\t\t\t\tWORLD: Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple string question
On 27 srp, 19:29, Wildemar Wildenburger [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I have one question about string.I am trying to make an function to analyze line of some text, this is my example: HELLO;HELLO2:WORLD:, if that function in this text find ; and : ( in this example will find both) e.g that function must return this: HELLO;\nHELLO2:\n\t\t\t\t\t\t\tWORLD: If I understand you correctly you want to replace ; by ;\n and : by :\n\t\t\t\t\t\t\t. Well guess what? The replace() method does just this. Have a read: URL:http://docs.python.org/lib/string-methods.html /W Hello, No,that's not what I need... When this function detect ; or : ,it must append character \n or \n\t ahead : or ; another e.g 1) text=Hello world;Hello:Hello2 2) When function detect ; or : it must append character \n or \n \t ahead : or ;, so that must look like this: NEW TEXT : Hello world;\nHello:\n\t\t\n\n\n\n\n\nHello2 Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: code indentation
On 26 srp, 13:43, Steve Holden [EMAIL PROTECTED] wrote: Thorsten Kampe wrote: * (Wed, 25 Jul 2007 11:22:03 -0700) On 25 srp, 17:31, Wildemar Wildenburger [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: And while we're on the topic of communication: The original poster would do well to learn that increasing the number of consecutive punctuation marks (!!!, ???) is a sure way to turn away many people who would otherwise be helpful. Sentences need at most one '!' or '?', adding more does not improve the chances of being taken seriously. And if you can help me than please help me , but if you can't then please don't leave me some stupid messages Whats stupid about this? It's sane advice. Which looks more serious to you: this: I can't do it Can you PLEASE help me!!!?! or this: I don't know the answer. Can you please help me? Even if it makes no difference to you, to many people it does. So Ben is right: People *will* take your posts more seriously if you restrict your use of punctuation (if only because its easier to read). Don't feel offended, nobody was trying to put you down. On this group I ask for serious help and now we talk about communication. Then I you don't know how to help me then please DON'T SAY ANYTHING You already got serious help even though you haven't realised that yet. We should be making allowances for this particular poster on account of relative youth: I hadn't realised earlier, but we are dealing with a fourteen-year-old. Since fourteen-year-olds already know everything we should be honored we are being asked for help at all ;-) regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - Hi again, Just one more question, can I maybe do this indentation with string e.g here is my failed example of try with string: kl=n=90;if n==90:print'kajmakimar' for line in kl.split(;): li=[] m=li.append(line) if line.endswith(':'): m.append(\n\t\t\t\t\t\t\t\t) print m .so maybe if you can help me with this? Regards, Vedran (http://www.v-programs.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: code indentation
On 25 srp, 01:07, Ben Finney [EMAIL PROTECTED] wrote: Steve Holden [EMAIL PROTECTED] writes: [EMAIL PROTECTED] wrote: On 24 srp, 05:20, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 23 Jul 2007 16:53:01 -0300, ...:::JA:::... [EMAIL PROTECTED] escribió: So..how can I do this? I will appreciate any help! Try with a simple example. Let's say you want to convert this: [...] [...] Can you give me some example script of this? Please!!! PS: THANKS FOR YOUR TIME!! It's unfortunate that you are having difficulty with two languages simultaneously: your command of English, though impressive, appears to be insufficient for you to explain the problem [...] And while we're on the topic of communication: The original poster would do well to learn that increasing the number of consecutive punctuation marks (!!!, ???) is a sure way to turn away many people who would otherwise be helpful. Sentences need at most one '!' or '?', adding more does not improve the chances of being taken seriously. -- \We have to go forth and crush every world view that doesn't | `\ believe in tolerance and free speech. -- David Brin | _o__) | Ben Finney Hi, I was only ask for help becose I don't understand this tokenize module so well. And if you can help me than please help me , but if you can't then please don't leave me some stupid messages Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: code indentation
On 25 srp, 17:31, Wildemar Wildenburger [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: And while we're on the topic of communication: The original poster would do well to learn that increasing the number of consecutive punctuation marks (!!!, ???) is a sure way to turn away many people who would otherwise be helpful. Sentences need at most one '!' or '?', adding more does not improve the chances of being taken seriously. And if you can help me than please help me , but if you can't then please don't leave me some stupid messages Whats stupid about this? It's sane advice. Which looks more serious to you: this: I can't do it Can you PLEASE help me!!!?! or this: I don't know the answer. Can you please help me? Even if it makes no difference to you, to many people it does. So Ben is right: People *will* take your posts more seriously if you restrict your use of punctuation (if only because its easier to read). Don't feel offended, nobody was trying to put you down. /W HELLO, On this group I ask for serious help and now we talk about communication. Then I you don't know how to help me then please DON'T SAY ANYTHING Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: code indentation
On 24 srp, 05:20, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 23 Jul 2007 16:53:01 -0300, ...:::JA:::... [EMAIL PROTECTED] escribió: If you are using the tokenize module as suggested some time ago, try to analyze the token sequence you get using { } (or perhaps begin/end pairs in your own language, that are easier to distinguish from a dictionary display) and the sequence you get from the real python code. Then write a script to transform one into another: from tokenize import generate_tokens from token import tok_name from cStringIO import StringIO def analyze(source): g = generate_tokens(StringIO(source).readline) for toknum, tokval, _, _, _ in g: print tok_name[toknum], repr(tokval) I think you basically will have to ignore INDENT, DEDENT, and replace NAME+begin with INDENT, NAME+end with DEDENT. So..how can I do this? I will appreciate any help! Try with a simple example. Let's say you want to convert this: for x in range(10): begin print x end into this: for x in range(10): print x Using the analyze() function above, the former block (pseudo-python) gives this sequence of tokens: NAME 'for' NAME 'x' NAME 'in' NAME 'range' OP '(' NUMBER '10' OP ')' OP ':' NEWLINE '\n' NAME 'begin' NEWLINE '\n' NAME 'print' NAME 'x' NEWLINE '\n' NAME 'end' ENDMARKER '' The latter block (real python) gives this sequence: NAME 'for' NAME 'x' NAME 'in' NAME 'range' OP '(' NUMBER '10' OP ')' OP ':' NEWLINE '\n' INDENT ' ' NAME 'print' NAME 'x' DEDENT '' ENDMARKER '' If you feed this token sequence into untokenize, in response you get a source code equivalent to the real python example above. So, to convert your pseudo python into the real python, it's enough to convert the first token sequence into the second - and from that, you can reconstruct the real python code. Converting from one sequence into the other is a programming exercise and has nothing to do with the details of the tokenize module, nor is very Python-specific - looking at both sequences you should figure out how to convert one into the other. (Hint: a few additional newlines are not important) It is even simpler than the example given in the tokenize documentation: http://docs.python.org/lib/module-tokenize.html - which transforms 3.1416 into Decimal(3.1416) by example. Once you get this simple case working, you may try what happens with this: for x in range(10): begin print x end and this: for x in range(10): begin print x end and later this: for x in range(10): begin print x end You are now using explicit begin/end pairs to group statements, so indentation is no more significant. You may want to preprocess the pseudo-python source, stripping any leading blanks, before using tokenize - else you'll get indentation errors (which are bogus in your pseudo-python dialect). Since this will be your own Python dialect, don't expect that someone else will do the work for you - you'll have to do it yourself. But it's not too dificult if you do the things in small steps. In case you get stuck at any stage and have specific questions feel free to ask. -- Gabriel Genellina Hello, Sorry, now I become very nuisance and stupid but please I really need this.Do you remember my topic python changing keywords name ,and do you remember example that you give me for translate keywords? Can you give me some example script of this? Please!!! PS: THANKS FOR YOUR TIME!! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with exec
On 23 srp, 09:19, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 22 Jul 2007 10:36:59 -0300, [EMAIL PROTECTED] escribió: Since the application is transforming its input, it could transform braces into indentation. Of course *Python* doesn't use braces, but the question was how to write pseudo-Python without using indentation to indicate grouping. This previously is exactly what I need can you help me somehow about this code indentation, on any way you know.Plese help I will really appreciate this!! If you are using the tokenize module as suggested some time ago, try to analyze the token sequence you get using { } (or perhaps begin/end pairs in your own language, that are easier to distinguish from a dictionary display) and the sequence you get from the real python code. Then write a script to transform one into another: from tokenize import generate_tokens from token import tok_name from cStringIO import StringIO def analyze(source): g = generate_tokens(StringIO(source).readline) for toknum, tokval, _, _, _ in g: print tok_name[toknum], repr(tokval) I think you basically will have to ignore INDENT, DEDENT, and replace NAME+begin with INDENT, NAME+end with DEDENT. -- Gabriel Genellina Hello, I know what do you mean and I really need that , but I don't know how to I do this. Please help me! It's really important to me Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with exec
On 21 srp, 22:31, Steve Holden [EMAIL PROTECTED] wrote: ...:::JA:::... wrote: Hello, After my program read and translate this code: koristi os,sys; ispisi 'bok kaj ima'; into the: import os,sys; print 'bok kaj ima'; and when it run this code with exec, I always get error like this, but I still dont't know what is a problem: Traceback (most recent call last): File C:\Python24\Lib\site-packages\VL\__init__.py, line 188, in kompajlati kompajlati_proces() File C:\Python24\Lib\site-packages\VL\__init__.py, line 183, in kompajlati_proces h2=Konzola() File C:\Python24\Lib\site-packages\VL\__init__.py, line 158, in __init__ k=kod(ZTextCtrl.GetLabel()) File C:\Python24\Lib\site-packages\VL\__init__.py, line 83, in kod exec(str_ngh) File string, line 1 import os ,sys ; ^ SyntaxError: invalid syntax This is almost certainly because the code contains embedded carriage returns: code = import os,sys;\nprint 'bok kaj ima'; exec code bok kaj ima code = import os,sys;\r\nprint 'bok kaj ima'; exec code Traceback (most recent call last): File stdin, line 1, in module File string, line 1 import os,sys; ^ SyntaxError: invalid syntax PS: How can I change when user write script with my program to he don't need aspirate the lines of his source code e.g. import os,sys n=90 if n==90:print OK else:print No I'm afraid I don't understand this question. If you are talking about the indentation of the code, if you don't want indentation you will have to use braces - { and } - to indicate the nesting structure of your program. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - Hello, Thanks for everything previously, but just to I ask about code indentation,this with { and } doesn't employed, here is my example how can I solve this about code indentation: n=90 if n==90: {print bok kjai ma'} File input, line 2 {print bok kjai ma'} ^ SyntaxError: invalid syntax Thanks!!! Regards,Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with exec
I wasn't playing silly games at all, and I did prefix that part ofmy answer with I'm afraid I don't understand this question. The OP is writing a program to translate a Python-like language that uses non-English keywords into Python. Since the application is transforming its input, it could transform braces into indentation. Of course *Python* doesn't use braces, but the question was how to write pseudo-Python without using indentation to indicate grouping. regards Steve Hi, This previously is exactly what I need can you help me somehow about this code indentation, on any way you know.Plese help I will really appreciate this!! Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Problem with building extension in Python
Hi, I have already install Microsoft visual studio .NET 2003 and MinGw, when I try to build a extension: python my_extension_setup.py build ( or install ) , I get an error: LINK : fatal error LNK1141: failure during build of exports file error: command 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe' failed with exit status 1141.What shoud I do??? If you now anything useful, please contact me!! Thanks!! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to send files via bluetooth with python to a mobile
Drex je napisao/la: Hi, I have been looking on the internet for some info about sending files from PC to a mobile phone (I have a nokia 6288) but I was not able to find anything. there is a lot of info how to transfer files from a symbian phone to a pc, but nothing about sending them in the oposite direction. would anybody point me to some resources on the topic? thanks, regards dz Hi, I'm not sure but try this: ( py_s60 ) http://sourceforge.net/projects/pyed/ regards, vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: how to send files via bluetooth with python to a mobile
[EMAIL PROTECTED] je napisao/la: Drex je napisao/la: Hi, I have been looking on the internet for some info about sending files from PC to a mobile phone (I have a nokia 6288) but I was not able to find anything. there is a lot of info how to transfer files from a symbian phone to a pc, but nothing about sending them in the oposite direction. would anybody point me to some resources on the topic? thanks, regards dz Hi, I'm not sure but try this: ( py_s60 ) http://sourceforge.net/projects/pyed/ regards, vedran Hi again, and also try this: http://sourceforge.net/projects/pys60 regards, vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
Danyelle Gragsone je napisao/la: Hi, Yeah .. if its ubuntu then you have python already installed. I would suggest that you start reading the documentation on your distro. How did you get your distro if you don't know what it is? That concerns me a bit. Ubuntu has alot of documentation as well as a help channel on irc. irc.freenode.net #ubuntu. You can pull up alot of documentation by just typing ubuntu documentation or ubuntu guides in google. good luck! Danyelle On 6/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Danyelle Gragsone je napisao/la: Greetings, Python is usally already installed on most distros. In a terminal window type python to see if something happens. Also please provide what distro you are running. Danyelle On 6/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list Helo, Probably my distro is ubuntu --- I don't what is it, and ' want install/build python from source -- http://mail.python.org/mailman/listinfo/python-list Hi again, This previously was very useful THANKS. I just want ask you is there, is there any folder with that basic Python on ubuntu linux where can I find file Grammar and change the names of python keywords. THANKS AGAIN! -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
Hello, No. The only way to change the keywords would be to edit the Python source and re-compile it. This was very helpful information , I already know that but I don't know how to that.PLEASE HELP ME ABOUT THIS, I WILL BE VERY GRATEFUL TO YOU. ( IF you can please step by step how to I install that source ) THANKS -- http://mail.python.org/mailman/listinfo/python-list
Installing python under the linux
Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
Danyelle Gragsone je napisao/la: Greetings, Python is usally already installed on most distros. In a terminal window type python to see if something happens. Also please provide what distro you are running. Danyelle On 6/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list Helo, Probably my distro is ubuntu --- I don't what is it, and ' want install/build python from source -- http://mail.python.org/mailman/listinfo/python-list
RE: Changing the names of python keywords
Hello, I on working on windows and Python 2.4. Where can I find and CHANGE python grammar. ( I just want to change the keywords ) PLEASE HELP ME SOMEBODY!! THANKS! -- http://mail.python.org/mailman/listinfo/python-list
Python changing keywords name
Hello AGAIN, I on working on windows and Python 2.4. Where can I find and CHANGE python grammar. ( I just want to change the keywords ) PLEASE HELP ME SOMEBODY!! THANKS! -- http://mail.python.org/mailman/listinfo/python-list
RE: Changing the names of python keywords
Hello again, Thanks for everything previously, I was change the grammar and Lib/ keyword.py, now Python recognize koristiti as a keyword, but that is not enough: when I write in my python shell: koristiti os # koristiti get keyword color, but I get error: File input, line 1 koristi os ^ SyntaxError: invalid syntax and now, when I write: import os # import don't get keyword color but still working Please help me,thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Promijena imena pythonovim kljucnim rijecima
Ognjen Bezanov je napisao/la: [EMAIL PROTECTED] escribió: Hello again, Thanks for everything previously, I was change the grammar and Lib/ keyword.py, now Python recognize koristiti as a keyword, but that is not enough: when I write in my python shell: koristiti os # koristiti get keyword color, but I get error: File input, line 1 koristi os ^ SyntaxError: invalid syntax and now, when I write: import os # import don't get keyword color but still working Please help me,thanks Sorry, but I am having some trouble understanding what exactly you are trying to do. Mozda bi bilo lakse da objasnis na neki drugi jezik, sta mislis o tome? Ogi. Pozdrav, (Hrvatski) Pokusavam napraviti nesto kao programski jezik tj. program za 3D modeliranje kodom, u tom programu zelim sve kljucne rijeci iz programskog jezika Python ali i preimenovati kao svoje npr. kada korisnik u mom programu upise: koristiti os ja zelim da moj program to procita kao import os ja sam u file-u Lib/keywords.pyzamijenio kljucnu rijec s koristiti,sada python koristiti prepoznaje kao kljucnu rijec, a import ne.Sada kada napisem: import os # i dalje je sve uredu samo sto import ne dobije boju koristiti os # a kod ovoga koristiti dobije boju kljucne rijeci ali ja dobim gresku: SyntaxError: invalid syntax Molim vas pomoc s ovim se mucim vec mjesec dana,pozdrav i HVALA! -- http://mail.python.org/mailman/listinfo/python-list
Changing the names of python keywords and functions
Hello, I am trying to make a program for 3D modelling with programming.And I want make my own program commands, for example when user type code in my program: koristiti OS- (THIS IS MY IMAGINARY EXAMPLE OF KEYWORD), my program must write this code in some user file, but my program must read this command like: import os.How can I do something like that?? Please, HELP ME somebody!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing the names of python keywords and functions
[EMAIL PROTECTED] je napisao/la: I'm not quite clear on what you are asking, but you can use the __import__() function to import modules by name. I want to invent something like my programming language like Python with the same keywords just changed, for example if user type in my programming language: koristiti os This line of code my program must write in some file, and my program (when it run this user file) must read this line of code like: import os (I just want to change names of keywords) -- http://mail.python.org/mailman/listinfo/python-list