Re: best GUI library for vector drawing program
pierbre.it [EMAIL PROTECTED] wrote: I used wxWidgets for a work like that. I found it quite easy to use and I found simple to create a Gui with wxdev which is quite rad. bye Pier Paolo There is also pycad, but apart from knowing that it exists, I know nothing about it. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Overriding Thread.join in derived class.
If one creates a thread using threading.Thread and makes it a daemon by calling setDaemon(), then when Python is exiting it will not attempt to call join() on that thread and wait for it to complete first. The problem with this is that the daemonised thread will continue to run while atexit register callbacks are being called and while Python is being subsequently destroyed The result is that the daemonised thread may access application components that have been cleaned up and in the worst case as Python progresses with destroying interpreters it could try accessing things like sys.modules which may no longer exist. End result is that it could result in a Python exception at some point, evidenced by messages starting with: Exception in thread Thread-1 (most likely raised during interpreter shutdown) or: Unhandled exception in thread started by bound method Thread.__bootstrap of Thread(Thread-1, started daemon) In order to avoid this, do people think that as an alternative to creating daemonised thread that it would be reasonable to create a derived Thread class for the particular task which overrides Thread.join() method to set some flag or otherwise take some action that the thread would notice to tell it to stop, and then call base class Thread.join(). This way you can flag the thread to shutdown automatically when Python is going around calling join() on non daemonised threads. Or am I missing the obvious as far as ways of flagging threads to tell them to stop? Note that this is where Python is being used embedded in a C program. There is no Python main function where code can be put to signal threads to otherwise stop. Graham -- http://mail.python.org/mailman/listinfo/python-list
Canceling events on COM objects
I have MapPoint working in Python, and I'm trying to cancel events on the map, but I can't seem to make that happen. I'm responding to the events successfully in my panel object. My code is like this: global MapPointMod MapPointMod = win32com.client.gencache.EnsureModule({51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}, 0, 1, 0) class MyPanel(wx.Panel): def __init__(self, *args, **kwds): # begin wxGlade: MyPanel.__init__ kwds[style] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.frame = args[0] MyMap = MakeActiveXClass(MapPointMod.MappointControl, eventObj=self) self.window_1 = MyMap(self, -1) self.window_1.OpenMap(C:\\TEMP\\GPS_ON.ptt) ... ... def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print tada My event fires just fine, but I can't seem to figure out how to cancel the event so that mappoint doesn't do its stuff with it...I've tried setting Cancel based on the mappoint specs, but it doesn't seem to get sent back anywhere... Any ideas please? Thanx, OLIVER -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption and hashing
These are the algorithms supported in the last version of PyCrypto: $ ls pycrypto-2.0.1/src/ AES.c Blowfish.c DES.cIDEA.c RIPEMD.c winrand.c ARC2.ccast5.c _dsa.c MD2.c _rsa.c XOR.c ARC4.cCAST.c _fastmath.c MD4.c SHA256.c block_template.c DES3.c hash_template.c RC5.c stream_template.c So it haven't Twofish, Serpent, neither Whirlpool. Neither many others. OK sorry, I was wrong. Isn't blowfish a better version of twofish anyway? -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption and hashing
Laszlo Nagy [EMAIL PROTECTED] writes: OK sorry, I was wrong. Isn't blowfish a better version of twofish anyway? No. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption and hashing
On 18 ago, 00:20, Paul Rubin http://[EMAIL PROTECTED] wrote: Kless [EMAIL PROTECTED] writes: So it haven't Twofish, Serpent, neither Whirlpool. Neither many others. Unless you have an interoperability requirement or some other specific issue, you should stick with AES and the SHA2 family. Don't make your own cipher selections unless you know completely what you're doing. This is especially the case for business applications in the US, since AES and SHA are US federal standards and if you use them and something goes wrong with them, you can at least say you followed the standard. If you use anything else, you will have more to answer for. Well, I only know that I choose the best public cryptographic algorithms. SHA-2 has been designed by the National Security Agency (NSA), and I'm sure that many people trust on the NSA so that every people make its election. But I'm sure that many people will avoid use algorithms recommend by the governement. And I don't know why :P, they always say the truth and we must trust on them. I'm sure that having great experts on cryptography they are not bee able of put a backdoor indetectable or better to debilitate the algorithm so that it is easier to break it. -- http://mail.python.org/mailman/listinfo/python-list
Guitars, amps, tabs and more!!
Reviews of latest models of best guitars, fender, gibson, yamaha, and many more, with pictures and prices. http://pro-guitars.blogspot.com/ And if you want to win a free guitar go here http://freeguitars.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the result of a process after exec*()
On 17 Sie, 16:33, AndrewTK [EMAIL PROTECTED] wrote: Hi, I am trying to write a Python script that takes a ZIP file from a web form (using CGI) and uses either of the UN*X unzip, gunzip, tar, bunzip2 utilities to expand it. I can use Python to save the script to disk; but processing it is another matter. If for example I have received a *.tar.gz file, I need to first pass it through gunzip; then through the tar utility. I also want to process the resulting directory. The problem for me is this: once an external process is called via exec*() the script has effectively fulfilled its task. Is there any way one can process a file with an external process and continue further processing in Python; /once the external processing is completed/? Many thanks, Andrew Hi Andrew, Have You got some kind of requirement for using exec*() and calling system gunzip etc? I'd do It with urllib2 module (to download the file) and tarfile module for extracting the *.tag.gz archive. Cheers, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: How to say $a=$b-{A} ||={} in Python?
beginner [EMAIL PROTECTED] wrote: On Aug 16, 5:43 pm, [EMAIL PROTECTED] (Lawrence Oluyede) wrote: beginner [EMAIL PROTECTED] wrote: I'd like to do the following in more succint code: if k in b: a=b[k] else: a={} b[k]=a b.setdefault(k, a) I am afraid it is not the same. b.setdefault(k, {}) will always create an empty dict, even if k is in b That is certainly true, but does it matter? You waste a very small amount of time creating a dict you don't use. $ python -m timeit '{}' 100 loops, best of 3: 0.247 usec per loop On my machine 250 ns gets you a new dict... -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Naming dictionaries recursively
That sounds like a solution. I think the core of the question is as follows; if I was to call the dict() function for each line, thus creating a dictionary, and then rename it to dict['name'], will there be a namespace collision on the next loop when dict() is called again? Obviously the first dictionary will still be there, as it still has a refcount of 1; but if it gets overwritten, will the object that the new name refers to be overwritten too? -- http://mail.python.org/mailman/listinfo/python-list
passing arguments with ampersands
hey, i have a win32 gui application that accepts filenames as arguments (either via command line or via associating an extension to the application) which are then opened in it. the problem is that as soon as the filename contains characters like '', the process fails at the very beginning (sys.argv). for example when the full path of the file im trying to open like this is Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt when i put 'print sys.argv[1:]' at the very beginning of the script, all i get is this: Quote:['D:\\ftp\\Music\\Mixes'] i already have a piece of code that puts together paths with spaces sent via arguments, but this '' drives me crazy. other than that, after i close the application (which actually starts without any errors), the commands line gets filled with a message like this: Quote:The system cannot find the path specified. 'Beyond' is not recognized as an internal or external command, operable program or batch file. any idea how to solve this? [image: Sad] thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: unexpected optparse set_default/set_defaults behavior
[EMAIL PROTECTED] wrote: Some rather unexpected behavior in the set_default/set_defaults methods for OptionParser that I noticed recently: [...] Why does set_default not raise an exception when passed a key that it doesn't recognize? Bad typysts bewaer. The only reason I can think not to raise an exception is so that defaults can be defined before the options are added. Is there some use case that I'm not thinking of here? I realize that changing this could break some existing scripts, but I'm still tempted to file this as a bug. If you file it as a bug then I can assure you that you'll be told of a long list of use-cases that depend on that feature. -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments with ampersands
Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt when i put 'print sys.argv[1:]' at the very beginning of the script, all i get is this: Quote:['D:\\ftp\\Music\\Mixes'] Can you share the portion of the code? Are you quoting the argument that you are passing? for e.g: #cat 1.py import sys print sys.argv[1] #python 1.py I am able to print the spaces and characters I am able to print the spaces and characters -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-list
swapping
hi everbody, i have a file with data: fhl1fkh2 dfp1chk1 mal3alp14 mal3moe1 mal3spi1 mal3bub1 mal3bub3 mal3mph1 mal3mad3 hob1nak1 i have written code to check the redudant pairs my code: data = [] data1 = [] fh = open('sheet1','r') for line in fh: if line not in data: data.append(line) else: print line fh.close() fh1 = open('sheet2','r') for line1 in fh1: if line1 not in data1: data1.append(line1) else: print line1 fh1.close() result: klp5bub1 apn1apn2 but i have do the same for the revere ,to check the result like this for eg: apn2apn1 what is the concept to do this regards shafreen -- http://mail.python.org/mailman/listinfo/python-list
Re: How to say $a=$b-{A} ||={} in Python?
Paul McGuire [EMAIL PROTECTED] wrote: Carl Banks' post using defaultdict is the correct solution. The raison d'etre for defaultdict, and the reason that it is the solution to the OP's question, is that instead of creating a just-in-case default value every time, the defaultdict itself is constructed with a factory method of some kind (in practice, it appears that this factory method is usually the list or dict class constructor). If a reference to the defaultdict gives a not-yet-existing key, then the factory method is called to construct the new value, that value is stored in the dict with the given key, and the value is passed back to the caller. No instances are created unless they are truly required for initializing an entry for a never-before-seen key. I think that if you truly want to emulate a perl hash then you would want this which does the above but recursively. from collections import defaultdict class hash(defaultdict): def __init__(self): defaultdict.__init__(self, hash) D=hash() D[1][2][3][4]=5 D[1][4][5]=6 print D -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Tkinter Programming--Expensive!
W. Watson [EMAIL PROTECTED] wrote: Why is the book in Subject (author is Grayson) so expensive? $100 on Amazon and $195 on ABE. Aren't there alternatives? There is an excellent section (266 pages) on TKinter in Programming Python by Mark Lutz. I've got the 2nd edition. Lutz concentrates on TK programming using classes, making re-usable components which I found really helpful compared to the ad-hoc way I'd seen TK presented previously. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Naming dictionaries recursively
On Aug 18, 11:44 am, TYR [EMAIL PROTECTED] wrote: That sounds like a solution. I think the core of the question is as follows; if I was to call the dict() function for each line, thus creating a dictionary, and then rename it to dict['name'], will there be a namespace collision on the next loop when dict() is called again? Obviously the first dictionary will still be there, as it still has a refcount of 1; but if it gets overwritten, will the object that the new name refers to be overwritten too? if data2name might give colliding names then you could use tuples as dictionary keys as shown below: import modulename datadict = dict( ((data2name(d), count), d) for count,d in enumerate(modulename.data) ) Generally, if you try and create two keys with the same name in a dictionary, they will clash and only the second value is retained. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments with ampersands
O.R.Senthil Kumaran wrote: Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt when i put 'print sys.argv[1:]' at the very beginning of the script, all i get is this: Quote:['D:\\ftp\\Music\\Mixes'] Can you share the portion of the code? Are you quoting the argument that you are passing? for e.g: #cat 1.py import sys print sys.argv[1] #python 1.py I am able to print the spaces and characters I am able to print the spaces and characters I suspect that the ampersand is being interpreted as a command terminator, and that the shell syntax error has been overlooked. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments with ampersands
theres no special portion of code, just the one that handles filenames with spaces. the problem is that when i associate a file extension to my application and i open it, the filename is not quoted before passed as an arguement. i dont know if its the problem of windows or something, or it was just my fault when i incorrectly associated the extension. anyway, this is the code that outputs the second quote i posted in the original message: args = None if len(sys.argv) 1: args = sys.argv[1:] print args and this is the code that handles the filenames with spaces (as space generally delimits cmdline params). its not very ellegant, needs a bit of tuning, but it works (i dont use any kind of -d --something params yet). [code] newargs = [] if args: first = None for arg in args: if not first: first = arg continue if os.path.isfile(first): newargs.append(first) first = None continue if arg.find(:) == -1: first = .join([first, arg]) if first: newargs.append(first) [/code] how can i make the params get quoted before send as arguments? thanks in advance. 2007/8/18, O.R.Senthil Kumaran [EMAIL PROTECTED]: Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt when i put 'print sys.argv[1:]' at the very beginning of the script, all i get is this: Quote:['D:\\ftp\\Music\\Mixes'] Can you share the portion of the code? Are you quoting the argument that you are passing? for e.g: #cat 1.py import sys print sys.argv[1] #python 1.py I am able to print the spaces and characters I am able to print the spaces and characters -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-list
Python hash
On Aug 18, 12:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote: I think that if you truly want to emulate a perl hash then you would want this which does the above but recursively. from collections import defaultdict class hash(defaultdict): def __init__(self): defaultdict.__init__(self, hash) D=hash() D[1][2][3][4]=5 D[1][4][5]=6 print D -- Nick Craig-Wood [EMAIL PROTECTED] --http://www.craig-wood.com/nick Nick, I thought I'd save your hash implementation away in my bag of tricks: # File: autovivifying_dict.py from collections import defaultdict class hash(defaultdict): Used like a dict except sub-dicts automagically created as needed Based on: http://groups.google.com/group/comp.lang.python/msg/f334fbdafe4afa37 D=hash() D[1][2][3][4]=5 D[1][4][5]=6 D hash({1: hash({2: hash({3: hash({4: 5})}), 4: hash({5: 6})})}) hash({1: hash({2: hash({3: hash({4: 5})}), 4: hash({7: 8})})}) hash({1: hash({2: hash({3: hash({4: 5})}), 4: hash({7: 8})})}) def __init__(self, *a, **b): defaultdict.__init__(self, hash, *a, **b) def __repr__(self): return hash(%s) % (repr(dict(self)),) def _test(): import doctest doctest.testmod() if __name__ == __main__: _test() - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
wxPython with directpython
Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: python video editing libs
On 18 kol, 05:01, math2life [EMAIL PROTECTED] wrote: On Aug 17, 5:55 pm, DavidM [EMAIL PROTECTED] wrote: Hi, Does anyone know of any python or python-wrapped libs for video editing? My requirements: - open video files in any of the popular containers (avi, mov, ogg, flv etc) and all the popular codecs (mpeg3, theora, mpeg2 etc) and audio codecs (raw, wav, mp3 etc) - get an abstract video clip object on opening such a file - query the clip object to determine stuff like length, framerate, size etc - iterate through all the frames, and get a frame object with each frame - with a frame object, be able to access individual pixels, add graphic images (eg, via PIL), export frame to graphics file (eg jpeg) - with video clip object, be able to change framerate, insert/remove frames etc, and render out with desired a-v codecs and container - good well-documented API, preferably some usage examples Does anything like this exist? Cheers David Python OpenCV wrapper will meet most of your need, but I am not sure , plz check it out. Hi, I'am not sure, try pymedia Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython with directpython
On Aug 18, 8:08 am, [EMAIL PROTECTED] wrote: Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran You need to post some more code, preferably the function that calls the directx stuff. And how do you catch the close event? It sounds like you've got multiple objects bound to it which causes the entire program to close. You might consider running the directx stuff in a separate thread. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Canceling events on COM Objects in python
On Aug 17, 11:54 pm, Oliver Nelson [EMAIL PROTECTED] wrote: I have MapPoint working in Python, and I'm trying to cancel events on the map, but I can't seem to make that happen. I'm responding to the events successfully in my panel object. My code is like this: global MapPointMod MapPointMod = win32com.client.gencache.EnsureModule({51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}, 0, 1, 0) class MyPanel(wx.Panel): def __init__(self, *args, **kwds): # begin wxGlade: MyPanel.__init__ kwds[style] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.frame = args[0] MyMap = MakeActiveXClass(MapPointMod.MappointControl, eventObj=self) self.window_1 = MyMap(self, -1) self.window_1.OpenMap(C:\\TEMP\\GPS_ON.ptt) ... ... def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print tada My event fires just fine, but I can't seem to figure out how to cancel the event so that mappoint doesn't do its stuff with it...I've tried setting Cancel based on the mappoint specs, but it doesn't seem to get sent back anywhere... Any ideas please? Thanx, OLIVER This probably isn't the best place to post questions of this nature. You should try the wxPython's user group or the pywin32 group. http://wxpython.org/maillist.php http://mail.python.org/mailman/listinfo/python-win32 Is the event you're trying to cancel caught by wxPython's event handlers or win32? Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: What does this thread have to do with classical music,
ah [EMAIL PROTECTED] wrote: Art Deco wrote: ah [EMAIL PROTECTED] wrote: Art Deco wrote: ah [EMAIL PROTECTED] wrote: Art Deco wrote: ah [EMAIL PROTECTED] wrote: Art Deco wrote: ah [EMAIL PROTECTED] wrote: Art Deco wrote: Who wrote? What does that have to do with classical music, snuhwolf? What does that have to do with classical music, snuhwolf? How many more times will you be asking the same tired, lame questions, Tholen? Till 2056? At that point, he will have made the Thirty Years Pset War look like 1967 in the Sinai. It must have been Hell to keep a garden during those times. Did they all eat jerky, or what? Worse -- worm-laden hardtack. Luxury! Why, I remember when I was a lad . . . we used to watch the local churls across the fences eating that well. We only had millings (and (occasionally) water) on Tuesdays and Fridays. Grog and hardtack, life is good! ¡Viva la basura! Vivat les ordures! Vivara los trunctiato! das Leben ist gut! -- Official Overseer of Kooks and Saucerheads for alt.astronomy Trainer and leash holder of: Honest Clockbrain John nightbat fro0tbat of alt.astronomy Tom TommY Crackpotter Potter http://www.caballista.org/auk/kookle.php?search=deco You really are one of the litsiest people I know, Mr. Deco. --Kali, quoted endlessly by David Tholen as evidence of something I am claiming that you believe ah's family name is ah, Deco, and I substantiated that claim. --David Tholen Quite a kook-out, Deco. You've been frothing even more ever since I demonstrated how you believe that ah's family name is ah. --David Tholen -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython with directpython
On 18 kol, 15:35, [EMAIL PROTECTED] wrote: On Aug 18, 8:08 am, [EMAIL PROTECTED] wrote: Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran You need to post some more code, preferably the function that calls the directx stuff. And how do you catch the close event? It sounds like you've got multiple objects bound to it which causes the entire program to close. You might consider running the directx stuff in a separate thread. Mike Hi, no,that's all code I've got,I mean it's all code that I run with my program for now. You might consider running the directx stuff in a separate thread. How? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: clarification
samwyse wrote: Scott David Daniels wrote: lefts = set() rights = set() with open('sheet1', 'r') as fh: for line in fh: trimmed = line.strip() if trimmed: # Skip blanks (file end often looks like that) left, right = line.strip().split('\t') lefts.add(left) rights.add(right) result = lefts rights -Scott # change to however many columns may later exist cols = [ set() for i in range(0, 2) ] with open('sheet1', 'r') as fh: for line in fh: for col, data in zip(cols, line.strip().split('\t')): col.add(data) result = cols[0] cols[1] My laptop started complaining about low power before I was really finished with this last night, so I just hit Send and went to bed. The last line really should be: result = reduce(operator.and_, cols) I'll note that using 'zip' transparently deals with handling those cases where there are either more or fewer columns of data than expected. Finally, does anyone familar with P3K know how best to do the reduction without using 'reduce'? Right now, sets don't support the 'add' and 'multiply' operators, so 'sum' and (the currently ficticious) 'product' won't work at all; while 'any' and 'all' don't work as one might hope. Are there an 'intersection' and 'union' built-ins anywhere? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Tkinter Programming--Expensive!
Thanks. I'm borrowing it from a library and see the URL on the back of the book. www.manning.com/grayson James Stroud wrote: W. Watson wrote: Why is the book in Subject (author is Grayson) so expensive? $100 on Amazon and $195 on ABE. Aren't there alternatives? Read the fine print. Its available as an ebook for about $25.00 at Manning. You can print out just the parts you need--or read it from your iphone. James -- Wayne Watson (Nevada City, CA) Web Page: speckledwithStars.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Tkinter Programming--Expensive!
Thanks. I'll test the waters on Amazon. Nick Craig-Wood wrote: W. Watson [EMAIL PROTECTED] wrote: Why is the book in Subject (author is Grayson) so expensive? $100 on Amazon and $195 on ABE. Aren't there alternatives? There is an excellent section (266 pages) on TKinter in Programming Python by Mark Lutz. I've got the 2nd edition. Lutz concentrates on TK programming using classes, making re-usable components which I found really helpful compared to the ad-hoc way I'd seen TK presented previously. -- Wayne Watson (Nevada City, CA) Web Page: speckledwithStars.net -- http://mail.python.org/mailman/listinfo/python-list
Re: clarification
On 17/08/07, Beema shafreen [EMAIL PROTECTED] wrote: hi everybody, i have a file with data separated by tab mydata: fhl1fkh2 dfp1chk1 mal3alp14 mal3moe1 mal3spi1 mal3bub1 mal3bub3 mal3mph1 mal3mad3 hob1nak1 hob1wsp1 hob1rad3 cdr2cdc13 cdr2cdc2 shows these two are separated by tab represented as columns i have to check the common data between these two coloumn1 an coloumn2 my code: data = [] data1 = [] result = [] fh = open('sheet1','r') for line in fh.readlines(): splitted = line.strip().split('\t') data.append(splitted[0]) data1.append(splitted[1]) for k in data: if k in data1: result.append(k) print result fh.close() can you tell me problem with my script and what should is do for this For a start, you are iterating k in data *everytime* you iterate a line in fh which will give you a speed issue and give you duplicates in the result. The following is probably what you intended to do for line in fh.readlines(): do stuff for k in data: do stuff .split() splits by spaces, newlines AND tabs so you just need splitted = line.split() eg ln = 'fhl1\tfkh2\r\n' ln.split() ['fhl1', 'fkh2'] I think I would have done something like this (not tested) Input = open('sheet1').read().split() data = set(Input[::2]) data1 = set (Input[1::2]) result = data.intersection(data1) or even this (if you don't need data and data1 later in the code) Input = open('sheet1').read().split() result = set(Input[::2]).intersection(set (Input[1::2])) HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: clarification
samwyse [EMAIL PROTECTED] wrote: ... Finally, does anyone familar with P3K know how best to do the reduction without using 'reduce'? Right now, sets don't support the 'add' and 'multiply' operators, so 'sum' and (the currently ficticious) 'product' won't work at all; while 'any' and 'all' don't work as one might hope. Are there an 'intersection' and 'union' built-ins anywhere? For intersection and union of a sequence of sets, I'd use: def union_all(sos): result = set() for s in sos: result.update(s) return result def intersect_all(sos): it = iter(sos) result = set(it.next()) for s in it: result.intersection_update(s) return result The latter will raise an exception if sos is empty -- I don't think the intersection of no sets at all has a single natural interpretation (while the union of no sets at all appears to be naturally interpreted as an empty set)... if you disagree, just wrap a try/except around the initialization of result, and return whatever in the except clause. Of course, hoisting the unbound method out of the loops can afford the usual small optimization. But my point is that, in Python, these operations (like, say, the concatenation of a sequence of lists, etc) are best performed in place via loops calling mutator methods such as update and intersection_update (or a list's extend, etc), rather than functionally (building and tossing away many intermediate results). E.g., consider: brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in range(0, 100, 3)]' 'r=set()' 'for x in sos: r.update(x)' 10 loops, best of 3: 18.8 usec per loop brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in range(0, 100, 3)]' 'r=reduce(set.union, sos, set())' 1 loops, best of 3: 87.2 usec per loop Even in a case as tiny as this one, reduce is taking over 4 times longer than the loop with the in-place mutator -- and it only gets worse, as we're talking about O(N squared) vs O(N) performance! Indeed, this is part of what makes reduce an attractive nuisance...;-). [[And so is sum, if used OTHERWISE than for the documented purpose, computing the sum of a sequence of numbers: a loop with r.extend is similarly faster, to concatenate a sequence of lists, when compared to sum(sol, [])...!!!]] Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Memory leak when creating lots of object
On 17 Aug, 04:51, Godzilla [EMAIL PROTECTED] wrote: On Aug 16, 1:13 am, Paul Moore[EMAIL PROTECTED] wrote: On 14 Aug, 05:57, Godzilla [EMAIL PROTECTED] wrote: Do you see memory growth with precisely this code? Over what period? How much? I have it running for more than 1 hour... the main application software runs for about 50 days non stops and the memory just keep growing... I'm sorry. Just to be precise, how long would I need to run the code you posted to see a memory growth? What should I do next? Can I force garbage collection manually? If so, how do I do that? As Terry suggested, look at the gc module (gc.collect). But on inspection, I don't see a memory leak that would be cured by forcing a collection, which is why I'd like to reproduce the problem before offering suggestions... Paul. -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython with directpython
On Aug 18, 9:46 am, [EMAIL PROTECTED] wrote: On 18 kol, 15:35, [EMAIL PROTECTED] wrote: On Aug 18, 8:08 am, [EMAIL PROTECTED] wrote: Hello, I'am using DirectPython 0.8, wxPython 2.8.4.2 (ansi) for Python 2.5 and I'm running it on windows XP SP2. When I run my wx program, and this program run directpython code: (I run it under wx frame) example code: import d3dx fr=d3dx.Frame(unicode(My frame)) fr.mainloop() .this code run some d3dx frame, and when I close this d3dx frame it close my whole program ( and wx frame). Regards, Vedran You need to post some more code, preferably the function that calls the directx stuff. And how do you catch the close event? It sounds like you've got multiple objects bound to it which causes the entire program to close. You might consider running the directx stuff in a separate thread. Mike Hi, no,that's all code I've got,I mean it's all code that I run with my program for now. You might consider running the directx stuff in a separate thread. How? Regards, Vedran Check out this link for more information on running stuff in another thread: http://wiki.wxpython.org/LongRunningTasks?highlight=%28longrunning%29 Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Canceling events on COM Objects in python
Mike, Thank you for the suggestion. I will ask over there also. The event is sent back from the COM interface as the code illustrates. MakeActiveXClass allows me to pass the object that will receive events. I don't understand much more detail about how it works. It is certainly a different model than the standard wx event system... OLIVER [EMAIL PROTECTED] wrote: On Aug 17, 11:54 pm, Oliver Nelson [EMAIL PROTECTED] wrote: I have MapPoint working in Python, and I'm trying to cancel events on the map, but I can't seem to make that happen. I'm responding to the events successfully in my panel object. My code is like this: global MapPointMod MapPointMod = win32com.client.gencache.EnsureModule({51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}, 0, 1, 0) class MyPanel(wx.Panel): def __init__(self, *args, **kwds): # begin wxGlade: MyPanel.__init__ kwds[style] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.frame = args[0] MyMap = MakeActiveXClass(MapPointMod.MappointControl, eventObj=self) self.window_1 = MyMap(self, -1) self.window_1.OpenMap(C:\\TEMP\\GPS_ON.ptt) ... ... def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print tada My event fires just fine, but I can't seem to figure out how to cancel the event so that mappoint doesn't do its stuff with it...I've tried setting Cancel based on the mappoint specs, but it doesn't seem to get sent back anywhere... Any ideas please? Thanx, OLIVER This probably isn't the best place to post questions of this nature. You should try the wxPython's user group or the pywin32 group. http://wxpython.org/maillist.php http://mail.python.org/mailman/listinfo/python-win32 Is the event you're trying to cancel caught by wxPython's event handlers or win32? Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Cancelling events on a COM Object
Roger, I tried modifying my code so that I have def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print click Cancel = True return Cancel But this doesn't seem to have changed anything. Am I doing this wrong? OLIVER Roger Upole wrote: Oliver Nelson wrote: I have MapPoint working in Python, and I'm trying to cancel events on the map, but I can't seem to make that happen. I'm responding to the events successfully in my panel object. My code is like this: global MapPointMod MapPointMod = win32com.client.gencache.EnsureModule({51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}, 0, 1, 0) class MyPanel(wx.Panel): def __init__(self, *args, **kwds): # begin wxGlade: MyPanel.__init__ kwds[style] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.frame = args[0] MyMap = MakeActiveXClass(MapPointMod.MappointControl, eventObj=self) self.window_1 = MyMap(self, -1) self.window_1.OpenMap(C:\\TEMP\\GPS_ON.ptt) ... ... def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print tada My event fires just fine, but I can't seem to figure out how to cancel the event so that mappoint doesn't do its stuff with it...I've tried setting Cancel based on the mappoint specs, but it doesn't seem to get sent back anywhere... Any ideas please? Thanx, OLIVER Instead of assigning to the variable name, output parameters need to be returned from the method Roger -- http://mail.python.org/mailman/listinfo/python-list
sort dictionary by specific values
Hi, I need to perform some horrible functions in python I need to do, using sort in a similar way that Excel can. With a dictionary like: Code: ( text ) 1. d 2. {8: (99, 99), 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), (56, 78), (99, 78)], 5: (67, 77)} I want to sort the entire dictionary based on the last values in each line. First for [-1][0] and then[-1][0]. So sorted descending I would like the output to look like: Code: ( text ) 1. d 2. {8: (99, 99), 4: [(45, 78), (56, 78), (99, 78)], 9: [(55, 67), (77, 66), (67, 88)], 5: (67, 77)} Many thanks -- http://mail.python.org/mailman/listinfo/python-list
creating weblogo-like .png output
Hi, For the new program I am creating I want to display some data in a format similar to weblogo. http://www.lecb.ncifcrf.gov/%7Etoms/sequencelogo.htmlBasically I want to create .png output of a table I have that shows percentage of DNA. There is a python implementation for this, but I can only seem to install it under linux and I want to make this in xp so I can use the psyco module. Also the weblogo version contains a lot more complexity than I need. Any points to tutorials, or other advice would be helpful. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: sort dictionary by specific values
dorje tarap wrote: Hi, I need to perform some horrible functions in python I need to do, using sort in a similar way that Excel can. With a dictionary like: Code: ( text ) 1. d 2. {8: (99, 99), 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), (56, 78), (99, 78)], 5: (67, 77)} I want to sort the entire dictionary based on the last values in each line. First for [-1][0] and then[-1][0]. So sorted descending I would like the output to look like: Code: ( text ) 1. d 2. {8: (99, 99), 4: [(45, 78), (56, 78), (99, 78)], 9: [(55, 67), (77, 66), (67, 88)], 5: (67, 77)} Many thanks I can't make any sense of your requirements or your example, but perhaps I can help somewhat. You CANNOT sort a (standard Python) dictionary. You CAN find some alternative implements of dictionaries on the web that allow ordering, and you CAN extract the key,value pairs from a dictionary into a list, and sort that list (by any criteria you want). Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: sort dictionary by specific values
dorje tarap escribió: 2. {8: (99, 99), 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), (56, 78), (99, 78)], 5: (67, 77)} I want to sort the entire dictionary based on the last values in each line. First for [-1][0] and then[-1][0] Each line means each value in the dictionary? Did you mean ordering [-1][0] and then [-1][1]? Dictionaries cannot be ordered, but you can work with its items (as a list). Your data is not homogeneous (values in the dictionary are both tuples and list of tuples). If you can build it that way: d = {8: [(99, 99)], 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), (56, 78), (99, 78)], 5: [(67, 77)] It would be easy to sort: import operator cmplast = lambda x, y: cmp(x[-1], y[-1]) sorted(d.items(), key=operator.itemgetter(1), cmp=cmplast, reverse=True) or cmplast1 = lambda x, y: cmp(x[1][-1], y[1][-1]) sorted(d.items(), cmp=cmplast1, reverse=True) [(8, [(99, 99)]), (4, [(45, 78), (56, 78), (99, 78)]), (9, [(55, 67), (77, 66), (67, 88)]), (5, [(67, 77)])] -- http://mail.python.org/mailman/listinfo/python-list
[Announce] PyGooCanvas 0.9.0
I am pleased to announce version 0.9.0 of the Python bindings for Goocanvas. It is available at: https://developer.berlios.de/projects/pygoocanvas/ The bindings are updated with the new Goocanvas API PyGooCanvas 0.9.0 (Aug 18 2007) = o Wrap goo_canvas_item_get_bounds (Gian Mario) o fix compilation on Solaris, patch by JerryYu [EMAIL PROTECTED]. Fixes LP#130106 (Gian Mario) o Add goocanvas.ItemSimple.get_line_width (Gian Mario) o Docs updated fixes LP#124921 (Gian Mario) Blurb: == Goocanvas [1] is a canvas widget for GTK+, It is similar in many ways to FooCanvas, hence the name, but it uses cairo for rendering, it has an optional model/view split, and uses interfaces for items views (so you can easily turn any application object into a canvas item or view). PyGooCanvas is a wrapper which exposes the goocanvas API to the python world. It is fairly complete; most of the API are covered. The documentation is done, anyway bug reports on docs are really important to improve the documentation. Like the GTK+ library, PyGTK and GooCanvas itself PyGooCanvas is licensed under the GNU LGPL, so is suitable for use in both free software and proprietary applications. PyGooCanvas requires: = o Goocanvas = 0.9.0 o PyGObject = 2.10.1 (2.11.3 to build the docs) o PyGTK = 2.10.4 o PyCairo = 1.2.0 Bug reports should go to https://launchpad.net/pygoocanvas/ [1] http://sourceforge.net/projects/goocanvas cheers -- Gian Mario Tagliaretti -- http://mail.python.org/mailman/listinfo/python-list
Symbolic Link
I am trying to create a link to a file, which I can then use in an HTML page. The system is Linux on a hosted web service, running python 2.3. Other than that I have no knowledge of the system. The link is created OK, but when I try to use it as filename for the IMG TAG, it does not get displayed. The page source of the created page is pointing to the link as temp/test1.jpg Any ideas ? srcFile = temp/test2.jpg linkFile = temp/test1.jpg if os.path.islink(linkFile): print Link Exists, nl pass else: print Making Link, nl os.symlink(srcFile, linkFile) print 'BRimg src=%sthe image/IMGBRBR' % linkFile print 'img src=%sthe image/IMG' % srcFile -- http://mail.python.org/mailman/listinfo/python-list
Re: Drawing a graph
Ghirai wrote: Hello list, I need to draw a graph, 2 axes, 2D, nothing fancy. One of the axes is time, the other one is a series of integers. I don't care much about the output format. Are there any specialized libraries for this, or should i use PIL? Thanks. Hey dude, why don't you just bite the bullet and implement your own plotting classes using wxPython? For your need (nothing fancy, as you said), relying on your own work is better, and making Python/wxPython plots is not really difficult. I myself have implemented a complete stock graphing application in Python using wxPython, including candlesticks and the works. In the long run, you will be better of relying on your own effort/understanding, believe me. Good luck! Baalbek -- http://mail.python.org/mailman/listinfo/python-list
Parser Generator?
Hi all, I need to do syntax parsing of simple naturual languages, for example, weather of London or what is the time, simple things like these, with Unicode support in the syntax. In Java, there are JavaCC, Antlr, etc. I wonder what people use in Python? Antlr also has Python support but I'm not sure how good it is. Comments/hints are welcome. -- http://mail.python.org/mailman/listinfo/python-list
PEP 11 update - Call for port maintainers to step forward
I made a quick update to PEP 11, Removing support for little used platforms. I added details about ending support for AtheOS/Syllable and BeOS. I also added a yet-to-be-fleshed out section entitled Platform Maintainers. I intend that to the extent possible we document the responsible parties for various platforms. Obviously, common platforms like Windows, Mac OS X, Linux and common Unix platforms (Solaris, *BSD, what else?) will continue to be supported by the core Python developer community, but lesser platforms should have one or more champions, and we should be able to get ahold of them to determine their continued interest in supporting Python on their platform(s). If you are the owner of a minor platform, please drop me a note. Ones I'm aware of that probably need specialized support outside the core Python developers include: IRIX Tru64 (aka OSF/1 and other names (what else?)) OS2/EMX (Andrew MacIntyre?) Cygwin MinGW HP-UX AIX Solaris version 8 SCO Unixware IRIX and Tru64 are likely to go the way of the dodo if someone doesn't step up soon to offer support. I don't expect the others to disappear soon, but they tend to need more specialized support, especially in more challenging areas (shared library support, threading, etc). If you maintain the platform-specific aspects for any of these platforms, please let me know. If you aren't that person but know who is, please pass this note along to them. If I've missed any other platforms (I know I must have have missed something), let me know that as well. Thanks, -- Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Parser Generator?
Jack schrieb: Hi all, I need to do syntax parsing of simple naturual languages, for example, weather of London or what is the time, simple things like these, with Unicode support in the syntax. In Java, there are JavaCC, Antlr, etc. I wonder what people use in Python? Antlr also has Python support but I'm not sure how good it is. Comments/hints are welcome. There are several options. I personally like spark.py, the most common answer is pyparsing, and don't forget to check out NLTK, the natural language toolkit. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: python video editing libs
On Sat, 18 Aug 2007 12:55:47 +1200, DavidM wrote: Does anything like this exist? GStreamer/GNonLin might possibly support what you are looking for, though I have not tested this. http://docs.programmers.ch/index.php/Using_Gnonlin_with_GStreamer_and_Python -Samuel -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
mosscliffe schrieb: I am trying to create a link to a file, which I can then use in an HTML page. The system is Linux on a hosted web service, running python 2.3. Other than that I have no knowledge of the system. The link is created OK, but when I try to use it as filename for the IMG TAG, it does not get displayed. The page source of the created page is pointing to the link as temp/test1.jpg Any ideas ? srcFile = temp/test2.jpg linkFile = temp/test1.jpg if os.path.islink(linkFile): print Link Exists, nl pass else: print Making Link, nl os.symlink(srcFile, linkFile) print 'BRimg src=%sthe image/IMGBRBR' % linkFile print 'img src=%sthe image/IMG' % srcFile In what environment is that script running? If it's apache, it might be that the apache settings disallow for following links. Diez -- http://mail.python.org/mailman/listinfo/python-list
How to call module functions inside class instance functions?
Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error Thanks, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
How to make a module function visible only inside the module?
Hi Everyone, Is there any equivalent version of C's static function in Python. I know I can make a class function private by starting a function name with two underscores, but it does not work with module functions. For exmaple, __func1 is still visible outside the module. mymodule.py my module def __func1(): print Hello main.py import mymodule mymodule.__func1() Thanks, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Parser Generator?
On Aug 18, 5:22 pm, Jack [EMAIL PROTECTED] wrote: Hi all, I need to do syntax parsing of simple naturual languages, for example, weather of London or what is the time, simple things like these, with Unicode support in the syntax. In Java, there are JavaCC, Antlr, etc. I wonder what people use in Python? Antlr also has Python support but I'm not sure how good it is. Comments/hints are welcome. Antlr seems to be able to generate python code, too. -- http://mail.python.org/mailman/listinfo/python-list
constructor or initialization function for module
Hi Everyone, An extended module (.pyd) written in C have an init function that is called when the module is imported. Does anyone know if there is a way to provide an init function for a module written in python? Thanks, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Fatest standard way to sum bytes (and their squares)?
On Sun, 12 Aug 2007 02:26:59 -0700, Erik Max Francis wrote: For a file hashing system (finding similar files, rather than identical ones), I need to be able to efficiently and quickly sum the ordinals of the bytes of a file and their squares. Because of the nature of the application, it's a requirement that I do it in Python, or only with standard library modules (if such facilities exist) that might assist. So far the fastest way I've found is using the `sum` builtin and generators:: ordinalSum = sum(ord(x) for x in data) ordinalSumSquared = sum(ord(x)**2 for x in data) This is about twice as fast as an explicit loop, but since it's going to be processing massive amounts of data, the faster the better. Are there any tricks I'm not thinking of, or perhaps helper functions in other modules that I'm not thinking of? I see a lot of messages attacking the CPU optimization, but what about the I/O optimization - which admittedly, the question seems to sidestep. You might experiment with using mmap() instead of read()... If it helps, it may help big, because the I/O time is likely to dominate the CPU time. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
On Aug 18, 5:40 pm, beginner [EMAIL PROTECTED] wrote: Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error Thanks, Geoffrey You might want to check one of the online tutorials about how to code classes. Google or look at Learning Python here http://www.python-eggs.org/ def func1(): print hello class MyClass: def func2(self): #how can I call func1 here. func1() #results in an error MC= MyClass() MC.func2() -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
beginner wrote: Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error If you had bothered to include the error message it would have been obvious that the problem with your code isn't in body of the method at all - you have failed to include an argument to the method to pick up the instance on which the method is called. I am guessing that when you create an instance and call its func2 method you see the message Traceback (most recent call last): File test07.py, line 12, in module myInstance.func2() TypeError: func2() takes no arguments (1 given) which would have been a very useful clue. Please include the traceback in future! Here's a version of your program that works. [EMAIL PROTECTED] ~/Projects/Python $ cat test07.py my module here def func1(): print hello class MyClass: def func2(self): #how can I call func1 here. func1() #results in an error myInstance = MyClass() myInstance.func2() [EMAIL PROTECTED] ~/Projects/Python $ python test07.py hello regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: constructor or initialization function for module
beginner wrote: Hi Everyone, An extended module (.pyd) written in C have an init function that is called when the module is imported. Does anyone know if there is a way to provide an init function for a module written in python? The body of a Python module is executed the first time it is imported (that's how the functions and classes get defined: class and def statements are executable), so just put your initialization code inline. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
beginner [EMAIL PROTECTED] wrote: I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error [EMAIL PROTECTED] ~ % cat t.py def func1(): print hello class MyClass: def func2(): func1() [EMAIL PROTECTED] ~ % python -c import t [EMAIL PROTECTED] ~ % As you can see there no compiling error, because the syntax is correct, you'll eventually get a runtime error like this: import t c = t.MyClass() c.func2() Traceback (most recent call last): File stdin, line 1, in module TypeError: func2() takes no arguments (1 given) That's because you left out the self argument in the definition of func2(). This version is correct: -- def func1(): print hello class MyClass(object): def func2(self): func1() c = MyClass() c.func2() -- [EMAIL PROTECTED] ~ % python tcorrect.py hello HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a module function visible only inside the module?
beginner [EMAIL PROTECTED] wrote: Is there any equivalent version of C's static function in Python. I know I can make a class function private by starting a function name with two underscores, but it does not work with module functions. The trick for the name mangling does not work at module level. Anyway, if you read the PEP 8 [1] you can correctly write your code following a well known coding standard. A function like this: def _f(): pass is meant to be private, you can also state it in the function's docstring to be more clear, if you want, but it's not necessary For exmaple, __func1 is still visible outside the module. Yes, and _f() will also be. There's no such thing as enforcing encapsulation in Python, even the __method() trick can be easily bypassed if you have to. 1 - http://www.python.org/dev/peps/pep-0008/ HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
On Aug 18, 8:18 pm, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error If you had bothered to include the error message it would have been obvious that the problem with your code isn't in body of the method at all - you have failed to include an argument to the method to pick up the instance on which the method is called. I am guessing that when you create an instance and call its func2 method you see the message Traceback (most recent call last): File test07.py, line 12, in module myInstance.func2() TypeError: func2() takes no arguments (1 given) which would have been a very useful clue. Please include the traceback in future! Here's a version of your program that works. [EMAIL PROTECTED] ~/Projects/Python $ cat test07.py my module here def func1(): print hello class MyClass: def func2(self): #how can I call func1 here. func1() #results in an error myInstance = MyClass() myInstance.func2() [EMAIL PROTECTED] ~/Projects/Python $ python test07.py hello regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading -- Hide quoted text - - Show quoted text - I apologize for not posting the exact code and error message. The missing self is due to a typo of mine. It is not really the problem I am encountering. testmodule.py - Test Module def __module_level_func(): print Hello class TestClass: def class_level_func(self): __module_level_func() main.py -- import testmodule x=testmodule.TestClass() x.class_level_func() The error message I am encountering is: NameError: global name '_TestClass__module_level_func' is not defined I think it has something to do with the two underscores for __module_level_func. Maybe it has something to do with the python implementation of the private class level functions. By the way, the reason I am naming it __module_level_func() is because I'd like __module_level_func() to be private to the module, like the C static function. If the interpreter cannot really enforce it, at least it is some sort of naming convention for me. Thanks, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
On Aug 18, 8:13 pm, Zentrader [EMAIL PROTECTED] wrote: On Aug 18, 5:40 pm, beginner [EMAIL PROTECTED] wrote: Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error Thanks, Geoffrey You might want to check one of the online tutorials about how to code classes. Google or look at Learning Python herehttp://www.python-eggs.org/ def func1(): print hello class MyClass: def func2(self): #how can I call func1 here. func1() #results in an error MC= MyClass() MC.func2()- Hide quoted text - - Show quoted text - Thanks for your help. The missing self is a typo of mine. It is not the problem I am encountering. Sorry for posting the wrong code. -- http://mail.python.org/mailman/listinfo/python-list
Re: constructor or initialization function for module
On Aug 18, 8:25 pm, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, An extended module (.pyd) written in C have an init function that is called when the module is imported. Does anyone know if there is a way to provide an init function for a module written in python? The body of a Python module is executed the first time it is imported (that's how the functions and classes get defined: class and def statements are executable), so just put your initialization code inline. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - I see. That works. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a module function visible only inside the module?
On Aug 18, 8:27 pm, [EMAIL PROTECTED] (Lawrence Oluyede) wrote: beginner [EMAIL PROTECTED] wrote: Is there any equivalent version of C's static function in Python. I know I can make a class function private by starting a function name with two underscores, but it does not work with module functions. The trick for the name mangling does not work at module level. Anyway, if you read the PEP 8 [1] you can correctly write your code following a well known coding standard. A function like this: def _f(): pass is meant to be private, you can also state it in the function's docstring to be more clear, if you want, but it's not necessary For exmaple, __func1 is still visible outside the module. Yes, and _f() will also be. There's no such thing as enforcing encapsulation in Python, even the __method() trick can be easily bypassed if you have to. 1 - http://www.python.org/dev/peps/pep-0008/ HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair Thanks a lot. I was using two underscores, __module_method() as my static method convention, and then I had some problems calling them from inside class methods. -- http://mail.python.org/mailman/listinfo/python-list
Weekly Python Patch/Bug Summary
Patch / Bug Summary ___ Patches : 417 open (+13) / 3855 closed ( +0) / 4272 total (+13) Bugs: 1069 open ( +4) / 6800 closed (+10) / 7869 total (+14) RFE : 262 open ( -1) / 296 closed ( +1) / 558 total ( +0) New / Reopened Patches __ Replacing char* with const char* (2007-08-12) http://python.org/sf/1772673 opened by eXt [python-mode] Properly highlight lambda with no arguments (2007-08-12) http://python.org/sf/1772721 opened by Michal Kwiatkowski -q (quiet) option for python interpreter (2007-08-13) http://python.org/sf/1772833 opened by Marcin Wojdyr Decimal and long hash, compatibly and efficiently (2007-08-13) http://python.org/sf/1772851 opened by Mark Dickinson Remove references to _xmlrpclib from xmlrpclib.py (2007-08-14) http://python.org/sf/1773632 opened by Alan McIntyre Unify __builtins__ - __builtin__ (2007-08-15) http://python.org/sf/1774369 opened by Christian Heimes Add Checkbutton get() and set(value) (2007-08-14) http://python.org/sf/1774370 opened by Graham Horler Make it possible to use SVK to develop Python (2007-08-14) http://python.org/sf/1774414 opened by Collin Winter Override flags set by IOBase in io.StringIO (2007-08-15) http://python.org/sf/1774828 opened by Alexandre Vassalotti Convert str to bytes in io.BytesIO.__init__ (2007-08-15) http://python.org/sf/1774833 opened by Alexandre Vassalotti zipfile: Allow reading duplicate filenames (2007-08-15) http://python.org/sf/1775025 opened by Graham Horler utt-32 codecs (2007-08-16) http://python.org/sf/1775604 opened by Walter Dörwald Minor corrections to smtplib (2007-08-17) http://python.org/sf/1776581 opened by Alan McIntyre New / Reopened Bugs ___ urllib2 hangs with some documents. (2007-08-12) http://python.org/sf/1772481 opened by Creature dir() on traceback objects returns an empty list (2007-08-11) CLOSED http://python.org/sf/1772489 opened by Collin Winter exec() doesn't take an open file (2007-08-12) CLOSED http://python.org/sf/1772686 opened by Neal Norwitz chr(128) in u'only ascii' - TypeError with misleading msg (2007-08-13) http://python.org/sf/1772788 opened by Pekka Laukkanen Using telnetlib fails with unicode strings containing only a (2007-08-13) http://python.org/sf/1772794 opened by Pekka Laukkanen Py Lib Ref, 3.6.1 String Methods startswith() typo (2007-08-13) CLOSED http://python.org/sf/1772890 opened by arxaaron xmlrpclib crash when PyXML installed (2007-08-13) http://python.org/sf/1772916 opened by lplatypus Binding Control-space fails (2007-08-15) http://python.org/sf/1774736 opened by Ali Gholami Rudi Not exiting when running tests (2007-08-15) http://python.org/sf/1774840 opened by José Pablo Pupeno Fernández Display CallTips for classes using metaclasses. (2007-08-16) http://python.org/sf/1775388 opened by Noam Raphael Buffer overflow when listing deeply nested directory (2007-08-17) http://python.org/sf/1776160 opened by Björn Lindqvist glob.glob inconsistent (2007-08-18) http://python.org/sf/1776674 opened by norbidur tempfile.TemporaryFile differs between platforms (2007-08-18) http://python.org/sf/1776696 opened by Kenneth Loafman memoryview('test') is causing a segfault (2007-08-19) http://python.org/sf/1777057 opened by Christian Heimes Bugs Closed ___ ERROR - Microsoft Visual C++ Runtime Library (2007-05-18) http://python.org/sf/1721161 closed by gbrandl dir() on traceback objects returns an empty list (2007-08-11) http://python.org/sf/1772489 closed by collinwinter words able to decode but unable to encode in GB18030 (2007-08-09) http://python.org/sf/1770551 closed by perky exec() doesn't take an open file (2007-08-12) http://python.org/sf/1772686 closed by bcannon Py Lib Ref, 3.6.1 String Methods startswith() typo (2007-08-13) http://python.org/sf/1772890 closed by gbrandl decimal.Decimal(trash) produces informationless exception (2007-08-08) http://python.org/sf/1770009 closed by facundobatista mark deprecated modules in indexes (2003-10-02) http://python.org/sf/816725 closed by gbrandl Python function/method/constant names as HTML-tag IDs (2005-07-24) http://python.org/sf/1243945 closed by gbrandl Collapse distutils docs (2005-12-07) http://python.org/sf/1375258 closed by gbrandl some section links (previous, up, next) missing last word (2006-09-15) http://python.org/sf/1559142 closed by gbrandl RFE Closed __ -q (quiet) option for python interpreter (2007-05-30) http://python.org/sf/1728488 closed by wojdyr -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
By the way, the reason I am naming it __module_level_func() is because I'd like __module_level_func() to be private to the module, like the C static function. If the interpreter cannot really enforce it, at least it is some sort of naming convention for me. re the above: set file permissions for testmodule.py to limit access. IMHO it is a better solution. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parser Generator?
On 19 aug 2007, at 00.22, Jack wrote: Hi all, I need to do syntax parsing of simple naturual languages, for example, weather of London or what is the time, simple things like these, with Unicode support in the syntax. In Java, there are JavaCC, Antlr, etc. I wonder what people use in Python? Antlr also has Python support but I'm not sure how good it is. Comments/hints are welcome. -- http://mail.python.org/mailman/listinfo/python-list Antlr can generate Python code. However, I don't think a parser generator is suitable for generating natural language parsers. They are intended to generate code for computer language parsers. However, for examples on parsing imperative English sentences, I suggest taking a look at the class library for TADS 3 (Text Adventure Development System) http://www.tads.org The lanuge has a syntax reminding of c++ and Java. - An astronomer to a colleague: -I can't understsnad how you can go to the brothel as often as you do. Not only is it a filthy habit, but it must cost a lot of money too. -Thats no problem. I've got a big government grant for the study of black holes. Tommy Nordgren [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Searching for pixel color
Hello, I was just wondering if anyone knew of a way to search the screen for a certain color in Python. I know it is possible to do this in other languages, but I'm not sure how I'd go about doing this in Python. Just to let you know, I'm running windows XP and I don't really need it to be a cross platform solution, but if it was that'd be an extra bonus. Thanks very much for taking the time to read this and, hopefully, respond! _ Advertisement: Win Dad the Footy Final with Cadbury Favourites! http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fbs%2Eserving%2Dsys%2Ecom%2FBurstingPipe%2FadServer%2Ebs%3Fcn%3Dtf%26c%3D20%26mc%3Dclick%26pli%3D243221%26pi%3D0%26ord%3D%25%25RANDOM%25%25_t=765445318_r=hotmail_email_tagline_Aug07_Cadburys_m=EXT -- http://mail.python.org/mailman/listinfo/python-list
Segmentation Fault in 2.5 Installation
Hi. I was attempting to instal the 2.5 release on my Ubuntu box. Config went fine. Make went fine. Make instal, not so much. I get: Compiling /usr/local/lib/python2.5/test/test_compare.py ... Compiling /usr/local/lib/python2.5/test/test_compile.py ... Compiling /usr/local/lib/python2.5/test/test_compiler.py ... Compiling /usr/local/lib/python2.5/test/test_complex.py ... Compiling /usr/local/lib/python2.5/test/ test_complex_args.py ... make: *** [libinstall] Segmentation fault Any ideas on how to proceed? Do you need any additional information from me? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
ANN: UliPad 3.7 released!
UliPad is a flexible editor, based on wxPython. It's has many features,just like:class browser, code auto-complete, html viewer, directory browser, wizard, etc. The main feature is the usage of mixin. This makes UliPad can be extended easily. So you can write your own mixin or plugin, or simple script, these can be easy and seamless integrated with UliPad. What's new in 3.7 === New Features and Changes: #. Add PEP8 sytle checking #. Enhance calltip showing #. Add a new option in Preference, which is used for when you toggle comment lines(Ctrl+/ or Ctrl+\) if it'll popup a comment dialog. You can find it in Preference-Document-Show comment character dialog when adding comment. #. Saving auto todo window status #. Changing shortcut of quote dialog from Ctrl+Q to Ctrl+' #. Changing the number of recent files to 20 #. Changing shortcut Ctrl+Alt+L to Alt+Z, Ctrl+Alt+B to Alt+X #. Saving the status of Message window word wrap #. Saving the snippets window position #. The results of find in files can only show the filenames and you can copy them to clipboard #. Add Spanish language translation and Traditional Chinese language translation #. Using ZestyParser Module to parse the source code syntax #. Improving input assistant functionality #. Adding config.txt documentation #. When saving files, automatically adding accordingly filename suffix #. Adding mixin reload mechanism, it will be very useful when developing #. Adding folder sort functionality when adding new folder to directory browser window #. Adding template in input assistant, and you can press TAB key to jump to the next field. The template just like: ${1:something}. #. Adding LUA syntax support #. Adding mako(template module) support plugin #. Adding batch filenames rename plugin #. Enable ftp window be openned left or bottom pane according to the openning position #. Adding Alt+R shortcut for open recently files #. Merging new 1.20 version winpdb to ulipad Bug fix: #. Fix ctag support bug #. Fix default style bug #. Fix the wrong cursor jumping after undo operating #. Fix xml lexer type bug #. Fix copying bug when the text block has no indent #. Fix openning multi-view bug from menu items #. Fix the input focus losing bug when openning bottom pane or double-click on directory browser entries #. Fix user can open multi find dialogs bug #. Fix register functionality in windows UliPad has been ported to code.google.com, so you can visit the new project site at: http://code.google.com/p/ulipad, and also visit the new svn address. Recommends using source version. Source Code: http://ulipad.googlecode.com/files/ulipad.3.7.zip Win Execute Code: http://ulipad.googlecode.com/files/ulipad.3.7.exe If you have any suggestion or question, please subscribe the ulipad mailling list: http://groups.google.com/group/UliPad -- I like python! UliPad The Python Editor: http://code.google.com/p/ulipad/ My Blog: http://www.donews.net/limodou -- http://mail.python.org/mailman/listinfo/python-list
Re: Parser Generator?
Thanks for all the replies! SPARK looks promising. Its doc doesn't say if it handles unicode (CJK in particular) encoding though. Yapps also looks powerful: http://theory.stanford.edu/~amitp/yapps/ There's also PyGgy http://lava.net/~newsham/pyggy/ I may also give Antlr a try. If anyone has experiences using any of the parser generators with CJK languages, I'd be very interested in hearing that. Jack Jack [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I need to do syntax parsing of simple naturual languages, for example, weather of London or what is the time, simple things like these, with Unicode support in the syntax. In Java, there are JavaCC, Antlr, etc. I wonder what people use in Python? Antlr also has Python support but I'm not sure how good it is. Comments/hints are welcome. -- http://mail.python.org/mailman/listinfo/python-list
Understanding closures
Hi, I want to use variables passed to a function in an inner defined function. Something like- def fun1(method=None): def fun2(): if not method: method = 'GET' print '%s: this is fun2' % method return fun2() fun1() However I get this error- UnboundLocalError: local variable 'method' referenced before assignment This however works fine. def fun1(method=None): if not method: method = 'GET' def fun2(): print '%s: this is fun2' % method return fun2() fun1() Is there a simple way I can pass on the variables passed to the outer function to the inner one without having to use or refer them in the outer function? Thanks, Ramashish -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding closures
Ramashish Baranwal [EMAIL PROTECTED] wrote: Hi, I want to use variables passed to a function in an inner defined function. Something like- def fun1(method=None): def fun2(): if not method: method = 'GET' print '%s: this is fun2' % method return fun2() fun1() However I get this error- UnboundLocalError: local variable 'method' referenced before assignment This however works fine. def fun1(method=None): if not method: method = 'GET' def fun2(): print '%s: this is fun2' % method return fun2() fun1() Is there a simple way I can pass on the variables passed to the outer function to the inner one without having to use or refer them in the outer function? Sure, just don't ASSIGN TO those names in the inner function. Any name ASSIGNED TO in a given function is local to that specific function (save for global statements, which bypass variable of containing functions anyway). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
beginner [EMAIL PROTECTED] wrote: ... testmodule.py - Test Module def __module_level_func(): print Hello class TestClass: def class_level_func(self): __module_level_func() main.py -- import testmodule x=testmodule.TestClass() x.class_level_func() The error message I am encountering is: NameError: global name '_TestClass__module_level_func' is not defined I think it has something to do with the two underscores for __module_level_func. Maybe it has something to do with the python implementation of the private class level functions. By the way, the reason I am naming it __module_level_func() is because I'd like __module_level_func() to be private to the module, like the C static function. If the interpreter cannot really enforce it, at least it is some sort of naming convention for me. The two underscores are exactly the cause of your problem: as you see in the error message, the compiled has inserted the CLASS name (not MODULE name) implicitly there. This name mangling is part of Python's rules. Use a SINGLE leading underscore (NOT double ones) as the sort of naming convention to indicate privacy, and Python will support you (mostly by social convention, but a little bit technically, too); use a different convention (particularly one that fights against the language rules;-) and you're fighting city hall to no good purpose and without much hope of achieving anything whatsoever thereby. Alex -- http://mail.python.org/mailman/listinfo/python-list
[ python-Bugs-1776160 ] Buffer overflow when listing deeply nested directory
Bugs item #1776160, was opened at 2007-08-17 06:24 Message generated for change (Comment added) made by montanaro You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1776160group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Windows Group: Platform-specific Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bj�rn Lindqvist (sonderblade) Assigned to: Nobody/Anonymous (nobody) Summary: Buffer overflow when listing deeply nested directory Initial Comment: This code: import os import os.path TARGET='C:/code/python/foo' base = TARGET for x in range(200): subdirs = os.listdir(base) base = os.path.join(base, subdirs[0]) print base Produces a TypeError (buffer overflow) when run on a to deeply nested directory for windows to handle: .. more output here.. C:code/python/foo\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.p ng\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png\foo bar.png Traceback (most recent call last): File killdir.py, line 6, in module subdirs = os.listdir(base) TypeError: listdir() argument 1 must be (buffer overflow), not str -- Comment By: Skip Montanaro (montanaro) Date: 2007-08-18 06:38 Message: Logged In: YES user_id=44345 Originator: NO Worked as expected for me on Mac OS X 10.4.10 running from the trunk (you didn't mention what version you were using). In ~/tmp/deep I created a maximally nested directory tree from the shell like so: cd /Users/skip/tmp/deep for i in `range 1000` ; do x=`printf %04d $i` echo $x mkdir $x cd $x done where the range command is analogous to Python's range builtin: % range 20 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 The for loop barfed after making directory 0205. In Python I then executed these statements: import os.path base = /Users/skip/tmp/deep for x in range(210): subdirs = os.listdir(base) base = os.path.join(base, subdirs[0]) print base This went until it got to dir 0200 where it raised an OSError: [Errno 63] File name too long: '/Users/skip/tmp/deep//0001/.../0199/0200' which stands to reason since base was 1025 characters long at that point. MAXPATHLEN is defined to be 1024 on my system, so the OSError is to be expected. Skip -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1776160group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1777057 ] memoryview('test') is causing a segfault
Bugs item #1777057, was opened at 2007-08-19 03:13 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 3000 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Christian Heimes (tiran) Assigned to: Nobody/Anonymous (nobody) Summary: memoryview('test') is causing a segfault Initial Comment: ./python -c memoryview('test') Segmentation fault I compiled Python 3.0 with $ ./configure --with-pydebug --enable-unicode=ucs4 and $ make EXTRA_CFLAGS=-DPy_REF_DEBUG -DPy_TRACE_REFS -DPy_DEBUG after a make clean; rm -rf build; svn up I've used gdb to trace the segfault: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1210415424 (LWP 14436)] 0x080f77a0 in PyErr_SetObject (exception=0x81962c0, value=0xb7cee3a8) at Python/errors.c:55 55 if (exception != NULL -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1777057 ] memoryview('test') is causing a segfault
Bugs item #1777057, was opened at 2007-08-19 03:13 Message generated for change (Settings changed) made by tiran You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 3000 Status: Open Resolution: None Priority: 8 Private: No Submitted By: Christian Heimes (tiran) Assigned to: Nobody/Anonymous (nobody) Summary: memoryview('test') is causing a segfault Initial Comment: ./python -c memoryview('test') Segmentation fault I compiled Python 3.0 with $ ./configure --with-pydebug --enable-unicode=ucs4 and $ make EXTRA_CFLAGS=-DPy_REF_DEBUG -DPy_TRACE_REFS -DPy_DEBUG after a make clean; rm -rf build; svn up I've used gdb to trace the segfault: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1210415424 (LWP 14436)] 0x080f77a0 in PyErr_SetObject (exception=0x81962c0, value=0xb7cee3a8) at Python/errors.c:55 55 if (exception != NULL -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1775388 ] Display CallTips for classes using metaclasses.
Bugs item #1775388, was opened at 2007-08-16 08:28 Message generated for change (Settings changed) made by kbk You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1775388group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: IDLE Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Noam Raphael (noamr) Assigned to: Kurt B. Kaiser (kbk) Summary: Display CallTips for classes using metaclasses. Initial Comment: Hello, Currently, if you write something like this: class MyType(type): pass class MyClass(object): __metaclass__ = MyType def __init__(self, a): pass And write in the shell: MyClass( a calltip won't be displayed. To fix this, replace this line in CallTups.py: if type(ob) in (types.ClassType, types.TypeType): with this one: if issubclass(type(ob), (types.ClassType, types.TypeType)): and now it works. Thanks, Noam -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1775388group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1777057 ] memoryview('test') is causing a segfault
Bugs item #1777057, was opened at 2007-08-18 18:13 Message generated for change (Comment added) made by nnorwitz You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 3000 Status: Closed Resolution: Fixed Priority: 8 Private: No Submitted By: Christian Heimes (tiran) Assigned to: Neal Norwitz (nnorwitz) Summary: memoryview('test') is causing a segfault Initial Comment: ./python -c memoryview('test') Segmentation fault I compiled Python 3.0 with $ ./configure --with-pydebug --enable-unicode=ucs4 and $ make EXTRA_CFLAGS=-DPy_REF_DEBUG -DPy_TRACE_REFS -DPy_DEBUG after a make clean; rm -rf build; svn up I've used gdb to trace the segfault: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1210415424 (LWP 14436)] 0x080f77a0 in PyErr_SetObject (exception=0x81962c0, value=0xb7cee3a8) at Python/errors.c:55 55 if (exception != NULL -- Comment By: Neal Norwitz (nnorwitz) Date: 2007-08-18 21:25 Message: Logged In: YES user_id=33168 Originator: NO Committed revision 57193. This problem was due to not initializing the new BufferError properly. Travis mentioned this in his post to python-3000. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1777057group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com