Re: Interactive shell for demonstration purposes
On Wed, 11 May 2005 16:21:19 +0200, Brian Quinlan <[EMAIL PROTECTED]> wrote: >Ville Vainio wrote: >> Hmm, do you consider the fonts in a console window unreadable? > >In fullscreen mode, yes (you get no choice of font size in Windows XP). >In Windowed mode you still only get a limited font selection (only two >fonts and only a few type sizes [most of which are small]). > >> I've >> given a few presentations using ipython on win32 and it worked alright >> - but I suppose the projector quality is a factor here... > >I'll get by but I was hoping for something better. > If you make your console 96 wide and set the font to Lucida Console Bold 24point, it will probably expand to near full screen on 1024x768. You can set the scroll buffer to a couple hundred lines and adjust console widow height to suit. Use the properties from the system icon, or get there by Alt-Space P etc. You can change the fg/bg colors also, though not a big selection either. I'm not a fan of idle for my system (NT4) though it looks nice enough and has more fonts to choose from. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding startup files
On Thursday 12 May 2005 05:24 am, Mike Meyer wrote: > jeff elkins <[EMAIL PROTECTED]> writes: > > On Wednesday 11 May 2005 04:44 pm, Grant Edwards wrote: > >> On 2005-05-11, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> > The following script demonstrates a method that should work for you. I > >> > believe it is entirely cross-platform. > >> > > >> > #! /usr/bin/python > >> > > >> > import sys > >> > import os > >> > > >> > print os.path.abspath(os.path.dirname(sys.argv[0])) > >> > >> That will probably work most of the time, but... > >> > >> 1) you're not gauranteed that argv[0] contains the application > >> path/filename. > >> > >> 2) the directory containing the executable is not where > >> configuration files are supposed to be stored under > >> Unix/Linux. > > > > Thanks Grant, > > > > I live and develop in Linux, but unfortunately, 99.99% of the users of > > this particular application (analysis of medical laboratory data) will be > > working with Windows. > > Yes, but Windows these days supports multiple users. Are you sure that > you want to restrict your users to one configuration file per > installed version of the program? > > I'm not sure Windows has a good solution to this problem. My > experiences with trying to share applications between users on Windows > haven't been very pleasant. > > http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
phil wrote: > >> Then i got a tip that you can register a function that needs to be >> called when the object is going to be deleted. >> For instance to register a function __exit, you do this: >> > > > Here is the complete line class with your suggestion: > > Below is the output. > > Nice idea, maybe I did something wrong? > > class line: > def __init__(s,glob,argl,color=''): > atexit.register(s.__exit) > s.glob = glob > s.type = 'line' > s.color = color > if not s.color: s.color = glob.color > if len(argl) == 2: > wobj = glob.objs[ argl[0] ][0] > s.x0 = a0 = wobj.x > s.y0 = b0 = wobj.y > wobj = glob.objs[ argl[1] ][0] > s.x1 = a1 = wobj.x > s.y1 = b1 = wobj.y > > elif len(argl) == 4: > s.x0 = a0 = float( argl[0] ) > s.y0 = b0 = float( argl[1] ) > s.x1 = a1 = float( argl[2] ) > s.y1 = b1 = float( argl[3] ) > else: return > s.midx = (s.x0 + s.x1) / 2 > s.midy = (s.y0 + s.y1) / 2 > s.len = sqrt( (s.x1 -s.x0)**2 + (s.y1 -s.y0)**2 ) > if (s.y1 -s.y0) == 0: s.slope = 0 > elif (s.x1 -s.x0) == 0: s.slope = 99 > else: s.slope = ( (s.y1 -s.y0) / (s.x1 -s.x0) ) > > # center point of graph is 400,300 > # scale is no of pixels per unit of measure > x0 = a0 * s.glob.scale + 400 > y0 = 300 - b0 * s.glob.scale > x1 = a1 * s.glob.scale + 400 > y1 = 300 - b1 * s.glob.scale > s.obj = glob.can.create_line(x0,y0,x1,y1, > width=glob.width,fill=s.color) > def __exit(s): > print 'exit' > s.glob.can.delete(s.obj) > > # def __del__(s): > # s.glob.can.delete(s.obj) > > > exit > > Error in sys.exitfunc: > Traceback (most recent call last): > File "/usr/local/lib/python2.3/atexit.py", line 20, in _run_exitfuncs > func(*targs, **kargs) > File "./graph.py", line 972, in __exit > s.glob.can.delete(s.obj) > File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 2085, in delete > self.tk.call((self._w, 'delete') + args) > _tkinter.TclError: invalid command name ".1076354284" > I don't know what's wrong in your example. Here it works (doesn't help you of course). I would first try with an easy example an try to test the atexit functionality like that. It seems that the problem you are having isn't related to the atexit part. Sorry i couldn't be of more help Benedict -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP Printing with wxPython
On Thursday 12 May 2005 04:56 am, Mike Meyer wrote: > James Carroll <[EMAIL PROTECTED]> writes: > > If you are doing this just for yourself, and you know you have a > > printer that will really print just the plain text when you send it > > plain text (like a dot matrix printer from the early 90s) then you can > > probably open the printer device and send it text. Under windows you > > can try opening LPT1 or on unix it's probably /dev/lpr or something > > like that. > > Under Unix, you shouldn't be able to open the line printer, whether > it's /dev/lpr or /dev/lpt0 or whater. You shouldn't have > permission. > > Instead, as was suggested earlier, use the "lpr" command and send it > the text/data on standard input. Any reasonably managed Unix system > should be able to handle a fair range of graphics formats, though > postscript is preferred. > > -- > Mike Meyer <[EMAIL PROTECTED]> > http://www.mired.org/home/mwm/ > Independent WWW/Perforce/FreeBSD/Unix consultant, email for more > information. I've been using: p=os.popen('lp','w') p.write("some text') p.Close() Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Module on Getting the Date & Time
Sara Khalatbari <[EMAIL PROTECTED]> writes: Hi, > Is there a Modules in Python that returns the time & > date of today when ran? You mean a method in a module? Yes, there's good 'ol time module, which will probably provide what you need: >>> import time >>> time.time() # number of seconds (+ fract) elapsed after 01.01.1970 1115881981.3717401 >>> time.ctime() # current time in string format 'Thu May 12 10:13:20 2005' >>> time.localtime() # current time as a tuple (2005, 5, 12, 10, 13, 30, 3, 132, 1) For details, see 'pydoc time' -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n"; -- http://mail.python.org/mailman/listinfo/python-list
subclass dialog or put in the resource files?
I'm using wxPython and design the gui via wxglade. One of the gui components is a simple dialog class that gets displayed when a user exits the program. I want to use the same dialog but with a different text for closing certain dialogs in the program. (it's a pure "do you want to exit " dialog) What would i better use, knowing the rest of the gui is in a resource (xrc) file: 1. Find some way to put a standard exit dialog in the resource file and then somehow try to set the message to the correct one. 2. Make a simple dialog class that accepts the message to be displayed. I could even use glade to generate the python code for a start. What would be the better/cleaner/logical way to do this? Thanks, Benedict -- http://mail.python.org/mailman/listinfo/python-list
tkinter puzzler
I have a gui with a bunch of buttons, labels, the usual stuff. It uses the grid manager: gui = Frame() gui.grid() gui.Label().grid() # put some widgets into the gui ...# more widgets Now at the the very bottom of the gui, I want to add two more buttons, let's say "stop" and "go". I want "stop" to appear in the gui's lower left corner and "go" to appear in the gui's lower right corner. Suppose that up to now, row 16 is the last row in the gui. Then this works: Button(gui, text="stop").grid(sticky=W) # starts row 17 Button(gui, text="go").grid(row=17, column=1, sticky=E) But I don't really want that hardwired row number and I don't want to keep counting rows and adjusting stuff if I stick new rows in the gui. So I try the obvious, make one Frame widget containing both new buttons: stopgo = Frame(gui) Button(stopgo, "stop").grid(sticky=W) Button(stopgo, "go").grid(sticky=E) and try to stretch it across the bottom row of the gui: stopgo.grid(sticky=E+W) However, the buttons keep coming out centered in the gui's bottom row pretty much no matter what I do (I've tried all sorts of combinations). Am I missing something? I'm not a tkinter whiz and this stuff is pretty confusing. I did come up with an ugly workaround that I'll spare you the agony of seeing, but there should be a natural way to do this. Thanks for any advice. -- http://mail.python.org/mailman/listinfo/python-list
Re: TAKE_FOCUS
phil wrote: > WM_TAKE_FOCUS does not work on WinXP ?? > I was sure I had used that on win before. > Works on Linux. > > I have a function I need to run when the window > gets the focus. How do you do that in Tkinter > on Win32? > Thanks > Take a look at the module docs for Tkinter you will need the one of the focus_* methods $pydoc Tkinter | focus_set(self) | Direct input focus to this widget. | | If the application currently does not have the focus | this widget will get the focus if the application gets Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter puzzler
Paul Rubin wrote: > I have a gui with a bunch of buttons, labels, the usual stuff. It > uses the grid manager: > >gui = Frame() >gui.grid() >gui.Label().grid() # put some widgets into the gui >...# more widgets > > Now at the the very bottom of the gui, I want to add two more buttons, > let's say "stop" and "go". I want "stop" to appear in the gui's lower > left corner and "go" to appear in the gui's lower right corner. > Suppose that up to now, row 16 is the last row in the gui. Then this > works: > > Button(gui, text="stop").grid(sticky=W) # starts row 17 > Button(gui, text="go").grid(row=17, column=1, sticky=E) > > But I don't really want that hardwired row number and I don't want to > keep counting rows and adjusting stuff if I stick new rows in the gui. > So I try the obvious, make one Frame widget containing both new buttons: > stopgo = Frame(gui) > Button(stopgo, "stop").grid(sticky=W) > Button(stopgo, "go").grid(sticky=E) > > and try to stretch it across the bottom row of the gui: > > stopgo.grid(sticky=E+W) > > However, the buttons keep coming out centered in the gui's bottom row > pretty much no matter what I do (I've tried all sorts of combinations). > > Am I missing something? I'm not a tkinter whiz and this stuff is > pretty confusing. I did come up with an ugly workaround that I'll > spare you the agony of seeing, but there should be a natural way to do > this. > > Thanks for any advice. Sorry to say Paul but you may have to show us that ugly code! I'm no whiz with the grid manager (I prefer pack!) but seeing your code will help us help you I suspect you need to look at the columnconfigure / rowconfigure methods of the container (toplevel or frame) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
praba kar wrote: > --- Tim Williams <[EMAIL PROTECTED]> wrote: >>Why don't you want to use smtplib ? > > In Php we can build a Mail Message by > Mail_mime class and send this message by > Mail::Factory's class send Method. Here Php > doesn't use any smtp modules. Like that > In Python I used email.Message class to > build Mail Message and Now I am searching > modules to send this message as mail. You can still use smtplib: msg = email.Message() ... smtp = smtplib.SMTP(...) smtp.sendmail(from, to, msg.as_string()) -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
praba kar <[EMAIL PROTECTED]> writes: > In Php we can build a Mail Message by > Mail_mime class and send this message by > Mail::Factory's class send Method. Here Php > doesn't use any smtp modules. Like that > In Python I used email.Message class to > build Mail Message and Now I am searching > modules to send this message as mail. Python isn't PHP. In python, the standard way to send a message is with the smtp module. If you do an "import this" in a python interpreter, it will tell you (among other things) "There should be one-- and preferably only one --obvious way to do it." The smtp module is that way. Since smtp is also how mail is sent around the internet, this makes a lot of sense. Now, the PHP mail command uses the system's sendmail binary (at least on Unix). You can do that by hand using the subprocess module in 2.4, or os.system or os.popen or something similar on earlier versions of Python. All this really does is asks sendmail to put a message in the queue from the command line, rather than via the smtp port. It's probably slower than talking to the already running smtp daemon. On Windows, the PHP mail command connects to an smtp server - which is exactly what smtplib does. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using TCL files in Python ?
Many thanks to all who have helped me out on this one - much appreciated. Pete On Wed, 11 May 2005 07:22:09 -0500, Jeff Epler wrote: > While I've never used it, there *is* a Tix module in Python which > appears to wrap the widgets provided by Tix. In Fedora Core 2, Python > doesn't seem to be configured to use Tix OOTB but a one-liner (that > should be harmless elsewhere) does make it work. > > These classes are defined in the Tix module: > ['Shell', 'Meter', 'TixSubWidget', 'ExFileSelectDialog', > 'NoteBookFrame', 'DirSelectDialog', 'Control', 'LabelEntry', > 'ButtonBox', 'ScrolledTList', 'Select', 'HList', 'Balloon', 'PopupMenu', > 'DirSelectBox', 'ComboBox', 'ScrolledWindow', 'Grid', 'CheckList', > 'DialogShell', 'Tree', 'DirList', 'ResizeHandle', 'NoteBook', > 'ListNoteBook', 'ScrolledGrid', 'FileEntry', 'ScrolledHList', 'DirTree', > 'OptionMenu', 'ScrolledText', 'LabelFrame', 'FileSelectBox', > 'ScrolledListBox', 'InputOnly', 'PanedWindow', 'StdButtonBox', > 'FileSelectDialog', 'CObjView', 'ExFileSelectBox', 'TList'] > > Here's what I did to get a simple Tix widget to work: import Tkinter, Tix t = Tkinter.Tk() t.tk.call("package", "require", "Tix") > '8.1.8.4' u = Tix.ComboBox(t) for i in range(30): u.insert("end", "Item %d" % i) > ... u.pack() > > Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Unique Elements in a List
[EMAIL PROTECTED] (Aahz) writes: >>[x for x in data if data.count(x) == 1] >> >>suffice? it is also "stable" preserving order of items. Lemme demo: > > Only for small datasets -- this is an O(N^2) algorithm. I realized that, but maybe I should've pointed it out too. For the OP if he/she is unaware - notation O(N^2) (big O n squared) means the computing time of the algorithm increases exponentially (where exponent is 2) relative to the size of the input. Eg. if the input size is i and it takes p seconds to compute it, then given input size 10*i, the computing time would be 100*p. These notions can apply for memory usage as well, but the problem in here is the computing time: list.count() must iterate through the list each time, and as such the loop [x for x in data if data.count(x) == 1] iterates through each item in data (x for x in data), and for each item it will again iterate through each item in data to see how many times it occurred. If data contains 200 items, this idiom would iterate the structure 40 000 times. With today's computers one wouldn't notice it, unless each item requires heavy processing (eg. launching a separate process per item etc). However, if the length of the data can be thousands or even tens of thousands, this idiom would become unusable. If data contained 75 000 items, the loop would do 25 625 000 000 iterations, effectively bringing cpu to halt.. So, generally one should avoid using exponential O(n^k) (where k > 1) algorithms, unless faster O(n) or O(n*lg(n)) solution is either impossible (or too complex, and inputs are known to be small etc). Wikipedia has good resources and pointers to related things, see http://en.wikipedia.org/wiki/Analysis_of_algorithms -- #!/usr/bin/perl -w $h={23,69,28,'6e',2,64,3,76,7,20,13,61,8,'4d',24,73,10,'6a',12,'6b',21,68,14, 72,16,'2c',17,20,9,61,11,61,25,74,4,61,1,45,29,20,5,72,18,61,15,69,20,43,26, 69,19,20,6,64,27,61,22,72};$_=join'',map{chr hex $h->{$_}}sort{$a<=>$b} keys%$h;m/(\w).*\s(\w+)/x;$_.=uc substr(crypt(join('',60,28,14,49),join'', map{lc}($1,substr $2,4,1)),2,4)."\n"; print; -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP Printing with wxPython
jeff elkins <[EMAIL PROTECTED]> writes: >> Instead, as was suggested earlier, use the "lpr" command and send it >> the text/data on standard input. Any reasonably managed Unix system >> should be able to handle a fair range of graphics formats, though >> postscript is preferred. > I've been using: > > p=os.popen('lp','w') > p.write("some text') > p.Close() Yeah. System V called it lp. BSD called it lpr. Most modern systems have both, as they are just a front end to the line printer (when was the last time you saw an honest-to-gods line printer?) daemon. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Defunct Processes With subprocess.Popen
Mike Meyer wrote: >John Abel <[EMAIL PROTECTED]> writes: > > > >>Hi! >> >>I'm currently writing a script which launches external programs, but >>it keeps leaving zombie/defunct processes behind, until I kill the >>launching script, which is a bit of a pain, as it's supposed to be a >>daemon. The code I'm using is: >> >>newPid = subprocess.Popen( cmdLine[ 1: ], executable=cmdLine[ 0 ], >>close_fds=True ).pid >> >>I've tried calling it using the shell=True flag, but that leaves a >>zombie for the sh, instead. I'm not interested in any output, the >>only thing I need returning, is the pid of the new process. I've >>tried using spawn*, with the same results. Does anyone have any ideas? >> >> > >The processes are hanging around in a zombie state so the parent (or >someone) can get their exit status. > >Try calling os.wait() until it returns the exit status for all the >processes you've started. > > > Ahh, OK. Thanks for that. Works now. J -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (vs PHP stuff)
Terry Reedy wrote: > Because of these two posts (and a few others) extolling the PHP > documentation, I decided to take a look for myself to see what the > fuss was about and whether I could get any ideas on how to improve > Python's docs. > > [...] > > Finally, 80% of the chapter/page consists of a thrown-together > mish-mash of unsorted. unedited comments and questions. In my experience, the user comments in many cases are almost useless. Sometimes just confusing, sometimes contradicting each other, sometimes even incorrect. Sometimes correct and useful too, but IMO that gets drown between all the others. > [...] > Sorry, PHP doc fans: to me, this sort of inflated, noisey bloatware > is wretched, not outstanding. Thank you. I thought I was the only one in the world who doesn't like the PHP documentation. > Conclusion 1: if PHP is anything as awful as the manual, it is not > for me. I'm fairly sure you won't like PHP :) Some time ago I used to do some programming in PHP on the side. In the beginning, I thought PHP was quite a nice language. I even used it to write some small non-web programs that I would otherwise haven written in C or C++ (I didn't know Python at the time, nor any other decent scripting language(*) ). Then I discovered Python, which caused my dislike of PHP to grow even more. PHP tries to make everything as simple as possible but that doesn't always work out very well, as explained in the section 'Oversimplification Leading to Excessive Complexity' of this paper: http://www.ukuug.org/events/linux2002/papers/html/php/#section_5. Python OTOH makes things as simple as possible but not any simpler, and that turns out to work much better. (Disclaimer: I haven't done any web programming in the meantime, so I don't know from own experience how Python fares in that area. But I'm fairly confident that it would work out just nice.) (Sorry for this off-topic rant) (*) I know Python is not just a scripting language, but the things I used PHP for at the time really were nothing more than scripts, despite me thinking about writing them in C or C++. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
RE: windows directories for curr user
[flamesrock] | | Thanks for the code Tom. | | Unforunately, I get the following error message when trying to import | win32com in idle: | | >>> from win32com.shell import shell, shellcon | | Traceback (most recent call last): | File "", line 1, in -toplevel- | from win32com.shell import shell, shellcon | ImportError: No module named win32com.shell I should have said that you need the pywin32 libraries: http://pywin32.sf.net I just automatically install them on any win32 python system I get my hands on. You can achieve the same effect by using the ActiveState Python distribution. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
Kay Schluehr wrote: > > Yes. What we are seeking for and this may be the meaning of Armins > intentiously provocative statement about the speed of running HLLs is a > successor of the C-language and not just another VM interpreter that is > written in C and limits all efforts to extend it in a flexible and > OO-manner. Python is just the most promising dynamic OO-language to > follow this target. > Bytecode engine is the best method for dynamic code execution ("exec", eval, etc). A low level OOP language would be very suitable for a python VM. pyvm has that. A big part of it is written in "lightweight C++" [1]. That makes it less portable as the lwc preprocessor is using GNU-C extensions. However, it's the same extensions also used by the linux kernel and AFAIK the intel compiler supports them too. So probably the bigger "competitor" of pyvm is boost-python. And that's one reason the release of the source is stalled until it gets better. Stelios [1] http://students.ceid.upatras.gr/~sxanth/lwc/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Finding startup files
[Mike Meyer] [... snip discussions of where to put config files ...] | Yes, but Windows these days supports multiple users. Are you sure that | you want to restrict your users to one configuration file per | installed version of the program? | | I'm not sure Windows has a good solution to this problem. My | experiences with trying to share applications between users on Windows | haven't been very pleasant. I have the impression that few configs are stored these days without being per-user. However, there are "All Users" versions of the appdata directories, and so on, which could be used for such a purpose. from win32com.shell import shell, shellcon import win32api print shell.SHGetPathFromIDList ( shell.SHGetSpecialFolderLocation (1, shellcon.CSIDL_APPDATA) ) print shell.SHGetPathFromIDList ( shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_COMMON_APPDATA) ) TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter puzzler
Paul Rubin wrote: I think you are missing the columnconfigure()/rowconfigure() methods as Martin Franklin pointed out. Anyway, here is some code to illustrate the matter. I've found it helpful to use "false" colors to see what's going on. the yellow 'main' frame contains the red 'north' and the blue 'south' frame. import Tkinter as tk root = tk.Tk() main = tk.Frame(root, bg="yellow") main.pack(expand=True, fill="both") main.columnconfigure(0, weight=1) main.rowconfigure(0, weight=1) north = tk.Frame(main, bg="red") north.columnconfigure(1, weight=1) for row, text in enumerate("alpha beta gamma delta".split()): label = tk.Label(north, text=text) label.grid(row=row, column=0, sticky="NW") entry = tk.Entry(north) entry.grid(row=row, column=1, sticky="NEW") button = tk.Button(north, text=text.upper()) button.grid(row=row, column=2, sticky="NW") north.rowconfigure(row, weight=1) north.grid(column=0, row=0, sticky="NEW") south = tk.Frame(main, bg="blue") stop = tk.Button(south, text="Stop") go = tk.Button(south, text="Go") stop.grid(column=0, row=0) go.grid(column=2, row=0) # the empty column takes all the extra space south.columnconfigure(1, weight=1) south.grid(column=0, row=1, sticky="NSEW") root.mainloop() Peter -- http://mail.python.org/mailman/listinfo/python-list
SWIG/IDLE/Python: F5 SHIP.py works but "import SHIP" gives "ImportError: dynamic module does not define init function (initSHIP)"
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24 to obtain SHIP_wrap.cpp and SHIP.py; the latter contains the line "import _SHIP". I compile SHIP_wrap.cpp and a bunch of files into a DLL which I have the linker place in _SHIP.pyd and all goes well. I start IDLE (version 1.1.1, with Python 2.4.1) If I open SHIP.py in an edit window and run it (using F5) it runs and if I do >>> _SHIP.__dict__.keys() I get a load of function names which are like the ones I'd expect (new_BallScrew for example, where BallScrew is one of my classes [and is the interface class to the thing I am really interested in which is already called BallScrewC, before you ask]). Then I can do things like: >>> bs = BallScrew(0) >>> bs.Stop() >>> del bs They work fine. Except of course I really want to put all that stuff in a script, say test1.py: import SHIP # This is where my problems begin. bs = BallScrew(0) bs.GotoLimit(1) bs.Stop() del bs Which I do and when I run test1.py using F5, the line "import SHIP" in test1.py produces: ImportError: dynamic module does not define init function (initSHIP) So, why can I run SHIP.py straight into Python using F5 but not import it either directly (>>> import SHIP gives the same error) or indirectly when I am running another file? One way round this (though I would like to solve this problem as it will make things easier as the application grows) is for F5 in IDLE not to restart the Python interpreter. My aim is for an engineer to be able to use IDLE to write programs to test hardware without having to learn C++ to access my OO interface. IDLE and Python are ideal but I want to make it easy for them to load the interface (i.e. SHIP) between Python and my OO interface. Many thanks in advance for any helpful suggestions, Bill PS I posted this to [EMAIL PROTECTED] but it did not seem to get through. SHIP.i: %module SHIP %{ #include "SHIPIF.hpp" %} %include "SHIPIF.hpp" SHIP.py (with no initSHIP L ): # This file was created automatically by SWIG. # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _SHIP def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "this"): if isinstance(value, class_type): self.__dict__[name] = value.this if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown del value.thisown return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static) or hasattr(self,name) or (name == "thisown"): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0) def _swig_getattr(self,class_type,name): method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError,name import types try: _object = types.ObjectType _newclass = 1 except AttributeError: class _object : pass _newclass = 0 del types ToString = _SHIP.ToString class ObjectCounterC(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, ObjectCounterC, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, ObjectCounterC, name) def __repr__(self): return "<%s.%s; proxy of C++ ObjectCounterC instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args): _swig_setattr(self, ObjectCounterC, 'this', _SHIP.new_ObjectCounterC(*args)) _swig_setattr(self, ObjectCounterC, 'thisown', 1) def __del__(self, destroy=_SHIP.delete_ObjectCounterC): try: if self.thisown: destroy(self) except: pass class ObjectCounterCPtr(ObjectCounterC): def __init__(self, this): _swig_setattr(self, ObjectCounterC, 'this', this) if not hasattr(self,"thisown"): _swig_setattr(self, ObjectCounterC, 'thisown', 0) _swig_setattr(self, ObjectCounterC,self.__class__,ObjectCounterC) _SHIP.ObjectCounterC_swigregister(ObjectCounterCPtr) class CallBack(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, CallBack, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, CallBack, name) def __repr__(self): return "<%s.%s; proxy of C++ CallBack instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args): _swig_setattr(self, CallBack, 'this', _SHIP.new_CallBack(*args)) _swig_setattr(self, CallBack, 'thisown', 1) def __del__(self, destroy=_SHIP.delete_CallBack): try: if self.thisown: destroy(self) except: pass def S
Re: Proxy Design Advice Needed
Thanks for the hint so far! The recipe shown there does not exactly what I want though, it doesn't do the type() stuff and it hooks up every _ variable which could get crucial if the wrapped object's methods uses them too. So I think my question boils down to how I can make type(Proxy) return type(WrappedObject)? Any hints? -Matthias -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP Printing with wxPython
There's a working version in the wxPython Demo... If you run the wxpython demo, and choose Print Framework under Miscellaneous it has code that looks a whole lot like what's on the wiki, only you can test it and try it out and see if it's broken for you there. If anything doesn't work, let the wxPython mailing list people know about it, and they'll have a work-around or a fix (or show you what you should be doing) in no time. -Jim On 5/11/05, Mario <[EMAIL PROTECTED]> wrote: > > "James Carroll" <[EMAIL PROTECTED]> wrote: > >I especially like the HtmlEasyPrinting write-up here: > > http://wiki.wxpython.org/index.cgi/Printing > > Thank you for your suggestion but I'm just not able to make it work, as i > said on the original post, I do exactly what is wrote there, but it gives > errors, I think the script is not updated and not working fine with the > latest versions of python or wxpython. > > Mario > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
Dear All, From this below answer I got clear idea for mail sending Module. I am expecting this kind of answer . Thank you for your immediate response. --- Mike Meyer <[EMAIL PROTECTED]> wrote: > praba kar <[EMAIL PROTECTED]> writes: > > In Php we can build a Mail Message by > > Mail_mime class and send this message by > > Mail::Factory's class send Method. Here Php > > doesn't use any smtp modules. Like that > > In Python I used email.Message class to > > build Mail Message and Now I am searching > > modules to send this message as mail. > > Python isn't PHP. In python, the standard way to > send a message is > with the smtp module. If you do an "import this" in > a python > interpreter, it will tell you (among other things) > "There should be > one-- and preferably only one --obvious way to do > it." The smtp module > is that way. Since smtp is also how mail is sent > around the internet, > this makes a lot of sense. > > Now, the PHP mail command uses the system's sendmail > binary (at least > on Unix). You can do that by hand using the > subprocess module in 2.4, > or os.system or os.popen or something similar on > earlier versions of > Python. All this really does is asks sendmail to put > a message in the > queue from the command line, rather than via the > smtp port. It's > probably slower than talking to the already running > smtp daemon. > > On Windows, the PHP mail command connects to an smtp > server - which is > exactly what smtplib does. > > -- > Mike Meyer <[EMAIL PROTECTED]> > http://www.mired.org/home/mwm/ > Independent WWW/Perforce/FreeBSD/Unix consultant, > email for more information. > -- > http://mail.python.org/mailman/listinfo/python-list > Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
Dear All, From this below answer I got clear idea for mail sending Module. I am expecting this kind of answer . Thank you for your immediate response. --- Mike Meyer <[EMAIL PROTECTED]> wrote: > praba kar <[EMAIL PROTECTED]> writes: > > In Php we can build a Mail Message by > > Mail_mime class and send this message by > > Mail::Factory's class send Method. Here Php > > doesn't use any smtp modules. Like that > > In Python I used email.Message class to > > build Mail Message and Now I am searching > > modules to send this message as mail. > > Python isn't PHP. In python, the standard way to > send a message is > with the smtp module. If you do an "import this" in > a python > interpreter, it will tell you (among other things) > "There should be > one-- and preferably only one --obvious way to do > it." The smtp module > is that way. Since smtp is also how mail is sent > around the internet, > this makes a lot of sense. > > Now, the PHP mail command uses the system's sendmail > binary (at least > on Unix). You can do that by hand using the > subprocess module in 2.4, > or os.system or os.popen or something similar on > earlier versions of > Python. All this really does is asks sendmail to put > a message in the > queue from the command line, rather than via the > smtp port. It's > probably slower than talking to the already running > smtp daemon. > > On Windows, the PHP mail command connects to an smtp > server - which is > exactly what smtplib does. > > -- > Mike Meyer <[EMAIL PROTECTED]> > http://www.mired.org/home/mwm/ > Independent WWW/Perforce/FreeBSD/Unix consultant, > email for more information. > -- > http://mail.python.org/mailman/listinfo/python-list > Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (vs PHP stuff)
Terry Reedy wrote: > Conclusion 1: if PHP is anything as awful as the manual, it is not for me. the whole idea that turning the manual into a wiki or a forum will solve all problems is extremely naive. on the other hand, having written lots of "manual enhancing material", I would love to be able to add links to the library manual in some non-intrusive way (similar to blog trackbacks). what you need is a way to uniquely identify a library construct (e.g. a psuedo-URL or simply a dotted path), a way to contribute a path/link collection, and an addition to the HTML generation toolchain that adds relevant links to the generated HTML. e.g. http://effbot.org/python-annotations.xml";> Building An Asynchronous FTP Client asynchat.async_chat http://effbot.org/zone/asyncore-ftp-client.htm The select module select.select http://effbot.org/librarybook/select.htm Using the tempfile module to open temporary files tempfile tempfile.TemporaryFile http://effbot.org/librarybook/tempfile.htm#tempfile-example-2 Importing Python Modules statement:import statement:from http://effbot.org/zone/import-confusion.htm (I'm sure some RDF hacker can come up with an unreadable alternative to this, if necessary ;-) this eliminates the need for constant monitoring of wiki pages and forums, and reduces the workload for the documentation editors compared to all the "feel free to contribute patches" alternatives. if some annotation provider produces bad stuff or spam, remove his/her annotations, or use a whitelist/blacklist on individual items. if someone fixes the python.org end of things, I can generate an effbot.org annotation index within a day or two. -- http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
"flupke" wrote: >> Then i got a tip that you can register a function that needs to be >> called when the object is going to be deleted. >> For instance to register a function __exit, you do this: >> class line: >> def __init__(s,glob,argl,color=''): >> atexit.register(s.__exit) > I don't know what's wrong in your example. Here it works (doesn't help > you of course). I would first try with an easy example an try to test > the atexit functionality like that. It seems that the problem you are > having isn't related to the atexit part. do you (or whoever gave you the tip) have the slightest idea what atexit does? -- http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
"phil" <[EMAIL PROTECTED]> wrote: >> Then i got a tip that you can register a function that needs to be >> called when the object is going to be deleted. >> For instance to register a function __exit, you do this: > > Here is the complete line class with your suggestion: > > Below is the output. > > Nice idea, maybe I did something wrong? > > class line: > def __init__(s,glob,argl,color=''): > atexit.register(s.__exit) atexit is used to clean up when the *interpreter* shuts down, not when any object is going to be deleted. > File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 2085, in delete > self.tk.call((self._w, 'delete') + args) > _tkinter.TclError: invalid command name ".1076354284" this usually means that you're trying to execute Tkinter methods on a widget that no longer exists (probably because Tkinter has been shut down, at this point). -- http://mail.python.org/mailman/listinfo/python-list
Re: TAKE_FOCUS
"phil" wrote: > WM_TAKE_FOCUS does not work on WinXP ?? > I was sure I had used that on win before. > Works on Linux. > > I have a function I need to run when the window > gets the focus. How do you do that in Tkinter > on Win32? binding the event should work. (and make sure that the takefocus option is set) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (vs PHP stuff)
> toolchain that adds relevant links to the generated HTML. e.g. oops. here's the pre-paste-and-cut-error text: toolchain that adds relevant links to the generated HTML. with that in place, external contributors can then place an annotation file on their own server, and send the link to the editors. e.g. -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
Hi all. Steve Holden wrote: > > ... to conflict with the "can't teach an old dog new tricks" ... Excuse my English (also some terms of your replay have no correspondance in my English dictionary...) and my lack of patience (beeing an "old dog" ...). My original request was mainly centered on flow chart and "import" interfered with "my" understanding of an application. By the way, (replaying to Sébastien Boisgérault) of course I don't use indirect import of any sort (it's too tricky for me...). The only constructive comments was that of George Sakkis on using UML sequence diagrams. Also Mike Meyer points me in the same direction (with more arguments and ... warnings). I will stick with their advice: I will abandon my project of implementing a flow chart tool... A last word of reconciliation: I must thank the expert group for their valuable activity especially towards the newbies like me... Regards. -- http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
> > do you (or whoever gave you the tip) have the slightest idea what atexit does? > Yeah, I got the tip on this group. researched and found it was for when program ends! I was trying to treat it like a destructor. darn. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jesus said, "I am the way, the truth and the life: no one can come to the Father(God)(in Heaven), but by me." (John 14:6) This means that if you die without trusting in Jesus Christ as your Lord and Saviour you will die in your sins and be forever sepa
I don't give a feather or a fig. MJRB -- http://mail.python.org/mailman/listinfo/python-list
Re: Read tab delimited ascii file
On 5/12/05, Irvine, Wayne D <[EMAIL PROTECTED]> wrote: > I have a tab delimited ascii/excel file formated like ... The CSV module can help you: http://docs.python.org/lib/module-csv.html HTH, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
pexpect: TIMEOUT exception never raised
I have a python script which uses pexpect and I want to timeout (i.e. raise pexpect.TIMEOUT) if a long running command does not produce the output I am expecting. To simulate the 'long running command', consider the following example which simply runs the 'yes' command which prints an endless series of 'y' characters to the terminal. I want to timeout after 10 seconds -: child=pexpect.spawn('ssh [EMAIL PROTECTED]') child.sendline('yes') child.expect([pexpect.TIMEOUT, "the pattern I'm expecting"],10) In this situation, pexpect.TIMEOUT will never be raised. The TIMEOUT exception is only raised if *no* output is received or the output has completed and the pattern expected is not matched within the timeout period. But what about situations where a command produces an infinite amount of output? In the above example, the child.expect statement will hang forever. I thought about using signal.signal to set an alarm that fires a few seconds after timeout and explicitly closes the session. However, my application is multi-threaded (i.e. each thread respresents a connection to a remote host) and signals can not be used outside the main thread :-( Any ideas? Cheers. Adrian Casey. -- http://mail.python.org/mailman/listinfo/python-list
Sleepycat Bsdbd 4.3.27 and Python 2.4.1
Hi all, I’ve just compiled Python 2.4.1 on a linux box (RHEL 3AS) after having installed Berkeley DB 4.3.27 from sleepycat Software.During the configure/build process python correctly found the BSBDB library. I then installed the rest of my environment which is correctly working with Python 2.3 When I try to run one of my procedures I get the following error trying to opening a common shelve file : Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/local/lib/python2.4/site-packages/mod_python/publisher.py", line 136, in handler result = util.apply_fs_data(object, req.form, req=req) File "/usr/local/lib/python2.4/site-packages/mod_python/util.py", line 361, in apply_fs_data return object(**args) File "/discoe/script/cgi/cgi-mpy/cgi-mpy_login.py", line 116, in controlla_login dbase = shelve.open(file_AUTENTICAZIONE) #apre shelve File "/usr/local/lib/python2.4/shelve.py", line 231, in open return DbfilenameShelf(filename, flag, protocol, writeback, binary) File "/usr/local/lib/python2.4/shelve.py", line 212, in __init__ Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback, binary) File "/usr/local/lib/python2.4/anydbm.py", line 83, in open return mod.open(file, flag, mode) File "/usr/local/lib/python2.4/dbhash.py", line 16, in open return bsddb.hashopen(file, flag, mode) File "/usr/local/lib/python2.4/bsddb/__init__.py", line 285, in hashopen e = _openDBEnv() File "/usr/local/lib/python2.4/bsddb/__init__.py", line 339, in _openDBEnv e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) DBError: (156471272, 'Unknown error 156471272') Any hint or suggestion is welcom Thnx Marco Cassiano -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (vs PHP stuff)
> > > Conclusion 1: if PHP is anything as awful as the manual, it is not for me. > > the whole idea that turning the manual into a wiki or a forum will solve all > problems is extremely naive. > Wha? I haven't done PHP for a couple of years, but when I really needed documentation, the PHP docs were well organized, and told me exactly what I needed, and when I didn't find it in the official part of the docs, invariably someone had run into the same problem I had and posted the solution at the end of the docs page. It really is great when you are actually doing PHP and it's your main resource. Even if you're just critisizing something that you're vaguely familliar with, for the fun of it, you're not actually critisizing it as much as calling it poo poo without any real world examples of why it "is extremely naive" or what would work better... One of the things I like about the python list is that it generally has a high signal to noise ratio, but this is just noise... -Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: Destructor Woes, was Advice needed on __del__
Fredrik Lundh wrote: > "flupke" wrote: > > >>>Then i got a tip that you can register a function that needs to be >>>called when the object is going to be deleted. >>>For instance to register a function __exit, you do this: > > >>>class line: >>>def __init__(s,glob,argl,color=''): >>>atexit.register(s.__exit) > > >>I don't know what's wrong in your example. Here it works (doesn't help >>you of course). I would first try with an easy example an try to test >>the atexit functionality like that. It seems that the problem you are >>having isn't related to the atexit part. > > > do you (or whoever gave you the tip) have the slightest idea what atexit does? > > As i said, it works for me. I use it to log the closure of my main program. Maybe my first message wasn't clear on the use of atexit. Benedict -- http://mail.python.org/mailman/listinfo/python-list
Europython update
This is a news update about the Europython 2005 conference, to be held in Göteborg, Sweden 27-29 June - We have received a very nice array of talks this year, and we expect to be the biggest Python conference ever in terms of subjects covered. Many thanks to all the speakers who are putting their efforts into this. - A list of talks is now available,either through the "Track Overview" menu item on the Europython website, or directly at http://www.python-in-business.org/ep2005/atracks.chtml - Around the end of May we will be soliciting input from all attendees on what talks they aremost interested in. This information will be used in scheduling, in order to reduce the amounts of collisions between popular talks and in order to reduce the risk of overcrowding a small room with a talk that turns out to be very popular. - Early bird registrations end 15 May. Registration for the low cost accomodation close to the conference venue ends on the same day. We may have further accomodation available at a later date, but we can't make any promises. - Please help us become the biggest Python/Zope conference. Talk to your friends about Europython and write about the conference in your blog. The more people who show up, the more we can spend on getting the best and most interesting talks. - This year we have a special focus on Python newbies in the Tutorials track. If you have staff or customers who need a well rounded introduction to Python, send them to Europython 2005. For all conference details, go to: http://www.europython.org See you in Göteborg. EuroPython Team. About EuroPython: Europython is an annual conference for the Python and Zope communities. It circulates between different sites in Europe. Having started in Charleroi, Belgium, it is now in Göteborg, Sweden and will move to CERN in Swizerland next year. Europython is a community conference run by volunteers. -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem combining python code and html
Any suggestions to the problem with only one character being displayed? Thanks Thanks for your time "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hansan a écrit : >> Hi all, I hope you have time to help me out a little. My problem is that >> I want to combine some python code I have made with some html templates, >> I found a tutorial at dev shed: > (snip a whole lot of code) > >> But I get the error message: >> error: multiple repeat >> args = ('multiple repeat',) ", Content,TemplateInput) File >> "/home//Python-2.3.2//lib/python2.3/sre.py", line 151, in subn return >> _compile(pattern, 0).subn(repl, string, count) >> I tried making the templates global, but that dosnt help either. > > Why should it ? > >> Is the code from dev shed wrong, > > Seems like... And it is *very* ugly. > >> And is there a nother way to combine python code and html templates? > > Many. The one I prefer is Zope Page Templates (there's a free-standing > implementation named SimpleTAL), but I didn't tried all and every existing > solutions. > -- http://mail.python.org/mailman/listinfo/python-list
Launch file in Notepad
Newbie question: I'm trying to lauch Notepad from Python to open a textfile: import os b1="c:\test.txt" os.system('notepad.exe ' + b1) However, the t of test is escaped by the \, resulting in Notepad trying to open "c: est.txt". How do I solve this? (By the way, b1 comes from a command line parameter, so the user enters c:\test.txt as command line parameter.) George -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
Paul> Some parts of the lib doc are better than others. The only way to Paul> understand SocketServer, for example, is to read the long comment Paul> at the beginning of the source file. I've been wanting to get Paul> around to merging that with the doc writeup and adding some Paul> examples. Thanks for the suggestion. I just incorporated the module doc string into the SocketServer doc (CVS HEAD and 2.4 release branch). Paul> Tkinter, as well, is practically undocumented as far as the base Paul> distro is concerned, but there's some good docs for it elsewhere Paul> on the web. I'll let someone else tackle that one. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
[EMAIL PROTECTED] wrote: > So forgive me if I'm in trouble... Instead of mocking me, the better > should be to give me an brief idea of the import's roll (namespaces, > visibility and so on...) if you're interested in learning stuff, why not spend your time reading up on how things work, rather than bragging about how you won't use classes, etc, and posting silly assertions. there are plenty of information on python.org; if you get stuck on some specific part of it, there are lots of people here than can help you sort things out. but if you don't even want to try, all you're doing is wasting time -- your own, and others. -- http://mail.python.org/mailman/listinfo/python-list
RE: Launch file in Notepad
try b1="c:/test.txt" It seems to work for me on Windows 2000. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] n.org]On Behalf Of George Sent: Thursday, May 12, 2005 9:41 AM To: python-list@python.org Subject: Launch file in Notepad Newbie question: I'm trying to lauch Notepad from Python to open a textfile: import os b1="c:\test.txt" os.system('notepad.exe ' + b1) However, the t of test is escaped by the \, resulting in Notepad trying to open "c: est.txt". How do I solve this? (By the way, b1 comes from a command line parameter, so the user enters c:\test.txt as command line parameter.) George -- http://mail.python.org/mailman/listinfo/python-list ___ The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
George said unto the world upon 2005-05-12 09:41: > Newbie question: > > I'm trying to lauch Notepad from Python to open a textfile: > > import os > b1="c:\test.txt" > os.system('notepad.exe ' + b1) > > However, the t of test is escaped by the \, resulting in Notepad trying > to open "c: est.txt". > > How do I solve this? There are several ways, but the preferred solution is to switch the slash direction: "c:/test.txt". Python's smart enough to notice its running on Windows and do the right thing with the slash. (Other choice include using raw strings: r"c:\test.txt", and explicitly escaping the backslash: "c:\\test.txt".) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
Ivan> I get that. My question, cleverly concealed in a rant, was, "Why Ivan> does clicking on the Documentation link at python.org NOT take me Ivan> to docs.python.org?" I almost changed that link, but then reconsidered. Compare http://docs.python.org/ with http://www.python.org/docs/ The former is just the main documentation that's part of the Python distribution. The latter contains links to lots of supplementary material, much of which is not part of python.org. The original functional goal of the http://docs.python.org/ URL was to provide a cleaner isolation of "just the facts, Ma'am" so that Google could do a better job presenting documentation search results. Previously, it was impossible to separate the mailing list archives from the documentation proper in Google searches. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
>> - hacking SWIG. Shouldn't be too hard and will instantly give >> us access to wx, qt, etc. Mike> You can't assume that because some package is a C/C++ library Mike> wrapped for Python that it uses SWIG. pyqt, for example, doesn't Mike> use SWIG at all. It uses SIP, which is considerably more Mike> complicated than SWIG. PyGTK uses its own lisp-y thing as the wrapper IDL. Actually, it's specific to GTK and is AFAIK is used to wrap GTK by languages besides Python. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
[George] > b1="c:\test.txt" With this code, your problem is the embedded tab as you say. Use either r"c:\test.txt" or "c:\\test.txt". However, if this is true: > By the way, b1 comes from a command line parameter, so the user enters > c:\test.txt as command line parameter. then there will be no embedded tab. How are you prompting the user? When I run this: import os b1=raw_input("Enter a filename: ") os.system('notepad.exe ' + b1) and enter c:\test.txt, it works as expected. [Brian] > There are several ways, but the preferred solution is to switch the > slash direction: "c:/test.txt". Python's smart enough to notice its > running on Windows and do the right thing with the slash. In fairness to Windows, I don't believe Python does anything special here. Windows itself happily accepts either forward slash or backslash at the OS level - it's only the shells (explorer.exe or to a lesser extent cmd.exe) that don't accept forward slashes. -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding startup files
On 2005-05-11, jeff elkins <[EMAIL PROTECTED]> wrote: > I'm totally new to Python (obvious,yes?) so how might argv[0] fail? argv[0] contains whatever is put there by the program that exec'ed you, and can therefore contain just about anything (or nothing). It may not contain a full path, and your program's install directory may not be in your $PATH (it be executed by a shortcut or symlink). If you're controlling how the program is installed and started, then you're probably safe. -- Grant Edwards grante Yow! I guess it was all a at DREAM... or an episode of visi.comHAWAII FIVE-O... -- http://mail.python.org/mailman/listinfo/python-list
Re: "/usr/bin/ld: cannot find -lmysqlclient" when building MySQL-Python
[EMAIL PROTECTED] wrote: > Hi. I'm trying to build MySQL-python-1.2.0 on my Linux FC2 > (with MySQL 3.23.58). See: https://sourceforge.net/tracker/index.php?func=detail&aid=1146226&group_id=22307&atid=374932 And also try the new 1.2.1c3 release candidate. -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
On 2005-05-12, Brian van den Broek <[EMAIL PROTECTED]> wrote: >> b1="c:\test.txt" >> os.system('notepad.exe ' + b1) >> >> However, the t of test is escaped by the \, resulting in Notepad trying >> to open "c: est.txt". > There are several ways, but the preferred solution is to switch the > slash direction: "c:/test.txt". Python's smart enough to notice its > running on Windows and do the right thing with the slash. Does Python really look at the string and mess with the slash? I don't think it needs to, since the Windows system calls have always accepted forward slashses, haven't they? -- Grant Edwards grante Yow! Ask me the DIFFERENCE at between PHIL SILVERS and visi.comALEXANDER HAIG!! -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
[Paul Rubin] > It's true that CPython doesn't have a compiler and that's > a serious deficiency. Hi, Paul. I did not closely follow all of the thread, so maybe my remark below, only repeats what others might have said and I missed? Deep down, why or how not having a [traditional, to-native-code] compiler is a deficiency for CPython? We already know that such a beast would not increase speed so significantly, while using much more memory. It is true that a standard traditional compiler for CPython would allow one would be to check the box: [x] has a compiler in the fashion of the day language information sheet, and for some readers, not having that box checked is a deficiency in itself. :-) So far, it seems that the only way to get speed is to attach static type information to some variables. Some compilation avenues do it through information added either in Python source code or in extraneous declarative files, other approaches do it by delaying compilation until such information is discovered at run-time. The former taints the purity of real CPython as the only source. The later often shows spectacular speed gain, but not always, and may bloat size unboudedly. -- François Pinard http://pinard.progiciels-bpi.ca -- http://mail.python.org/mailman/listinfo/python-list
Speed of the different python-based HTTP-servers
I'm thinking of switching from my Twisted-HTTP-server-project to CherryPy or Snakelets etc etc. The project involves alot of database-access using SQLObject and SQLite ( perhaps MySQL and PostgreSQL in the future ) and some heavy IO-stuff ( scanning of local filesystem to extract meta information about images and storing this info in the database. This won't happen too often though). I don't expect this project to have alot of traffic once online, but it would kinda suck if my software couldn't handle it if it really took off. So my question is; based on the very brief description above, are there any of the python-based frameworks that fits my project better than the others? And are there some of the frameworks that doesn't scale particulary well? Benchmarks anyone? My main focus is simplicity, one of the main reason I'm looking for something else than Twisted. I'm a little conserned about the threading-issues when using thread-based frameworks though, but if speed and scalability would increase dramatically I'm inclined to struggle with the threads anyhow. Snakelets and CherryPy both look interesting compared to Twisted ( and CherryPy seems to have some code available using SQLObject allready, while Snakelets does not, so I'm leaning towards CherryPy at the moment ). I want to use ZPT or simpleTAL for templating and SQLObject for database-access etc if that makes any differences. Thanks for any input you might have. Best regards, Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib download insanity
Timothy> i DELETED the file from my webserver, uploaded the new Timothy> one. when my app logs in it checks the file, if it's changed it Timothy> downloads it. the impossible part, is that on my pc is Timothy> downloading the OLD file i've deleted! if i download it via IE, Timothy> i get the new file. SO, my only conculsion is that urllib is Timothy> caching it some where. BUT i'm already calling urlcleanup(), so Timothy> what else can i do? here is the code Is there a proxy between you and the web server? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
On Thu, 12 May 2005 15:41:14 +0200, George <[EMAIL PROTECTED]> wrote: >Newbie question: > >I'm trying to lauch Notepad from Python to open a textfile: > >import os >b1="c:\test.txt" >os.system('notepad.exe ' + b1) > >However, the t of test is escaped by the \, resulting in Notepad trying >to open "c: est.txt". Right. '\t' is a tab, not two characters. You can get the characters you want by escaping the escape > >How do I solve this? > >(By the way, b1 comes from a command line parameter, so the user enters >c:\test.txt as command line parameter.) It should be ok then, unless you have somehow processed the command line parameter and interpreted the backslash as an escape. E.g., pargs.py here prints command line args and backslash is an ordinary string character as you see in argv[3] below. If it were a tab, you would see whitespace instead of the backslash. [ 7:35] C:\pywk\parse\ast>type c:\util\pargs.py import sys for i in xrange(len(sys.argv)): print 'argv[%d]: "%s"' % (i,sys.argv[i]) [ 7:35] C:\pywk\parse\ast>py24 c:\util\pargs.py abc def c:\test.txt argv[0]: "c:\util\pargs.py" argv[1]: "abc" argv[2]: "def" argv[3]: "c:\test.txt" If by "command line" you mean your own programmed input, make sure you use raw_input, not input, e.g., >>> print '-->>%s<<--' % raw_input('Enter text please: > ') Enter text please: > c:\test.txt -->>c:\test.txt<<-- But input evaluates the input string (also posing security problems if you don't trust the user): >>> print '-->>%s<<--' % input('Enter text please: > ') Enter text please: > c:\test.txt Traceback (most recent call last): File "", line 1, in ? File "", line 1 c:\test.txt ^ SyntaxError: invalid syntax That was from evaluating, so we can quote: >>> print '-->>%s<<--' % input('Enter text please: > ') Enter text please: > "c:\test.txt" -->>c: est.txt<<-- ^^--there's that tab \t again, unless you escape the backslash >>> print '-->>%s<<--' % input('Enter text please: > ') Enter text please: > "c:\\test.txt" -->>c:\test.txt<<-- But in your example above, >>> b1="c:\test.txt" >>> b1 'c:\test.txt' >>> list(b1) ['c', ':', '\t', 'e', 's', 't', '.', 't', 'x', 't'] >>> print '-->>%s<<--'%b1 -->>c: est.txt<<-- Escaping the escape: >>> b1="c:\\test.txt" >>> print '-->>%s<<--'%b1 -->>c:\test.txt<<-- Using raw string format (prefixed r on string), which won't work if string ends in backslash BTW) >>> b1=r"c:\test.txt" >>> print '-->>%s<<--'%b1 -->>c:\test.txt<<-- To see the single tab character in your original >>> b1="c:\test.txt" >>> b1[2] '\t' >>> ord(b1[2]) 9 BTW, you might want to use os.system('start notepad ' + b1) if you want an independent process and not wait for notepad to finish. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
Richie Hindle wrote: >>By the way, b1 comes from a command line parameter, so the user enters >>c:\test.txt as command line parameter. > > > How are you prompting the user? When I run this: > > import os > b1=raw_input("Enter a filename: ") > os.system('notepad.exe ' + b1) > > and enter c:\test.txt, it works as expected. So it does with me, but the user does not enter the filename, he launches my Python script file from the DOS-prompt with a command line parameter, for example: test.py c:\test.txt In that case the \ escapes the t. (read on!) That is, until now. For some very strange reason it suddenly works as expected. I don't understand it anymore, but never mind. Maybe I changed my little proggie somehow, causing it accidentally to work. Thanks anyway. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Sleepycat Bsdbd 4.3.27 and Python 2.4.1
Marco> I've just compiled Python 2.4.1 on a linux box (RHEL 3AS) after Marco> having installed Berkeley DB 4.3.27 from sleepycat Software. Marco> During the configure/build process python correctly found the Marco> BSBDB library. ... Marco> File "/usr/local/lib/python2.4/bsddb/__init__.py", line 339, in _openDBEnv Marco> e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) Marco> DBError: (156471272, 'Unknown error 156471272') Marco> Any hint or suggestion is welcom Was your shelve file created with an earlier version of Berkeley DB? If so, you probably have to update the file so it can be read by the new version. As part of the Berkeley DB install/upgrade you should probably have a db_upgrade command. Check it out. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: subclass dialog or put in the resource files?
flupke wrote: > > I'm using wxPython and design the gui via wxglade. One of the gui > components is a simple dialog class that gets displayed when a user > exits the program. > I want to use the same dialog but with a different text for closing > certain dialogs in the program. (it's a pure "do you want to exit > " dialog) > > What would i better use, knowing the rest of the gui is in a resource > (xrc) file: > > 1. Find some way to put a standard exit dialog in the resource file and > then somehow try to set the message to the correct one. > > 2. Make a simple dialog class that accepts the message to be displayed. > I could even use glade to generate the python code for a start. > > What would be the better/cleaner/logical way to do this? > > Thanks, > Benedict I found what i was looking for. I first load the dialog from the resource files and then i change the text like this: children = self.d_exit.GetChildren() for control in children: if ( type(control) is wx.StaticText ): control.SetLabel("") Benedict -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
Hi Fredrik, thank you for saying that I am > ... posting silly assertions. I didn't born " Python expert", and I am hardly trying to learn something. I don't like classes but this assertion (silly... I agree) is due to the fact that "I don't understand them well" (I hope to change mind in a near future). Another item (for me...) difficult, is "import modules", and "plenty of information" (as you said) does not help me much: the mechanism of variable visibility and namespaces is not clear to me. It will be enough an example of the various type of imports and they difference in terms of namespaces or, better, of something you can see on your monitor, or print like, for example, a dictionary. As you can see from my replay to Steve Holden, I have abandoned my project on flowcharting. I must study (as you adviced me)... Bye. -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
Grant Edwards wrote: > On 2005-05-12, Brian van den Broek <[EMAIL PROTECTED]> wrote: > Does Python really look at the string and mess with the slash? > I don't think it needs to, since the Windows system calls have > always accepted forward slashses, haven't they? It did, but now not anymore. I don't understand why, maybe I've changed something in the code. See my other post. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
On Thu, 12 May 2005 14:20:29 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2005-05-12, Brian van den Broek <[EMAIL PROTECTED]> wrote: > >>> b1="c:\test.txt" >>> os.system('notepad.exe ' + b1) >>> >>> However, the t of test is escaped by the \, resulting in Notepad trying >>> to open "c: est.txt". > >> There are several ways, but the preferred solution is to switch the >> slash direction: "c:/test.txt". Python's smart enough to notice its >> running on Windows and do the right thing with the slash. > >Does Python really look at the string and mess with the slash? >I don't think it needs to, since the Windows system calls have >always accepted forward slashses, haven't they? > For a path parameter, I think so. But various command shells us '/' the way unix uses '-' -- i.e., for options/switches. E.g. ls -R foo/bar would work as dir /s "foo/bar" since the shell would pass on the quoted string to the os level (with quotes removed) Likewise dir foo\bar/s would work, but not dir foo/bar/s or dir/s foo/bar I don't know why MS used backslashes when unix had a perfectly good path syntax (not to mention drive letter idiocy). Maybe some legal idiocy, wanting to be different to be safe from SCO types? Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
On Thursday 12 May 2005 08:57 am, Skip Montanaro wrote: > Ivan> I get that. My question, cleverly concealed in a rant, was, "Why > Ivan> does clicking on the Documentation link at python.org NOT take me > Ivan> to docs.python.org?" > I almost changed that link, but then reconsidered. Compare > http://docs.python.org/ > with > http://www.python.org/docs/ [...] > The original functional goal of the http://docs.python.org/ URL was to > provide a cleaner isolation of "just the facts, Ma'am" so that Google could > do a better job presenting documentation search results. Previously, it was > impossible to separate the mailing list archives from the documentation > proper in Google searches. Maybe a good compromise would be to have a search form on the http://www.python.org/doc/ page labeled "Search Documentation" which did a search on http://docs.python.org/ , then? Though I see that "Browse Documentation" does indeed go to http://docs.python.org . Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
Bengt Richter wrote: > On Thu, 12 May 2005 15:41:14 +0200, George <[EMAIL PROTECTED]> wrote: >>(By the way, b1 comes from a command line parameter, so the user enters >>c:\test.txt as command line parameter.) > > It should be ok then, unless you have somehow processed the command line > parameter and interpreted > the backslash as an escape. E.g., pargs.py here prints command line args and > backslash is > an ordinary string character as you see in argv[3] below. If it were a tab, > you would see > whitespace instead of the backslash. Perhaps that's what I did (processing the command line parameter). For some reason it works now. > If by "command line" you mean your own programmed input, make sure you use > raw_input, not input, e.g., I was referring to the user launching my script with a filename as parameter: test.py c:\test.txt Here's my code so far (it removes blank lines from the input file (for example c:\test.txt), and creates a new file (c:\test_new.txt) to store the output): import string import sys import os if len(sys.argv)<=1: print 'Usage: dbl.py [filename]' sys.exit() b1=sys.argv[1] b2=b1[:-4] + '_new' + b1[-4:] f1=open(b1,'r') f2=open(b2,'w') r1=f1.readlines() for r in r1: if string.capwords(r)<>'': f2.write(r) f1.close() f2.close() print 'Output file: ' + b2 os.system ('start notepad.exe ' + b2) George -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
Steven Bethard wrote: > Ivan Van Laningham wrote: >> The Python docs are not ideal. I can never remember, for instance, >> where to find string methods (not methods in the string module, but >> methods with '') > > Hmmm... Well going to http://docs.python.org/ and typing "string > methods" into the search box gives, as the first hit: > > http://docs.python.org/lib/string-methods.html > > Even if you just search for "string", that URL is the second hit, and > pretty clearly the right one from the title. > > STeVe Heh, searching "dict methods" didn't produce the correct results on the first page. "dictionary methods" did. searching for "append" returned the array's module page as the first result, and list's module page as the 8th result. Search for "static" came up with nothing. Search for "staticmethod" came up with the built-in-funcs page, from which I had to search again for "staticmethod". The search mechanism isn't all that great (imo anyways). Honestly, neither is the PHP one, except when you are only searching the function list. Then its the bomb. I also like how each PHP function gets its own page and each page is full of examples. And I love how each page shows related functions. Granted its easier to do the function list search for PHP because there are no namespaces or classes, but still I think Python could do something similar. Say for instance search for "append" and it will come back with a page for list's append, a page for array's append, etc. My idea for a manual's table of contents: 1. Variables 2. Conditional and Branching Constructs 3. Looping Constructs 4. Functions 5. Modules 6. Classes 7. Exceptions 8. Built-in 8.1 Functions 8.2 Types Of course there should be more detailed sublevels. The tutorial (at least chapters 3-11) make a good (partial) manual. I think those chapters should be the basis for a real manual vs. a tutorial. If I wanted to learn about "types" in Python, where do I look? The PHP manual has a whole section on the built-in types, how to get the type of a var, how to change cast the type of a var, etc. I think that is such an important and basic part of any language, yet its scattered all over Python documention, difficult to find (i.e. not in a manual, but the library reference). I guess what I'm trying to say is that there should be a "manual" which is half way between the tutorial and the library reference, that is organized more like a traditional manual (whatever that means, right?) and is more easily searchable. -- C -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
Steven Bethard wrote: > Christopher J. Bottaro wrote: >> Contrast that with Python. First off there is no "search" mechanism >> built into the documentation page (yes I know you can google it, but that >> just doesn't feel right). > > Um, are you looking at the current documentation page? > > http://docs.python.org/ > > In the upper right hand corner, I see a box entitled "Search:" and a > button that says "submit". Oops. I link directly to the tutorial and library reference...=) > STeVe -- C -- http://mail.python.org/mailman/listinfo/python-list
How "return" no return ?
Hello, I want that the return sentence don't return anything, how can I do it?. If i do only return it returns None, and pass don't run too. Can anyone help me?, thanks. XIMO -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
Ximo wrote: >Hello, I want that the return sentence don't return anything, how can I do >it?. If i do only return it returns None, and pass don't run too. > >Can anyone help me?, thanks. >XIMO > > > > Returning None is the same as returning nothing. What exactly are you trying to do? -- http://mail.python.org/mailman/listinfo/python-list
Creating new StructuredText-like content type for Zope/Plone
I prefer to use my own text format instead of StructuredText or the like, because I also use emacs outline mode a lot. What would be the best approach for creating this new content type in Zope/Plone? Writing a new Plone product with page templates seems fairly involved, but maybe it's desirable to have that control. Would Archetypes suffice? Thanks in advance, --tobias -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file in Notepad
On 2005-05-12, Bengt Richter <[EMAIL PROTECTED]> wrote: >>> There are several ways, but the preferred solution is to switch the >>> slash direction: "c:/test.txt". Python's smart enough to notice its >>> running on Windows and do the right thing with the slash. >> >>Does Python really look at the string and mess with the slash? >>I don't think it needs to, since the Windows system calls have >>always accepted forward slashses, haven't they? > > For a path parameter, I think so. But various command shells us '/' the > way unix uses '-' -- i.e., for options/switches. E.g. You're right. It's the applications that choke on the forward slash. Back in the bad old days there was a way to tell DOS to use '-' for the switch character, but not all apps paid attention to the setting. > I don't know why MS used backslashes when unix had a perfectly > good path syntax (not to mention drive letter idiocy). Maybe > some legal idiocy, wanting to be different to be safe from SCO > types? I think the use of forward slashes for command line switches was adopted by CP/M from DEC's OSes (e.g. RSX-11). CP/M didn't have directories in the beginning, so nobody worried about what to use for path separators (DEC used colons, IIRC). DOS was a straight-up ripoff of CP/M and kept '/' as the option character. Later when directories were added to DOS, they picked '\' as the path seperator becuase '/' was the default switch caracter. The C-language "system calls" always accepted either, but they may have been translating forward to backward before making the DOS call calls. -- Grant Edwards grante Yow! .. If I had heart at failure right now, visi.comI couldn't be a more fortunate man!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Interactive shell for demonstration purposes
Bengt Richter wrote: > If you make your console 96 wide and set the font to Lucida Console Bold > 24point, > it will probably expand to near full screen on 1024x768. You can set the > scroll buffer > to a couple hundred lines and adjust console widow height to suit. Use the > properties > from the system icon, or get there by Alt-Space P etc. That's not bad. There are two caveats: 1. you have to set the width to 72 characters (instead of 80) at 1024x768 with 24 point fonts 2. you can't run in full-screen mode Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
"Ximo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, I want that the return sentence don't return anything, how can I do > it?. If i do only return it returns None, and pass don't run too. > > Can anyone help me?, thanks. > XIMO > Just don't use a return statement at all, or do something like [function body] if not val = None: return val [end of function] -- http://mail.python.org/mailman/listinfo/python-list
Is there a better way to delete the image from a Tkinter button other than the following:
Is there a better way to delete the image from a Tkinter button other than the following: - reconstructing the button - image=blank.gif -- Regards, Casey -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as "int a" my progrtam return de prompt and nothing more, for exemple: >>> 2+2 4 >>> int a >>> Then I'm finding that de function which execute "int a" return me nothing, and no >>> int a None >>> "Joseph Garvin" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > Ximo wrote: > >>Hello, I want that the return sentence don't return anything, how can I do >>it?. If i do only return it returns None, and pass don't run too. >> >>Can anyone help me?, thanks. >>XIMO >> >> >> >> > Returning None is the same as returning nothing. What exactly are you > trying to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
[Ximo] > I want that the return sentence don't return anything, how can I do > it? `return' always return something (if we except the case of generators). Used without arguments, it returns None, as you discovered already. If a function "falls through" its end, None is implicitely returned. A function always have a value. I do not understand the need of "not returning anything". What do you mean? What is the real need? > [...] pass don't run too. `pass' surely runs. However, `pass' is not a `return' statement. -- François Pinard http://pinard.progiciels-bpi.ca -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
On 2005-05-12, Tim Williams <[EMAIL PROTECTED]> wrote: > "Ximo" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hello, I want that the return sentence don't return anything, how can I do >> it?. If i do only return it returns None, and pass don't run too. >> >> Can anyone help me?, thanks. >> XIMO >> > > Just don't use a return statement at all, That's exactly the same as "return None" -- Grant Edwards grante Yow! World War Three can at be averted by adherence visi.comto a strictly enforced dress code! -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
Paul Rubin wrote: > Yes, there are several Python compilers already ... > It's true that CPython doesn't have a compiler and that's a serious > deficiency. A lot of Python language features don't play that well > with compilation, and that's often unnecessary. So I hope the baseline > implementation changes to a compiled one before the language evolves > too much more. Years ago, presented at one of the Python conferences, was a program to generate C code from the byte code. It would still make calls to the Python run-time library (just as C does to its run-time library). The presenter did some optimizations, like not decref at the end of one instruction when the next immediately does an incref to it. The conclusion I recall was that it wasn't faster - at best a few percent - and there was a big memory hit because of all the duplicated code. One thought was that the cache miss caused some of the performance problems. Does that count as a compiler? Andrew [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
On Thu, May 12, 2005 at 04:42:34PM +0100, Tim Williams wrote: > Just don't use a return statement at all, or do something like > > [function body] > if not val = None: > return val > [end of function] i didn't understood that. if you don't return nothing explicitly the function returns None. (or am i wrong?) c. -- Hi, I'm a .signature virus! Copy me to your .signature file and help me propagate, thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: a cx_Oracle ORA-01036 problem
>> SQL = """insert into D.D_NOTIFY values (:CARDREF, :BANKKEY, :OK1, :OK2 \ >> :DEBTEUR, :DEBTDEN, to_date(:INVOICE_DATE,'DD.MM.YY'), >> to_date(:PAYMENT_DEADLINE,'DD.MM.YY'), :POINTS)""" >> > Try using a variable name other than "id" for the CARDREF variable... say > "card_id". id is a built in function name; I suspect your problem may be > that you are assiging that function to the variable rather than your > intended value... I changed it to 'cardref' but I'm still getting the same error. -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
"Christopher J. Bottaro" <[EMAIL PROTECTED]> writes: > because there are no namespaces or classes, but still I think Python could > do something similar. Say for instance search for "append" and it will > come back with a page for list's append, a page for array's append, etc. A seperate page for each method of every class? Ouch. I think that's serious overkill. Having the entries for the methods in the pages be labelled, so that a search could return a direct link to the appropriate paragraph, that would be a major improvement. > If I wanted to learn about "types" in Python, where do I look? The PHP > manual has a whole section on the built-in types, how to get the type of a > var, how to change cast the type of a var, etc. I think that is such an > important and basic part of any language, yet its scattered all over Python > documention, difficult to find (i.e. not in a manual, but the library > reference). Python variables don't have types. Python objects have types. Python further confuses the issue by overloading "types" to mean builtin types, which are different classes, which can both instantiate as a variable. If you're doing things Pythonically, you generally don't care what type a variable has - you care that it supports the operations you want. Changing the type of an object is either impossible or dificult, depending on the object - and not to be undertaken lightly. What I'm trying to say is that "type" just isn't as important a concept in Python as it is in other languages. PHP, for instance, apparently has a number of automatic conversions between types if various operations are applied, so you have to care what type an object is or risk getting it converted accidently. Python doesn't do that. Many languages have typed variables, so everything you do will depend on the type of the variable. Python doesn't do that. Some OO languages conflate types and classes, and use isinstane for type checking. Python doesn't do that. All that python cares about - and all that you really need to care about - is that the object referenced by the variable support the features you want to use. > I guess what I'm trying to say is that there should be a "manual" which is > half way between the tutorial and the library reference, that is organized > more like a traditional manual (whatever that means, right?) and is more > easily searchable. Given that Python hides the difference between user-defined objects and built-in objects, it's not clear to me that anything other than the current system, with all the classes/types in one place, makes sense. That's not to say the documentation can't be improved. I'm just not convinced that a "manual" pulling in parts from multiple different places is an improvement. That said, I'd like to ask what's wrong with the language reference? It provides a nice reference on the syntax and semantics of the language. What does the tutorial provide that you can't get from the Language Reference? http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling Tcl apps redux
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: . . . >Absolutely! Looking at the wiki there are a bunch of solutions, all of >which work in specialized circumstances. Nothing like, say the "freeze" >script of Python. . . . !?! Has Python's freeze changed so much that it's now a universal solution? I need to re-acquaint myself with it ... -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
- Original Message - From: "Corrado Gioannini" <[EMAIL PROTECTED]> > On Thu, May 12, 2005 at 04:42:34PM +0100, Tim Williams wrote: > > Just don't use a return statement at all, or do something like > > > > [function body] > > if not val = None: > > return val > > [end of function] > > i didn't understood that. > if you don't return nothing explicitly the function returns None. > (or am i wrong?) No, you're right, my bad :) Was thinking about something else similar and got stuck in a mindset -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib download insanity
Timothy Smith wrote: > ok what i am seeing is impossible. > i DELETED the file from my webserver, uploaded the new one. when my app > logs in it checks the file, if it's changed it downloads it. the > impossible part, is that on my pc is downloading the OLD file i've > deleted! if i download it via IE, i get the new file. SO, my only > conculsion is that urllib is caching it some where. BUT i'm already > calling urlcleanup(), so what else can i do? Here are some ideas to use in your hunt. - If you are getting a cached local file then the returned object will have a "name" attribute. result = urllib.retrieve(".") print result.fp.name As far as I can tell, this will only occur if you use a tempcache or a file URL. - You can force some debugging of the open calls, to see if your program is dealing with a local file. >>> old_open = open >>> def my_open(*args): ... print "opening", args ... return old_open(*args) ... >>> open("/etc/passwd") >>> import __builtin__ >>> __builtin__.open = my_open >>> open("/etc/passwd") opening ('/etc/passwd',) >>> You'll may also need to change os.fdopen because that's used by retrieve if it needs a tempfile. If you want to see where the open is being called from, use one of the functions in the traceback module to print the stack trace. - for surety's sake, also do import webbrowser webbrowser.open(url) just before you do urllib.retrieve(url, filename) This will double check that your program is using the URL you expect it to use. - beyond that, check that you've got network activity, You could check the router lights, or use a web sniffer like ethereal, or set up a debugging proxy - check the headers. If your ISP is using a cache then it might insert a header into what it returns. But if it was caching then your IE view should have seen the cached version as well. Andrew [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
Mike> Given that Python hides the difference between user-defined Mike> objects and built-in objects, it's not clear to me that anything Mike> other than the current system, with all the classes/types in one Mike> place, makes sense. Maybe the Module Index should be renamed "Module/Type Index" and embellished with the builtin types, so that you'd find "float (builtin)", "string (builtin)", "dict (builtin)", etc. in the appropriate alphabetical positions. Skip -- http://mail.python.org/mailman/listinfo/python-list
Python Polymorphism
Dear all, How could I use Python polymorphism? Which kind of structures Python give me to use polymorphism? Where can I find specific documentation? Thanks and Best regards. Cadu Moreira __ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs -- http://mail.python.org/mailman/listinfo/python-list
Re: Unique Elements in a List
Edvard Majakari wrote: > I realized that, but maybe I should've pointed it out too. For the OP if > he/she is unaware - notation O(N^2) (big O n squared) means the computing time > of the algorithm increases exponentially (where exponent is 2) relative to the > size of the input. Normally this is called a polynomial, rather than exponential increase. Exponential increases are typically of the form (C^N) (they are all equivalent). Polynomial times are hallways characterized by their largest exponent, So you never call something O(N^3 - N^2) Since, as N gets large enough, The N^2 term shrinks to non-existence. http://en.wikipedia.org/wiki/Exponential_time > ... generally one should avoid using exponential O(n^k) (where k > 1) Again polynomial, not exponential time. Note that there is no polynomial time algorithm with (k < 1), since it takes O(n) time to read the problem. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Debugging python with c++ extensions under windows with eclipse CDT
Hello all, I would like to debug my python libraries, written in c++, with GDB (gnu debugger) I'm using the mingw compiler in a windows environment. As development environment I use eclipse with the CDT plugin. This plugin also has a nice GUI frontend for the GDB. I've already tried several setups, no setup seemed to work. Therefore my first question simply is: has anybody already succeeded in using the GDB used by eclipse CDT to debug a c++ extension? Is this actually the best way to debug DLLs in windows? Is visual studio better suited for the job? Is there another option I am not aware of? thx a lot for reading so far Peter In the following section I explain in detail what I've already tried. It can easily be skipped. Ok, an overview of the things I've already done: first, to use mingw with the python distribution, I've first followed http://sebsauvage.net/python/mingw.html in order to get an adjusted libpython23.a Otherwise you cannot use the mingw compiler with python under windows In order to debug my code, I've found in this newsgroup the topic: "Debugging python with C++ extensions" and similar I've found http://ruby.wag.caltech.edu/Tutorials/double-debugger.html I've tried somewhat similar in my eclipse CDT environment: I start a python script, which pauses at a point I've inserted: >>>a = raw_input("") Now I can start the GDB and attach it to this running python process... In eclipse this is "right mouse click" > debug > debug > "c/c++ attach to local application" I create a new configuration of this type, fill in the correct DLL. (making sure my binary parser was correct, this is usually the problem if you can't find any binaries) all this did not same to work... I get an error" Cannot access memory at address 0x68f52bcc Cannot access memory at address 0x68f52bcc" and I no longer understand anything which is going on in the the debugger. So again the basic question is: has anybody already succeeded in using the GDB for debugging python c++ libraries in windows? Does this also work when you use the eclipse environment? once again, kind regards -- http://mail.python.org/mailman/listinfo/python-list
Tix hlist and item_exists
I can't seem to get this function to work. If the item does not exist I get an exception, rather than a return value of false. Here's an example: #!/usr/bin/python from Tix import * root = Tk() listBox = HList(root) item = "some item" if not listBox.item_exists(item, 0): listBox.add(item, itemtype=TEXT, text=item) Any ideas? Peter -- http://mail.python.org/mailman/listinfo/python-list
Python with MSC.Mentat
Hi all, I'm running into a very strange problem at work. We're using an application called MSC.Mentat (modelling/meshing application) which provides a programmable interface through Python. Because we were told that the Python version they ship is missing some libraries we compiled it ourselves on both Solaris 9 and RedHat EL 3.0 When we use some of our inhouse scripts, which were written by a student who has left us a long time ago, the scripts work great on the Solaris version. (they were once written with Python 1.5 in mind so we get some string/strop errors but nothin terribly wrong) However, if we use the exact same method for our Linux version, Mentat (which calls the Python scripts) core dumps with the following messages: Traceback (most recent call last): File "main_process.py", line 6, in ? from read_data_file import retrieve_param File "read_data_file.py", line 3, in ? from pickle import * File "pickle.py", line 33, in ? import struct ImportError: /cadappl/python/2.2.4-64/lib/python2.2/lib-dynload/struct.so: undefined symbol: PyInt_FromLong Exception py_mentat.error: 'Error in module main\n' in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection When I do an 'nm' on the struct.so file I can see that PyInt_FromLong is undefined (along with a whole batch of others) but this is the same on the Solaris version so that can't be it. Do you have any idea what could cause this? Kind regards, Jeroen Kleijer -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding startup files
Grant Edwards <[EMAIL PROTECTED]> writes: > On 2005-05-11, jeff elkins <[EMAIL PROTECTED]> wrote: > >> I'm totally new to Python (obvious,yes?) so how might argv[0] fail? > > argv[0] contains whatever is put there by the program that > exec'ed you, and can therefore contain just about anything (or > nothing). It may not contain a full path, and your program's > install directory may not be in your $PATH (it be executed by a > shortcut or symlink). That's true for the C-level, i.e. main's argv. If you're only concerned about CPython and the program is a script living in a file, then sys.argv[0] is the filename the python interpreter itself used to read the script. Hence it's a valid filename that refers to the script. It may be a relative filename, of course, in which case it won't be correct anymore if the program changes its working directory. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ -- http://mail.python.org/mailman/listinfo/python-list
Can get reference of a part of a list?
I want make a 2-D array from a list,all elements is references of list's,like this: a = [1,2,3,4] b = [ [1,2], [3,4] ] when change any elements of a, the elements of b will change too, so I can use some function for list to change b. c/c++ can work in this way,I think let b[0] = a[0:2], b[1] = a[2:3],but it's not reference,it's copy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Graphing Utilities.
> A pslatex backend certainly would be interesting. A Gnuplot backend > would probably not be feasible. Does it expose its raw drawing operations? There is a patch [ 1027032 ] Connect gnuplot_x11 to exterior application window http://sourceforge.net/tracker/index.php?func=detail&aid=1027032&group_id=2055&atid=302055 which allows to "Connect gnuplot_x11 to exterior application window...". If you test it, please write a note there and the patch can go to cvs. --- PM -- http://mail.python.org/mailman/listinfo/python-list
Re: Can get reference of a part of a list?
"flyaflya" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want make a 2-D array from a list,all elements is references of > list's,like this: > a = [1,2,3,4] > b = [ [1,2], [3,4] ] > when change any elements of a, the elements of b will change too, so I > can use some function for list to change b. > c/c++ can work in this way,I think let b[0] = a[0:2], b[1] = a[2:3],but >it's not reference,it's copy. Look into Numerical Python or Numarray, where slices are views instead of copies. TJR -- http://mail.python.org/mailman/listinfo/python-list
Re: Can get reference of a part of a list?
Le Fri, 13 May 2005 00:58:49 +0800, flyaflya a écrit : > I want make a 2-D array from a list,all elements is references of > list's,like this: > a = [1,2,3,4] > b = [ [1,2], [3,4] ] > when change any elements of a, the elements of b will change too, so I > can use some function for list to change b. > c/c++ can work in this way,I think let b[0] = a[0:2], b[1] = a[2:3],but > it's not reference,it's copy. If the original list contains only numeric values of the same type, i.e only integers or only floats, the Numeric array reshape() function is what you need : import Numeric as N aa = N.array([1, 2, 3, 4]) bb = N.reshape(aa, (2, 2)) print bb array([[1, 2], [3, 4]]) bb[0][:] = (7, 8) aa array([7, 8, 3, 4]) That is there is only one homogeneous list of values, no copy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed of the different python-based HTTP-servers
Thomas W wrote: > I don't expect this project to have alot of traffic once online, but it > would kinda suck if my software couldn't handle it if it really took > off. What would be "a lot" > So my question is; based on the very brief description above, are there > any of the python-based frameworks that fits my project better than the > others? And are there some of the frameworks that doesn't scale > particulary well? Benchmarks anyone? With the note that benchmarks are dangerous, here are some numbers: http://snakelets.sourceforge.net/benchmark.html I'd say just install it on your own system and run your own tests. > I want to use ZPT or simpleTAL for templating and SQLObject for > database-access etc if that makes any differences. Snakelets has Ypages for templating, but it is not really difficult to use your own template library (someone is successfully using PyMeld, for instance). It is database agnostic, meaning that no database code whatsoever is in the package. This means that you are 100% free to choose your own db persistence system. --Irmen. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
"Skip Montanaro" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Maybe the Module Index should be renamed "Module/Type Index" and > embellished > with the builtin types, so that you'd find "float (builtin)", "string > (builtin)", "dict (builtin)", etc. in the appropriate alphabetical > positions. +1 TJR -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Polymorphism
Carlos Moreira wrote: > How could I use Python polymorphism? > Which kind of structures Python give me to use > polymorphism? > Where can I find specific documentation? www.python.org (have you read the tutorial?) -- http://mail.python.org/mailman/listinfo/python-list
Re: How "return" no return ?
"Ximo" wrote: > I am doing a interpret of lines and it show me a prompt, and I want if I > write a declaration as "int a" my progrtam return de prompt and nothing > more, for exemple: > > >>> 2+2 > 4 > >>> int a > >>> > > Then I'm finding that de function which execute "int a" return me nothing, > and no > > >>> int a > None > >>> what Python version are you using? here's what a normal Python interpreter is supposed to do with your example: >>> 2+2 4 >>> int a File "", line 1 int a ^ SyntaxError: invalid syntax >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Polymorphism
--- Fredrik Lundh <[EMAIL PROTECTED]> wrote: > www.python.org :-/ > > (have you read the tutorial?) Are you talking about: http://docs.python.org/tut/tut.html I fear that doesn't exist one word about polymorphism (in an explicit way). Anyway, I use Python since 2000 year and already use OO Python features since the begin. But now, I need more technical informations. Thanks and best regards Cadu Moreira Yahoo! Mail Stay connected, organized, and protected. Take the tour: http://tour.mail.yahoo.com/mailtour.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
On 5/12/05, Terry Reedy <[EMAIL PROTECTED]> wrote: > > "Skip Montanaro" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Maybe the Module Index should be renamed "Module/Type Index" and > > embellished > > with the builtin types, so that you'd find "float (builtin)", "string > > (builtin)", "dict (builtin)", etc. in the appropriate alphabetical > > positions. > > +1 > > TJR > +1 Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem combining python code and html
"Hansan" wrote: > The change did remove the error message, and I can see what was wrong. > However there is now a new problem, the only thing that is displayed is one > single character and that is: < > > Do you or anyone else have a suggestion to what the cause to this new > problem is ? my fault; I somehow expected you to figure out that you had to fix up the rest of the function as well, and forgot that you were just cutting and pasting from a rather lousy example, without understand all the de- tails. here's the rest of the relevant code: if SubResult[1] == 0: raise BadTemplateException print "Content-Type: text/html\n\n" print SubResult[0] in the original code, re.subn returns a 2-tuple containing the new string and a count, but replace only returns the string. the easiest way to fix this is to get rid of the BadTemplate check; just replace the above code with: print "Content-Type: text/html\n\n" print SubResult if you really want the BadTemplateException, you can do: if SubResult == TemplateInput: raise BadTemplateException print "Content-Type: text/html\n\n" print SubResult hope this helps! (I was about to add a short comment on how this illustrates why examples are not a universal solution to all documentation problems, unless they're carefully written and carefully documented. but such talk will only offend the PHP crowd, so I better skip that) -- http://mail.python.org/mailman/listinfo/python-list