ANN : rest2web 0.2.0
*UPDATE* rest2web 0.2.0 This is a major update to rest2web, introducing lots of new features and improvements. The main new features are : * rest2web now renders pages a whole directory at a time and builds a tree of the site structureas it goes. This allows the new standard functions to provide very simple ways of automatically building sidebars. The data strucures are also available for you to process yourself. * The new *standard functions* also include a one line way to print navigation trails. * You can now specify your template encoding and output encoding - rest2web is fully unicode internally. It ought to 'do the right thing' if you don't specify what encodings are being used (even if you mix encodings). * A new system of macros for frequently used shorthands (including smilies and Python source coloring). * Lots more values available in the template namespace. :Author: Michael Foord :Contact: [EMAIL PROTECTED] :Version: 0.2.0 :Date: 2005/06/01 :License: BSD-License http://www.voidspace.org.uk/documents/BSD-LICENSE.txt :Home Page: http://www.voidspace.org.uk/python/rest2web :Sourceforge: http://sourceforge.net/projects/rest2web :Development: SVN Repository https://svn.rest2web.python-hosting.com/trunk/ :Support: Pythonutils Mailing List http://www.voidspace.org.uk/mailman/listinfo/pythonutils_voidspace.org.uk :Quick Download: http://www.voidspace.org.uk/cgi-bin/voidspace.py?file=rest2web.zip (725k) Note : rest2web requires the pythonutils module http://www.voidspace.org.uk/python/pythonutils.html What is restweb ? === rest2web is a tool for automatically building websites, or parts of websites. It allows you to maintain your content as reST (see http://docutils.sourceforge.net ) - a relaxed (WYSIWYG) text markup. (You can keep content as HTML as well if you prefer). It will generate HTML from your contents and insert it into HTML templates, automatically building index pages, sidebars, and navigation trails (breadcrumbs) as it goes. It features a simple templating system, macros, and more. Adding pages to your site can be as simple as dropping the text file of cotnent into the desired directory. rest2web will add it to the index page and build the target file. If you delete a page, rest2web can automatically update the indexes for you. Because rest2web resolves all links locally, it can be used to create HTML files viewable from the filesystem. This makes it an ideal way to create documentation. See the docs and example site (included in the distribution) : http://www.voidspace.org.uk/python/rest2web The example site illustrates most of the features of rest2web, which is now building a significant proportion of Voidspace - see http://www.voidspace.org.uk/technology for a live example. What's Changed Since 0.1.0 ? === Version 0.2.0 2005/06/01 Various minor changes especially additions to the namespace pages are rendered in. Sites are rendered a whole section at a time. This means pages have index data for that section available. This is the ``sections`` variable in the namespace. Added the ``output-encoding`` and `final_encoding`` values to the restindex. Added the ``template-encoding`` value to the restindex. rest2web is now entirely unicode internally. It's now possible to specify title and description for the default section. Added indextree and thispage, allows building of sidebars. Added standard functions. Added macros. Started using subversion repository. Changed all line endings to 'LF'. What's Next ? === The next step is to have rest2web automatically create contents and sitemaps for sites it is creating. I'd like to integrate with a system that inspects Python objects for helping to automate some of the process of documenting Python projects. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Performance Issues please help
PyPK wrote: I was testing this piece of code and it takes about 24-30 seconds to do a look up on a list(m) of size 1000x1000 m - list of size 1000x1000 import time print time.ctime() box = {} for r,row in enumerate(m): for c,e in enumerate(row): if box.has_key(e): params = box[e] box[e] = ( min(c, params[0]), min(r, params[1]), max(c, params[2]), max(r, params[3] ) ) else: box[e] = [c, r, c, r] print time.ctime() Can some one tell me what exactly is taking more time here. Is it because I am using dictionaries or what is the problem. Can some one help me improve this .Is there a better way to write this. AFAICT the row index 'r' can only grow. Therefore one min() and one max() should be superfluous (untested): def make_box(m): box = {} for r, row in enumerate(m): for c, e in enumerate(row): if e in box: left, top, right, bottom = box[e] box[e] = (min(c, left), top, max(c, right), r) else: box[e] = (c, r, c, r) return box Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Software licenses and releasing Python programs for review
If this thread has shown anything it is I'm a bit green with respect to software licenses, but the other thing is that I consider myself as an isolated case and I wanted to know if there were others who wanted the same thing as me. I'm curious to know what the money that open source or GPL'd projects get and what this money means to these people's overall income. I am sure that any amount would motivate somebody to continue their work on a project, but myself in particular, I consider my project to be a tool for teaching and I view teaching as helping others...which I would gladly offer without price. I wanted to see if there were others who shared my view of helping others freely with their knowledge. Yes, what I ask may seem ridiculous, but I don't view it that way. Instead, I find that it is the implication of using a restrictive license such as I described to be ridiculous: if there is no monetary gain option in the license, then this implies that nobody (or very few) will be willing to do any work or asking for something for nothing. It isn't for nothing if you value knowledge and learning. I admit that my view is a bit idealistic which leads me to believe that maybe I should reconsider the whole decision altogether. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a hex value
John Machin wrote: delim = chr(0x15) Ooooh -- a function with a constant arg; I wonder what that evaluates to? chr(0x15) '\x15' Shsh. OK, let's double-check that: chr(0x15) 'The argument is constant -- but not necessarily the /function/.' Shsh :-) Peter -- http://mail.python.org/mailman/listinfo/python-list
Moving Places, Subtracting from slices/lists
Hi All, playing around with the tut now. How can I get this code to remove the original instance of 'roof'.? hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... hotcat ['Cat', 'roof', 'on', 'a', 'hot', 'tin', 'roof'] Perhaps a replace or something after the 2nd line of the for function.? hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... hotcat[x:len(x)] = [] ... Traceback (most recent call last): File stdin, line 3, in ? TypeError: slice indices must be integers I feel I'm close to it. Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Software licenses and releasing Python programs for review
poisondart [EMAIL PROTECTED] writes: If this thread has shown anything it is I'm a bit green with respect to software licenses, but the other thing is that I consider myself as an isolated case and I wanted to know if there were others who wanted the same thing as me. You're going through the same issues that most of us involved in free software have gone through at some time. Welcome. I'm curious to know what the money that open source or GPL'd projects get and what this money means to these people's overall income. Well, it varies, but I'd say most of the time, it's done as a community contribution, not for money. It's similar to doctors doing free medical clinics, lawyers doing pro bono legal work, etc. However, it's possible to make a living writing GPL'd code, and some people do that. (I've done it in the past). Yes, what I ask may seem ridiculous, but I don't view it that way. Instead, I find that it is the implication of using a restrictive license such as I described to be ridiculous: if there is no monetary gain option in the license, then this implies that nobody (or very few) will be willing to do any work or asking for something for nothing. It isn't for nothing if you value knowledge and learning. Well, long experience has shown that in practice, such clauses tend to turn away users and developers. I admit that my view is a bit idealistic which leads me to believe that maybe I should reconsider the whole decision altogether. The really idealistic view is that once the program is published, the author has no special relation to it that others don't have. This is what the GPL tries to approximate, by giving users similar rights to the author's (e.g. guaranteed access to the source code). Note also that in your other posts, you're using selling in an imprecise and confusing way. This might help: http://www.gnu.org/philosophy/selling.html Some more articles on the general free software topic: http://www.gnu.org/philosophy/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Moving Places, Subtracting from slices/lists
Hi All, getting closer, me thinks. hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... del hotcat[x] ... Traceback (most recent call last): File stdin, line 3, in ? TypeError: list indices must be integers How do I get that x to be an integer b4 it is entered into the indice.? Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong with Zope 3 ?
Kay Schluehr wrote: Wolfram Kraus wrote: Kay Schluehr wrote: The last downloadable release is from november 2004. The Windows installer is configured for Python 2.3(!). The Zope.org main page announces Zope 2.8 beta 2. Is it stillborn? Kay What you see is not Zope 3, it is Zope X 3. To quote from the X3 information page: Zope X3 3.0 is for developers. If you are expecting an end-user application, this is not for you. Yes I noticed this almost 8 months ago, read a bit of the documentation and articles published that time, regarded it as interesting and considered it for future development. But since then absolutely nothing happened. No project plan, no time-schedule, no subsequent releases. You can always scan the zope3-mailinglist at zope.org (or via news.gmane.org) to see whats happening. Migth be a better place for questions, too. The current stable brance is Zope2.X If you want to incorporate some functionalty from X3 in Zope 2.X, do a search for Five No, I do not want to migrate components from a new major release backwards, as well as I do not want to migrate applications from WinXP to Win98. This seems to be the wrong development process direction. Well, the problem is that it is not a new major release but a new mayor experimental release. And X3 is not backward compatible, so a lot of Z2 products, e.g. Plone, don't work with X3. Regards, Kay HTH, Wolfram (still using Z2 ;-)) -- http://mail.python.org/mailman/listinfo/python-list
Re: The need to put self in every method
Fernando M. schrieb: i was just wondering about the need to put self as the first parameter in every method a class has because, if it's always needed, why the obligation to write it? couldn't it be implicit? Or is it a special reason for this being this way? See section 1.4.4 in http://www.python.org/doc/faq/general.html -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Moving Places, Subtracting from slices/lists
On Jun 2, 2005, at 12:12 AM, Mark Sargent wrote: Hi All, getting closer, me thinks. hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... del hotcat[x] ... Traceback (most recent call last): File stdin, line 3, in ? TypeError: list indices must be integers How do I get that x to be an integer b4 it is entered into the indice.? Cheers. if you add print x to the loop you will see that X is the various words. to get an integer, you could search the list for the index of x. but that's lame. btw hotcat[:] is a *copy* of hotcat, so just leave out [:] enumerate is a function that adds indexes to a list. observe: hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for index, word in enumerate(hotcat): if word == 'roof': del hotcat[index] you could also use a list comprehension hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] hotcat = [x for x in hotcat if x != 'roof'] -- Elliot Temple http://www.curi.us/ --- [This E-mail scanned for viruses by Declude Virus] -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser, mapping one key to multiple values
Am Wed, 01 Jun 2005 17:18:42 -0500 schrieb Larry Bates: I accomplish this by using the following construct with ConfigParser: [sync files] ignore_001=.*/foodir/.*\.pyc ignore_002=.*/foodir/.*~ Hi, I found out, that you can have newlines in the value: ignore_regex = .*/CVS(/.*)?$ .*/\.cvsignore$ .*\.pyc$ .*/\.# If you call split() on the value, you get the list you need. Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The need to put self in every method
Aahz schrieb: Because Python has no declarations there must be a different way to indicate in which category an identifier falls. [...] Any objection to swiping this for the FAQ? (Probably with some minor edits.) There is already a 'self' section (1.4.4) in the official Python FAQ. Looks like this has been forgotten. Perhaps it would be helpful to create a short version of the FAQ with the top most frequently asked questions/stumbling blocks/annoyances titled top 10 things you always wanted to know about Python and didn't dare to ask and post it weekly in this newsgroup :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to restrict lenght of entry widget to certain number of character
Michael Onfrek wrote: I'm playing with entry again and trying to restrict length of entry widget to certain number of character, so users cannot enter more character into it. Any ideas? import Tkinter as tk root = tk.Tk() var = tk.StringVar() max_len = 5 def on_write(*args): s = var.get() if len(s) max_len: var.set(s[:max_len]) var.trace_variable(w, on_write) entry = tk.Entry(root, textvariable=var) entry.pack() root.mainloop() Not very elegant, but better than nothing. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Like a star, I burn bright, dissipating into the night.
Hi phaywood, Re: Your grooving to this mantra of mine: Like a star, I burn bright, dissipating into the night. Seeing as you're in Comp.Lang.C, I'll express that in MicroSoft_C++ 7.1, slowly dissipating Sun into Night. I'm using special 32 bit random number routines here, but, because the appropriate graphics would be too much work, the results can only be viewed in a debugger. #pragma warning( disable: 4127 4508 ) #define WIN32_LEAN_AND_MEAN #include windows.h #define LOOP while ( 1 ) #define Loop( N ) int J = - 1, LLL = N ; while ( ++ J LLL ) #define LoopD( N ) int J = N ; while( -- J ) #define Tics ( QueryPerformanceCounter( ( Quad * ) _Tics ), _Tics ) typedef LARGE_INTEGER Quad ; typedef int * int_P ; const int HighResQual = 0x400, DecM = HighResQual* 4- 1, LongLeg = 63 , Short_Leg = 37, BothLegs = LongLeg + Short_Leg , Seed_Buf_Sz = 2 * BothLegs - 1, StopBit = 1 30 , EvenBits = StopBit - 2, Rand_Mask = StopBit - 1 ; int LegsBuf [ BothLegs ], HighResBuf [ HighResQual ]; int_P RanE = HighResBuf + BothLegs, RanP ; __int64 _Tics ; Deal(); Shuffle () { int StreamSperation = 70 - 1, Seed_Buf[ Seed_Buf_Sz ] , Seed = int( Tics ), Seed_2 = Seed + 2 EvenBits; RanP = RanE ; { Loop( BothLegs ) { Seed_Buf[ J ] = Seed_2 ; Seed_2 = 1 ; if ( Seed_2 = StopBit ) Seed_2 -= EvenBits; } } ZeroMemory( Seed_Buf + BothLegs, ( BothLegs - 1 ) * 4 ); Seed_Buf[ 1 ] ++ ; Seed_2 = Seed Rand_Mask ; LOOP { { LoopD( BothLegs ) Seed_Buf[ 2 * J ] = Seed_Buf[ J ]; } { int_P P = Seed_Buf + 1, R = Seed_Buf + Seed_Buf_Sz - 1 ; Loop( BothLegs - LongLeg / 2 - 1 ) P[ 2 * J ] = R [ -2 * J ] EvenBits ; } { int_P B = Seed_Buf, P = B + Seed_Buf_Sz, R = B + Short_Leg - 1 ; LoopD( BothLegs ) { if ( ! ( * -- P 1 ) ) continue; R [ J ] = R [ J ] - * P Rand_Mask ; B [ J - 1 ] = B [ J - 1 ] - * P Rand_Mask; } } if ( Seed_2 1 ) { memmove( Seed_Buf + 1, Seed_Buf, BothLegs * 4 ); * Seed_Buf = Seed_Buf [ BothLegs ]; if ( Seed_Buf [ BothLegs ] 1 ) Seed_Buf [ Short_Leg ] = Seed_Buf [ Short_Leg ] - Seed_Buf[ BothLegs ] Rand_Mask ; } if ( ! Seed_2 ! -- StreamSperation ) break ; Seed_2 = 1 ; } memmove( LegsBuf, Seed_Buf + Short_Leg, LongLeg * 4 ); memmove( LegsBuf + LongLeg, Seed_Buf, Short_Leg * 4 ); Deal(); } int Deal() { if ( ! RanP ) Shuffle(); if ( RanP RanP RanE ) return * RanP ++ ; RanP = HighResBuf ; memmove( HighResBuf, LegsBuf, sizeof LegsBuf ); { Loop( HighResQual - BothLegs ) HighResBuf [ J + BothLegs ] = HighResBuf [ J ] - HighResBuf [ J + LongLeg ] Rand_Mask ; } int_P P = HighResBuf + HighResQual - Short_Leg; { Loop( Short_Leg ) LegsBuf [ J ] = P [ J - LongLeg ] - P [ J ] Rand_Mask ; } P = HighResBuf + HighResQual - LongLeg ; Loop( LongLeg ) LegsBuf [ J + Short_Leg ] = P [ J ] - LegsBuf [ J ] Rand_Mask ; return * RanP ++ ; } inline float Rand() { return Deal() / ( float ) Rand_Mask ; } main() { double Star = 1e308, Night = 0 ; LOOP { float Dissipation = Rand(); if ( Star Dissipation ) { Star = 0 ; return ; } Star -= Dissipation, Night += Dissipation ; } } -- http://mail.python.org/mailman/listinfo/python-list
where to find the doc about python regular expression?
thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: BUG pythonw vs subprocess
John J. Lee wrote: Paul Rubin http://[EMAIL PROTECTED] writes: I thought pythonw didn't provide a console and so it could be that stdin and stdout aren't connected to anything. Popen therefore doesn't make sense. You have to use sockets or something. Yeah... I don't know about module subprocess, but I recall there's a known bug where pythonw actually crashes on win9x when you write to sys.stdout, since it's not connected to anything... John So then it's not possible to get pythonw apps eg tkinter guis to use subprocess properly? Seems a bit daft to me. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
pointers in com object functions
Hi, One of the functions in the com object I need to use has a pointer in one of it's functions (object.function(string input, struct * output)) I've tried to use the id() function but then Python gives me a message that it's an int, not a tructure and when I just give the object without a pointer, the object is still empty afterwards. I've created the struct with win32com.client.Record(structure, object) Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za -- http://mail.python.org/mailman/listinfo/python-list
wxpython or PyQT to make a simulink clone ?
I would like to make a software like simulink: http://www.mathworks.com/cmsimages/sl_mainpage_wl_7488.gif using python. In order of bulding the interface (dragdrop block, link system between the blocks, run the simulation, double click on a block to open its properties, ...) which library will make my job easyer, PyQT or WxPython ? -- http://mail.python.org/mailman/listinfo/python-list
Re: where to find the doc about python regular expression?
ÒÊÃÉɽÈË wrote: thanks Did you try Google: http://www.google.com/search?q=python+regular+expressions First hit is: http://www.amk.ca/python/howto/regex/ -- Klaus Alexander Seistrup Magnetic Ink, Copenhagen, Denmark http://magnetic-ink.dk/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to restrict lenght of entry widget to certain number of character
import Tkinter as tk Hi! Can you explain what line above mean? I also found : http://effbot.org/zone/tkinter-entry-validate.htm It works for me, but I not really understand how? :) Thanks for help! -- http://mail.python.org/mailman/listinfo/python-list
Re: viewing generated images
Tim Flynn wrote: def createWidgets(self): self.image_size = (50,50) self.pilim = Image.new( 1, self.image_size ) # Generate a blank image f = lambda(x): 0 Image.eval( self.pilim, f ) I'm not sure what you think that line is doing, but it probably doesn't do what you think it does. try changing the Image.new call to self.pilim = Image.new( 1, self.image_size, 0 ) instead. self.bmi = ImageTk.BitmapImage( image = self.pilim, foreground = 'black' ) self.canvas = Canvas( width=100, height = 100, bg = 'white' ) self.quitButton = Button( self, text=Quit, command=self.quit ) self.quitButton.grid() self.canvas.grid() im_id = self.canvas.create_bitmap( 0, 0, anchor = 'nw', bitmap = self.bmi ) it's a terminology confusion: for historical reasons, Tkinter distinguishes between bitmaps and images (this separation comes from the X window system). Bitmap- Image creates an image. changing to create_image should fix the problem. (if you're doing an image viewer, you may want to use PhotoImage instead of BitmapImage, btw). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Here
On 2005-05-31, Mark Sargent [EMAIL PROTECTED] wrote: for the same things, what do you primarily use it for. Could you show me Web apps using nevow/twisted for work, and pygtk apps for fun. You might browse around sourceforge a bit: http://sourceforge.net/softwaremap/trove_list.php?form_cat=178 Dave Cook -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as client-side browser script language
Greg Ewing [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... If the DOM objects are implemented as built-in Python types, there shouldn't be any difficulty with that. Python objects have complete control over which attributes can be read or written by Python code. That, together with restricting what the open() function can do, ought to provide a pretty good sandbox. Is that really enough, though? Previous discussions [1] suggested that the problem was pretty extensive, and the topic has been proposed [2] for the Summer of Code thing [3], although $4500 may not be a lavish enough amount if the work requires a complete overhaul of CPython. But on the subject of Python as a browser *extension* language where you download extensions from trusted sources and run them from the browser, PyKDE can be used with Konqueror to explore this area, although it does require a very recent PyKDE to work fully - see the kpartplugins on this page for more information: http://www.boddie.org.uk/david/Projects/Python/KDE/index.html It would also be great to unify Konqueror and Mozilla in some way by providing a common API for Python extensions - this could be done by wrapping Mozilla's DOM, presumably exposed via PyXPCOM [4], in a way similar to qtxmldom [5], and then making sure the boilerplate (initialising the extension, getting initial references to browser documents) is separated out from the actual extension code. Paul [1] http://www.amk.ca/python/howto/rexec/rexec.html [2] http://wiki.python.org/moin/RestrictedExecution [3] http://code.google.com/summerofcode.html [4] http://www.mozilla.org/catalog/architecture/xpcom/pyxpcom/ [5] http://www.python.org/pypi/qtxmldom -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython or PyQT to make a simulink clone ?
[EMAIL PROTECTED] wrote: I would like to make a software like simulink: http://www.mathworks.com/cmsimages/sl_mainpage_wl_7488.gif using python. In order of bulding the interface (dragdrop block, link system between the blocks, run the simulation, double click on a block to open its properties, ...) which library will make my job easyer, PyQT or WxPython ? wxPython has OGL which provides part of such an interface. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython or PyQT to make a simulink clone ?
thank you. I am watching the exemple of OGL. Very interesting! -- http://mail.python.org/mailman/listinfo/python-list
Re: dictionaries and threads
I've been trying to find a Python tutorial on threading - does anyone have a reference? Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Software licenses and releasing Python programs for review
Paul Rubin wrote: poisondart [EMAIL PROTECTED] writes: Yes, what I ask may seem ridiculous, but I don't view it that way. Instead, I find that it is the implication of using a restrictive license such as I described to be ridiculous: if there is no monetary gain option in the license, then this implies that nobody (or very few) will be willing to do any work or asking for something for nothing. It isn't for nothing if you value knowledge and learning. Well, long experience has shown that in practice, such clauses tend to turn away users and developers. And for thoroughness, allow me to add even if they have no intention or desire to profit monetarily. I can't explain exactly why this is the case, but it seems to be true in the overwhelming majority of cases. Academic projects with non-commercial clauses languish in obscurity while academic Open Source projects thrive. The contributors to the Open Source projects value knowledge and learning just as much as the lonely developers of the non-commercial-only projects, but for whatever reason, they don't contribute to those non-commercial-only projects. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: BUG pythonw vs subprocess
Paul Rubin wrote: I thought pythonw didn't provide a console and so it could be that stdin and stdout aren't connected to anything. Popen therefore doesn't make sense. You have to use sockets or something. Well my example is explicitly using PIPE for stderr stdin, but I don't know how to tell it to ignore stdin. The value None seems to be used to signal that the existing stdin is used and that fails. I believe the solution is just to use PIPE for stdin as well and then I don't have to write to it. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython or PyQT to make a simulink clone ?
Pierre Schnizer [EMAIL PROTECTED] writes: There was an old discussion on comp.lang.python: http://groups.google.de/group/comp.lang.python/browse_thread/thread/9ce44f40011016ec/a2e52b824de9bfb1?q=simulinkrnum=6hl=de#a2e52b824de9bfb1 I have seen the later code of Eric Lechak looked very interesting, but the link above is not active any more. Unfortunately I have no copy any longer ... Pierre -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert string to list or tuple
Ruud de Jong wrote: Steven Bethard schreef: But unless the person eval-ing your code *only* writes immaculate code I can see that you can probably screw them. ;) I wonder why __subclasses__ isn't a restricted attribute... Is it ever used for something that isn't evil? ;) STeVe Completely off topic, but I just cannot resist showing off. Some time ago I used __subclasses__ in a way that is not evil. I think. The details are described in the following thread: http://groups.google.nl/group/comp.lang.python/browse_thread/thread/5c1 ccb986c66cdc1/ A summary: I used __subclasses__ to apply the Chain-of-Responsibility pattern to object creation. The code would appear to instantiate an object of the root of a class hierarchy, but the actual object that was created would be an instance of a subclass. So to get back to your question: yes, there are non-evil uses for __subclasses__. Weird perhaps, but non-evil. Non-standard, sure . Too clever for my own good, very likely. I've done almost exactly the same thing. The base class uses __subclasses__ to find the best matching subclass based on the factory parameters. In my case I was retrieving files from the web, so I had a base Handler class and created HtmlHandler, ImageHandler c. class Handler(object): '''Class to process files''' __map = {} @classmethod def _resolveClass(klass, isdir, name): map = Handler.__map if not map: for c in klass.__subclasses__(): for ext in c.Extensions: map['.'+ext.lower()] = c if isdir: klass = FolderHandler else: ext = os.path.splitext(name)[1].lower() if ext not in map: map[ext] = DefaultHandler klass = map[ext] return klass(name) @classmethod def fromPathname(klass, name, path, uri, db): isdir = os.path.isdir(os.path.join(path, name)) obj = klass._resolveClass(isdir, name) obj._initialize(name, path, uri, db) return obj @classmethod def fromUrl(klass, uri, text, db=None): ... and so on ... and then subclasses such as: class ImageHandler(Handler): Extensions = ('jpg', 'jpeg', 'gif', 'png') type = 'Image' class DefaultHandler(Handler): Extensions = ('',) type = 'Ignored' This also contains the only code I think I've written with a class definition in a for loop: # General categories EXTENSIONS = { 'js': 'javascript', 'php': 'php', 'doc': 'Word Document', 'xls': 'Spreadsheet', 'ppt': 'Powerpoint', 'css': 'Stylesheet', 'swf': 'Flash', 'pdf': 'File', 'rtf': 'File', 'zip': 'File', } Classes = [] for ext in EXTENSIONS: class GeneralHandler(Handler): Extensions = (ext,) type = EXTENSIONS[ext] Classes.append(GeneralHandler) -- http://mail.python.org/mailman/listinfo/python-list
Re: Moving Places, Subtracting from slices/lists
Elliot Temple wrote: btw hotcat[:] is a *copy* of hotcat, so just leave out [:] when you want to modify the thing you're looping over, you need to be careful. looping over a copy is often a good idea (see the Python tutorial and the FAQ for more on this). enumerate is a function that adds indexes to a list. observe: hotcat = ['roof', 'roof', 'roof'] for index, word in enumerate(hotcat): if word == 'roof': del hotcat[index] print hotcat ['roof'] if I understand the OP correctly, he wants to *move* the roof to the end of the string. try: hotcat.remove(root) hotcat.append(root) except ValueError: pass is most likely the fastest way to do that. /F -- http://mail.python.org/mailman/listinfo/python-list
how to retrieve info about print jobs
Hi all, We have several printers in our company network. I would like to know if it is possible to check the current print jobs/queues for each of them. That way, if a user wants to print something (big), I could give her a hint as to which printer would get the job done first. We're using win2k and xp, btw. Any ideas? I'm pretty new to python, I'm afraid.. TIA, g -- http://mail.python.org/mailman/listinfo/python-list
decimal and trunkating
i want to trunkate 199.999 to 199.99 getcontext.prec = 2 isn't what i'm after either, all that does is E's the value. do i really have to use floats to do this? -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a hex value
David Bear wrote: I have a file that I need to parse. Items in it are delimited by a hex 15 (0x015). I know it must be trivial to assign a hex value to a variable but I'm not seeing it in my python essential ref. how can I do delim = 0x15 while: ln = file.read() if ln[0] == delim: do something I've looked at the hex function but it doesn't sound like what I want. you can use use ord(ln[0]) == delim or ln[0] == '\x15' or ln[0] == chr(delim) or ln.startswith(\x015) or some other variation. fwiw, I'm pretty sure file.read() doesn't do what you want either (unless you're 100% sure that the file only contains a single item). if the file isn't larger than a few megs, consider using items = file.read().split(\x15) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How to restrict lenght of entry widget to certain number of character
Peter Otten wrote: Michael Onfrek wrote: import Tkinter as tk Hi! Can you explain what line above mean? I also found : http://effbot.org/zone/tkinter-entry-validate.htm It works for me, but I not really understand how? :) import Tkinter as tk Make objects defined in Tkinter available under the tk prefix. E. g. to access an Entry you can do 'tk.Entry'. Had you imported it 'import Tkinter' you would have to do 'Tkinter.Entry' instead. So you are saving a few keystrokes. Doing 'from Tkinter import *' saves you still more keystrokes but is considered bad style except for demonstration purposes. var = tk.StringVar() entry = tk.Entry(root, textvariable=var) Create a StringVar and connect it to the Entry widget. Any changes the user makes in the Entry are reflected in the StringVar's value which can be accessed with its get() method. max_len = 5 def on_write(*args): s = var.get() if len(s) max_len: var.set(s[:max_len]) Define a function that doesn't care about the arguments passed to it. It reads the current value of the StringVar 'var' and, if necessary, trims it to 'max_len_' characters. var.trace_variable(w, on_write) Tell the StringVar to call the function on_write() every time its value is changed. So every time the user edits the data in the Entry, in turn the Entry changes the data of the StringVar, which calls the on_write() function which may or may not change the StringVar -- and that change is reflected in what the Entry displays. This smells like an endless loop, but so far we seem to be lucky... If you look again at Fredrik Lundh's ValidatingEntry, you will find all the elements explained above packed nicely into one class, with the extra refinement that he keeps another copy of the value which is used to restore the old state when the new value is found to be invalid. Peter Thank you, man! You should write an tutorial to Tkinter or something like that. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to retrieve info about print jobs
On 6/2/05, Guy Lateur [EMAIL PROTECTED] wrote: We have several printers in our company network. I would like to know if it is possible to check the current print jobs/queues for each of them. That way, if a user wants to print something (big), I could give her a hint as to which printer would get the job done first. We're using win2k and xp, btw. You can probably do this with WMI. Ah yes, see http://www.c-sharpcorner.com/Code/2002/May/IntPrinterQWMI.asp. You can drive WMI from Python with Tim Golden's WMI module - http://tgolden.sc.sabren.com/python/wmi.html. Do let us know what you come up with! -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
DOM question
Hi there, I have an XML document which contains a mixture of structural nodes (called 'section' and with unique 'id' attributes) and non-structural nodes (called anything else). The structural elements ('section's) can contain, as well as non-structural elements, other structural elements. I'm doing the Python DOM programming with this document and have got stuck with something. I want to be able to get all the non-structural elements which are children of a given 'section' elemenent (identified by 'id' attribute) but not children of any child 'section' elements of the given 'section'. e.g.: section id=a foobar/foo /section section id=b foobaz/foo section id=c barfoo/bar /section /section Given this document, the working function would return foobaz/foo for id='b' and barfoo/bar for id='c'. Normally, recursion is used for DOM traversals. I've tried this function which uses recursion with a generator (can the two be mixed?) def content_elements(node): if node.hasChildNodes(): node = node.firstChild if not page_node(node): yield node for e in self.content_elements(node): yield e node = node.nextSibling which didn't work. So I tried it without using a generator: def content_elements(node, elements): if node.hasChildNodes(): node = node.firstChild if node.nodeType == Node.ELEMENT_NODE: print node.tagName if not page_node(node): elements.append(node) self.content_elements(node, elements) node = node.nextSibling return elements However, I got exactly the same problem: each time I use this function I just get a DOM Text node with a few white space (tabs and returns) in it. I guess this is the indentation in my source document? But why do I not get the propert element nodes? Cheers, Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: using builtin array
Arrays are homogenous. No chance concatenating them. This should of course read No chance concatenating arrays of different typecodes. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: DOM question
However, I got exactly the same problem: each time I use this function I just get a DOM Text node with a few white space (tabs and returns) in it. I guess this is the indentation in my source document? But why do I not get the propert element nodes? Welcome to the wonderful world of DOM, Where insignificant whitespace becomes a first-class citizen! Use XPath. Really. It's well worth the effort, as it is suited for exactly the tasks you presented us, and allows for a concise formulation of these. Yours would be (untested) //section[id==$id_param]/node()[!name() == section] It looks from the root throug all the descending childs // after nodes with name section section that fulfill the predicate [id==$id_param] From this out we collect all immediate children /node() that are not of type section [!name() == section] -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Newbie question: Allocation vs references
Hello all, Behold: -- a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [ a, b ] print q[0][0] print q[1][1] a[0] = 'Snoo' b[1] = 'Gnuu' print q[0][0] print q[1][1] -- This will output: Foo Far Snoo Gnuu I assume it does so because q stores _references_ to a and b. How would do I do if I want to copy the list? I.e. I want the output from the code above to be: Foo Far Foo Far ..even if a[0] = 'Snoo' and b[1] = 'Gnuu' remain where they are. Or, better yet, how do I store a and b in q, and then tell Python that I want a and b to point to new lists, without touching the contents in q? C equivalent of what I want to do: --- a = calloc(n, size); prepare(a) q[0] = a; a = calloc(n, size); // new list; 'q' is unaffected if I change 'a' --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: Allocation vs references
Jan Danielsson [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Hello all, Behold: -- a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [ a, b ] print q[0][0] print q[1][1] a[0] = 'Snoo' b[1] = 'Gnuu' print q[0][0] print q[1][1] -- This will output: Foo Far Snoo Gnuu I assume it does so because q stores _references_ to a and b. How would do I do if I want to copy the list? I.e. I want the output from the code above to be: If your original assigment to q were: q = [ a[:], b[:] ] ... you would have copies of a and b, so that: a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [ a[:], b[:] ] print q[0][0] Foo print q[1][1] Far a[0] = 'Snoo' b[1] = 'Gnuu' print q[0][0] Foo print q[1][1] Far Foo Far Foo Far ..even if a[0] = 'Snoo' and b[1] = 'Gnuu' remain where they are. Or, better yet, how do I store a and b in q, and then tell Python that I want a and b to point to new lists, without touching the contents in q? That's easier: a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [a,b] a = ['Splee','Hoongk'] b = ['Blik','Poit'] print q[0][0] Foo print q[1][1] Far You've stuck the 'a' and 'b' labels on new objects this way. The original objects would vanish except that there is still a reference to them through the 'q' list. C equivalent of what I want to do: --- a = calloc(n, size); prepare(a) q[0] = a; a = calloc(n, size); // new list; 'q' is unaffected if I change 'a' --- -- rzed -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: Allocation vs references
On 2005-06-02 14:43:40, Jan Danielsson wrote: a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [ a, b ] Or, better yet, how do I store a and b in q, and then tell Python that I want a and b to point to new lists, without touching the contents in q? There are several ways to create a copy of a list: a1 = a[:] # new copy, sliced from 0 to end a2 = list(a) # create a new list object out of any sequence import copy a3 = copy.copy(a) # use the copy module So you could do for example: q1 = [ list(a), list(b) ] q2 = [ a[:], b[:] ] q3 = [ list(x) for x in (a,b)] Note that the copy module also has a function deepcopy that will make copies at all levels. So if you had: q = [a,b] q1 = copy.deepcopy(q2) every list in q1, even the inner a and b will be new copies. Note that non-mutables such as Foo and Bar are NOT copied, but as they cannot be changed, that doesn't matter. -- Stian Søiland Work toward win-win situation. Win-lose Trondheim, Norway is where you win and the other lose. http://soiland.no/ Lose-lose and lose-win are left as an exercise to the reader. [Limoncelli/Hogan] Og dette er en ekstra linje -- http://mail.python.org/mailman/listinfo/python-list
Re: dictionaries and threads
thanks. Looks good. -- http://mail.python.org/mailman/listinfo/python-list
Re: xml processing
On Wednesday 01 June 2005 11:01 am, Steven Bethard wrote: If you're not committed to pyxml, you might consider using ElementTree: http://effbot.org/zone/element-index.htm I find it *way* easier to work with. Thanks. I've installed it and am experimenting. -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Le Thu, 02 Jun 2005 19:59:08 +1000, Timothy Smith a écrit : i want to trunkate 199.999 to 199.99 round(199.999, 2) # 2 digits after the decimal point do i really have to use floats to do this? 19.999 is a float : type(19.999) is float # == True -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
F. Petitjean wrote: Le Thu, 02 Jun 2005 19:59:08 +1000, Timothy Smith a écrit : i want to trunkate 199.999 to 199.99 round(199.999, 2) # 2 digits after the decimal point Wrong. This will yield 200.00. do i really have to use floats to do this? 19.999 is a float : type(19.999) is float # == True He is speaking of Decimals... d = Decimal(199.999) d._round(5, decimal.ROUND_DOWN) Reinhold -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Timothy Smith [EMAIL PROTECTED] wrote: i want to trunkate 199.999 to 199.99 getcontext.prec = 2 isn't what i'm after either, all that does is E's the value. do i really have to use floats to do this? You could try this (from a script I use for my phone bill): from decimal import Decimal as d def roundDecimal(num, prec): return d(num).quantize(d(1e%d % (-prec))) where `prec` is the number of places after the decimal point. I'm sure there is a better solutions and someone will tell it, thereby teaching us both. ;-) Adia, Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython or PyQT to make a simulink clone ?
thank you, I checked viper, but the license is not so simple.. I am testing your truffaldino ! seems interesting, but I could not launch it. I am running: Python 2.3 wxpython 2.6 (for python 2.3) I installed mtalib, Truffaldino, Smeraldina and nodenet. Also installed DSV and pygsl-0.3.1_Numeric.win32-py2.3.exe Then, I launch /smeraldina/gui/wxsmeraldina but, nothing .. I do not have error messages. it could import all the modules. Can you please help me ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner question: Logs?
Elliot Temple wrote: from math import * log10(15625) It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with it, and is widely considered poor style, and should really only rarely be used. (The math module is probably one of the few places where some people make an exception, however, but it's still not a good habit to get into.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: DOM question
On Thu, 02 Jun 2005 14:34:47 +0200, Diez B. Roggisch [EMAIL PROTECTED] said: However, I got exactly the same problem: each time I use this function I just get a DOM Text node with a few white space (tabs and returns) in it. I guess this is the indentation in my source document? But why do I not get the propert element nodes? Welcome to the wonderful world of DOM, Where insignificant whitespace becomes a first-class citizen! Use XPath. Really. It's well worth the effort, as it is suited for exactly the tasks you presented us, and allows for a concise formulation of these. Yours would be (untested) //section[id==$id_param]/node()[!name() == section] Yes, in fact: //[EMAIL PROTECTED]//*[name()!='section'] would do the trick. I was trying to avoid using anything not in the standard Python distribution if I could help it; I need to be able to use my code on Linux, OS X and Windows. The xml.path package is from PyXML, yes? I'll just have to battle with installing PyXML on OS X ;-) Cheers, Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Timothy Smith wrote: i want to trunkate 199.999 to 199.99 getcontext.prec = 2 isn't what i'm after either, all that does is E's the value. do i really have to use floats to do this? I think you need a context with appropriate rounding set (e.g. ROUND_FLOOR?) and then use the quantize() method with an argument with the appropriate number of decimal places. For example, this works, though I'm definitely not a Decimal expert and am confident there's a more elegant approach (which might depend on more information about what you're doing): d = decimal.Decimal('199.999') decimal.getcontext().rounding = decimal.ROUND_FLOOR d.quantize(decimal.Decimal('1.00')) Decimal(199.99) -Peter (I hope this inspires someone who actually knows what he's doing with Decimal to post an improved solution.) -- http://mail.python.org/mailman/listinfo/python-list
Two questions
Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; 2. Philospohy(sp?) aside, I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? Thanks, - QS Computing. -- http://mail.python.org/mailman/listinfo/python-list
Re: any macro-like construct/technique/trick?
Andrew's approach is good, but you could so something a little simpler/more flexible. Untested of course. :-) Every callable object is followed by the args to pass it. So this: debug_emit(DbgObjFoo(a, b, costly_function(c))) becomes: debug_emit(DbgObjFoo, (a, b, costly_function, (c,))) def debug_emit(*args): if not debug: return # assume last arg is not a callable and skip it i = len(args) - 2 while i 0: if callable(args[i]): # call it! assume the next arg is a tuple of params new_value = args[i](*args[i+1]) args = args[:i] + (new_value,) + args[i+2:] emit_dbg_code(*args) cheers, n -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Reinhold Birkenfeld wrote: He is speaking of Decimals... d = Decimal(199.999) d._round(5, decimal.ROUND_DOWN) Is one really supposed to call the underscore methods like that? -Peter -- http://mail.python.org/mailman/listinfo/python-list
Python Win32 and Condor
Hi. I have a created a python script that opens a program then uses the com package to run a few things and then close. the program. It works perfectly fine when run normally. ie from command prompt or shell. Now I am using the University of Wisconsins queueing program Condor to execute this on a number of machines. So far it works perfectly on everyting I have tried. Until today. I tried It on another machine on the network, (same OS, WINXP as the rest) same everything actually but now I get this error. Traceback (most recent call last): File C:\Condor\execute\dir_3760\test.py, line 39, in ? AB = win32com.client.Dispatch(Broker.Application) File C:\Python23\Lib\site-packages\win32com\client\__init__.py, line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File C:\Python23\Lib\site-packages\win32com\client\dynamic.py, line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File C:\Python23\Lib\site-packages\win32com\client\dynamic.py, line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147024891, 'Access is denied.', None, None) The funny thing is it works without Condor, just executing regularly with cmd prompt. So I thought it was a condor problem but It runs on all other machines just fine, also a jscript run in the problem machine works with condor. Any help is apreciated. Brian Hamm -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Peter Hansen wrote: d = decimal.Decimal('199.999') decimal.getcontext().rounding = decimal.ROUND_FLOOR d.quantize(decimal.Decimal('1.00')) Decimal(199.99) Or skip changing the context and use the second argument to quantize: d.quantize(Decimal('1.00'), decimal.ROUND_FLOOR) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
On 2 Jun 2005 06:45:18 -0700, [EMAIL PROTECTED] said: Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; for i in range(0, 2): do stuff The range([start], stop, [step]) function generates a sequence of numbers which the the for loop iterates over. (You can also use xrange() for a more memory efficient solution for very large ranges). 2. Philospohy(sp?) aside, I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? To create binary only distributions for Windows you can use py2exe. Its distributions files can be fairly easily reverse engineered. Cheers, Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
[EMAIL PROTECTED] wrote: I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; for i in xrange(0, 3): # code Please read the tutorial. I'm fairly sure this and many more things you'll want to know are covered adequately. 2. Philospohy(sp?) aside, I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? They are compiled versions of the .py files, so definitely not the same. They are created automatically and transparently when you import .py modules, so normally you don't pay any attention to them. They can easily be reverse-engineered, if by that you mean turned back into source code. See decompyle for example. Using the compileall module you can manually compile .py to .pyc but, again, that's generally not needed. Use of tools like py2exe is generally advised for packaging and distibution if you don't want to distribute source, though few of the existing tools do much more than package up .pyc files inside archives, bundle the runtime library, and add wrapper code to make the execution transparent. Philosophy not entirely aside, you should note that object code in any language can easily be reverse-engineered in the same way, with the only difference being the degree of ease involved. If the code is worth enough to someone that they are willing to risk violating your license terms, they *will* be able to recover enough source code (whether it was Python, C, or assembly) to do what they need. The only certain protection is to keep the valuable code on a server and use some kind of web service (or whatever) to control access to its execution. (There have been *many* past discussions of all this in the forum -- it's a very tired topic by now -- so please feel free to peruse the archives via Google Groups before asking lots of the same questions over again. You'll be doing yourself a favour.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: How to restrict lenght of entry widget to certain number of character
Ideed, good idea! -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
[EMAIL PROTECTED] wrote: Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; Um, assuming that this loops through the numbers 0 to 2 and assigns them to the variable I, and then does something in code with I after it's been assigned, the python equivalent is: for I in range(0,3): //code (Note the whitespace after opening the for loop?) And then break the indenting to finish the for loop. So you're next piece of code (Whatever you had after end;) would go here: //morecode. 2. Philospohy(sp?) aside, I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? As long as you have write access to the directory that you're .py files are in, when you run python, it will generate the .pyc files for you as they are loaded. There is also a utility script in the main distribution called py_compile.py. E.g. compiling a whole directory of .py files: python /path/to/main/install/py_compile.py *.py And to compile them as optimised binary files (.pyo): python -O /path/to/main/install/py_compile.py *.py They are used like ordinary .py source files. (Python actually executes from the .pyc files it builds from your .py files.) They can be reverse-engineered, but then so can Java/C++/Assembler. Have a look through the group for something about being able to distribute your modules.pyc as a zipfile - I remember something about being able to do a -tiny- bit of extra protection by having them as a passworded zip file. Thanks, - QS Computing. Welcome. Joal -- http://mail.python.org/mailman/listinfo/python-list
optparse.py: FutureWarning error
I keep getting the following error/warning message when using the python based program getmail4: /usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up return (%s at 0x%x: %r I'm using python2.3.5 on a debian sid box. The getmail4 website/FAQ maintains that this is a bug in the optparse module. Any idea on how to resolve this? Thanks Kevin -- http://mail.python.org/mailman/listinfo/python-list
calling ksh script from python
hi all, I'm trying to call ksh script from python. I have a file (toto.env) with a scirpt looking like: -- begin --- #!/bin/ksh # export TOTO_ENV=/home/toto -- end --- I call it from python like that: -- begin --- import commands commands.getstatusoutput('. toto.env') -- end --- but it always return an error saying: sh: TOTO_ENV=/home/home: is not an identifier doesn anyone know why ? no matter what I use (popen,system...) it's always the same error... if I directly try to do commands.getstatusoutput('export TOTO_ENV=/home/toto') it's the same error... and what about this sh primpt in the error message, can't I use ksh script ? thanks for any help ronan -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
Peter Hansen wrote: Philosophy not entirely aside, you should note that object code in any language can easily be reverse-engineered in the same way, with the only difference being the degree of ease involved. If the code is worth enough to someone that they are willing to risk violating your license terms, they *will* be able to recover enough source code (whether it was Python, C, or assembly) to do what they need. Don't intend to hijack this thread, but this bit interests me. I know several accomplished C/assembly programmers who have told me that reverse engineering object code from either of these two languages is anything but trivial. Yet, I *hear* and *read* the opposite all of the time. Can anyone actually demonstrate a decompile that mirrors the original source? Also, I'd venture to say that the number of people in the world who can consistently reverse engineer object code is almost statistically insignificant... sure, they are out there, but you'll win the lottery before you meet one of them and most of them work for big, bad government agencies ;) -- http://mail.python.org/mailman/listinfo/python-list
wxPython
Hi, I've got a question about wxPython, wheres the best place to ask?? Mike -- http://mail.python.org/mailman/listinfo/python-list
return pramater in com object function
Hi, One of the functions in the com object I need to use has a pointer in one of it's functions (object.function(string input, struct * output)) (I've created the struct with win32com.client.Record(structure, object)) I've tried to use the id() function but then Python gives me a message that it's an int, not a tructure and when I just give the object without a pointer, the object is still empty afterwards. In the mailinglist archive I saw this message from Mark Hammond: Well, their IDL is at fault, and it clearly should be marked as [in,out]. All we should need to do is to get the makepy generated code for this function, and change the last type tuple for this function. It will be a tuple of, eg (pythoncom.VT_OBJECT, pythoncom.PARAMFLAG_FIN). Telling Python it is really _FIN | _FOUT should do the trick So I opened the by genPy generated file and tried to change the last tuple from _ApplyTypes_ but it was already 2 (PARAMFLAG_FOUT): return self._ApplyTypes_(1, 1, (24, 0), ((8, 1), (36, 2)), 'SetIDString', None,inID, outID) Does anyone know how to solve this? Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za -- http://mail.python.org/mailman/listinfo/python-list
[python-gtk] problem with multiple inheritance
Hi I'm trying to install a certain python program which uses gtk, and the following line: class view_tree_model(gtk.GenericTreeModel,gtk.TreeSortable): raises a TypeError: multiple bases have instance lay-out conflict Is this a bug in gtk, or python-gtk, or something? I know of people who run this program, so I guess sthg must be wrong in my system. I have Mdk 10.0, and in particular: pygtk2.0-wrapper-2.0.0-2mdk libgtk+1.2-1.2.10-38mdk gtk+2.0-2.4.9-9mdk pygtk2.0-2.0.0-2mdk libgtk+2.0_0-2.4.9-9mdk pygtk2.0-libglade-2.0.0-2mdk gtkdialogs-2.1-1mdk gtk-engines-0.12-8mdk Anybody can help? Thx Bartek -- Zamiast sensownej sygnatury...: | http://www.safetycam.pl | http://www.bpcc.org.pl/en,0,0.html | http://www.spoko.neostrada.pl | http://www.gorny.najlepsze.pl/imiona -- http://mail.python.org/mailman/listinfo/python-list
Re: decimal and trunkating
Peter Hansen wrote: Reinhold Birkenfeld wrote: He is speaking of Decimals... d = Decimal(199.999) d._round(5, decimal.ROUND_DOWN) Is one really supposed to call the underscore methods like that? Umm... no, I think not ;) But I couldn't find something better. Reinhold -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
Yep that improved the speed by about 50% now it takes about 10 secs instead of 24 seconds..Thanks much. I guess that is the best we could do right.It would be really helpful if I could get it less than 5 seconds. Any suggestions on that?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
rbt wrote: Peter Hansen wrote: Philosophy not entirely aside, you should note that object code in any language can easily be reverse-engineered in the same way, with the only difference being the degree of ease involved. If the code is worth enough to someone that they are willing to risk violating your license terms, they *will* be able to recover enough source code (whether it was Python, C, or assembly) to do what they need. Don't intend to hijack this thread, but this bit interests me. I know several accomplished C/assembly programmers who have told me that reverse engineering object code from either of these two languages is anything but trivial. Yet, I *hear* and *read* the opposite all of the time. Can anyone actually demonstrate a decompile that mirrors the original source? I give you one example: Online/Multiplayer GTA 3 or 4 (http://gta3mta.tk/) A C-App never intended to work that way - but skillfully patched so that it works! And that even only as OSS - no commercial interest (and thus funding). So I day Peter's statement has full validity - it's a question of interest. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
Richard Lewis wrote: On 2 Jun 2005 06:45:18 -0700, [EMAIL PROTECTED] said: Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; for i in range(0, 2): do stuff Eh, no. range(0, 3) would be correct, since the Python range function generates a list from start to stop-1. The range([start], stop, [step]) function generates a sequence of numbers which the the for loop iterates over. (You can also use xrange() for a more memory efficient solution for very large ranges). 2. Philospohy(sp?) aside, I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? They are a binary representation of bytecode, just like in Java. They can be reverse-engineered more easily than machine code, but it still is no no-brainer. Btw, they are created automatically... Reinhold -- http://mail.python.org/mailman/listinfo/python-list
PYTHONSTARTUP and the -i command line option
Greetings all, A quick query: as all sorts of stuff can be defined in a .pythonrc.py file or similar and called at python startup using the PYTHONSTARTUP environment variable, it's very useful and can enhance the interpreter experience greatly. However, executing a script using the -i command line option to put the Python interpreter into 'interactive mode' after script termination is also very useful. But these two things won't play together, as (by design, it seems) $PYTHONSTARTUP isn't read when the -i option is used, leaving me with an unenhanced Python interpreter environment after after script execution. Is the any way round this, other than editing all my scripts or manually loading the .pythonrc.py script in the interpreter? Thanks in advance for any hints! Chris Wood -- http://mail.python.org/mailman/listinfo/python-list
Re: DOM question
Yes, in fact: //[EMAIL PROTECTED]//*[name()!='section'] would do the trick. I was trying to avoid using anything not in the standard Python distribution if I could help it; I need to be able to use my code on Linux, OS X and Windows. The xml.path package is from PyXML, yes? I'll just have to battle with installing PyXML on OS X ;-) As a fresh member of the MacOSX community I can say that so far except pygame I made everything run. So - I don't expect that to be too much of a problem. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Software licenses and releasing Python programs for review
On Thu, Jun 02, 2005 at 01:57:25AM -0700, Robert Kern wrote: And for thoroughness, allow me to add even if they have no intention or desire to profit monetarily. I can't explain exactly why this is the case, but it seems to be true in the overwhelming majority of cases. Academic projects with non-commercial clauses languish in obscurity while academic Open Source projects thrive. The contributors to the Open Well, it's easily explained. (Well at least my motivation in this case) I do not touch things that I cannot use generally and being a commercial IT consultant this basically means: *) opensource is better than commercial payware. (because for free (as in beer) is usable in more contexts) *) GPL is acceptable for much stuff, because I can install GPL'ed stuff for a customer. *) GPL is not acceptable for library stuff, because as a software developer I'm sometimes forced to do closed stuff. (Yep, even nowadays there are place where it's basically a legal requirement.) Implications: *) qt is a bordercase: GPL for free, or commercial for pay. Not perfect but good enough. *) A number of O-R mappers for Python are of no relevance to me, because they are GPL. O-R mappers are development libraries. The idea is that I'm mostly not interested in learning tools that are not of general use. So basically, stuff not meeting this criteria, is only interesting if it's unique: *) commercial stuff is only interesting if there is no competing open-source project. *) GPL'ed building blocks are only interesting when there is no competing LGPL version. Example: OCR on Linux/Unix. There are no perfect solutions there so a GPL'ed solution might be ok. (Especially because one can use OCR without linking with a lib *grin*) Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: anygui,anydb, any opinions?
Skip Montanaro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Are we talking about a drag-and-drop GUI builder? Thomas I am! What about Glade? Thomas Dying to try that. Ask me again in a week. I use Glade at work on a regular basis. Took me a few days to get proficient, and it has some warts, but it sure beats the heck out of manually creating all those widgets in my Python code. Skip Yes. Anything that automates/assists the creation of the user interface is a phenomenal time saver. The task of getting data from and delivering it to a human operator is still the most difficult and time consuming part of creating software. It is so onerous that it tempts one to abandon writing software for organic beings altogether. My reference to Visual Basic was meant to be a poke in the eye. The language itself stinks. BUT - having a robust IDE with keyword tooltip prompts, built in language documentation, robust built in debugging, and most of all - a stable GUI , a standard suite of widgets for interacting with those pesky, error prone humans, the ability to draw these on a form with a mouse and have all that running in minutes! It no longer matters that the language itself smells like 4 day old fish! No amount of linguistic or structural elegance can have as much impact on productivity as the IDE/GUI. It drives me crazy when someone suggests that it might amount to no more than a bit of fluff hardly worth bothering with because when it comes to programming - An excellent IDE/GUI just trumps everything. Thomas Bartkus -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way of doing this?
On Mon, 30 May 2005 14:05:36 +0200, Magnus Lycka wrote: Steven D'Aprano wrote: print is a statement, not a function. The brackets are syntactically correct, but pointless. Remove them. ... On Sat, 28 May 2005 13:24:19 +, Michael wrote: while( newNS ): Guido (our Benevolent Dictator For Life and creator of Python) hates seeing whitespace next to parentheses. I agree with him. while(newNS) good, while( newNS ) bad. while is a statement, not a function. The brackets are syntactically correct, but pointless. Remove them. ;^) Um. Er. Of course I knew that. I deliberately made that error to see if others were paying attention. Well done, go to the head of the class. *cough* :-) while newNS: Not only are they pointless (in both print and while), but they are blurring the distinction between statements and callables, and they add noise. Only wrap the expression following a statement such as while, if, print etc in () if the following expression spans several lines. Yes, of course you are right. Serves me right for replying to Usenet posts in the wee hours of the morning. Although, pardon me for stating the obvious, using brackets for precedence, or to add clarity by careful grouping, is always allowed even if the expression doesn't span more than one line. eg while (index 0) and (not found or still_working): -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Software for System Builders, Resellers, and Hardware Purchasers Only.
GET latest softwares, 99% savings. http://jtj.pebms6p0mh7wm87.narrjl.com Human nature is not of itself vicious. I believe in God, only I spell it Nature. -- http://mail.python.org/mailman/listinfo/python-list
TkInter Listbox Widget Formatting
I've searched high and low, and I can't seem to find a way to center or right justify the text in a Listbox widget using TkInter. The justify option is unrecognized. Any options I'm missing, or a known work-around? Thanks! Kyle -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.4: tarfile tell() and seek() seem to be broeken
On Wed, 01 Jun 2005 14:58:23 +0200, N. Volbers wrote: - subsequent calls of fd.readline() and fd.tell() will yield the correct lines but always the same value from fd.tell(). Is there a mistake on my side or does this need fixing? This is a bug. Although the pseudo file object's readline() method returns the file data line-wise, the data is processed block-wise (100 chars) internally. Therefore, the output of tell() will always return the position right after the current block if it is used in conjunction with readline(). Thank you for pointing that out. I'll take care of this getting fixed. -- Lars Gustäbel [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
link to the HP 3115 iPAQ - list of features for info -- $350 w/Bluetooth built-in
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItemitem=5778810554ssPageName=MER C_VIC_ReBay_Pr4_PcY_BIN -- http://mail.python.org/mailman/listinfo/python-list
Re: convert a string to tuple
On Tue, 31 May 2005 13:14:09 -0700, querypk wrote: how do I convert b is a string b = '(1,2,3,4)' to b = (1,2,3,4) You can do: def str2tuple(s): Convert tuple-like strings to real tuples. eg '(1,2,3,4)' - (1, 2, 3, 4) if s[0] + s[-1] != (): raise ValueError(Badly formatted string (missing brackets).) items = s[1:-1] # removes the leading and trailing brackets items = items.split(',') L = [int(x.strip()) for x in items] # clean up spaces, convert to ints return tuple(L) For real production code, you will probably want better error checking. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: calling ksh script from python
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: ... I call it from python like that: -- begin --- import commands commands.getstatusoutput('. toto.env') -- end --- but it always return an error saying: sh: TOTO_ENV=/home/home: is not an identifier doesn anyone know why ? ... and what about this sh primpt in the error message, can't I use ksh script ? Yes and no. You can expect system(), popen() et al. to invoke the standard UNIX shell, sh, so you must supply an expression that will be correctly executed by that shell. That expression can execute a program written in another language - for example, 'ksh toto.env' or just './toto.env' if you have made it executable and it starts with #!/bin/ksh. That's really the best way to invoke a script. Meanwhile, it might be worthwhile to reconsider the use of ksh here, if you have any choice in the matter. Ksh is fine for interactive use, but has some unfortunate flaws as a programming shell, and due to proprietary issues one commonly encounters an alternative implementation that's even worse. On most modern platforms, sh will have a pretty good programming feature set, and will be more reliable (especially if it isn't just ksh by another name.) Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: anygui,anydb, any opinions?
Thomas My reference to Visual Basic was meant to be a poke in the eye. Thomas The language itself stinks. BUT - having a robust IDE with Thomas keyword tooltip prompts, built in language documentation, robust Thomas built in debugging, and most of all - a stable GUI , a standard Thomas suite of widgets for interacting with those pesky, error prone Thomas humans, the ability to draw these on a form with a mouse and Thomas have all that running in minutes! It no longer matters that the Thomas language itself smells like 4 day old fish! No amount of Thomas linguistic or structural elegance can have as much impact on Thomas productivity as the IDE/GUI. Thomas It drives me crazy when someone suggests that it might amount to Thomas no more than a bit of fluff hardly worth bothering with because Thomas when it comes to programming - Thomas An excellent IDE/GUI just trumps everything. Glade is fine for building Gtk user interfaces. I have no idea if there are similar tools for other widget sets, though I wouldn't be surprised if such tools existed. Once the GUI is fairly stable, most of the development after that occurs in the underlying functional part of the code (at least in my recent experience). For that, no amount of Glade slinging will help. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
Thanks to you all for the quick response. I've noticed that when I do $ python myprog.py the file myprog.pyc file is not created, but the .pyc files for files I import *are* created. Is this intentional and, if so, how do I get the myprog.pyc file? Thanks, - QS Computing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: Allocation vs references
Stian Søiland wrote: There are several ways to create a copy of a list: [snip] a2 = list(a) # create a new list object out of any sequence I'll just point out that FWIW, this is by far my favorite idiom of the ones offered because it applies to pretty much all the builtin container types: py d = {1:42, -37:0} py d2 = dict(d) py d == d2, d is d2 (True, False) py s = set(['a', 'd', 'e']) py s2 = set(s) py s == s2, s is s2 (True, False) py L = [3.14, 0.707] py L2 = list(L) py L == L2, L is L2 (True, False) STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
[EMAIL PROTECTED] wrote: Thanks to you all for the quick response. I've noticed that when I do $ python myprog.py the file myprog.pyc file is not created, but the .pyc files for files I import *are* created. Is this intentional and, if so, how do I get the myprog.pyc file? I thought the docs covered this, so I left it out. The main .py file is not converted to a .pyc file for reasons I can't remember (and don't care... after it, that's just the way it is). If you really need a .pyc for it, the simplest thing to do is import myprog from the interactive prompt. The compileall module I mentioned would also be able to do this. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
On Thu, 02 Jun 2005 06:45:18 -0700, qscomputing wrote: Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to create a for loop in the style I'm used to from Delphi ie: for I:=0 to 2 do begin //code end; Use Delphi. If you insist on using Python (and why wouldn't you?), then I'm afraid you will have to create for loops in the Python style: for i in range(3): do_something Notice the small gotcha: if you want to loop over the values 0, 1, and 2, you have to use range(3), NOT range(2). This may seem strange now, but it is actually very useful and prevents a lot of off-by-one errors. 2. Philospohy(sp?) aside, Philosophy. I could potentially want to create a binary-only distribution of my finished apps. I noticed the documentation on .pyc files: how do I create these In PythonCard? I have no idea. Sorry. In ordinary Python? When you run or import a Python module, the Python interpreter first looks for a .pyc file of the same name that is more recent than the .py file. If it doesn't find one, it compiles the .py file into byte-code, stores the byte-code in the .pyc file, and runs that. In other words, to create your .pyc file, just run your .py file and Python will do it automatically. and, aside from being basically read-only, are they used just like ordinary .py source files? And can they be easily reverse-engineered? Yes, they can be easily reverse-engineered. The short answer is, Python has not been designed to hide your code. If that's what you are trying to do, perhaps you need to think about _why_ you want to go to all that extra effort to keep your software secret, rather than just _how_ to keep it secret. I can think of a number of reasons why somebody might want to hide their code. In no particular order: (1) You are ashamed of the quality of your buggy code, and don't want people to see how bad it is. If so, learn to write better code, and the best way of doing that is to let people see your code and give you advice. (2) You have stolen somebody else's code, and are trying to keep that fact secret. If so, pay the licence fee, or legally reverse-engineer the code, or use OpenSource software that allows copying. If the code you have stolen is valuable enough, the legal owners will find out, even without the source code. (3) You have create an incredibly valuable piece of code that will be worth millions, but only if nobody can see the source code. Yeah right. (4) It's MY CODE, nobody is allowed to use it unless I SAY SO!!! Fine, whatever you say, there are tens or hundreds of thousands of OpenSource software packages competing with your software without those restrictions. Good luck. (5) Your code has security holes and you hope that the bad guys won't find them without access to the source code. Be prepared for serious embarrassment, because the crackers WILL crack your code, source code or no source code. Obscurity is no substitute for security. (6) You are worried about people copying the code for their friends without paying you for it. How does keeping the source code secret stop them from copying the .pyc files and giving them to their friends? (7) You are using secret programs licenced from another programmer or company, and the conditions of use are that the source code isn't made available. Good luck, I hope it works out for you. (8) You are programming a game or puzzle, and you don't want players to cheat by reading the source code. Consider pulling out the information they need to cheat and putting it in an encrypted data file instead. There may be other reasons for wanting to keep the code secret. Some of them might even be good reasons, for some value of good. The reality is, the more valuable your code is, the more effort people will put into reverse-engineering it. People will find out how it works, if they care enough, and the more valuable your program, the more they will care. On the other hand, there are incredible advantages to making your code available to the users of your software. I'm sure you already know those advantages: you are learning Python, which is based on those principles of openness. If you want to discuss these issues further, please feel free. If you really what to hide your code, you might like to think about using C-extensions instead. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions
rbt wrote: Peter Hansen wrote: Philosophy not entirely aside, you should note that object code in any language can easily be reverse-engineered in the same way, with the only difference being the degree of ease involved. If the code is worth enough to someone that they are willing to risk violating your license terms, they *will* be able to recover enough source code (whether it was Python, C, or assembly) to do what they need. Don't intend to hijack this thread, but this bit interests me. I know several accomplished C/assembly programmers who have told me that reverse engineering object code from either of these two languages is anything but trivial. Yet, I *hear* and *read* the opposite all of the time. Can anyone actually demonstrate a decompile that mirrors the original source? It all depends on the definition of reverse engineering. In my opinion and experience, very little code in the world is so sophisticated that it is not roughly as easy to write equivalent code from scratch (with the original, working program as a guide of what the code actually does) as it would be to convert the object code back into source. (Exceptions such as decompyle which may make the job near trivial aside.) If that's true, it leaves us with a very small subset of the code in any given program, that might actually be worth the effort of converting back to source. That bit of code will generally turn out to be so small that once again an automated conversion to source is not really necessary, since analysis of the object code would with relatively little effort allow one to reverse engineer some equivalent source, in whatever language (or pseudo-code) one chose. So, for languages like C, where the compilation process is fairly destructive to things like the variable names and control structures used, reverse engineering in the sense of automated conversion back to equivalent source code is rather difficult, probably infeasibly so for most non-trivial programs. I personally don't understand the need for this, other than in the case of I lost my source, and the correct answer there is a session of pummelling, followed by tarring and feathering with the pages of the Subversion Book. On the other hand, reverse engineering in the sense of creating source code capable of reproducing the effects of the valuable and interesting parts of the object code is not that difficult, and in the sense of understanding how this code works is even easier, being just the first part of that step. Software development is far more about choosing the right problems to solve and the right ways to solve them than it is about writing source code for the program that will do the job. And if I had an automated tool to reproduce source code for a given program, I'd still be very concerned that I didn't end up with any of its automated test cases. ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Easy way to detect hard drives and partitions in Linux
I need a way to detect hard drives and their partitions... labels would be nice too... I did some googling but did not find anything all too useful. This will strictly be on Linux / Unix so any help would be greatly appreciated. TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython
Michael wrote: Hi, I've got a question about wxPython, wheres the best place to ask?? The wxPython mailing list. Visit www.wxpython.org to find it and more. -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
PyPK wrote: Yep that improved the speed by about 50% now it takes about 10 secs instead of 24 seconds..Thanks much. I guess that is the best we could do right.It would be really helpful if I could get it less than 5 seconds. Any suggestions on that?? Things to try: * in-lining the min and max expressions * depending on the distribution of e, it may be faster to catch KeyErrors def search1(m): box = {} for r,row in enumerate(m): for c,e in enumerate(row): try: minc, minr, maxc, maxr = box[e] box[e] = ( c minc and c or minc, r minr and r or minr, c maxc and c or maxc, r maxr and r or maxr) except KeyError: box[e] = (c, r, c, r) return box Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONSTARTUP and the -i command line option
Christopher Wood wrote: But these two things won't play together, as (by design, it seems) $PYTHONSTARTUP isn't read when the -i option is used, leaving me with an unenhanced Python interpreter environment after after script execution. Is the any way round this, other than editing all my scripts or manually loading the .pythonrc.py script in the interpreter? Modifying the contents of your .pythonrc script and therein setting the PYTHONINSPECT environment variable via os.environ comes to mind. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy way to detect hard drives and partitions in Linux
RunLevelZero wrote: I need a way to detect hard drives and their partitions... labels would be nice too... I did some googling but did not find anything all too useful. This will strictly be on Linux / Unix so any help would be greatly appreciated. os.popen('/sbin/sfdisk -l /dev/hda') etc... ? Or reading from /proc/ide and friends? -- http://mail.python.org/mailman/listinfo/python-list
Re: calling ksh script from python
In article [EMAIL PROTECTED], Donn Cave [EMAIL PROTECTED] wrote: . . . Meanwhile, it might be worthwhile to reconsider the use of ksh here, if you have any choice in the matter. Ksh is fine for interactive use, but has some unfortunate flaws as a programming shell, and due to proprietary issues one commonly encounters an alternative implementation that's even worse. On most modern platforms, sh will have a pretty good programming feature set, and will be more reliable (especially if it isn't just ksh by another name.) . . . Infidel. While I sure feel that way about csh(1), it surprises me you'd criticize ksh(1) so. 'Fact, 'mong all the *sh-s, I *recommend* ksh for programming. May- be the two of us see things differently. -- http://mail.python.org/mailman/listinfo/python-list
PYSH? (was:Re: calling ksh script from python)
Cameron Laird wrote: Infidel. While I sure feel that way about csh(1), it surprises me you'd criticize ksh(1) so. 'Fact, 'mong all the *sh-s, I *recommend* ksh for programming. May- be the two of us see things differently. I keep wondering how difficult it would be to make a Python shell that exposes all of Python but also includes some builtin commands such as cd, mkdir, etc., that are just names bound to os.chdir, os.mkdir..., and is smart enough to take a given command from the user and try to do a os.system() on it based on the path. IOW, I'd love to have all of Python available as my unix shell, while still doing shell-type stuff such as traversing directories, launching applications, etc. There's likely a project that does this already that I'm just unaware of. -- Paul McNett http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner question: Logs?
import math math.log10(15625) To find out the names of function in the math module without checking the docs, do dir(math) #same for any other module To get more info, do help(math) # same for any other module with a doc string Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner question: Logs?
Peter Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Elliot Temple wrote: from math import * log10(15625) It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with it, and is widely considered poor style, and should really only rarely be used. Which is why I often do things like import math as m m.log... -- http://mail.python.org/mailman/listinfo/python-list
New mailing list to discuss Google Summer of Code
In order to centralize discussion and minimize spam, we've created a new mailing list to discuss the Google Summer of Code from a Python POV. I strongly encourage people interested in discussing possible projects, people who'd be willing to help students this summer as mentors, and any students considering applying for the program to join and start discussions on that list. The mailing list web page is at: http://mail.python.org/mailman/listinfo/summerofcode Cheers, -- David Ascher (PSF) -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.4: tarfile tell() and seek() seem to be broeken
Am Thu, 02 Jun 2005 17:57:20 +0200 schrieb Lars Gustäbel: On Wed, 01 Jun 2005 14:58:23 +0200, N. Volbers wrote: - subsequent calls of fd.readline() and fd.tell() will yield the correct lines but always the same value from fd.tell(). [...] Thank you for pointing that out. I'll take care of this getting fixed. Thanks for taking care of it ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode string in exec
First off, I just have to correct your terminology. exec is a statement, and doesn't require parentheses, so talking about exec() invites confusion. I'll answer your question in terms of eval(), which takes a string representing a Python expression, interprets it, and returns the result. In Python 2.3, the following works right: eval(uu'\u0190') u'\u0190' Here, the string passed to eval() contains the literal LATIN CAPITAL LETTER OPEN E, and the expected unicode string is returned The following behaves surprisingly: eval(u'\u0190') '\xc6\x90' ... you seem to get the UTF-8 encoding of the unicode. This is related to PEP 263 (http://www.python.org/peps/pep-0263.html) but the behavior of compile(), eval() and exec don't seem to be spelled out. Jeff pgp7R8SrUm3oO.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: TkInter Listbox Widget Formatting
This isn't an option in the stock Tk listbox or any of the alternatives I know of offhand (bwidget ListBox, TixTList). The TkTable widget, which can also display multiple columns, can select different justifications, either for the whole table, or for single cells. I've never used TkTable with Python/Tkinter, however. Jeff pgpJEp4ubX0Ge.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list