[issue6983] Add specific get_platform() for freebsd
Stef Walter s...@memberwebs.com added the comment: Good plan. So the issue is: * Platform specific eggs are built containing a path that has the full patch level of the freebsd kernel, like 8.2-RELEASE-p2. The -p2 part is updated for every security patch of FreeBSD. * Thus when you apply a security patch to FreeBSD, platform specific eggs built for that version of FreeBSD (before the security patch was applied) are no longer considered compatible. FYI, FreeBSD has an unwritten policy of keeping all 8.x releases backwards compatible with one another. So platform specific eggs built for 8.1 would work without inherent problems on 8.2 or 8.3. But at the very least, platform specific eggs should not be dependent on the patch level of the FreeBSD kernel. On 11/20/2011 03:38 PM, Éric Araujo wrote: Éric Araujo mer...@netwok.org added the comment: This is still a bothersome issue, but we've taken to patching every version of python downstream before deploying them. All for a simple three line patch. Sorry about the unsatisfactory situation. Could we start anew and define exactly what the problem is, so that distutils2 can be free of it? (I’m afraid distutils can’t be changed: even undocumented, the platform string used for FreeBSD is certainly used by tools out there that we don’t want to break. I second the suggestion to bring up the issue to the projects responsible for eggs, i.e. setuptools and distribute, not distutils.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6983 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6983 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ANN] Android Debug Bridge (ADB) Scripting Language For Android (SL4A) convenience library
hello, The information on ADB / SL4A is quiet overwhelming. Despite that, especially for people, not familiar with Linux, it's not an easy task to get their first program running. This library allows you to easy upload and run Python files on a Android device, without pressing any button on the Android device. After installing SL4A and Py4A on the Android device, and ADB on the hostmachine, it's just a matter of connecting the USB cable between Android device and host-PC, and run the program. One of the simplest program that will run out of the box (without touching any button on the Android device) : # * from adb_sl4a_support import ADB_Connection ADB = ADB_Connection () print ADB # Create a simple program Simple_Program = import android droid = android.Android (( '%s', %s )) droid.makeToast ( Wasn't that easy?) % ( ADB.SL4A_Servers [-1][0], ADB.SL4A_Servers [-1][1] ) # execute the program (this will run the program from the host PC !!) exec ( Simple_Program ) # * you can find the library here: http://code.google.com/p/pylab-works/downloads/detail?name=adb_sl4a_support.pycan=2q= cheers, Stef -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN] Android Debug Bridge (ADB) Scripting Language For Android (SL4A) convenience library
hello, The information on ADB / SL4A is quiet overwhelming. Despite that, especially for people, not familiar with Linux, it's not an easy task to get their first program running. This library allows you to easy upload and run Python files on a Android device, without pressing any button on the Android device. After installing SL4A and Py4A on the Android device, and ADB on the hostmachine, it's just a matter of connecting the USB cable between Android device and host-PC, and run the program. One of the simplest program that will run out of the box (without touching any button on the Android device) : # * from adb_sl4a_support import ADB_Connection ADB = ADB_Connection () print ADB # Create a simple program Simple_Program = import android droid = android.Android (( '%s', %s )) droid.makeToast ( Wasn't that easy?) % ( ADB.SL4A_Servers [-1][0], ADB.SL4A_Servers [-1][1] ) # execute the program (this will run the program from the host PC !!) exec ( Simple_Program ) # * you can find the library here: http://code.google.com/p/pylab-works/downloads/detail?name=adb_sl4a_support.pycan=2q= cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: (don't bash me too hard) Python interpreter in JavaScript
On 15-11-2011 21:37, Passiday wrote: Hello, I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? skulpt ? cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
[issue6983] Add specific get_platform() for freebsd
Stef Walter s...@memberwebs.com added the comment: Shrug. I guess you can close it. This is still a bothersome issue, but we've taken to patching every version of python downstream before deploying them. All for a simple three line patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6983 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
how to make a nested list
hello, I need a nested list, like this A= [ [None,None], [None,None], [None, None] ] A[2][0] =77 A [[None, None], [None, None], [77, None]] Because the list is much larger, I need a shortcut (ok I can use a for loop) So I tried B = 3 * [ [ None, None ]] B[2][0] = 77 B [[77, None], [77, None], [77, None]] which doesn't work as expected. any suggestions ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
and becomes or and or becomes and
hello, must of us will not use single bits these days, but at first sight, this looks funny : a=2 b=6 a and b 6 a b 2 a or b 2 a | b 6 cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
maybe useful : datetime conversion
hello, using datetimes from a lot of different sources, in many languages, I had about 30 python helper routines, which I now packed in one class, much simpler. Although I used the Delphi date-format as the base, it shouldn't be difficult to rewrite the class for another type. The input can be one of the following types : - None: the current date-time is used - 3.9 : a Delphi datetime - 3 : a Delphi datetime - 3.9 : a Delphi datetime as a string - 3,9 : a Delphi datetime as a (Dutch) string - 20-5-11 : short year notation - 20-05-2011 : long year notation - 2009-09-24 10:12:24 : Access string - datetime.datetime ( 2011, 1, 15 ) - time.struct_time - wx.DateTime - time.time() (through method from_time) Maybe someone can use it. cheers, Stef import time import datetime import wx Delphi_Date_0 = datetime.date ( *time.strptime ( '30-12-1899', '%d-%m-%Y' )[0:3]).toordinal() # # class Delphi_Date ( float ) : def __new__ ( self, Something = None ) : Class meant to handle any datetime type, and converts it basically to a Delphi DateTime (float: number of days since 1-1-1900). The input can be one of the following types : - None: the current date-time is used - 3.9 : a Delphi datetime - 3 : a Delphi datetime - 3.9 : a Delphi datetime as a string - 3,9 : a Delphi datetime as a (Dutch) string - 20-5-11 : short year notation - 20-05-2011 : long year notation - 2009-09-24 10:12:24 : Access string - datetime.datetime ( 2011, 1, 15 ) - time.struct_time - wx.DateTime with extra methods, also the following can be used - from_time : time.time float The following output methods are available - to_time () - to_datetime () - to_String ( self , Format = %d-%m-%Y ) - to_String_Short () - to_String_Date_Time_Short () - to_String_Time_Short () - to_String_Date_Time () - to_wxTime () - to_Iso () # The current date-time is used, if no parameter is specified if Something is None : Something = datetime.datetime.now () # floating point is assumed to be a Delphi datetime # to specify a time.time float, use the method from_time # Delphi_Date().from_time ( time.time() # which is equivalent to # Delphi_Date() if isinstance ( Something, float ) : Value = Something # sometimes a Delphi datetime is stored as an integer elif isinstance ( Something, int ) : Value = Something # A string can represent a lot of things elif isinstance ( Something, basestring ) : # a float or integer, # also the Ducth notation where deceimal separator is a comma try : Value = float ( Something.replace(',','.') ) except : # a string as a short year notation try : Value = datetime.datetime.strptime ( Something, '%d-%m-%y' ) except ValueError : # a string as a long year notation try: Value = datetime.datetime.strptime ( Something, '%d-%m-%Y' ) except : # a string as a (Dutch) Access notation try : # Access string : 2009-09-24 00:00:00 Value = datetime.datetime.strptime ( Something.split(' ')[0], %Y-%m-%d ) except : Value = Delphi_Date_0 import traceback traceback.print_exc Value = Value.toordinal() - Delphi_Date_0 # datetime.datetime () elif isinstance ( Something, datetime.datetime ) : Value = Something.toordinal() - Delphi_Date_0 # time.struct_time elif isinstance ( Something, time.struct_time ) : Value = time.mktime ( Something ) DT = datetime.datetime.fromtimestamp ( Value ) Value = DT.toordinal() - Delphi_Date_0 # wx.DateTime elif isinstance ( Something, wx.DateTime ) : DT = datetime.date ( Something.GetYear (), Something.GetMonth () + 1, Something.GetDay () ) Value = DT.toordinal() - Delphi_Date_0 else : print type(Something), Something raise error ( 'aap' ) return float.__new__ ( self, Value ) def from_time ( self, Time ) : DT = datetime.datetime.fromtimestamp ( Time ) return Delphi_Date ( DT ) def to_time ( self ): return time.mktime ( self.to_datetime().timetuple() ) def to_datetime ( self ) : #return datetime.datetime.fromordinal ( int ( round ( self + Delphi_Date_0 ))) return datetime.datetime.fromordinal ( self + Delphi_Date_0 ) def to_String ( self , Format = %d-%m-%Y ) : DT = self.to_datetime() try : return DT.strftime ( Format ) except : return '01-01-1900' def
is there an autocompletion like Dasher ?
hello, I would like to have a autocompletion / help /snippet system like Dasher : http://www.inference.phy.cam.ac.uk/dasher/ anyone seen such a component ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an autocompletion like Dasher ?
On 08-05-2011 01:28, Dan Stromberg wrote: On Sat, May 7, 2011 at 3:40 PM, Stef Mientki stef.mien...@gmail.com mailto:stef.mien...@gmail.com wrote: hello, I would like to have a autocompletion / help /snippet system like Dasher : http://www.inference.phy.cam.ac.uk/dasher/ anyone seen such a component ? Ummm... For what OS and what hardware? Windows desktop (and webbrowser would be nice) Do you need something that was written in Python? preferable thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you use with Python for GUI programming and why?
On 11-03-2011 22:45, Dan Stromberg wrote: On Fri, Mar 11, 2011 at 12:54 PM, Fred Pacquier xne...@fredp.lautre.net mailto:xne...@fredp.lautre.net wrote: Robert sigz...@gmail.com mailto:sigz...@gmail.com said : Is there a push to one toolkit or the other? If you are just now getting started, I would honestly suggest you save a whole lot of time and dive straight into PyQt. I've tried most 'em over the years (including some now discontinued), and in my experience Qt is way above the rest, especially as far as consistency and productivity are concerned. The Python bindings are very mature and well maintained, and go a long way attenuating the evil C++ roots. I havent tried Nokia's equivalent (PySide). I'm not sure what its fate will turn out, given the company's change of heart and Microsoft honeymoon. At least PyQt is't going anywhere soon. Didn't Nokia acquire Trolltech (and hence the rights to much if not all of Qt) in 2008? yep, and they just sold the commercial part of QT to Digia. I'm not at all sure Qt's future is as bright as one might wish for. They've already declared that Qt will not be ported to Windows Mobile in any official way, and of course mobile (not necessarily Windows Mobile) is where just about everything is headed. And Nokia is talking with Micraosoft about using theirs Phone 7 Actually, for something that's very cross-platform, you might check this out: http://radicalbreeze.com/ Bryan can be a bit of a goober, but it sounds like he's successfully implemented a great idea for quickly and easily writing cross-platform applications. another way of reaching the same goal, is to use a wrapper that supports the different backends. As I found wxPython much too difficult (I was a Delphi guy), I started directly with a wrapper when I started using wxPython a few years ago. In the meanwhile I've extended (very experimental) the wrapper so it not only supports wxPython, but also PyJamas, PySide and PyGUi. cheers, Stef Illumination even gives you the full Adobe Flex, Android Java, iOS Obj-C and Python source code to the projects you create. Making it a great way to prototype new projects, or learn new languages. I've still got a soft spot for Pyjamas though - it's opensource. -- http://mail.python.org/mailman/listinfo/python-list
SQLite server using execnet ?
hello, knowing that SQllite is not a client/server database, still want to see if a simple client/server setup would solve my current problems for the moment (because I love the simplicity of SQLlite, and planned to go to a client / server database in the future) Now I wonder if anyone has considered to use Python execnet-module to realize a simple SLQlite client / server application. If I look at the documentation of execnet, (and I realize that I'm a great optimist) it would take between 20 and 50 lines of Python code. thanks very much for your opinions. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to decide between PHP and Python
As to choice between Python and PHP, I would say learn anything but PHP. Even Perl has fewer tentacles than PHP. type this in a form field 2.2250738585072011e-308 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError: global name 'btn_Matlab' is not defined ?
On 28-12-2010 15:15, Steven D'Aprano wrote: On Tue, 28 Dec 2010 14:34:19 +0100, Stef Mientki wrote: hello, Never seen this before and I've no explanation whatsoever (Python 2.6) I've some dynamic generated code, one of objects generated is a wx.Button, called 'btn_Matlab'. How do you generate the code? What code is generated? What does it do? After the code is generated, I can see that the button is created in the local namespace print locals()['btn_Matlab'] wx._controls.Button; proxy of Swig Object of type 'wxButton *' at 0x3602d28 but if I try to print the button (at exactly the same location), I get an error print btn_Matlab NameError: global name 'btn_Matlab' is not defined ? Why isn't the compiler first checking the local namespace ? any clues ? My guess is that you've declared btn_Matlab as global, and then dynamically created a local with the same name using exec or similar. thanks Stevem, I found a solution. I indeed tried to inject local variables from a stack a few levels deeper, which doesn't seem to be possible (or reliable). The documentation isn't overwhelming about that point, exec and eval doesn't mention anything, but execfile warms for this issue. The code now looks something like this: self.p_locals = sys._getframe ( StackUp ).f_locals self.p_globals = sys._getframe ( StackUp ).f_globals Component = eval ( defi[1], self.p_globals, self.p_locals ) ( Parent, **Extra ) self.p_globals[ 'Component' ] = Component if 'self' in defi[0] : exec ( '%s = Component' %( defi[0] ), self.p_globals, self.p_locals ) else : exec ( '%s = Component' %( defi[0] ), self.p_globals) cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: The good, the bad, and the ugly!
On 30-12-2010 02:03, rantingrick wrote: On Dec 29, 6:41 pm, Gerry Reno gr...@verizon.net wrote: wxPython looks good but I don't see anyone developing support for things like smartphones. No wx is not the answer to our problems Just partial ;-) Why not write a (Pythonic) wrapper and choose what will be under neat it ? My personal situation at this moment: * for desktop applications we basically use wxPython * the use of sizers in wxPython is not easy and full of cross-pointers with useless names. Therefor we already used a wrapper for wxPython. * for components missing in wxPython, we embed PySide-QT and Delphi components in wxPython * for server-side web applications we use web2py * for client-side web applications we use PyJamas * for mobile devices we use PocketPyGUI * as PySide-QT is making a huge progress at the moment and has improved licenses, (and might be usable for mobile devices) we might want to move gradually from wxPython to PySide-QT Right at this moment, I'm writing a new wrapper, that already can handle (in a simple way) wxPython and PySide-QT(partial). After this works fully, PyJamas and Web2pY will be added (PockectPyGui can probably fully be replaced by QT) cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
NameError: global name 'btn_Matlab' is not defined ?
hello, Never seen this before and I've no explanation whatsoever (Python 2.6) I've some dynamic generated code, one of objects generated is a wx.Button, called 'btn_Matlab'. After the code is generated, I can see that the button is created in the local namespace print locals()['btn_Matlab'] wx._controls.Button; proxy of Swig Object of type 'wxButton *' at 0x3602d28 but if I try to print the button (at exactly the same location), I get an error print btn_Matlab NameError: global name 'btn_Matlab' is not defined ? Why isn't the compiler first checking the local namespace ? any clues ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]
On 17-12-2010 17:02, Adam Tauno Williams wrote: On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote: Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and i'd like to base on something actual. I do not *believe* this is true. http://pypi.python.org/pypi/cloudooo/1.0.9 for instance is Python 2.6 and uses PyUNO. I would strongly recommend against floundering about in OOo's very complex XML files - it is trivially easy to render a document unusable. looks great, but is there something alike for Windows ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: python-parser running Beautiful Soup needs to be reviewed
I've no opinion. I'm just struggling with BeautifulSoup myself, finding it one of the toughest libs I've seen ;-) Really? While I'm by no means an expert, I find it very easy to work with. It's very well structured IMHO. I think the cause lies in the documentation. The PySide documentation is much easier to understand (at least for me) http://www.pyside.org/docs/pyside/PySide/QtWebKit/QWebElement.html cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: python-parser running Beautiful Soup needs to be reviewed
On 11-12-2010 17:24, Martin Kaspar wrote: Hello commnity i am new to Python and to Beatiful Soup also! It is told to be a great tool to parse and extract content. So here i am...: I want to take the content of a td-tag of a table in a html document. For example, i have this table table class=bp_ergebnis_tab_info tr td This is a sample text /td td This is the second sample text /td /tr /table How can i use beautifulsoup to take the text This is a sample text? Should i make use soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get the whole table. See the target http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323 Well - what have we to do first: The first thing is t o find the table: i do this with Using find rather than findall returns the first item in the list (rather than returning a list of all finds - in which case we'd have to add an extra [0] to take the first element of the list): table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'}) Then use find again to find the first td: first_td = soup.find('td') Then we have to use renderContents() to extract the textual contents: text = first_td.renderContents() ... and the job is done (though we may also want to use strip() to remove leading and trailing spaces: trimmed_text = text.strip() This should give us: print trimmed_text This is a sample text as desired. What do you think about the code? I love to hear from you!? I've no opinion. I'm just struggling with BeautifulSoup myself, finding it one of the toughest libs I've seen ;-) So the simplest solution I came up with: Text = table class=bp_ergebnis_tab_info tr td This is a sample text /td td This is the second sample text /td /tr /table Content = BeautifulSoup ( Text ) print Content.find('td').contents[0].strip() This is a sample text And now I wonder how to get the next contents !! cheers, Stef greetings matze -- http://mail.python.org/mailman/listinfo/python-list
is it possible to see if a class has a decorator ?
hello, I would like to know if a class definition has a decorator, is that possible ? And if so, is it possible to determine the name of these decorator(s) ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to see if a class has a decorator ?
On 06-12-2010 12:08, Ben Finney wrote: Stef Mientki stef.mien...@gmail.com writes: I would like to know if a class definition has a decorator, I'm not sure what this question means. Applying a decorator to a class definition produces a normal class. Classes don't “have” decorators; classes can be returned by a decorator function, but AFAIK the resulting class doesn't “have” the decorator in any sense. is that possible ? The return value of a decorator isn't special in any way, AFAIK. Any function can return a class object or a function object, and any function can be used as a decorator. The only thing that makes a function a decorator is how it is used in the code; but it doesn't leave a trace that I know of. Now, what is it you're trying to do? Perhaps there's a better solution we can come up with. Thanks Ben, here some more explanation. I've a number of (dynamic) applications, launched from a central wrapper. All these modules have a class Start, which launches the application and embeds them in the wrapper application. Module 1: class Start (): Module 2: @auth class Start (): ... When the wrapper application is started, it looks for all dynamic modules (without importing them), and list these application in a hierarchical tree. In the above axmple, I would like to know that the class Start in Module 2 has the decorator Auth, *without importing the module*, (so depending on the user logged in, I can decide to add or not add the module to the hierarchical tree). thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to see if a class has a decorator ?
On 06-12-2010 16:04, Jean-Michel Pichavant wrote: Stef Mientki wrote: On 06-12-2010 12:08, Ben Finney wrote: Stef Mientki stef.mien...@gmail.com writes: I would like to know if a class definition has a decorator, I'm not sure what this question means. Applying a decorator to a class definition produces a normal class. Classes don't “have” decorators; classes can be returned by a decorator function, but AFAIK the resulting class doesn't “have” the decorator in any sense. is that possible ? The return value of a decorator isn't special in any way, AFAIK. Any function can return a class object or a function object, and any function can be used as a decorator. The only thing that makes a function a decorator is how it is used in the code; but it doesn't leave a trace that I know of. Now, what is it you're trying to do? Perhaps there's a better solution we can come up with. Thanks Ben, here some more explanation. I've a number of (dynamic) applications, launched from a central wrapper. All these modules have a class Start, which launches the application and embeds them in the wrapper application. Module 1: class Start (): Module 2: @auth class Start (): ... When the wrapper application is started, it looks for all dynamic modules (without importing them), and list these application in a hierarchical tree. In the above axmple, I would like to know that the class Start in Module 2 has the decorator Auth, *without importing the module*, (so depending on the user logged in, I can decide to add or not add the module to the hierarchical tree). thanks, Stef Mientki You best bet is to parse the source file. thanks, I was afraid of that. cheers, Stef JM -- http://mail.python.org/mailman/listinfo/python-list
Re: A web site using Python
On 04-12-2010 15:54, hid...@gmail.com wrote: I am working on a tool that can create an application like that without write server code, but the system is write in Python3.1 very interesting, could you give us some more information about the project for the OP: with web2py, your site could be up within an hour. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On 04-12-2010 23:42, Jorge Biquez wrote: Hello all. Newbie question. Sorry. As part of my process to learn python I am working on two personal applications. Both will do it fine with a simple structure of data stored in files. I now there are lot of databases around I can use but I would like to know yoor advice on what other options you would consider for the job (it is training so no pressure on performance). One application will run as a desktop one,under Windows, Linux, Macintosh, being able to update data, not much, not complex, not many records. The second application, running behind web pages, will do the same, I mean, process simple data, updating showing data. not much info, not complex. As an excersice it is more than enough I guess and will let me learn what I need for now. Talking with a friend about what he will do (he use C only) he suggest to take a look on dBase format file since it is a stable format, fast and the index structure will be fine or maybe go with BD (Berkley) database file format (I hope I understood this one correctly) . Plain files it is not an option since I would like to have option to do rapid searches. What would do you suggest to take a look? If possible available under the 3 plattforms. Thanks in advance for your comments. Jorge Biquez You should take a look at one of the database wrappers. I use the DAL of Web2Py, the main advantages are - easy use of database (more easy than SQL) - easy migration of database structure (is done automatically) - same interface on desktop and in web applications - all major database (including SQLite and Postgres) supported and can be switched easily cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: building a web interface
On 20-11-2010 23:40, Shel wrote: Hello, I am pretty new to all this. I have some coding experience, and am currently most comfortable with Python. I also have database design experience with MS Access, and have just created my first mySQL db. So right now I have a mySQL db structure and some Python code. My end goal is to create a browser-based interactive fiction/game thing. My code is currently just using dummy data rather than pulling in data from the db, but I think/hope it won't be too big of a deal to interact with the db through Python (famous last words...). My main problem right now is how to do the web interface. I don't know much about web architecture, unfortunately. I think I need a CGI script? What I would really like is to find a GUI tool to design the interface that would have customizable templates or drag-and-drop elements or something, so I wouldn't have to code much by hand. Something easy, if such a tool exists. Also would prefer something that I would be able to install/use without having much access to the server where the site will be hosted (on a university server that I don't have control over). I don't fully understand how a lot of the tools I have been looking at work, but it seems like they're often things where you'd have to get an administrator to do stuff on the server (is that right?), which I would prefer to avoid. It looks like Django has some sort of standalone implementation, but I'm not clear on how that would work or how much of a learning curve there would be for using it. If anyone has any thoughts or suggestions, I would really appreciate it. Hope my questions make sense. I don't really know what I'm doing, so could be they're a bit silly. I apologize if that's the case, and please let me know if you need any additional informmation. Thanks, Shel you might take a look at web2py, it can be handled quit low level, runs perfectly on a the build python server, and you switch to almost any database at any time cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: What was your strategy?
On 14-11-2010 23:32, Jorge Biquez wrote: Hello all. Quick question. I know some of you are with Python since started, some other maybe later. I was wondering if you can share what was the strategy you followed to master Python (Yes I know I have to work hard study and practice a lot). I mean did you use special books, special sites, a plan to learn each subject in a special way. I would like to know, if possible, comments specially from some of you who in the past had other languages, frameworks and platforms and left (almost) all of them and stayed with Python. Thanks in advance Jorge Biquez I think you have to start with determining a goal, some kind of application you want or like to create. Learning to program without a goal (which good well be school assignments) is in my opinion fruitless. Secondly you've to decide if the application will be an old fashion desktop application or a modern web application, or maybe even, it should start as a desktop application and should be easily be converted to a webappplication in the future. (btw I mainly write desktop applications ;-) When you've a goal and a global scope, you can find the right tools: language (Python of course), IDE, framework, etc. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. Steve I agree with you, but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) cheers, Stef regards Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11-11-2010 19:36, david wright wrote: *From:* Stef Mientki stef.mien...@gmail.com *To:* python-list@python.org *Sent:* Thu, November 11, 2010 10:20:03 AM *Subject:* Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ? On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. - Steve I agree with you, - but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) So, assuming you want the 'straight ahead' (i.e. no framework, like Django) your looking at vanilla CGI programming. form = cgi.FieldStorage() # parse query string, handles decoding and GET and POST print pname:, form[name].value http://docs.python.org/library/cgi.html thanks David, looks that was what I was looking for, I'll investigate all the properties of Fieldstorage. thanks, Stef Enjoy! :) David -- http://mail.python.org/mailman/listinfo/python-list
Re: JavaScript vs Python
On 09-11-2010 10:25, Lawrence D'Oliveiro wrote: In message mailman.757.1289287828.2218.python-l...@python.org, Chris Rebert wrote: On Mon, Nov 8, 2010 at 10:52 PM, Lawrence D'Oliveiro l...@geek-central.gen.nz wrote: Because JavaScript is actually a decent language in its own right. The Good Parts of it anyway. Python, too, has its good parts, you have to admit... And there's a (or even more) Python to JS compilers, I never heard of a JS to Python compiler. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: utf-8 coding sometimes it works, most of the time it don't work.
hello Uli, thanks, I think you hit the nail on it's head, PyScripter indeed changes default encoding but .. On Wed, Sep 22, 2010 at 9:16 AM, Ulrich Eckhardt eckha...@satorlaser.comwrote: Stef Mientki wrote: When running this python application from the command line ( or launched from another Python program), the wrong character encoding (probably windows-1252) is used. Rule #1: If you know the correct encoding, set it yourself. This particularly applies to files you open yourself (use the codec module). In the case of your program, I guess the stream with the faulty encoding is stdin/stdout, who's encoding is guessed by Python, but which you can override. Check sys.stdin.encoding. None, So I guess it's using the windows default, which is windows-1252, and it's ReadOnly so I can't change it. Can you tell me how I change the default Python encoding, or how to set the encoding in Popen, this is the statement I use to launch my program subprocess.Popen ( [ 'python', Filename ] ) thanks, Stef Mientki When I run this program from PyScripter ( either internal engine or remote engine), MSHTML shows the correct character encoding, perfect! Interesting, I would say that PyScripter sets up the environment differently, so that Python guesses a different encoding. Also make sure both are calling the same Python, I get 'cp850' or 'US-ASCII' depending on whether I call the native MS Windows Python or the Cygwin Python. In the main file, and in the major files that constains strings I've added the following 2 lines: # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals This shouldn't matter. This just tells Python that the sourcecode itself is encoded in UTF-8 and that you want to use Unicode names in your string literals, it doesn't affect the output of your program. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
utf-8 coding sometimes it works, most of the time it don't work.
hello, I've a pyjamas application (python to javascript translator), that can be run (as pure python) in MSHTML (IE Com interface) . When running this python application from the command line ( or launched from another Python program), the wrong character encoding (probably windows-1252) is used. When I run this program from PyScripter ( either internal engine or remote engine), MSHTML shows the correct character encoding, perfect! In the main file, and in the major files that constains strings I've added the following 2 lines: # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals From the Pyjamas and PyScripter group I've no answer untill now. any clues where to look for the problem ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a way to get the encoding of python file
On 12-09-2010 19:28, Robert Kern wrote: On 9/12/10 4:14 AM, Stef Mientki wrote: hello, Is it possible to get the encoding of a python file from the first source line, (if there's any), after importing it ( with '__import__' ) # -*- coding: windows-1252 -*- The regular expression used to match the encoding declaration is given here: http://docs.python.org/reference/lexical_analysis.html#encoding-declarations yes, but then I've to read the first line of the file myself. In the meanwhile I found another (better ?) solution, (I'm using Python 2.6) Place these 2 lines at the top of the file # -*- coding: windows-1252 -*- from __future__ import unicode_literals or these # -*- coding: utf-8 -*- from __future__ import unicode_literals then you always get the correct unicode string back. thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
is there a way to get the encoding of python file
hello, Is it possible to get the encoding of a python file from the first source line, (if there's any), after importing it ( with '__import__' ) # -*- coding: windows-1252 -*- thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a library/program that converts sqlite database from windows-1252 to utf-8 ?
On 12-09-2010 00:07, Robert Kern wrote: On 9/11/10 4:45 PM, Stef Mientki wrote: On 11-09-2010 21:11, Robert Kern wrote: SQLite internally stores its strings as UTF-8 or UTF-16 encoded Unicode. So it's not clear what you mean when you say the database is windows-1252. Can you be more specific? I doubt that, but I'm not sure ... From the documentation, it looks like SQLite does not attempt to validate the input as UTF-8 encoded, so it is possible that someone pushed in raw bytes. See Support for UTF-8 and UTF-16 in the following page: http://www.sqlite.org/version3.html For some databases written by other programs and written with Python, with cursor = self.conn.cursor () self.conn.text_factory = str Can only be read back with with text_factory = str then the resulting string columns contains normal strings with windows 1252 coding, like character 0xC3 You can probably use self.conn.text_factory = lambda x: x.decode('windows-1252') to read the data, though I've never tried to use that API myself. You will need to write a program yourself that opens one connection to your existing database for reading and another connection to another database (using the defaults) for writing. Then iterate over your tables and copy data from one database to the other. You may also be able to simply dump the database to a text file using sqlite3 bad-database.db .dump bad-sql.sql, read the text file into Python as a string, decode it from windows-1252 to unicode and then encode it as utf-8 and write it back out. Then use sqlite3 good-database.db .read good-sql.sql to create the new database. I've never tried such a thing, so it may not work. Yes, I think I've to do somethhing like that, to conserve the structure and field types, it's even more complex. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
is there a library/program that converts sqlite database from windows-1252 to utf-8 ?
thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a library/program that converts sqlite database from windows-1252 to utf-8 ?
On 11-09-2010 21:11, Robert Kern wrote: SQLite internally stores its strings as UTF-8 or UTF-16 encoded Unicode. So it's not clear what you mean when you say the database is windows-1252. Can you be more specific? I doubt that, but I'm not sure ... For some databases written by other programs and written with Python, with cursor = self.conn.cursor () self.conn.text_factory = str Can only be read back with with text_factory = str then the resulting string columns contains normal strings with windows 1252 coding, like character 0xC3 Reading these databases with text_factory = unicode, results in exceptions, when such a string with 0xC3 is encountered. As I want to switch completely to unicode, to prevent these kind of problems in the future. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
are there pros or contras, keeping a connection to a (sqlite) database ?
hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this: self.conn = sqlite3.connect ( self.filename ) Now I wonder if there are pros or contras to keep the connection to the database continuously open ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: State Machines in Python
On 04-09-2010 15:36, Jack Keegan wrote: Hi girls guys, Just joined the group. I'm new to Python but been picking it up pretty easy. I love it! I'm hoping to use it to make a controlling application for an experiment. Basically I want to use it to interface with some data acquisition (DAQ) hardware to accept incoming signals and respond sending signals to the outputs. I'm looking for an efficient State Machine algorithm as I need the timing to be as good as possible. What is as good as possible, 1 usec, 1 msec ? What operating system are you using ? Are you planning feedback ? For a comparison, I did a few years ago sampling in Python, with NI cards (they ensure time accuracy which can never be achieved in software), 50 kHz (divided over 1 to 8 channels), 32 bit, storage and graphical display, and processor activity was about 10%. Maybe you should also look at what those radio guys from gnu radio achive. cheers, Stef As there is no switch statement in Python, I've been looking around for a good implementation. Most of the algorithms I've come across seem to be based on parsing applications. I'd like something more suited to my needs. I'd like to avoid excessive use of 'if-elif-else' statements as each would have to be checked to find the right conditions which would have an time overhead involved. I have seen an implementation of the switch using dictionaries but someone had commented that creating and throwing away dictionaries also comes at a cost. I was wondering if any of you could advise or point me in the right direction. Any help would be greatly appreciated. Thanks, Jack -- http://mail.python.org/mailman/listinfo/python-list
what is this kind of string: b'string' ?
in winpdb I see strings like this: a = b'string' a 'string' type(a) type 'str' what's the b doing in front of the string ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Editor or IDE ActiveX control
On 27-08-2010 00:22, Thomas Jollans wrote: On Thursday 26 August 2010, it occurred to Sathish S to exclaim: Hi Ppl, Is there any python IDE or editor that has an ActiveX control which could be embed in other Windows applications. I'm basically looking to write a application that can show the indentations of python, change the color of keywords etc on a application, which will save this python script and run it from command prompt. It sounds to me like you're just looking for any old halfway decent embeddable programmer's editor that happens to have syntax definitions for Python. I'd suggest you have a look at Scintilla. Quite a good editing control, I don't think it comes wrapped in ActiveX or anything like that, just interface it in your favourite language using the DLL's C API. Scintilla is full embedded in wxPython. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Save/load like matlab?
On 23-08-2010 21:44, Daniel Fetchinson wrote: I wonder if there is a way to save and load all python variables just like matlab does, so I can build a code step by step by loading previous states. I am handling a python processing code for very large files and multiple processing steps. Each time I find a bug, I have to run the whole thing again, which is time consuming. Perhaps pickle is the thing you are looking for? http://docs.python.org/library/pickle.html or even cpickle which is lot faster cheers, Stef HTH, Daniel -- http://mail.python.org/mailman/listinfo/python-list
does someone has a binary 32-bit windows installer for arac ?
thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Opinions please -- how big should a single module grow?
On 09-07-2010 06:37, Steven D'Aprano wrote: This is a style question rather than a programming question. How large (how many KB, lines, classes, whatever unit of code you like to measure in) should a module grow before I should break it up into a package? I see that, for example, decimal.py is 3000 lines of code, so I can assume that 3 KLOC is acceptable. Presumably 3000 KLOC is not. Where do you draw the line? For the purposes of the discussion, you should consider that the code in the module really does belong together, and that splitting it into sub- modules would mean arbitrarily separating code into separate files. interesting question. From the answers already given, I assume it doesn't matter, as long as all the functionality in that module is related. Would it be a good idea to split a module in 2 parts, part 1 : everything that would normally accessible from the outside part 2 : everything that is only used inside the module I think in this way a user of the module (that doesn't know the module yet) has a far more easier entrance. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Anyone using GPG or PGP encryption/signatures in your Python apps?
On 02-07-2010 09:39, geremy condra wrote: On Thu, Jul 1, 2010 at 11:48 AM, pyt...@bdurham.com wrote: Curious if any of you are using GPG or PGP encryption and/or signatures in your Python apps? Yes; disclaimer: I'm the author of evpy and am currently working on a openssl wrapper proposed for inclusion in the stdlib. Great Geremy !, but it's difficult to find, and I couldn't find any documentation. Did I not look at the right places ? thanks Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Hwy doesn't len(None) return zero ?
hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result ) 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result ) 1 ) : So I wonder why len is not allowed on None and if there are objections to extend the len function . thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Hwy doesn't len(None) return zero ?
On 30-06-2010 20:56, Gary Herron wrote: On 06/30/2010 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result ) 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result ) 1 ) : So I wonder why len is not allowed on None and if there are objections to extend the len function . thanks, Stef Mientki Because the natural interpretation of len only makes sense for concepts such as a container or collection. The value None is no such thing. Assigning a meaning to len(None) begs the question of meanings for len(True), len(False), len(3.14), len(sys), ... This is a slippery slope, best avoided. But there are solutions: 1. Have your functions return [] or () or whatever.If they are to return a list, and the list may be empty, [] is correct. thanks guys, I think that will be the best idea. cheers, Stef 2. If you insist on a function returning a list sometimes and other values at other times (such as None), then be prepared to write your code which uses the result with test to determine which type was returned. Fortunately that's not hard, as your one example shows. 3. Create a test function Empty(Result) which does what you want returning a boolean and write your tests as: if Empty(Result): ... Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: Will and Abe's Guide to Pyjamas
On 14-06-2010 17:53, lkcl wrote: oh look - there's a common theme, there: web technology equals useless :) this is getting sufficiently ridiculous, i thought it best to summarise the discussions of the past few days, from the perspective of four-year-olds: http://pyjs.org/will_and_abe_guide_to_pyjamas.html l. and how does this fit in ? http://pyxpcomext.mozdev.org/samples.html cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: GUIs - A Modest Proposal
Aren't all programms going webbased in the near future ? And if so, wouldn't it be better to hook to GWT or something like that (I can't oversee all the conesquences)? cheers, Stef Mientki On 06-06-2010 04:22, ant wrote: I get the strong feeling that nobody is really happy with the state of Python GUIs. Tkinter is not widely liked, but is widely distributed. WxPython and PyGtk are both powerful, but quirky in different ways. PyQt is tied to one platform. And there are dozens more. Whether or not we like graphics programming, it's not going to go away. I get the uneasy feeling whenever I start a new project that there should be a 'better' GUI than the ones I currently use (WxPython and PyGtk). Fragmentation is our enemy. Our resources are being dissipated. Is it not time to start again? We have shown that it is possible to do the right thing, by creating Python3. I ask the group; should we try to create a new GUI for Python, with the following properties?: - Pythonic - The default GUI (so it replaces Tkinter) - It has the support of the majority of the Python community - Simple and obvious to use for simple things - Comprehensive, for complicated things - Cross-platform - Looks good (to be defined) - As small as possible in its default form If so, what are the next steps? The Python SIG on GUIs closed years ago. Should that be revived? This is A Modest Proposal (J. Swift). In a sense, I am suggesting that we eat our own babies. But don't we owe it to the community? -- http://mail.python.org/mailman/listinfo/python-list
Re: Ugly modification of a class, can it be done better ?
On 21-05-2010 03:27, Steven D'Aprano wrote: Sorry for breaking threading, but Stef's original post has not come through to me. On Thu, May 20, 2010 at 8:13 PM, Stef Mientki stef.mien...@gmail.com wrote: So I want to change the behavior of the class dynamically. I've done it by adding a global variable (Base_Grid_Double_Click) in the module, initial set to None, but can be changed by the main program to some callback function. (see the code below) How is this supposed to work? If you have *one* global, then *every* instance will see the same setting. But that's exactly what I need ;-) The problem is a little more complicated, I've several frame-works, that searches for specific modules (applications) in a specific directory. The frame work should determine what should happen (e.g. on a doubleclick of a grid cell) in these modules (application), but the frame work has no idea what kind of instances are in these modules. The same module can be used in different frame-works (or even stand-alone) and the behavior of e.g. a doubleclick, can differ, depending on the frame work. Describing the situation above, I realize that the concept is already spaghetti in itself ;-) but for a modular system this works like a charm. So for the moment I'll stick to the orginal solution. thank you all for the responses. cheers, Stef Mientki To change it dynamically, you enter a nightmare world of having to save the global, modify it, then restore it, every single time. Trust me, I've been there, this is the *worst* way of programming. This is why object oriented inheritance was invented, to escape this nonsense! The first thing is to make the callback specific to the class, not global. Why does your printing code need access to the callback that handles double-clicking on a grid? It doesn't! So don't give it that access (at least, not easy access). Put the callback in the class. class MyClass: callback = None def method(self, *args): if self.callback is None: behaviour_with_no_callback() else: behaviour_with_callback() Now if you want to apply a callback to some instances, and not others, it is totally simple: red = MyClass() blue = MyClass() red.callback = my_callback_function and you're done. If you have lots of instances that use the same callback? Make a subclass. class MyDottedClass(MyClass): pass red = MyClass() blue = MyClass() red_with_green_dots = MyDottedClass() blue_with_green_dots = MyDottedClass() MyDottedClass.callback = dotted_callback And now all the dot instances will use the same callback without effecting the undotted instances. What to change them all to use a different behaviour? MyDottedClass.callback = something_different and now they all change, again without effecting the undotted instances. Is this a valid construction ( sorry I'm not a programmer), or are there better ways to accomplish similar dynamic behavior ? Of course you're a programmer! You're writing programs, aren't you? -- http://mail.python.org/mailman/listinfo/python-list
Ugly modification of a class, can it be done better ?
hello, This might be a strange question, but as a practical guy, I'm not searching for the best solution, but for a practical solution. I've a class which I've used very extensively. Now I want to extend that class with an action on a double click event, but that action is determined by the main program. Normally I would create an derived class and add that specific action. But I find it too much effort in this specific case, half of the instances need the extension, half of it dont. So I want to change the behavior of the class dynamically. I've done it by adding a global variable (Base_Grid_Double_Click) in the module, initial set to None, but can be changed by the main program to some callback function. (see the code below) Is this a valid construction ( sorry I'm not a programmer), or are there better ways to accomplish similar dynamic behavior ? thanks, Stef Mientki #== module grid_library == Base_Grid_Double_Click = None class Base_Grid ( wx.grid.Grid ) : def __init__ ( self, self.Bind ( gridlib.EVT_GRID_CELL_LEFT_DCLICK , self._On_Double_Click ) def _On_Double_Click ( self, event ) : if Base_Grid_Double_Click : Row = event.Row Col = event.Col Col_Label = self.GetColLabelValue ( Col ) Row_Label = self.GetRowLabelValue ( Row ) Base_Grid_Double_Click ( self.GetCellValue ( Row, Col ), Col_Label, Row_Label ) else : event.Skip () -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython: How to get letter colour from TextCtrl
On 17-05-2010 23:29, D. Schramm wrote: Hello, I've got a problem getting the colour of a single letter within the TextCtrl widget: letterstyle = wx.TextAttr() self.p1.GetStyle(self.p1.XYToPosition(0,0),letterstyle) color = letterstyle.GetTextColour() print color This should display the colour value of the very first letter in the very first line of the TextCtrl. But no matter what I try, it always returns the value (-1, -1, -1, 255). Any help? AFAIK, TextAttributes are just onw way, you can set them, but never read them back. cheers, Stef Thanks in advance, Dennis Schramm -- http://mail.python.org/mailman/listinfo/python-list
Re: Do any debuggers support edit and continue?
On 12-05-2010 19:42, Joel Koltner wrote: Just curious... in Microsoft's Visual Studio (and I would presume some other tools), for many languages (both interpreted and compiled!) there's an edit and conitnue option that, when you hit a breakpoint, allows you to modify a line of code before it's actually executed. Does any Python debugger support this feature? Being an interpreted language it doesn't seem like it would necessarily be too onerous to support? It'd be quite handy in that, especially if you hit a breakpoint due to the interpreter throwing an error, you could fix just the line in question and keep going, rather than having to stop the entire program, fix the line, and then run again and potentially kill a bunch of time getting the program back into the same state. Thanks, ---Joel Koltner winpdb perhaps ? Stef -- http://mail.python.org/mailman/listinfo/python-list
how to make a piece of code lowercase, except strings / comment ?
hello, I use Python with some simplifications and a few extensions, as a scripting language for non-programmers. One of the simplifications is that the language should be case-insensitive. This is done by making the code lowercase. But now the strings in the code are also converted to lowercase. Is there an easy way to make a piece of code lowercase, except all string items (single / double /triple quoted and comment) ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
rfind bug ?
With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: rfind bug ?
On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No. Don't you think someone would have found such an obvious bug by now? if it's not a bug, then the start index has no meaning ... ... and some would call that a bug. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: rfind bug ?
On 21-04-2010 12:33, Alf P. Steinbach wrote: * Chris Rebert: On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki stef.mien...@gmail.com wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No. Don't you think someone would have found such an obvious bug by now? if it's not a bug, then the start index has no meaning ... ... and some would call that a bug. Ah, I neglected to take your use of .rfind()'s second parameter into account! As can be interpolated from the part of the docs James quotes: s.rfind(' ', 7) === s[7:].rfind(' ') + 7 # overlooking the 'not present' case That is, the second parameter to .rfind(), namely `start`, is relative to the *left* end of the string, not the right end. I can see how this might be unintuitive, but it does make the API more uniform. It seems that the OP also thought it was relative to the left end of the string. The difference is what it signifies: start of search, or end of search. With rfind the start parameter signifies the end of the search, and conversely, the third parameter end signifies where the search starts. :-) thanks Alf, that's indeed what I was missing. cheers, Stef Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Can this be done simpler ?
hello, I want to use Python to give users the possibility to analyze data and create their custom reports. So I want a very simple language definition for the user, like : - the script must be case-insensitive - user-words are automatically translated into function names - users strings, should be entered without the quotes, so these strings will be defined as names Now the code below seems to fulfill these wishes (in real life, the number of dummy procedures is about 40), but I always wonder if there's an easier way to achieve the same effect. thanks, Stef Mientki def _Meting ( Nr, Test, Subschaal ) : here the real calculation will be done global Result Result += str ( Nr ) + ': ' + Test + '/' + Subschaal + '\n' # Dummy procedures to add the extra argument Nr def _Meting_1 ( *args, **kwargs ) : _Meting ( 1, *args, **kwargs ) def _Meting_2 ( *args, **kwargs ) : _Meting ( 2, *args, **kwargs ) # end of dummy procedures # These are names definied by the user, retrieved from a database Meting_Namen = {} Meting_Namen [1] = 'Voormeting' Meting_Namen [2] = 'Nameting' # Make the user definied names available in the current namespace for Meting in Meting_Namen : Name = Meting_Namen [ Meting ].lower () # 'voormeting' exec ( Name + '= _Meting_' + str ( Meting ) ) # Another set of strings should be available as names (also retrieved from a database) test1 = 'Test1' fat = 'Fat' # Storage for the results Result = '' # Script entered by the user Code = Voormeting ( Test1, fat ) # execute the user script in the current namespace (make code case-insensitive) exec ( Code.lower () ) # for test print the result print Result -- http://mail.python.org/mailman/listinfo/python-list
finding objects in a piece of functional code ?
hello, I would like to translate some functional description into some standard class object, so it can be used as a basic building brick into a larger piece of code. Suppose the functional description is: Name = 'Test_Function' Out = 3 * In That's all I would like to write. So it should be translated into something : class Test_Function ( basic_buidling_brick ) : Orginal_Description = Name = 'Test_Function' Out = 3 * In def Run ( self, Inputs ) : Output = 3 * Input return Output One of the tasks is to find all objects in the functional code., so the translator can ask additional information for input/output/memory variables. The best I can think of is something like this: my={} my2=copy.copy(my) exec('A=3; B=4; C=A*B; print A,B,C',my) 3 4 12 for item in my : ... if item not in my2 : ... print item ... __builtins__ A C B But this doesn't work, if I use a not yet definied variable (like In in the example above). Are there better ways ? Or even better are there programs or libraries that can perfom such a translation ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: case insensitive list ?
On 05-04-2010 19:23, Robert Kern wrote: On 2010-04-05 12:17 PM, Stef Mientki wrote: hello, AFAIK there's no case insensitive list in Python. By case insentive I mean that that sort and memebr of is case insensitive. Does soeone has a implementation of sucha case insensitive list ? mylist.sort(key=lambda x: x.lower()) any(x.lower() == lowercase_query for x in mylist) thanks Robert, your code works perfectly, but I was thinking of something more easy to repeat and mor eidentical to existing lists. Or in other words, I want to use exactly the same commands and operators as with normal lists, like this _List = NoCase_List ( 'coala', 'donky' ) My_List.append ( 'Aap' ) My_List.append ( 'aapje' ) My_List.append ( 'beerthe' ) My_List.append ( 'BEER' ) print My_List My_List.sort () print My_List My_List.append ( 'aapJ' ) print My_List print My_List.index ( 'beer' ) print 'beer' in My_List print 'beert' in My_List After some trial and error the code below, gives almost the desired results. The only problem I see for now, is that replacing the items-list in wxpython widgets don't work, so I'l ask my question to the wxPython list. cheers, Stef class NoCase_List ( list ) : Case Insensitive List : The methods sort and index are case insensitive. The in operator works also case insensitive. After the list is sorted once, appending a new item keeps the list sorted. def __init__ ( self, *args, **kwargs ): self.Sorted = False list.__init__ ( self ) if isinstance ( args[0], list ) : for item in args [0] : self.append ( item ) else : self.append ( args[0] ) def append ( self, value ) : list.append ( self, value ) if self.Sorted : self.sort () def sort ( self, *args, **kwargs ) : self.Sorted = True def _sort ( a, b ) : return cmp ( a.lower(), b.lower() ) return list.sort ( self, _sort ) def index ( self, value ) : value = value.lower() for i, item in enumerate ( self ) : if item.lower() == value : return i else : return -1 def __contains__ ( self, value ) : return self.index ( value ) = 0 -- http://mail.python.org/mailman/listinfo/python-list
case insensitive list ?
hello, AFAIK there's no case insensitive list in Python. By case insentive I mean that that sort and memebr of is case insensitive. Does soeone has a implementation of sucha case insensitive list ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is cool!!
On 23-03-2010 17:55, Jose Manuel wrote: I have been learning Python, and it is amazing I am using the tutorial that comes with the official distribution. At the end my goal is to develop applied mathematic in engineering applications to be published on the Web, specially on app. oriented to simulations and control systems, I was about to start learning Java but I found Python which seems easier to learn that Java. Would it be easy to integrate Python in Web pages with HTML? I have read many info on Internet saying it is, and I hope so Any opinion you might take a look at http://www.sagemath.org/ cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Visual Python programming and decompilers?
On 11-03-2010 19:38, Ludolph wrote: Hi Guys At work I have been exposed to a Agile Platform called OutSystems. It allows you to visually program your web applications http://i.imgur.com/r2F0i.png and I find the idea very intriguing. Although not as low level as you want, http://mientki.ruhosting.nl/data_www/pylab_works/pw_animations_screenshots.html http://code.google.com/p/pylab-works/ and here an overview of similar packages cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: String is ASCII or UTF-8?
On 09-03-2010 18:02, Alf P. Steinbach wrote: * C. Benson Manica: Hours of Googling has not helped me resolve a seemingly simple question - Given a string s, how can I tell whether it's ascii (and thus 1 byte per character) or UTF-8 (and two bytes per character)? This is python 2.4.3, so I don't have getsizeof available to me. Generally, if you need 100% certainty then you can't tell the encoding from a sequence of byte values. However, if you know that it's EITHER ascii or utf-8 then the presence of any value above 127 (or, for signed byte values, any negative values), tells you that it can't be ascii, AFAIK it's completely impossible. UTF-8 characters have 1 to 4 bytes / byte. I can create ASCII strings containing byte values between 127 and 255. cheers, Stef hence, must be utf-8. And since utf-8 is an extension of ascii nothing is lost by assuming ascii in the other case. So, problem solved. If the string represents the contents of a file then you may also look for an UTF-8 represention of the Unicode BOM (Byte Order Mark) at the beginning. If found then it indicates utf-8 for almost-sure and more expensive searching can be avoided. It's just three bytes to check. Cheers hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: String is ASCII or UTF-8?
On 09-03-2010 18:36, Robert Kern wrote: On 2010-03-09 11:12 AM, Stef Mientki wrote: On 09-03-2010 18:02, Alf P. Steinbach wrote: * C. Benson Manica: Hours of Googling has not helped me resolve a seemingly simple question - Given a string s, how can I tell whether it's ascii (and thus 1 byte per character) or UTF-8 (and two bytes per character)? This is python 2.4.3, so I don't have getsizeof available to me. Generally, if you need 100% certainty then you can't tell the encoding from a sequence of byte values. However, if you know that it's EITHER ascii or utf-8 then the presence of any value above 127 (or, for signed byte values, any negative values), tells you that it can't be ascii, AFAIK it's completely impossible. UTF-8 characters have 1 to 4 bytes / byte. I can create ASCII strings containing byte values between 127 and 255. No, you can't. ASCII strings only have characters in the range 0..127. You could create Latin-1 (or any number of the 8-bit encodings out there) strings with characters 0..255, yes, but not ASCII. Probably, and according to wikipedia you're right. I think I've to get rid of my old books, Borland turbo Pascal 4 (1987) has an ASCII table of 256 characters, while the small letters say 7-bit ;-) cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: How to transmit a crash report ?
On 23-02-2010 15:21, Thomas wrote: On Feb 22, 9:27 pm, MRABpyt...@mrabarnett.plus.com wrote: Stef Mientki wrote: hello, in my python desktop applications, I'ld like to implement a crash reporter. By redirecting the sys.excepthook, I can detect a crash and collect the necessary data. Now I want that my users sends this information to me, and I can't find a good way of doing this. The following solutions came into my mind: (most of my users are on Windows, and the programs are written in Python 2.6) 1. mailto: doesn't work if the the user didn't install a default email client, or if the user uses a portable email client (that isn't started yet) Besides this limits the messages to small amounts of data. 2.other mail options: smtp AFAIK such a solution needs smtp authorization, and therefor I've to put my username and password in the desktop application. Try reading the documentation for Python's smtplib module. You don't need to provide any password. 3. http-post Although post is also limited in size, I could store information in cookies (don't know yet how), and cookies are sent parallel to the post message. On the server site I can use a small php script, that stores the post-data, cookies and/or send's a (long) email. are there better options ?- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - Try http://code.activestate.com/recipes/442459/ Apparently there's something terrible wrong on my system, because I do need username and password :-( First, a script that works without username and password. I guess it works, because the smtp_server is the smtp server of my provider, and I'm in that domain of my provider, so it won't work for a random user of my program. if Test ( 4 ) : import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart body = 'test_body' subject = 'test_subject' mail_to = 's.mien...@ru.nl' mail_from = 'stef.mien...@gmail.com' msg = MIMEMultipart ( 'alternative' ) msg [ 'To' ] = mail_to msg [ 'From'] = mail_from msg [ 'Subject' ] = subject part1 = MIMEText ( body, 'plain' ) msg.attach ( part1 ) smtp_server = 'mail.upcmail.nl' session = smtplib.SMTP ( smtp_server ) session.sendmail ( mail_from, [mail_to], msg.as_string() ) Using smtp on google , works only if I support username and password: if Test ( 5 ) : import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart body = 'test_body' subject = 'test_subject' mail_to = 's.mien...@ru.nl' mail_from = 'stef.mien...@gmail.com' msg = MIMEMultipart ( 'alternative' ) msg [ 'To' ] = mail_to msg [ 'From'] = mail_from msg [ 'Subject' ] = subject part1 = MIMEText ( body, 'plain' ) msg.attach ( part1 ) smtp_server = 'smtp.gmail.com' session = smtplib.SMTP ( smtp_server, 587 ) session.ehlo ( mail_from ) session.starttls () session.ehlo ( mail_from ) session.login (username, password ) session.sendmail ( mail_from, [mail_to], msg.as_string() ) And her a number of different tries with localhost / mail : if Test ( 6 ) : import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart body = 'test_body' subject = 'test_subject' mail_to = 's.mien...@ru.nl' mail_from = 'stef.mien...@gmail.com' msg = MIMEMultipart ( 'alternative' ) msg [ 'To' ] = mail_to msg [ 'From'] = mail_from msg [ 'Subject' ] = subject part1 = MIMEText ( body, 'plain' ) msg.attach ( part1 ) session = smtplib.SMTP ( 'localhost' ) Traceback (most recent call last): File D:\Data_Python_25\support\mail_support.py, line 375, in module session = smtplib.SMTP ( smtp_server ) File P:\Python26\lib\smtplib.py, line 239, in __init__ (code, msg) = self.connect(host, port) File P:\Python26\lib\smtplib.py, line 295, in connect self.sock = self._get_socket(host, port, self.timeout) File P:\Python26\lib\smtplib.py, line 273, in _get_socket return socket.create_connection((port, host), timeout) File P:\Python26\lib\socket.py, line 514, in create_connection raise error, msg error: [Errno 10061] No connection could be made because the target machine actively refused it #session = smtplib.SMTP ( 'localhost', 25 ) #session = smtplib.SMTP ( 'mail', 25 ) session = smtplib.SMTP ( 'mail', 1025 ) Traceback (most recent call last): File D:\Data_Python_25\support\mail_support.py, line 377, in module session = smtplib.SMTP ( 'mail', 1025 ) File P:\Python26\lib\smtplib.py, line 239, in __init__ (code, msg) = self.connect(host, port) File P:\Python26\lib\smtplib.py, line 295, in connect
How to transmit a crash report ?
hello, in my python desktop applications, I'ld like to implement a crash reporter. By redirecting the sys.excepthook, I can detect a crash and collect the necessary data. Now I want that my users sends this information to me, and I can't find a good way of doing this. The following solutions came into my mind: (most of my users are on Windows, and the programs are written in Python 2.6) 1. mailto: doesn't work if the the user didn't install a default email client, or if the user uses a portable email client (that isn't started yet) Besides this limits the messages to small amounts of data. 2.other mail options: smtp AFAIK such a solution needs smtp authorization, and therefor I've to put my username and password in the desktop application. 3. http-post Although post is also limited in size, I could store information in cookies (don't know yet how), and cookies are sent parallel to the post message. On the server site I can use a small php script, that stores the post-data, cookies and/or send's a (long) email. are there better options ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to continue after an exception ?
On 21-02-2010 03:51, Ryan Kelly wrote: On Sun, 2010-02-21 at 13:17 +1100, Lie Ryan wrote: On 02/21/10 12:02, Stef Mientki wrote: On 21-02-2010 01:21, Lie Ryan wrote: On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki stef.mien...@gmail.com wrote: hello, I would like my program to continue on the next line after an uncaught exception, is that possible ? thanks Stef Mientki That reminds me of VB's On Error Resume Next I think that's what I'm after ... A much better approach is to use callbacks, the callbacks determines whether to raise an exception or continue execution: def handler(e): if datetime.datetime.now()= datetime.datetime(2012, 12, 21): raise Exception('The world has ended') # else: ignore, it's fine def add_ten_error_if_zero(args, handler): if args == 0: handler(args) return args + 10 print add_ten_error_if_zero(0, handler) print add_ten_error_if_zero(10, handler) print add_ten_error_if_zero(0, lambda e: None) # always succeeds Or if you don't like having to explicitly manage callbacks, you can try the withrestart module: http://pypi.python.org/pypi/withrestart/ It tries to pinch some of the good ideas from Common Lisp's error-handling system. from withrestart import * def add_ten_error_if_zero(n): # This gives calling code the option to ignore # the error, or raise a different one. with restarts(skip,raise_error): if n == 0: raise ValueError return n + 10 # This will raise ValueError print add_ten_error_if_zero(0) # This will print 10 with Handler(ValueError,skip): print add_ten_error_if_zero(0) # This will exit the python interpreter with Handler(ValueError,raise_error,SystemExit): print add_ten_error_if_zero(0) Cheers, Ryan thanks Ryan (and others), your description of withstart was very informative, and I think I understand why it's impossible what I want (something like madExcept for Delphi / C / C++, see *http://www.madshi.net/madExceptDescription.htm ) * It are not the bugs that you can predict / expect to catch, but the uncaught bugs. So made some first steps, and this seems to be sufficient for now, if you're interested, look here, http://mientki.ruhosting.nl/data_www/pylab_works/pw_bug_reporter.html cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Is there a way to continue after an exception ?
hello, I would like my program to continue on the next line after an uncaught exception, is that possible ? thanks Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: obfuscate
On 10-02-2010 00:09, Alf P. Steinbach wrote: * David Robinow: On Tue, Feb 9, 2010 at 5:10 PM, Simon Brunning si...@brunningonline.net wrote: On 9 February 2010 16:29, Robert Kern robert.k...@gmail.com wrote: On 2010-02-09 09:37 AM, Daniel Fetchinson wrote: If the code base stabilizes in a production version after losing the alphas and betas they would be a great addition to the stdlib, I think. Why? I agree. Why wait? Put them in the stdlib now! Can we please stop this? I agree. sorry I don't, unless Python is only meant for the very well educated people in encryption. I haven't looked at the code but the functionality that's listed is useful, e.g. in a Usenet client, and it's fun to play around with for a beginner. I neither did look at the code, but as a beginner with just 3 years of experience in Python, I've tried several scrambling libs, for a quick and dirty use. All were much too difficult, so I made my own xor-something. Coming from Delphi, a scrambling lib is working is less than 10 minutes, without the need of any knowledge of encryption. I prefer Python over Delphi, but some things are made very complex in Python. cheers, Stef Also, for example, Christian Heimes wrote else-thread: «Your work should be interesting for everybody who has read Simon Sing's The Code Book: The Science of Secrecy from Ancient Egypt to Quantum» (and I for one have that book). Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
Yes, it certainly does. Not that you'll get many Pythonistas to confess to that fact. Somehow those who brag about the readability and expressiveness of source code just cannot admit that: class.method(sting name, int count) - is *obviously* more expressive than - class.method(name, count) Oh, well. This is obvious even in the Python documentation itself where one frequently asks oneself Uhh... so what is parameter X supposed to be... a string... a list... ? But I thought that was the one of beauties of Python, you don't need to know if the input parameter is a list or a string. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
Finally I develop a feeling that strong instrumentation / tools can bring us the best of two worlds. That I am dreaming on is an absolute new type/class of IDE suitable for Python and potentially for other dynamic-type languages. Instead of current text-oriented IDEs, it should be a database-centric I don't see what the advantage of the use of a database is in a fairly linear hierarchical structure like python objects and modules. and resemble current CAD systems instead of being just fancy text editor. Source text should be an output product of that CAD and not a source material itself. You mean something like LabView ? cheers, Stef (btw, my dreams ends up in the same needs) -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
On 03-02-2010 16:48, Vladimir Ignatov wrote: I don't see what the advantage of the use of a database is in a fairly linear hierarchical structure like python objects and modules. Imagine simple operation like method renaming in a simple dumb environment like text editor + grep. Now imagine how simple it can be if system knows all your identifiers and just regenerates relevant portions of text from internal database-alike representation. I think every IDE (not older than 20 years) does that already. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
On 03-02-2010 18:21, Vladimir Ignatov wrote: Imagine simple operation like method renaming in a simple dumb environment like text editor + grep. Now imagine how simple it can be if system knows all your identifiers and just regenerates relevant portions of text from internal database-alike representation. I think every IDE (not older than 20 years) does that already. And fix every reference to it in all files? For python? I don't think so. I even don't think this is possible at all. with tools like inspect it certainly should be possible That if several different objects have a similar named method? How will IDE classify calls and renames only some of calls and not others? yep, you're right, the IDE's I use have as the beste search / select / rename. But how often do you must/want to rename something (mature) ? cheers, Stef Vladimir Ignatov -- http://mail.python.org/mailman/listinfo/python-list
how to decode rtf characterset ?
hello, I want to translate rtf files to unicode strings. I succeeded in remove all the tags, but now I'm stucked to the special accent characters, like : Vóór the character ó is represented by the string r\'f3, or in bytes: 92, 39,102, 51 so I think I need a way to translate that into the string r\xf3 but I can't find a way to accomplish that. a Any suggestions are very welcome. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
class viewer ?
hello, I'd like to have a class viewer, something different from pydoc, and I wonder if someone has made something similar. from the given class, it's ancestors and it's derived classes, I'ld like to get the following information in a tree like structure: - the file were the class is definied - the attributes, split in inherited / created / overriden - the methodes, split in inherited / created / overriden - the files were instances of the class are created - and probably I forget a few any suggestions ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: how do I set a Python installation as the default under windows ?
Steve Holden wrote: Stef Mientki wrote: hello, I just upgraded from Python 2.5 to 2.6. Most of the things work, but I'm struggling with one issue, when I start Python in a command window, it still uses Python 2.5. Is there a way to get Python 2.6 as my default Python environment ? thanks, Stef Mientki It's a matter of replacing C:\Python25 with C:\Python26 in your PATH environment variable, which is what the Windows command processor uses to fined executable programs. Thanks Steve, that works exactly as you say. cheers, Stef It's normal to add both the directory the interpreter lives in /and/ its Scripts subdirectory, so you may have two replacements to make. See http://www.python.org/doc/faq/windows/ for more. If anyone has any good updates to that document I'll be happy to make them (or give you permission to make them ...). It was written a long time ago, and I'm not sure it's had much love. In particular there'll not be anything relating to Windows 7. regards Steve -- http://mail.python.org/mailman/listinfo/python-list
how to go back from 2.6.4 to 2.6.2 under windows ?
hello, I've just upgraded my system from Python 2.5 to 2.6.4, and installed the latest packages of a lot of libraries. Now one essential package (VPython) only works with Python 2.6.2. I tried to install Python 2.6.2 over this 2.6.4 installation, and indeed the readme file says it's 2.6.2, but the python and pythonw are still 2.6.4. Why is that so ?? Now assume that a number of packages (because compiled with 2.6.4) will not work correctly with 2.6.2. Is that correct ? So the best way would be to reinstall everything ?? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: how to go back from 2.6.4 to 2.6.2 under windows ?
Benjamin Kaplan wrote: On Sun, Dec 20, 2009 at 9:26 AM, Stef Mientki stef.mien...@gmail.com wrote: hello, I've just upgraded my system from Python 2.5 to 2.6.4, and installed the latest packages of a lot of libraries. Now one essential package (VPython) only works with Python 2.6.2. I tried to install Python 2.6.2 over this 2.6.4 installation, and indeed the readme file says it's 2.6.2, but the python and pythonw are still 2.6.4. Why is that so ?? Now assume that a number of packages (because compiled with 2.6.4) will not work correctly with 2.6.2. Is that correct ? 2.6.4 is just a bugfix release- it's binary compatible with the other 2.6 releases. So any package that worked under 2.6.2 shouid also work under 2.6.4 unless a new bug was introduced or it relied on a bug that was fixed. And any package that works under 2.6.4 will also work under 2.6.2 without recompiling unless it hits one of the bugs that was fixed. thanks Benjamin, Then VPython must hit one of the bugs that were fixed. On a second machine, - I removed Python 2.6.4 (without removing all other libraries) - installed Python 2.6.2 (without reïnstalling all the libraries) and indeed the VPython library works as expected. So I guess this is a reasonable approach, and all libraries should work well, unless one of these libraries has a work around for one of the bugs fixed between 2.6.2 and 2.6.4. cheers, Stef So the best way would be to reinstall everything ?? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: how to go back from 2.6.4 to 2.6.2 under windows ?
So I guess this is a reasonable approach, and all libraries should work well, unless one of these libraries has a work around for one of the bugs fixed between 2.6.2 and 2.6.4. Let VPython people know about this problem. People should be able to run it on the latest patched 2.6. Well this is the first line on the VPython download page ;-) To use Visual 5.13 with Python 2.6, use Python 2.6.2, NOT later versions such as Python 2.6.3 or Python 2.6.4 or Python 3.x: cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
how do I set a Python installation as the default under windows ?
hello, I just upgraded from Python 2.5 to 2.6. Most of the things work, but I'm struggling with one issue, when I start Python in a command window, it still uses Python 2.5. Is there a way to get Python 2.6 as my default Python environment ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: pyZui - anyone know about this?
Donn wrote: On Friday 11 December 2009 12:38:46 Daniel Fetchinson wrote: Youtube has a link 'Send message' on the profile of users, maybe sending a message to the person who uploaded the video will give you a useful response. I'm a Tube-tard so that never crossed my mind. Will give it a go. \d please let us know when you find more information about the project. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Bored.
Floris Bruynooghe wrote: On Nov 30, 11:52 pm, Stef Mientki stef.mien...@gmail.com wrote: Well I thought that after 2 years you would know every detail of a language ;-) Ouch, I must be especially stupid then! ;-) Sorry if I insulted you Floris! btw, I'm too still learning Python after I started 2 years ago. cheers, Stef Floris -- http://mail.python.org/mailman/listinfo/python-list
Re: Bored.
Necronymouse wrote: Hello, I am learning python for about 2 years and I am bored. Not with python but I have a little problem, when i want to write something I realise that somebody had alredy written it! So i don´t want to make a copy of something but i wanna get better in python skills. Don´t you know what I should do? ---sorry for my english, I ´m from czech rep... Well I thought that after 2 years you would know every detail of a language ;-) A few ideas ( or better said the things that I'm still missing, and I guess every one can name a few different ones ) - PyJamas needs a lot of extensions - Simultanuous recording of camera and sound (and preferable other signals) is completely missing - Rich editor or ( embedding of open office) - a system-wide mind mapper - graphical design package a la LabView There's also a Python site, were projects are submitted that needs something ( some even pay a little), but I can't remember where it is :-( cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Bored.
John Bokma wrote: Stef Mientki stef.mien...@gmail.com wrote: There's also a Python site, were projects are submitted that needs something ( some even pay a little), but I can't remember where it is :-( OP: A Python program to find it :D that was the mind mapper I mentioned :-) Stef John -- http://mail.python.org/mailman/listinfo/python-list
Re: python gui builders
Shawn Wheatley wrote: It's not quite all encompassing, but I found this link last year when looking for a similar comparison of Python GUIs: http://ginstrom.com/scribbles/2008/02/26/python-gui-programming-platforms-for-windows/ Tkinter, Qt, GTK, IronPython... I think the only thing missing is Jython w/ Swing or SWT. Check it out. Instead of *hello* world examples, I was thinking of *real* world applications, something like this, http://mientki.ruhosting.nl/data_www/pylab_works/random_gui.html which in a good GUI package should be doable in about 100 lines of code. cheers, Stef Shawn On Nov 18, 5:11 pm, Stef Mientki stef.mien...@gmail.com wrote: Wouldn't it be nice if each fan of some form of GUI-package, would post it's code (and resulting images) for generating one or two standard GUI-forms ? -- http://mail.python.org/mailman/listinfo/python-list
Re: plotting arrow in python
rudra wrote: Dear friends, I am very new in python. Actually, I think I will not do much python then using it to plotting data. I have not done any real thing in python, so plz be easy. Now , the problem I have a data set: 0.0 0.0 0.1 0.0 0.1 0.1 0.1 0.0 0.5 like that! the first two column are coordinate and 3rd one is magnitude of moment (say: x y,m)!! so what i want to do is draw an arrow of magnitude(m) in the position (x,y). I know how python read array, and how to draw an array(via matplotlib)...but totally confused with this one. can you people plz help? maybe take a look at VPython cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: python gui builders
Simon Hibbs wrote: On 18 Nov, 07:51, sturlamolden sturlamol...@yahoo.no wrote: GPL PyQT is GPL for now, but Qt itself is available under the LGPL as is PySide. Eventualy PySide, which tracks the PyQT API, will supplant it and the issue will be moot. For now it can be a problem, but PyQT developer licenses are very afordable at only a few hundred dollars. If a commercial project can't aford that, it's got problems. Only you can know enough to make an informed decision. Wx does look more usable than last time I used it for a project and is a fine option too, for me though QT is the gold standard against all others are measured, and generaly found wanting. Simon Hibbs Wouldn't it be nice if each fan of some form of GUI-package, would post it's code (and resulting images) for generating one or two standard GUI-forms ? Then everyone can judge the differences, and see what's simple and not so simple !! And of course I'm willing to contribute the wxPython (wrapped in some convenience procedures) for it. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: imputil.py, is this a bug ?
Gabriel Genellina wrote: En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki stef.mien...@gmail.com escribió: I get an error compiling with pyjamas, in the standard module imputil, _import_top_module Note that imputil is undocumented in 2.5, deprecated in 2.6 and definitively gone in 3.0 AttributeError: 'unicode' object has no attribute 'import_top' def _import_top_module(self, name): # scan sys.path looking for a location in the filesystem that contains # the module, or an Importer object that can import the module. for item in sys.path: if isinstance(item, _StringType): module = self.fs_imp.import_from_dir(item, name) else: module = item.import_top(name) if module: return module return None It seems that elements of sys.path can be of the type unicode so by adding the next 2 lines, everything works ok. elif isinstance ( item, basestring ) : module = self.fs_imp.import_from_dir ( str(item), name) is this a bug ? (I'm using Python 2.5.2 on Windows ) Yes, seems to be a bug. But given the current status of imputil, it's not likely to be fixed; certainly not in 2.5 which only gets security fixes now. I cannot test it at this moment, but I'd use the unicode item directly (that is, self.fs_imp.import_from_dir(item, name)). Or perhaps item.encode(sys.getdefaultfilesystemencoding()). str(item) definitively won't work with directory names containing non-ascii characters. Why are you using imputil in the first place? thanks Gabriel, well PyJamas is using (a copy) of it and I bumped into problems using PyJamas. I'll send this message to the PyJamas developers, because this stuff is far beyond my knowledge. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Doesn't MS-Windows likes Python ? (or: why more than 20 sec delay when running a program from Python)
hello, I've an AutoIt program that set some switches in the LAN settings. When I launch the AutoIt executable, the settings are changed immediately. When I launch the AutoIt executable from python (which is the intention), it hangs for about 20 seconds, before any action appears on the screen. Analyzing the script, shows that it hangs on the next 2 lines: Run ( control.exe ncpa.cpl ) WinWait( Network Connections) Transfering the Run command to Python, it hangs on the next subprocess call subprocess.call ( [ rcontrol.exe, ncpa.cpl ]) Does anyone have a clue, why starting a process takes 20 seconds longer when ran from Python ? And even more important, is there a work around ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: How can module determine its own path?
Robert Kern wrote: On 2009-10-30 12:19 PM, kj wrote: How can a module determine the path of the file that defines it? (Note that this is, in the general case, different from sys.argv[0].) __file__ but for modules launched with execfile, __file__ doesn't exists. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: How can module determine its own path?
Robert Kern wrote: On 2009-10-30 18:40 PM, Stef Mientki wrote: Robert Kern wrote: On 2009-10-30 12:19 PM, kj wrote: How can a module determine the path of the file that defines it? (Note that this is, in the general case, different from sys.argv[0].) __file__ but for modules launched with execfile, __file__ doesn't exists. Modules launched from execfile() using a properly initialized namespace dict do. interesting, but how do I configure a properly initialized namespace dict (other than my current namespace) ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedded python on systems without python installed
KillSwitch wrote: I have python successfully embedded in a program I wrote. What files do I need and where do I need to put them so that it can run on systems that don't have python installed? I embed python in Delphi apps, and the only thing I add is python24.dll, which I put in the same directory as the Delphi executable, (but i you want a less clean install, you can put the dll also in the windows directory) cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedded python on systems without python installed
KillSwitch wrote: I have python successfully embedded in a program I wrote. What files do I need and where do I need to put them so that it can run on systems that don't have python installed? I embed python in Delphi apps, and the only thing I add is python24.dll, which I put in the same directory as the Delphi executable, (but if you want a less clean install, you can put the dll also in the windows directory) cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Does someone has a 5-line working example of SOAP server request ?
hello, I want to ask some simple queries to a SOAP server ( through wdsl). The ICT department advised me to use a dot-net environment, because that should be able to handle wdsl automatically. As I have a quite large Python desktop application and I still don't understand what a dot-net program is, I prefer to add SOAP to my existing Python desktop application. Reading Dive into Python, the chapter SOAP web services, I estimated that would be very doable, without diving to deep in the details of SOAP and other web-protocols. But following the instructions in that book, I couldn't get it working. I also noticed that the libraries they suggest pyXML, fpconst, SOAPpy are relatively old 4,5 years, so these libs are either perfect or dead. So I tried some other libraries lxml, zsi,soaplib, but probably due to a lack of detailed knowledge of the soap protocol and it's usage, I couldn't get anything working. So could someone tell me what libraries I need to perform a SOAP query ? Is there a 5-line (Dive into Python had a 4-line example ;-) that can show the SOAP query is working ? (btw I use Python 2.5 on Windows if that matters) thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Unicode again ... default codec ...
hello, As someone else already said, every time I think : now I understand it completely, and a few weeks later ... Form the thread how to write a unicode string to a file ? and my specific situation: - reading data from Excel, Delphi and other Windows programs and unicode Python - using wxPython, which forces unicode - writing to Excel and other Windows programs almost all answers, directed to the following solution: - in the python program, turn every string as soon as possible into unicode - in Python all processing is done in unicode - at the end, translate unicode into the windows specific character set (if necessary) The above approach seems to work nicely, but manipulating heavily with string like objects it's a crime. It's impossible to change all my modules from strings to unicode at once, and it's very tempting to do it just the opposite : convert everything into strings ! # adding unicode string and windows strings, results in an error: my_u = u'my_u' my_w = 'my_w' + chr ( 246 ) x = my_s + my_u # to correctly handle the above ( in my situation), I need to write the following code (which my code quite unreadable my_u = u'my_u' my_w = 'my_w' + chr ( 246 ) x = unicode ( my_s, 'windows-1252' ) + my_u # converting to strings gives much better readable code: my_u = u'my_u' my_w = 'my_w' + chr ( 246 ) x = my_s + str(my_u) until I found this website: http://diveintopython.org/xml_processing/unicode.html By settings the default encoding: I now can go to unicode much more elegant and almost fully automatically: (and I guess the writing to a file problem is also solved) # now the manipulations of strings and unicode works OK: my_u = u'my_u' my_w = 'my_w' + chr ( 246 ) x = my_s + my_u The only disadvantage is that you've to put a special named file into the Python directory !! So if someone knows a more elegant way to set the default codec, I would be much obliged. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a unicode string to a file ?
Stephen Hansen wrote: snip although this is a very good explanation, and showing character encoding isn't that easy ;-) thanks very much ! Wasn't aware of the SQLite pragma. also thanks to the others who replied. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a unicode string to a file ?
Stephen Hansen wrote: On Thu, Oct 15, 2009 at 4:43 PM, Stef Mientki stef.mien...@gmail.com mailto:stef.mien...@gmail.com wrote: hello, By writing the following unicode string (I hope it can be send on this mailing list) Bücken to a file fh.write ( line ) I get the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128) How should I write such a string to a file ? First, you have to understand that a file never really contains unicode-- not in the way that it exists in memory / in python when you type line = u'Bücken'. It contains a series of bytes that are an encoded form of that abstract unicode data. There's various encodings you can use-- UTF-8 and UTF-16 are in my experience the most common. UTF-8 is an ASCII-superset, and its the one I see most often. So, you can do: import codecs f = codecs.open('filepath', 'w', 'utf-8') f.write(line) To read such a file, you'd do codecs.open as well, just with a 'r' mode and not a 'w' mode. Thanks guys, I didn't know the codecs module, and the codecs seems to be a good solution, at least it can safely write a file. But now I have to open that file in Excel 2000 ... 2007, and I get something completely wrong. After changing codecs to latin-1 or windows-1252, everything works fine. Which of the 2 should I use latin-1 or windows-1252 ? And a more general question, how should I organize my Python programs ? In general I've data coming from Excel, Delphi, SQLite. In Python I always use wxPython, so I'm forced to use unicode. My output often needs to be exported to Excel, SPSS, SQLite. So would this be a good design ? Excel| convertwxPython convertExcel Delphi |===to === in === to === SQLite SQLite | unicodeunicode latin-1SPSS thanks, Stef Mientki Now, that uses a file object created with the codecs module which operates with theoretical unicode streams. It will automatically take any passed in unicode strings, encode them in the specified encoding (utf8), and write the resulting bytes out. You can also do that manually with a regular file object, via: f.write(line.encode(utf8)) If you are reading such a file later with a normal file object (e.g., not one created with codecs.open), you would do: f = open('filepath', 'rb') byte_data = f.read() uni_data = byte_data.decode(utf8) That will convert the byte-encoded data back to real unicode strings. Be sure to do this even if it doesn't seem you need to if the file contains encoded unicode data (a thing you can only know based on documentation of whatever produced that file)... for example, a UTF8 encoded file might look and work like a completely normal ASCII file, but if its really UTF8... eventually your code will break that one time someone puts in a non-ascii character. Since UTF8 is an ASCII superset, its indistinguishable from ASCII until it contains a non-ASCII character. HTH, --S -- http://mail.python.org/mailman/listinfo/python-list
how to write a unicode string to a file ?
hello, By writing the following unicode string (I hope it can be send on this mailing list) Bücken to a file fh.write ( line ) I get the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128) How should I write such a string to a file ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: organizing your scripts, with plenty of re-use
[snip] The key is to put all the core functionality into a package, and place the package where Python can find it. Also, it's a good idea to use relative imports from inside the package. There is no need to juggle with sys.path nor even set PYTHONPATH nor import __main__ nor play any strange games; it Just Works (tm). please don't get angry, I'm not a programmer, I'm just a human ;-) Hierarchical choices are done on todays knowledge, tomorrow we might have different views and want/need to arrange things in another way. An otter may become a reptile ;-) So from the human viewpoint the following should be possible (and is for example possible in Delphi) - I can move the complete project anywhere I like and it should still work without any modifications (when I move my desk I can still do my work) Move a complete package anywhere along the PYTHONPATH and it will still work. Check. - I can move any file in he project to any other place in the project and again everything should work without any modifications ( when I rearrange my books, I can still find a specific book) Move any file in any directory to any other spot in that same directory and it will still work. Check. ;-) sub ;-) Humans are a lot smarter than computers. Even 'just humans'. ;-) If you move your book, then can't find it on the last shelf it used to be on, you look on other shelves, you look on your desk, you look on the coffe table, you look in your car, etc, etc, and so forth. If you move a file in a package to somewhere else, and you don't tell the package where it's at, it's not going to start looking all over the hard-drive for it. I didn't say whole the world;-) If that were the case you would have to be extra careful to have every module's name be distinct, and then what's the point of having packages? Yes, I still wonder ! cheers, Stef ~Ethan~ In my humble opinion if these actions are not possible, there must be redundant information in the collection. The only valid reason for redundant information is to perform self healing (or call it error correction), and here we have a catch-22. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list