Re: Converstion
On 28/04/2006 4:46 PM, Paddy wrote: > Something like (untested): > > out = [] > for ch in instring: > if ch==backspace: > if out: > out = out[:-1] > else: > out.append(ch) > outstring = ''.join(out) Instead of: if out: out = out[:-1] consider: del out[-1:] -- http://mail.python.org/mailman/listinfo/python-list
TypeError: 'module' object is not callable
dear python users I am not sure why I am getting Traceback (most recent call last): File "my.py", line 3, in ? urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') TypeError: 'module' object is not callable with this code import urlparse urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Direct acces to db unify on unix sco
hello, I am not sure whether I have understood you correctly, but if you mean unify as in www.unify.com then it is possible to directly link in the unify libraries statically into python. My experience was that the unify libraries do not like dynamic linking. The process of static linking involves using swig wrappers and I always found SCO to be particularly difficult. The process of wrapping using swig is not straightforward and would need a bit of explanation. If ODBC is a realistic option I would go for it, I suspect it would be easier in the long run. luca72 wrote: > Is it possible or i must use odbc? > > Rergards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: How to align the text of a Listbox to the right
On 27 Apr 2006 07:00:36 -0700, Leonardo da Vinci <[EMAIL PROTECTED]> wrote: > I have to use a Listbox that shows a list of entries. Every entry is a > char string quite long in size and I cannot set "width" to a large > value due to limitations of screen resolution. The rightmost part is > more important, so I thought that I could show only the end of the > string by aligning the field to the right. As I see it, there are two solutions to your problems: - Display your strings differently. It may seem stupid, but there are sometimes situations where it is the best solution. Think about Apple's way of displaying full file path names in menus: they put the file base name first, then the full directory after a separator. If you have a way to do that, your problem is solved. - Don't use a Listbox to display your list, but another widget. A simple Text with no wrap option may be a solution; setting a tag with the option justify=LEFT on your whole text would do the trick. But if your lines of text should be selectable, it may not be the right solution. In this case, another widget you can use is a Canvas. It's a little trickier but can be done. Here is an example: -- from Tkinter import * root = Tk() cnv = Canvas(root, width=150, height=250) cnv.grid(row=0, column=0, sticky='nswe') hscroll = Scrollbar(root, orient=HORIZONTAL, command=cnv.xview) hscroll.grid(row=1, column=0, sticky='we') vscroll = Scrollbar(root, orient=VERTICAL, command=cnv.yview) vscroll.grid(row=0, column=1, sticky='ns') cnv.configure(xscrollcommand=hscroll.set, yscrollcommand=vscroll.set) xMax = 0 y = 0 for i in range(20): lbl = Label(cnv, text='Very, very long item number %s' % i) cnv.create_window(150, y, window=lbl, anchor='ne') y += lbl.winfo_reqheight() xMax = max(xMax, lbl.winfo_reqwidth()) cnv.configure(scrollregion=(150 - xMax, 0, 150, y)) root.mainloop() -- Putting bindings on the Label widgets created in the loop can be used to simulate the behaviour of a Listbox. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module' object is not callable
On 28/04/2006 5:05 PM, Gary Wessle wrote: > dear python users > > I am not sure why I am getting > > > Traceback (most recent call last): > File "my.py", line 3, in ? > urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') > TypeError: 'module' object is not callable > > > with this code > > > import urlparse > > urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') > The message "TypeError: 'module' object is not callable" means that the "urlparse" that you are trying to call as a function is a module and is thus not callable. The module urlparse contains functions urlparse and urlsplit, among others. I'm dragging urlsplit into the arena as its name is not the same as the module name, and it might help you see what is happening. There are two ways of calling them: (1) >>> import urlparse >>> urlparse.urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '') >>> urlparse.urlsplit('http://www.cwi.nl:80/%7Eguido/Python.html') ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '') >>> (2) >>> from urlparse import urlparse, urlsplit >>> urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '') >>> urlsplit('http://www.cwi.nl:80/%7Eguido/Python.html') ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '') >>> Method (1) is probably better for you at the moment. I suggest that you read the Modules section in the tutorial: http://docs.python.org/tut/node8.html *and* all the earlier sections if you haven't already. -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Thanks for your tips. But dir() and inspect did not really help. dir(): ['GetIDsOfNames', 'GetTypeInfo', 'GetTypeInfoCount', 'Invoke', 'InvokeTypes', 'QueryInterface', '_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__getitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__repr__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] pprint.pprint(inspect.getmembers(objDom)): [('GetIDsOfNames', ), ('GetTypeInfo', ), ('GetTypeInfoCount', ), ('Invoke', ), ('InvokeTypes', ), ('QueryInterface', >>), ('_ApplyTypes_', >>), ... Further more this nice method also did not know any more: objDom._print_details_(): AxDispatch container Dispatch wrapper around Methods: Props: Get Props: Put Props: Any additional hint ? Could it be, that you must know in advance, what to ask a com object; so there is no dump possibility ? Thanks Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
"sturlamolden" <[EMAIL PROTECTED]> writes: > I believe MinGW can link .lib C libraries files from Visual Studio. But > there are no .a for Python24.dll as far as I can tell. But afaik you don't need one. -- Brian (remove the sport for mail) http://www.et.web.mek.dtu.dk/Staff/be/be.html http://www.rugbyklubben-speed.dk -- http://mail.python.org/mailman/listinfo/python-list
RE: Importing modules through directory shortcuts on Windows
[Roger Upole] | [... snipped ugly code ...] Thanks; I'll have to find the time to experiment with that a bit. 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: can i set up a mysql db connection as a class ?
On 04/28/2006 08:35 AM, *binarystar* wrote: Looking better at the """ Humble Database Connection Class """: if I am not mistaken, it seems to mix up connections and cursors. MySQLdb has a thread safety level of '1', meaning: "Threads may share the module, but not connections". So you have to give each thread an own connection. Beside of that I would prefer not to share the cursor object, although it should not really matter. The following should work and make the cursors private to the Execute function (untested): class DB_Connector(object): """ Humble Database Connection Class """ def __init__(self, host="localhost", user="MyUser", passwd="MyPassword", **other_db_arguments): self.host = host self.user = user self.passwd = passwd # Unpack Other Database Arguments Here self.CreateConnection() def CreateConnection(self): self.connection = MySQLdb.connect(self.host, self.user, self.passwd) def DestroyConnection(self): self.connection.close() def Execute(self, sql_statement): cursor = self.connection.cursor() cursor.execute(sql_statement) result = cursor.fetchall() cursor.close() return result > I suppose that is possible because you are calling the one instance of a > cursor object ... maybe you have to create a copy of the cursor object, > rather than passing a reference to the one object? or set up the > db_connection objects inside each of the threads? .. > > Winfried Tilanus wrote: >> On 04/28/2006 07:54 AM, *binarystar* wrote: >> >> Just wondering: is there any risk of two threads accessing the Execute >> function at the same time and getting something like this on the same >> cursor object: >> >> thread_1: self.cursor.Execute( sql_statement ) >> thread_2: self.cursor.Execute( sql_statement ) >> thread_1: return self.cursor.FetchAll() >> thread_2: return self.cursor.FetchAll() >> >> In that case the queries would seriously be messed up. My intuition says >> this would need some locking or a 'cursor-pool'. >> >> best wishes, >> >> Winfried >> >> >>> your on the right track ... create something like this ( hope the >>> formatting doesn't go to hay wire ) >>> >>> class DB_Connector(object): >>> >>> """ Humble Database Connection Class """ >>> def __init__(self, host="localhost", >>> user="MyUser",passwd="MyPassword", **other_db_arguments): >>> self.host = host >>>self.user = user >>>self.passwd = passwd >>> # Unpack Other Database Arguments Here >>> self.CreateConnection() >>>def CreateConnection( self ): >>> self.cursor = MySQLdb.connect(self.host, self.user, >>> self.passwd) >>>def DestroyConnection( self ): >>> self.cursor.close() >>>def Execute( self, sql_statement ): >>> self.cursor.Execute( sql_statement ) >>> return self.cursor.FetchAll() >>>Then when you run your program create an instance of the object >>> >>> db_connection = DB_Connector( 'localhost', 'administrator', >>> 'betelgeuse99', auto_commit=1, other_keyword_arg="yes" ) >>> >>> now when you pass the db_connection instance to other classes, a copy >>> will be made automagically >>> >>> thread_1_instance= ThreadingClass( db_connection ) >>> thread_2_instance= ThreadingClass( db_connection ) >>> thread_3_instance= ThreadingClass( db_connection ) >>> >>> should work .. >>> I hope this is useful -- http://mail.python.org/mailman/listinfo/python-list
Pattern_Recognition_School+Conf_2006:Deadline_Approaching
Approaching Deadlines!! PATTERN RECOGNITION EVENTS THIS SUMMER, 2006 ___ 4TH INTERNATIONAL SUMMER SCHOOL ON PATTERN RECOGNITION (ISSPR, 2006), 23-28 JULY, UK WWW.PatternRecognitionSchool.com The 4th International Summer School on Pattern Recognition will be organised at the University of Plymouth, UK (23-28 July, 2006). The school programme is listed below. Please pass on this email to your interested colleagues and students. This is a great summer school which I would recommend for everyone to attend. DEADLINE: Register BEFORE 01 MAY, 2006 through the website to get a discount on the fee. More than 100 participants in 2005! Speakers at the Summer School (ISSPR'2006) Dr. Sam Roberts Mathworks, UK (Introduction to Matlab) Prof. Wojtek Krzanowski University of Exeter, UK (Multivariate Statistics: Data Description) Dr. Mike Tipping, Microsoft Research, UK (Bayesian Pattern Recognition: Principles and Practice) Prof. Chris Bishop, Microsoft Research, UK (Latent Variables, Mixture Models and EM) Dr. Richard Everson, University of Exeter, UK (Dimensionality Reduction) Dr. Peter Tino University of Birmingham, UK (Probabilistic framework for model-based topographic map formation) Prof. Chris Williams, University of Edinburgh, UK (Neural Networks and Kernel Machines) Dr. Colin Campbell, University of Bristol, UK (Support Vector Machines and Kernel Methods: An Introduction and Review) Prof. John Shawe- Taylor, University of Southampton, UK (Kernel Based Methods) Dr. Steve Gunn, University of Southampton, UK (Matlab for Support Vector Machines) Prof. Mahesan Niranjan, University of Sheffield, UK (Classifier Performance Particle Filters for Tracking and Sequential Problems) Dr. Andrew Webb Qinetiq, UK (Decision TreesData Clustering) Prof. Xin Yao, University of Birmingham, UK (A Gentle Introduction to Evolutionary Computation; ATutorial on Evolutionary Multi-objective Optimisation) Dr. Richard Deardon, University of Birmingham, UK (Sequential Decision Making; Markov Chains Monte Carlo Methods) Dr. Jeremy Wyatt, University of Birmingham, UK (An Introduction to Reinforcement Learning) Dr. Ludmila Kuncheva, University of Wales, UK (Classifier Combination) Prof. Joseph Kittler, University of Surrey, UK (Feature Selection and Extraction) Prof. Sameer Singh, Loughborough University, UK (Multiresolution Pattern Recognition) Prof. Susan Craw, Robert Gordon University, UK (Case Based Reasoning) SUPPORTED BY: Microsoft, Springer, British Computer Society, and Mathworks. ___ IEEE CVPR CONFERENCE www.CVPR.org/2006 17-22 June, 2006 ___ 18th INTERNATIONAL CONFERENCE ON PATTERN RECOGNITION www.comp.hkbu.edu.hk/~icpr06 August 20-24, 2006 __ ICIAR CONFERENCE www.iciar.uwaterloo.ca/iciar06 18-20 September, 2006 __ Please see the event websites to get FULL information. Compiled by: Dr. Heather Mclleland -- http://mail.python.org/mailman/listinfo/python-list
Doubt with wx.ListCtrl
I have programmed this code: # self ist a panel self.partListCtrlMarks = wx.ListCtrl(self.panel, -1, style = wx.LC_REPORT) self.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnSelectedItemList,self.partListCtrlMarks) vs.Add(self.partListCtrlMarks, 1, wx.EXPAND | wx.ALL, 4) self.partListCtrlMarks.InsertColumn(0, "Name") self.partListCtrlMarks.InsertColumn(1, "Note") self.partListCtrlMarks.SetColumnWidth(1, 80) later I have this... idx = self.partListCtrlMarks.GetItemCount() self.partListCtrlMarks.InsertStringItem(idx, "Can embestido") self.partListCtrlMarks.SetStringItem(idx, 1, "De como a cabra smbiste o can") With self.partListCtrl.GetItemText(idx) I get only "Can embestido" which is in first column. My doubt is: How can I get the second column text "De como a cabra smbiste o can". --oOo-oOo-- Servicio de acceso ó correo electrónico vía web da Universidade de Vigo Servicio de acceso al correo electrónico vía web de la Universidad de Vigo Servicios Informáticos [ http://si.uvigo.es ] Universidade de Vigo [ http://www.uvigo.es ] URL: https://correoweb.uvigo.es -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex installation on windows XP: step-by-step guide
I added "step A.5" to the guide and published it on the Python wiki, so that anyone can update it easily: http://wiki.python.org/moin/PyrexOnWindows -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Brian Elmegaard wrote: > "sturlamolden" <[EMAIL PROTECTED]> writes: > >> I believe MinGW can link .lib C libraries files from Visual Studio. But >> there are no .a for Python24.dll as far as I can tell. > > But afaik you don't need one. Actually, a libpython24.a file was added in Python 2.4.1. The original 2.4.0 release didn't include one. AFAIR recent MINGW releases don't need this file any longer: http://mail.python.org/pipermail/python-dev/2005-October/057693.html -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not BDWGC?
[EMAIL PROTECTED] wrote: > I've heard that the reason why python uses reference counting rather > than tracing collector is because python cannot determine the root set > for its various C extensions. > But provided that BDWGC(full name: Boehm-Demers-Weiser conservative > garbage collector) is conservative --- can be used for C, and > opensourced, why python not adopt it as its gcmodule? google has the answer: http://groups.google.com/groups?q=Boehm-Demers+Python -- http://mail.python.org/mailman/listinfo/python-list
Re: How to align the text of a Listbox to the right
Sori Schwimmer ha scritto: > For a listbox, I would give a width and go with string > formatting. In your case, I guess that what I'll do is > to limit the width to something acceptable, and show > only the tail of the line. Yes, this is exactly what I wanted to do. Do you know a way to accomplish that? Because Eric Brunel said it is impossible on a Listbox. Thanks to everybody, L -- http://mail.python.org/mailman/listinfo/python-list
time conversions [hh:mm:ss.ms <-> sec(.ms)
Hi, I was looking at python & datetime and hoping that it would already have a method/func to translate time formats. I need to translate seconds to hh:mm:ss.ms and vice versa and would like the ability to do some basic arithmetic in these formats. I think that there just has to be a package or module out there that already does this with reasonable speed and accuracy. Sadly, i do indeed need both reasonable speed and accuracy since i will be adding up huge masses of small events (around 10 to 60 ms milliseconds in length) to create cloud like textures for real time audio/video at high sampling rates. i googled for hh:mm:ss.ms + python and didn't find much... best, -kp--- [mac os x w/ python 2.4.1] -- http://mail.python.org/mailman/listinfo/python-list
Re: Direct acces to db unify on unix sco
Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
python game with curses
Hi, I have wrote a game with python curses. The problem is that I want to confirm before quitting, while my implementation doesn't seem to work. Anyone can help me? [code] #!/usr/bin/python # # Brick & Ball in Python # by Jerry Fleming <[EMAIL PROTECTED]> # # This is a small game adapted from that in Motorola Mobile C289, and my first game in python :) # # This progrma is best run under linux. Since Windows port of Python has poor curses support, # play it under Windows is not recommended. If you have no linux box available, try Cygwin, # though it too has poor curses support. # # As I am a newbie to python, please tell me if you have a better implementation or any suggestions. # # TODO: # re-implemente it with wxPython, so one does not have to rely on the ugly curses. # session support. # pausing, especially when confirming # resize terminal at run time # # HISTORY # 2006-04-19: first version # # import curses import _curses import thread from time import sleep from string import split from random import randint # parameters: adjust them to fit you terminal brick_width = 7 brick_gap_x = 1 brick_gap_y = 1 speed = 0.05 # sleep time to control moving speed of the ball pause = 1 # time to pause # terminal initialization stdscr = curses.initscr() curses.noecho() curses.cbreak() curses.curs_set(0) stdscr.keypad(1) screen_height, screen_width = stdscr.getmaxyx() screen_height = screen_height - 1 screen_width = screen_width - 1 brick_rows = screen_height / 4 if brick_rows > 7: brick_rows = 7 brick_cols = (screen_width + brick_gap_x) / (brick_width + brick_gap_x) brick_margin = (screen_width - brick_cols * (brick_width + brick_gap_x) + brick_gap_x)/2 pad_position = randint(0, screen_width - brick_width) ball_position = [screen_height - 3, randint(0, screen_width - brick_width)] ball_direction = [-1, 1] # abs(tan(a)) must be 1 char = '' bricks = [] game_score = 0 ScreenSizeError = 'ScreenSizeError' tStart = ''' ___ _ ___ ___ _ _ __ _ ( \ (_) | | / _ \( \ | | | (_) (_ \_ | | ) ) _ | | _ ( (_) )) )_| | |_ _) ) _ _| |_| |__ ___ | __ ( / ___) |/ ___) |_/ ) ) _ (| __ (( | | | | | _ \ | / | | (_ _) _ \ / _ \| _ \ | |__) ) | | ( (___| _ ( ( (/ \ | |__) ) ___ | | | | | | | | | || |_| | | |_| | | | |_| | | | | |__/|_| |_|\)_| \_) \__/\_) |__/\_|\_)_) |_|_| |_| |_| \__ | \__)_| |_|\___/|_| |_| (/ by Jerry Fleming <[EMAIL PROTECTED]> GAME STARTING ... (this assumes that your terminal be larger that 130x40) ''' tExit = ''' 8 8 888 88 ad8ba 88 8bd8 d8 88 88 "" ,d d8" "8b88 Y8,,8P ,8P' 88 88 88 "" a8P88 Y8, ,8P d8" 88 88a 8b, ,d8 88 MM88MMM ,a8P" 88"8aa8",8P' 8b,dPPYba, 88 88" `Y8, ,8P' 88 88 d8"88 `88'd8" 88P' `"8a 88 88 )888(88 88 "" 88 88 ,8P'88 88 88 88 ,d8" "8b, 88 88,aa 88 88 d8" 88 88 88 888 8P' `Y8 88 "Y888 88 88 88 8P' 88 88 88 8 8 ''' tOver = ''' ,adba, 88 d8"'`"8b 88 d8' 88 88,adPPYYba, 88,dPYba,,adPYba, ,adPPYba, ,adPPYba, 8b d8 ,adPPYba, 8b,dPPYba, 88 88 8 "" `Y8 88P' "88""8a a8P_88a8" "8a `8b d8' a8P_88 88P' "Y8 88 Y8,88 ,adP88 88 88 88 8PP"""8b d8 `8b d8' 8PP""" 88 "" Y8a..a88 88,,88 88 88 88 "8b, ,aa"8a, ,a8" `8b,d8' "8b, ,aa 88 aa `"Y8P" `"8bbdP"Y8 88 88 88 `"Ybbd8"' `"YbbdP"' "8" `"Ybbd8"' 88 88 ''' tGoon = ''' 8 8 ,adba, ad8ba 88 8b d8 d8 88 d8"'`"8bd8" "8b88 Y8, ,8P ,8P' 88 d8' "" a8P88 Y8, ,8P d8"88 88 ,adPPYba, ,adPPYba, 8b,dPPYba, ,a8P" 88 "8aa8",8P' 8b,dPPYba, 88 88 8 a8" "8aa8" "8a 88P' `"8a d8"88 `88'd8" 88P' `"8a 88 Y8,88 8b
Strange constructor behaviour (or not?)
Hi, when defining: class A: def __init__(self, l=[]): self.l = l a = A() a.l.append() b = A() print a.l I get the output [] instead of an empty list. I guess it's because the default value in the constructor is constructed once and whenever the constructor is called without l being specified. My work around is: class A: def __init__(self, l=None): if l == None: self.l = [] else: self.l = l Is there a way to take the first definition but force the constructor to create a new empty list every time it is called? Thanks in advance Rolf Wester -- http://mail.python.org/mailman/listinfo/python-list
pgasync
Hi. Someone knows if this project is still alive? Thanks Manlio Perillo -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange constructor behaviour (or not?)
Rolf Wester wrote: > Hi, > > when defining: > > class A: > def __init__(self, l=[]): > self.l = l > a = A() > a.l.append() > b = A() > print a.l > > I get the output > > [] > > instead of an empty list. I guess it's because the default value in > the constructor is constructed once and whenever the constructor is > called without l being specified. Exactly right. See Python FAQ item 1.4.22 (http://www.python.org/doc/faq/general/#why-are-default-values-shared-be tween-objects) > My work around is: > > class A: > def __init__(self, l=None): > if l == None: > self.l = [] > else: > self.l = l > > Is there a way to take the first definition but force the constructor > to create a new empty list every time it is called? Not as far as I know. Worth reading the above FAQ as it also contains an interesting use of this side-effect. Dave. -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
eicwo01 wrote: > Thanks for your tips. > But dir() and inspect did not really help. Really ? def dump(obj): for name in dir(obj): print getattr(obj, name) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
RE: MinGW and Python
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > g] On Behalf Of Ross Ridge > Sent: Thursday, April 27, 2006 8:53 PM > Subject: Re: MinGW and Python > > > No one is working on removing MinGW's depency on MSVCRT.DLL. There is certainly work underway to ease the use of msvcrXX in mingw built binaries. It's already possible to do it today with some tweaking, but I seem to remember that this was already mentioned in this thread. For example: http://sourceforge.net/mailarchive/message.php?msg_id=7374474 I don't think it is a technical problem that prevents a mingw-python from being distributed, I rather see (in no particular order): 1) psychological issues: 'convenient IDE', 'better debugger' 2) legal issues: redistribution of msvcrXX 3) 'economical' issues: no one seems to be willing to reliably support a mingw-python No. 2 could be a show-stopper. There remains one technical issue that isn't a killer but would be inconvenient, IMHO: Can pywin32 be made working with a mingw-python (I'm quite sure it can't be made building on it)? I'd appreciate any datapoints about that ... cheers, aa -- Andreas Ames | Programmer | Comergo GmbH | Voice: +49 69 7505 3213 | ames AT avaya . com -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
bruno at modulix wrote: > eicwo01 wrote: >> Thanks for your tips. >> But dir() and inspect did not really help. > > Really ? > > def dump(obj): > for name in dir(obj): > print getattr(obj, name) > That will show him the attributes of the Python wrapper around the COM object, it won't show him the attributes of the underlying COM object itself. If I remember correctly (and its a while since I did this), you may be able to use win32com/client/makepy.py to generate a .py file from a type library. If you do this then the python wrapper will have methods to forward the calls, so you can inspect it as above. Unfortunately, not all COM objects have to have type libraries, so it isn't always possible to do this and then you have to fall back on reading the documentation for whatever COM object you are using. You can also embed a call to gencache.EnsureModule() into your code to generate the needed wrappers automatically: the output from makepy tells you this. The easy way to run makepy is to run PythonWin and use 'COM makepy utility' from its tool menu. Then all you have to do is figure out which of the type libraries in the system is the relevant one. -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
Hello, you only get information about a COM object when you have a wrapper. But you are using the dynamic invoke (Dispatch). So try the typelibrary browser in Pythonwin or use the generated wrapper with makepy or gencache.EnsureDispatch. But dir will give you only the methods and internal classes. The properties you get with OBJ._prop_map_get_.keys(). Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of bruno at modulix > Sent: Friday, April 28, 2006 10:29 AM > To: python-list@python.org > Subject: Re: Get all attributes of a com object > > eicwo01 wrote: > > Thanks for your tips. > > But dir() and inspect did not really help. > > Really ? > > def dump(obj): > for name in dir(obj): > print getattr(obj, name) > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in > p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Foriegn contents in Python Packages...
[EMAIL PROTECTED] wrote: > Is it possible to store "non-python" files in a directory that serves > as a Python Package? (Like an image file or an XML file.) > > Is this allowed for sub-directories that are not Python Packages? In > other words, can I have a Python Package that contains other Python > Packages and also folders that aren't Python Packages? Yes. And the __file__-attribute of an imported module gives you the location in the filesystem, so that you can access the contents in a path-agnostic way. AFAIK there is even some builtin stuff in setuptools to handle data files - go google :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: time conversions [hh:mm:ss.ms <-> sec(.ms)
On 28/04/2006 6:39 PM, kpp9c wrote: > Hi, > > I was looking at python & datetime and hoping that it would already > have > a method/func to translate time formats. I need to translate seconds to > hh:mm:ss.ms and vice versa and would like the ability to do some basic > arithmetic in these formats. Could you please be a little more specific? I guess that you have seconds-and-a-fraction in a float eg 3723.456 seconds, which is equivalent to 1 hour, 2 minutes and 3.456 seconds. How do you want that represented? You say hh:mm:ss.ms which could be interpreted as a string "01:02:03.456" -- but this format is not very useful for "basic arithmetic". OTOH a tuple representation like (1, 2, 3.456) can accommodate "arithmetic" of some sort or other more easily -- is that what you had in mind? Next question: exactly what basic arithmetic operations do you want to do in the hour-minute-second format, and why do you want to do them in that format, and not the seconds-only format? > I think that there just has to be a > package > or module out there that already does this with reasonable speed and > accuracy. Get the specification right first. Get the accuracy right second. Then worry about the speed. The "arithmetic" of which you speak can't be so mind-boggling that you can't write it in Python and test it yourself. You may find the specification changes under the influence of the implementation :-) > > Sadly, i do indeed need both reasonable speed and accuracy since i will > be adding up huge masses of small events (around 10 to 60 ms > milliseconds > in length) to create cloud like textures for real time audio/video at > high sampling rates. So why not keep it in seconds (or milliseconds)? Have you considered an extension, using C or Pyrex? > > i googled for hh:mm:ss.ms + python and didn't find much... > > best, > > -kp--- > > [mac os x w/ python 2.4.1] -- http://mail.python.org/mailman/listinfo/python-list
Re: time conversions [hh:mm:ss.ms <-> sec(.ms)
kpp9c wrote: > Hi, > > I was looking at python & datetime and hoping that it would already > have > a method/func to translate time formats. I need to translate seconds > to hh:mm:ss.ms and vice versa and would like the ability to do some > basic arithmetic in these formats. I think that there just has to be a > package > or module out there that already does this with reasonable speed and > accuracy. > > Sadly, i do indeed need both reasonable speed and accuracy since i > will be adding up huge masses of small events (around 10 to 60 ms > milliseconds > in length) to create cloud like textures for real time audio/video at > high sampling rates. > > i googled for hh:mm:ss.ms + python and didn't find much... > > best, > > -kp--- > > [mac os x w/ python 2.4.1] Hmmm ... not difficult to do, but it's the "speed" bit that's tricky. Here's quick and dirty implementation, but I wouldn't place any bets on it being fast (or accurate enough for that matter!) #!/bin/env python # vim: set noet sw=4 ts=4: import datetime def secs2time(s): ms = int((s - int(s)) * 100) s = int(s) # Get rid of this line if s will never exceed 86400 while s >= 24*60*60: s -= 24*60*60 h = s / (60*60) s -= h*60*60 m = s / 60 s -= m*60 return datetime.time(h, m, s, ms) def time2secs(d): return d.hour*60*60 + d.minute*60 + d.second + \ (float(d.microsecond) / 100) if __name__ == "__main__": for i in (8.123, 0.0, 5873, 12345.6789): print "%12.6f -> %15s -> %12.6f" % ( i, secs2time(i), time2secs(secs2time(i)) ) assert i == time2secs(secs2time(i)) from timeit import Timer timer = Timer( setup="from __main__ import time2secs, secs2time", stmt="time2secs(secs2time(12345.6789))") count = 100 total = timer.timeit(count) print "Time for %d invocations: %.10fs" % (count, total) print "Time per invocation: %.10fs" % (total / count,) And the output: 8.123000 -> 22:13:20.123000 -> 8.123000 0.00 ->00:00:00 -> 0.00 5873.00 ->01:37:53 -> 5873.00 12345.678900 -> 03:25:45.678900 -> 12345.678900 Time for 100 invocations: 9.3959178925s Time per invocation: 0.093959s Huh ... what d'ya know ... good thing I ain't a betting man! Dave. -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Duncan Booth wrote: > bruno at modulix wrote: > > >>eicwo01 wrote: >> >>>Thanks for your tips. >>>But dir() and inspect did not really help. >> >>Really ? >> >>def dump(obj): >> for name in dir(obj): >> print getattr(obj, name) >> > > > That will show him the attributes of the Python wrapper around the COM > object, it won't show him the attributes of the underlying COM object > itself. I stand corrected - and shouldn't answer questions about MS technos :( (snip) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: append function problem?
[EMAIL PROTECTED] wrote: > hello, recently i tried to use list.append() function in seemingly > logical ways, What seems logical and how it really works may not be the same... As a general rule, for builtin types, destructive methods returns None. I personnaly find it a wart, but what, it's the BDFL's choice. (snip) > I'm not sure why seed1 and the function doesn't recognize the list.. because list.append() modifys the list in place and returns None. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
[bruno at modulix] | Duncan Booth wrote: | > That will show him the attributes of the Python wrapper | around the COM | > object, it won't show him the attributes of the underlying | COM object | > itself. | | I stand corrected - and shouldn't answer questions about MS technos :( In fact, if a static wrapper has been built for the object in question, the usual help (), inspect () stuff will work, eg: import win32com.client # # Make sure a proxy module is built behind-the-scenes # word = win32com.client.gencache.EnsureDispatch ("Word.Application") help (word.__class__) class _Application(win32com.client.DispatchBaseClass) | Methods defined here: | | Activate(self) | | AddAddress(self, TagID=, Value=) | | AutomaticChange(self) | | BuildKeyCode(self, Arg1=, Arg2=, Arg3=, Arg4=) | | CentimetersToPoints(self, Centimeters=) | | ChangeFileOpenDirectory(self, Path=) | | CheckGrammar(self, String=) [snip] The only thing is that you can't always build a proxy module. I'm never quite sure why or why not. 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: MinGW and Python
Ames Andreas wrote: > 1) psychological issues: 'convenient IDE', 'better debugger' I prefer Eclipse when using MinGW. That IDE is on par with Visual Studio. And Python will be developed for GCC anyway. > 2) legal issues: redistribution of msvcrXX That is indeed the problem. msvcrXX cannot be redistributed with MinGW binaries. On the other hand, msvcrXX cannot be redistributed with py2exe standalones either. The current dependency on msvcrXX makes it illegal (mostly) to distribute standalone applications made with py2exe. You have to rely on msvcrXX already being installed in a system folder. The solution must be to get the msvcrXX dependency out of Python. > There remains one technical issue that isn't a killer but would > be inconvenient, IMHO: Can pywin32 be made working with a > mingw-python (I'm quite sure it can't be made building on it)? > I'd appreciate any datapoints about that ... Two issues: 1. COM. MinGW is not know to be the best compiler for COM development. Although MinGW binaries are COM ABI compatible. 2. MFC. A MinGW compiled MFC cannot be legally redistributed. -- http://mail.python.org/mailman/listinfo/python-list
Non-web-based templating system
Hi, I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this? Thanks, - QS Computing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression help
Edward Elliott wrote: > [EMAIL PROTECTED] wrote: >> If you are parsing HTML, it may make more sense to use a package >> designed especially for that purpose, like Beautiful Soup. > > I don't know Beautiful Soup, but one advantage regexes have over some > parsers is handling malformed html. Beautiful Soup is intended to handle malformed HTML and seems to do pretty well. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Serge Orlov wrote: > I extracted content.xml from a test file and the header is: > > > So any xml library should handle it just fine, without you trying to > guess the encoding. Yes my header also says UTF-8. However some kind person send me an e-mail stating that since I am getting \x94 and such output when using repr (even if str is giving correct output) there could be some problem with the XML-file not being completely UTF-8. Or is there some other reason I'm getting these \x94 codes? Or maybe this is just as it should be and there's no problem at all? Again? Anton 'octopussies respond only off-list' -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
[EMAIL PROTECTED] wrote: > Hi, > > I'm creating a small application in Python that uses lists and > dictionaries to create a rudimentary database. I'd like to create some > "fill-in-the-blanks" reports from this data, ideally by taking an RTF > or plaintext file as a template and replacing placeholder tags with my > data. > Are there any good pre-written systems that would allow me to do this? Maybe the built-in string interpolation is sufficient? print "Hello %(name)s" % dict(name="Peter Pan") diez -- http://mail.python.org/mailman/listinfo/python-list
Add file to zip, or replace file in zip
I have a script which zips up a directory, once it does with that (before it closes the zip file) I want to replace a file that was added to the zip, say "Foo.txt". So I tried this... [code] z = zipfile.ZipFile("blah.zip", "w") # zip the directory #... z.writestr("c:\\path\\to\\current\\foo_txt_file\\Foo.txt", "some new data") z.close() All this does is add a new Foo.txt file in the zip alongside the existing oneany suggestions? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > > >>Hi, >> >>I'm creating a small application in Python that uses lists and >>dictionaries to create a rudimentary database. I'd like to create some >>"fill-in-the-blanks" reports from this data, ideally by taking an RTF >>or plaintext file as a template and replacing placeholder tags with my >>data. >>Are there any good pre-written systems that would allow me to do this? > > > Maybe the built-in string interpolation is sufficient? > > print "Hello %(name)s" % dict(name="Peter Pan") > Else you may want to look at: - http://www.python.org/doc/2.4.2/whatsnew/node5.html - empy : http://www.alcyone.com/pyos/empy/ - cheetah : http://www.cheetahtemplate.org/ HTH -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
"Anton Vredegoor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Yes my header also says UTF-8. However some kind person send me an e-mail > stating that > since I am getting \x94 and such output when using repr (even if str is > giving correct > output) there could be some problem with the XML-file not being completely > UTF-8. Or is > there some other reason I'm getting these \x94 codes? Well that rather depends on what you are doing. If you take utf-8, decode it to Unicode, then re-encode it as cp1252 you'll possibly get \x94. OTOH, if you see '\x94' in a Unicode string, something is wrong somewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
On 28/04/2006 9:21 PM, Anton Vredegoor wrote: > Serge Orlov wrote: > >> I extracted content.xml from a test file and the header is: >> >> >> So any xml library should handle it just fine, without you trying to >> guess the encoding. > > Yes my header also says UTF-8. However some kind person send me an > e-mail stating that since I am getting \x94 and such output when using > repr (even if str is giving correct output) > there could be some problem > with the XML-file not being completely UTF-8. I deduce that I am the allegedly kind person. Firstly you have a problem with the "even if" part of "I am getting \x94 and such output when using repr (even if str is giving correct output)". Let txt = "\x93hello\x94". So you print repr(txt) and the result appears as '\x92hello\x94'. That is absolutely correct. It is an unambiguous REPRresentation of the string. In IDLE (or similar) on a Windows box (where the default encoding is cp1252) if you print str(txt) [or merely print txt] the display shows hello preceded/followed by the LEFT/RIGHT DOUBLE QUOTATION MARK (U+201C/U+201D) -- or some other pair of left/right thingies. That is also correct enough. Secondly, I stated nothing such about the XML-file. We were discussing "extracting from content.xml using OOopy's getiterator function". My point was that if you were seeing \x94 anywhere, THE OUTPUT FROM THAT FUNCTION must be encoded as cp1252. Here is the relevant part: == AV>> First I noticed that by extracting from content.xml using OOopy's getiterator function, some \x94 codes were left inside the document. AV>> But that was an *artifact*, because if one prints something using s.__repr__() as is used for example when printing a list of strings (duh) the output is not the same as when one prints with 'print s'. I guess what is called then is str(s). JM> Don't *guess*!!! AV>> Ok, now we have that out of the way, I hope. JM>> No, not quite. If you saw \x94 in the repr() output, but it looked "OK" when displayed using str(), then the only reasonable hypotheses are (a) the data was in an 8-bit string, presumably encoded as cp1252 (definitely NOT UTF-8), rather than a Unicode string (b) you displayed it via a file whose encoding was 'cp1252'. JM>> "... assuming something in the open office xml file was not quite 1252. In fact it wasn't, it was UTF-8 ..." --- another problem was assuming that the encoding used for the output of the OOopy interface (apparently cp1252; is there no documentation?) would be the same as in the .sxw file (UTF-8). === end of extract === > Or is there some other > reason I'm getting these \x94 codes? You are getting "these \x94 codes" when you do *WHAT* exactly? I refer you to Martin's unanswered questions: """What is the problem then? If you interpret the document as cp1252, and it contains \x93 and \x94, what is it that you don't like about that? In yet other words: what actions are you performing, what are the results you expect to get, and what are the results that you actually get?""" -- http://mail.python.org/mailman/listinfo/python-list
Re: python game with curses
Jerry, if you want anyone to answer your question, please read this: http://www.catb.org/~esr/faqs/smart-questions.html -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > In fact there are a lot of printable things that haven't got a text > attribute, for example some items with tag ()s. In my sample file I see , is that you're talking about? Since my file is small I can say for sure this tag represents two space characters. -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Richard Brodie wrote: > "Anton Vredegoor" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Yes my header also says UTF-8. However some kind person send me an e-mail >> stating that >> since I am getting \x94 and such output when using repr (even if str is >> giving correct >> output) there could be some problem with the XML-file not being completely >> UTF-8. Or is >> there some other reason I'm getting these \x94 codes? > > Well that rather depends on what you are doing. If you take utf-8, decode > it to Unicode, then re-encode it as cp1252 you'll possibly get \x94. OTOH, > if you see '\x94' in a Unicode string, something is wrong somewhere. Well, I mailed the content.xml to someone as a text attachment and it was damaged at the other end, whereas sending it as a file resulted in flawless transfer. So I guess there is something not quite UTF-8 in it. However Firefox has no problem opening it either here or at the other persons computer (the undamaged file of course). By the way, I also sent an MSwWord document (not as text) that I edited using OO back to the same person who is using MsWord and he is at the moment still recovering from an MSWord crash. Could it have something to do with the OO document being half as big as the MsWord Doc :-) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
Thanks, it looks like empy is what I need. -- http://mail.python.org/mailman/listinfo/python-list
Re: can i set up a mysql db connection as a class ?
So this opens and closes the connection every time i run the query? thats cool. i think that would fit in well. so when i need to run the query, i pass something like query = "SELECT * FROM `Table` WHERE `foo` = 'bar'" result = DB_Connector.Execute(query) and the result would be the same as if i ran the query right there in the thread? thanks for all your help gents, this is helping me a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: finding IP address of computer
Chris wrote: > How do I find and print to screen the IP address of the computer my > python program is working on? def readip(): import re, urllib f = urllib.urlopen('http://checkip.dyndns.org') s = f.read() m = re.search('([\d]*\.[\d]*\.[\d]*\.[\d]*)', s) return m.group(0) myip = readip() -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > Serge Orlov wrote: > > > I extracted content.xml from a test file and the header is: > > > > > > So any xml library should handle it just fine, without you trying to > > guess the encoding. > > Yes my header also says UTF-8. However some kind person send me an > e-mail stating that since I am getting \x94 and such output when using > repr (even if str is giving correct output) there could be some problem > with the XML-file not being completely UTF-8. Or is there some other > reason I'm getting these \x94 codes? Or maybe this is just as it should > be and there's no problem at all? Indeed, just load the file into ElementTree. Extending the example you posted before: data = zin.read(x) import elementtree.ElementTree as ET doc = ET.fromstring(data) officetag = "{http://openoffice.org/2000/office}"; body = self.doc.find(".//"+officetag+"body") for fragment in body.getchildren(): ... process one fragment of document's body ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex installation on windows XP: step-by-step guide
On 28 Apr 2006 01:06:55 -0700, Julien Fiore <[EMAIL PROTECTED]> wrote: I added "step A.5" to the guide and published it on the Python wiki, sothat anyone can update it easily:http://wiki.python.org/moin/PyrexOnWindows --http://mail.python.org/mailman/listinfo/python-listThanks to Julien and everyone who's helping on this! I've tried to play around with Pyrex several months ago and didn't have the time/knowledge to figure out why things weren't working. Chris-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > > Maybe the built-in string interpolation is sufficient? > > print "Hello %(name)s" % dict(name="Peter Pan") Or in recent pythons, the built-in string templating system (see http://docs.python.org/lib/node109.html) >>> from string import Template >>> d = dict(name="Barney") >>> s = Template("Hello $name") >>> s.substitute(d) 'Hello Barney' -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Serge Orlov wrote: > Anton Vredegoor wrote: >> In fact there are a lot of printable things that haven't got a text >> attribute, for example some items with tag ()s. > > In my sample file I see , is that you're talking > about? Since my file is small I can say for sure this tag represents > two space characters. Or for example in firefox: in Amsterdam So, probably yes. If it doesn't have a text attribrute if you iterate over it using OOopy for example: o = OOoPy (infile = fname) c = o.read ('content.xml') for x in c.getiterator(): if x.text: Then we know for sure you have recreated my other problem. Anton -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Tim Golden > Sent: Friday, April 28, 2006 11:45 AM > To: python-list@python.org > Subject: RE: Get all attributes of a com object > > [snip] > > The only thing is that you can't always build a proxy module. > I'm never quite sure why or why not. > You can only build a proxy module if you have the typelibrary information which not all programs provide, since it prohibits changes in the interface the easy way. E.g., MFC application will normally not provide a typelibrary but support dynamic dispatch. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > Serge Orlov wrote: > > > Anton Vredegoor wrote: > >> In fact there are a lot of printable things that haven't got a text > >> attribute, for example some items with tag ()s. > > > > In my sample file I see , is that you're talking > > about? Since my file is small I can say for sure this tag represents > > two space characters. > > Or for example in firefox: > > > in Amsterdam > > > So, probably yes. If it doesn't have a text attribrute if you iterate > over it using OOopy for example: > > o = OOoPy (infile = fname) > c = o.read ('content.xml') > for x in c.getiterator(): > if x.text: > > Then we know for sure you have recreated my other problem. I'm tweaking a small test file and see that is one space character is two space characters is three space characters -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Many thanks to all of you; I learned a lot and will come up next time hopefully with some less utopic project ... :-) Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
John Bokma wrote: > Eli Gottlieb <[EMAIL PROTECTED]> wrote: > > > Oh, God, not another one. > > Instead of cross posting more garbage, do as follows: > > Email a complaint to the email addresses you can look up yourself and > include the entire message of Xah: > > http://www.spamcop.net/sc?track=72.231.179.135posting host > http://www.spamcop.net/sc?track=xahlee.orgspamvertized > site Xah Lee has been around for a long time. I don't claim to understand him, but I don't think he is a troll- I think he is sincere in his postings, even if they are gibberish to everyone else. The only thing he is doing that should be considered abuse is crossposting to several groups (and he should certainly stop doing that). But he is only crossposting to about eight or so groups- hardly a Dave Rhodes incident. The great thing about Usenet is that it gives everyone a soapbox, even the slightly warped. Xah Lee should stop crossposting, but the fact that he is incoherent should not bar him from posting messages. He is actually a pretty interesting fellow when it comes to certain aspects of mathematics- I don't know if he still maintains his site about knot theory, but it was quite interesting, last time I looked. It's much easier to use a killfile than to complain to an ISP, and I think that that should be the preferred response to messages you don't like. Complaints to ISPs should be reserved for egregious abuse of the Usenet infrastructure. -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
[Stefan Schukat] | You can only build a proxy module if you have the typelibrary | information which not all programs provide, since it prohibits | changes in the interface the easy way. E.g., MFC application | will normally not provide a typelibrary but support dynamic | dispatch. Oh. Thanks. 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: not quite 1252
Anton Vredegoor wrote: > So, probably yes. If it doesn't have a text attribrute if you iterate > over it using OOopy for example: Sorry about that, I meant if the text attribute is None, but there *is* some text. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > Anton Vredegoor wrote: > > > So, probably yes. If it doesn't have a text attribrute if you iterate > > over it using OOopy for example: > > Sorry about that, I meant if the text attribute is None, but there *is* > some text. OK, I think I understand what you're talking about. It's ElementTree API. I have a special generator to process content of elements: def contents(e): """Yield sequence of subelements and text between subelements in the order as they come""" if e.text: yield e.text for sub_e in e.getchildren(): yield sub_e if sub_e.tail: yield sub_e.tail Example: >>> doc = ET.fromstring("""weatherin Amsterdamis >>> great""") >>> list(contents(doc)) ['weather', , 'in Amsterdam', , 'is great'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
[EMAIL PROTECTED] wrote: > Hi, > > I'm creating a small application in Python that uses lists and > dictionaries to create a rudimentary database. I'd like to create some > "fill-in-the-blanks" reports from this data, ideally by taking an RTF > or plaintext file as a template and replacing placeholder tags with my > data. > Are there any good pre-written systems that would allow me to do this? > > Thanks, > - QS Computing. > It may be overkill for your application but if you are looking for high quality .PDF output this combination works: ReportLab PageCatcher - reads .PDF background templates (note: not free) ReportLab - allows you to write on top of the .PDF template to produce a .PDF file as output. The results are a very high quality .PDF output document. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
Tagore Smith wrote: > It's much easier to use a killfile than to complain to an ISP, and I > think that that should be the preferred response to messages you don't > like. I'm inclined to agree. The problem is not Xah Lee (whom I have killfiled), but the people who insist on making my killfile useless by posting loads of follow-ups saying things amounting to "stop this insane gibberish". Every bloody time. Wake up, people ! You are not the victims, you are the problem. Shut up, /please/. (And yes, I do realise that I'm adding to the problem here, and indeed that I'm not following my own advice, nor heeding my own request.). -- chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Can one query full name (or version) of selected packages at pypi?
On Thu, Apr 20, 2006 at 02:26:02AM -0700, Caleb Hattingh wrote: > I could do these steps myself with normal http access and > screen-scraping, but is there already such a system/script somewhere? > Alternatively, how do you all keep versions of python addons > up-to-date? Manually? I use easy_install. Unfortunately not all packages work. Most notably the following failed last time I tried: twisted pygtk PIL win32all ctypes Mostly this is because they do something a little bit non standard with distutils. Newer versions of easy_install may have sorted these problems, I have not tried in the last month or two. http://peak.telecommunity.com/DevCenter/EasyInstall I hope that helps you out, Chris -- http://mail.python.org/mailman/listinfo/python-list
Awesome PySIG meeting last night
Ten folks attended the monthly Python Special Interest Group meeting, held monthly at the Amoskeag Business Incubator in Manchester. Ben was harassed. Announcements were made. Several Python gotchas were discussed. Paul Koning demonstrated a remarkable reinvention of the TECO (Tape Edit and COrrection system) in Python code. Interesting discussions on using a class definition as a dictionary to invoke single- and double-letter commands, even those not allowed as method names. Why exceptions are exceptional. Using wxPython to create a GUI screen for TECO like the PDP-11 VDT peripherals. The bang-up finale was running pi.tec - an inscrutable TECO macro that calculates Pi one digit at a time - to demonstrate his TECO compliance. Amazing. Regulars noted it ran much faster on Paul's laptop than it used to on a PDP-11, too. Next Month's meeting is May 25th and Ray Cote may demonstrate a recent application he's developed in Python. Stay tuned for details. Ted Roche Ted Roche & Associates, LLC http://www.tedroche.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Awesome PySIG meeting last night
On 4/28/06, Ted Roche <[EMAIL PROTECTED]> wrote: > Ten folks attended the monthly Python Special Interest Group meeting, > held monthly at the Amoskeag Business Incubator in Manchester. > > Ben was harassed. I must say, the level of harrassment was fairly low. I expect a higher quality of heckling from this group. Don't let it happen again. -- Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > Anton Vredegoor wrote: > > > So, probably yes. If it doesn't have a text attribrute if you iterate > > over it using OOopy for example: > > Sorry about that, I meant if the text attribute is None, but there *is* > some text. OK, I think I understand what you're talking about. It's ElementTree API. I have a special generator to process content of elements: def contents(e): """Yield sequence of subelements and text between subelements in the order as they come""" if e.text: yield e.text for sub_e in e.getchildren(): yield sub_e if sub_e.tail: yield sub_e.tail Example: >>> doc = ET.fromstring("""weatherin Amsterdamis >>> great""") >>> list(contents(doc)) ['weather', , 'in Amsterdam', , 'is great'] -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
Anton Vredegoor wrote: > Serge Orlov wrote: > > > Anton Vredegoor wrote: > >> In fact there are a lot of printable things that haven't got a text > >> attribute, for example some items with tag ()s. > > > > In my sample file I see , is that you're talking > > about? Since my file is small I can say for sure this tag represents > > two space characters. > > Or for example in firefox: > > > in Amsterdam > > > So, probably yes. If it doesn't have a text attribrute if you iterate > over it using OOopy for example: > > o = OOoPy (infile = fname) > c = o.read ('content.xml') > for x in c.getiterator(): > if x.text: > > Then we know for sure you have recreated my other problem. I'm tweaking a small test file and see that is one space character is two space characters is three space characters -- http://mail.python.org/mailman/listinfo/python-list
Re: Twisted and Tkinter
Fredrik is right, ChatFactory doesn't have sendLine as a method b/c it doesn't inherit it from ClientFactory. The code: protocol = ChatClient does do anything within ChatFactory except set the variable. Try out these. from twisted.protocols.basic import LineReceiver, LineReceiver.sendLine or change class ChatFactory(ClientFactory) --- to: class ChatFactory(ClientFactory, LineReceiver): or tell ChatFactory that sendLine comes from LineReceiver -- class ChatFactory(ClientFactory): protocol = ChatClient def clientConnectionFailed(self, connector, reason): reactor.stop() def clientConnectionLost(self, connector, reason): reactor.stop() def sendMessage(self): self.LineReceiver.sendLine("Test") I'm pretty sure that those should work. -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
Chris Uppal wrote: > I'm inclined to agree. The problem is not Xah Lee (whom I have killfiled), > but > the people who insist on making my killfile useless by posting loads of > follow-ups saying things amounting to "stop this insane gibberish". ... well, this is the problem with killfiles. Some clients do allow you to kill all threads and subthreads that are started by anyone in your killfile. -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
> > > > Wake up, people ! You are not the victims, you are the problem. Shut up, > > > > /please/. > > > > > > Cannot agree more! > > > > > > Wake up, people ! You are not the victims, you are the problem. Shut up, > > > /please/. > > > > Wholeheartedly agree! > > > > Wake up, people ! You are not the victims, you are the problem. Shut up, > > /please/. > > So true! > > Wake up, people ! You are not the victims, you are the problem. Shut up, > /please/. > Me too! Wake up, people ! You are not the victims, you are the problem. Shut up, /please/. -- http://mail.python.org/mailman/listinfo/python-list
Re: time conversions [hh:mm:ss.ms <-> sec(.ms)
kpp9c wrote: > I was looking at python & datetime and hoping that it would already > have a method/func to translate time formats. I need to translate seconds > to hh:mm:ss.ms and vice versa and would like the ability to do some basic > arithmetic in these formats. Have a look at datetime.timedelta: from datetime import timedelta seconds_value = 4237.63 td = timedelta(seconds=seconds_value) print td# Shows 1:10:37.63 print td.seconds# Shows 4237 other_td = td + timedelta(seconds=13) print other_td# Shows 1:10:50.63 print other_td.seconds# Shows 4250 > I think that there just has to be a package or module out there that > already does this with reasonable speed and accuracy. The accuracy seems perfect, don't know about speed - take some test :) Regards -- Faber http://faberbox.com/ http://smarking.com/ We live in a society exquisitely dependent on science and technology, in which hardly anyone knows anything about science and technology. -- Carl Sagan -- http://mail.python.org/mailman/listinfo/python-list
best way to determine sequence ordering?
If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'], and then figure out if a certain element precedes another element, what would be the best way to do that? Looking at the built-in list functions, I thought I could do something like: if L.index('A') < L.index('D'): # do some stuff But I didn't know if maybe there was a preferred method for this type of operation, or perhaps a better function to use to figure out the ordering. Or even if I wanted to write my own utility function to make it look cleaner than above, I'd still need to use something like above in my function, so I wanted to know what might be the 'cleanest' looking solution. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
ANN: Leo 4.4 rc1 released
Leo 4.4 release candidate 1 is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This version fixes a few minor bug reported in 4.4b4 and adds 9 new commands. The open-outline-by-name command supports filename completion. Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.4: -- - An Emacs-like mini-buffer: you can now execute any command by typing its long name, with tab completion. - Many new commands, including cursor and screen movement, basic character, word and paragraph manipulation, and commands to manipulate buffers, the kill ring, regions and rectangles. You can use Leo without using a mouse. - Flexible key bindings and input modes. You can emulate the operation of Emacs, Vim, or any other editor. - A tabbed log pane. The Find and Spell Check commands now use tabs instead of dialogs, making those commands much easier to use. Plugins or scripts can easily create new tabs. The Completion tab shows possible typing completions. - Autocompletion and calltips. - Dozens of other new features and bug fixes since Leo 4.3.3. Links: -- Leo: http://webpages.charter.net/edreamleo/front.html Home: http://sourceforge.net/projects/leo/ Download: http://sourceforge.net/project/showfiles.php?group_id=3458 CVS: http://leo.tigris.org/source/browse/leo/ Quotes: http://webpages.charter.net/edreamleo/testimonials.html Edward Edward K. Ream email: [EMAIL PROTECTED] Leo: http://webpages.charter.net/edreamleo/front.html -- http://mail.python.org/mailman/listinfo/python-list
os.startfile() - one or two arguments?
Can any Windows user give a working example of adding a "command verb" to os.startfile()? When I try it, it squawks that it takes only one argument. >>> os.startfile('d:/','explore') Traceback (most recent call last): File "", line 1, in ? TypeError: startfile() takes exactly 1 argument (2 given) from os module startfile( path[, operation]) Start a file with its associated application. When operation is not specified or 'open', this acts like double-clicking the file in Windows Explorer, or giving the file name as an argument to the start command from the interactive command shell: the file is opened with whatever application (if any) its extension is associated. When another operation is given, it must be a ``command verb'' that specifies what should be done with the file. Common verbs documented by Microsoft are 'print' and 'edit' (to be used on files) as well as 'explore' and 'find' (to be used on directories). Thanks, rpd "Give a man a fire and keep him warm for a day. Light a man on fire and he will be warm for rest of his life." --Terry Pratchett -- http://mail.python.org/mailman/listinfo/python-list
Re: os.startfile() - one or two arguments?
On 28 Apr 2006 08:06:02 -0700, BartlebyScrivener <[EMAIL PROTECTED]> wrote: Can any Windows user give a working example of adding a "command verb"to os.startfile()?When I try it, it squawks that it takes only one argument.>>> os.startfile('d:/','explore') ry: os.startfile(["d:/", "explore"]) you want a list for the args Traceback (most recent call last): File "", line 1, in ? TypeError: startfile() takes exactly 1 argument (2 given)from os modulestartfile( path[, operation])Start a file with its associated application.When operation is not specified or 'open', this acts like double-clicking the file in Windows Explorer, or giving the file nameas an argument to the start command from the interactive command shell:the file is opened with whatever application (if any) its extension is associated.When another operation is given, it must be a ``command verb'' thatspecifies what should be done with the file. Common verbs documented byMicrosoft are 'print' and 'edit' (to be used on files) as well as 'explore' and 'find' (to be used on directories).Thanks,rpd"Give a man a fire and keep him warm for a day. Light a man on fire andhe will be warm for rest of his life." --Terry Pratchett --http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-web-based templating system
<[EMAIL PROTECTED]> wrote: > Hi, > > I'm creating a small application in Python that uses lists and > dictionaries to create a rudimentary database. I'd like to create some > "fill-in-the-blanks" reports from this data, ideally by taking an RTF > or plaintext file as a template and replacing placeholder tags with my > data. > Are there any good pre-written systems that would allow me to do this? I have a certain fondness for the first over-100-lines module I wrote for Python, which eventually resulted in: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52305 and while I haven't checked its descendant: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/465508 it may have important enhancements. There are also a couple of variations on the web that are specialized for XML and HTML (search for yaptu), but the generic one should work better for RTF and TXT. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: os.startfile() - one or two arguments?
BartlebyScrivener wrote: > Can any Windows user give a working example of adding a "command verb" > to os.startfile()? > > When I try it, it squawks that it takes only one argument. > os.startfile('d:/','explore') > Traceback (most recent call last): > File "", line 1, in ? > TypeError: startfile() takes exactly 1 argument (2 given) Works fine for me with Python 2.5a2 on Win2K I ran: os.startfile('c:/','explore') And an explorer window popped up. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
RE: os.startfile() - one or two arguments?
[BartlebyScrivener] | Can any Windows user give a working example of adding a "command verb" | to os.startfile()? I'm afraid the core Python version of this command has only grown the command verb since 2.5a1. Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.startfile ("c:/temp.txt", "print") Traceback (most recent call last): File "", line 1, in ? TypeError: startfile() takes exactly 1 argument (2 given) >>> >>> But Python 2.5a1 (r25a1:43589, Apr 5 2006, 10:36:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.startfile ("c:/temp.txt", "print") >>> You can, however, use the pywin32 extensions in any version. For example: http://timgolden.me.uk/python/win32_how_do_i/print.html#shellexecute 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: os.startfile() - one or two arguments?
BartlebyScrivener wrote: > Can any Windows user give a working example of adding a "command verb" > to os.startfile()? > > When I try it, it squawks that it takes only one argument. > os.startfile('d:/','explore') > Traceback (most recent call last): > File "", line 1, in ? > TypeError: startfile() takes exactly 1 argument (2 given) > > from os module > > startfile(path[, operation]) > Start a file with its associated application. > > When operation is not specified or 'open', this acts like > double-clicking the file in Windows Explorer, or giving the file name > as an argument to the start command from the interactive command shell: > the file is opened with whatever application (if any) its extension is > associated. > > When another operation is given, it must be a ``command verb'' that > specifies what should be done with the file. Common verbs documented by > Microsoft are 'print' and 'edit' (to be used on files) as well as > 'explore' and 'find' (to be used on directories). The optional second argument was added in Python 2.5 (currently in alpha). These examples work for me, with python 2.5a2: os.startfile("Rechnung-28.10.pdf", "print") os.startfile("c:\\", "explore") Thomas -- http://mail.python.org/mailman/listinfo/python-list
Using Databases in Python
I would like to know if anybody can point me to the site, where it is possible to find the tutorial "Using Databases in Python" which is mentioned by Steve Holden here: http://tinyurl.com/ectj8 Thanks Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list
Re: Converstion
the del version - is that an optimisation? Is it actually faster? - I did not have enough info. to check so just did what came naturally to me :-) - Pad. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.startfile() - one or two arguments?
Whoops! Sorry all. I was using the "in-development" version of the documentation and didn't even realize it. Thank you, Rick -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing a function in-memory and in-place
Thanks for the answers, very helpful. I think I'm going to give Peter's hack a try, as it's actually quite close to what I'm trying to do -- I get the source for the new function, then that lets me make the old function become the new one. But I'll probably also use Michael's solution for class editing. Now I just have to figure out how to take in-memory structures and turn them into Python source code. Hmm... that actually leads me back to Michael's solution more, since in that model you are always dealing with source, and if you faithfully reproduce the source then you should more-or-less reproduce the same structures. Hmm... challenging. I guess this is one motivation for languages like Smalltalk to use an image, because they don't have to serialize code as source. Of course, I could use one of those pickle alternatives that knows how to pickle live objects; but that takes the project much further from normal Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
On 27 Apr 2006 12:06:44 -0700, sturlamolden <[EMAIL PROTECTED]> wrote: > > Alex Martelli wrote: > > > Provides the core msvcrt.lib for msvcr71.dll against which to link > > your extensions. This is critically important, as without it you are > > going to wind up linking against the wrong run-time and will see crashes > > whenever a core object such as a file is shared across run-time > > barriers. > > You can find msvcr71.dll in the same directory as Python. > > The problem is that you cannot redistribute msvcr71.dll unless you by a > copy of Visual Studio 2003 or install VC++ Toolkit 2003. As far as I > can tell, the .NET SDK license does not give you permission to > redistribute msvcr71.dll. So if you are going to use Py2Exe, this is a > dead end. But if you are just going to build a Python extension, you > don't need to redistribute the DLL (it's already in Python). In that > case you can use MinGW insted. Just make sure MinGW links with the > correct CRT. That is, open > > c:\mingw\lib\gcc\mingw32\3.4.2\specs > > in an editor and change "-lmsvcrt" to "-lmsvcr71" > > There is a second advantage with this. MinGW is an optimizing compiler. > The C/C++ compiler you get from the .NET SDK is not. This is untrue - the MSVC compiler in the VS 2003 Toolkit is exactly the same compiler that ships with real visual studio, and does excellent optimization. Modulo all the extremely correct comments in this thread about how useless it is to make comments about the optimization capabilities of a compiler, I find that the VS 2003 compiler generally generates faster and (often much) smaller code than GCC/mingw >There is a "Visual > C++ 2005 Express" edition which has an optimizing compiler. But it > links yet another version of the CRT, msvcr80.dll, and does not give > you permission to redistribute msvcr71.dll. > There are numerous distribution issues with the VS 2005 runtimes (I don't want to get into them now) besides the legal ones, but it's useless for building extension modules unless you also re-build Python (and then your Python can't use any other extension modules). It's workable for people embedding Python and probably not anyone else. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Converstion
Paddy wrote: > the del version - is that an optimisation? > Is it actually faster? del x[-1:] # or del x[-1] if you are sure that len(x) > 0 just deletes the last item (if any) from x whereas x = x[:-1] copies all but the last item of the original list into a new one. This can take much longer: [copy 1 lists with 5000 items on average] $ python -m timeit -n1 -s'data = range(1)' 'data = data[:-1]' 1 loops, best of 3: 38.9 usec per loop [remove the last item from a list 1 times] $ python -m timeit -n1 -s'data = range(1)' 'del data[-1:]' 1 loops, best of 3: 0.272 usec per loop $ python -m timeit -n1 -s'data = range(1)' 'del data[-1]' 1 loops, best of 3: 0.246 usec per loop Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: How to align the text of a Listbox to the right
Leonardo da Vinci wrote: >> to limit the width to something acceptable, and show >> only the tail of the line. > > Yes, this is exactly what I wanted to do. Do you know a way to > accomplish that? Because Eric Brunel said it is impossible on a > Listbox. Use a string slice. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.startfile() - one or two arguments?
Neat tutorial. Thank you! Rick -- http://mail.python.org/mailman/listinfo/python-list
wxPython problem
I'm a little confused. I installed wxPython on my Thinkpad T23, on which I'm running Fedora Core 5. I did it using Yum and Yumex, and everything installed fine. In fact, I now have PyShell and PyCrust in my applications. Within those two apps I can use wx as a module. But from the bash shell, when I use the same old Python interpreter, I can't use the wx module. It's there, under /usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/ (under that directory there are several directories: wx, wxPython). I don't know what to do now. Do I need to move the wx directory up directly under the site-packages directory? Please help, thanks... -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Databases in Python
It might be in his book, Python Web Programming, or just go to http://www.holdenweb.com/ and ask him yourself using the contact form. He's a generous contributor here. rick -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP techniques in Python
Dennis Lee Bieber wrote: > On Thu, 27 Apr 2006 14:32:15 -0500, Philippe Martin > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> What then is the point of the double underscore (if any) ?: > > To prevent masking/shadowing of inherited attributes... Note that it can fail to do this if you accidentally (or purposefully) name a class the same as a parent or ancestor class: >>> class Confusion(object): ... def __init__(self): ... self.__str = 'module 1' ... def get_module_1_confusion(self): ... return self.__str ... >>> module_1_confusion = Confusion >>> class Confusion(module_1_confusion): ... def __init__(self): ... self.__str = 'module 2' ... >>> module_2_confusion = Confusion >>> module_2_confusion().get_module_1_confusion() 'module 2' So you still need to at least check that the name of your subclass is different from the name of all its ancestors. This doesn't come up that often, but I know a few people have been bitten by it. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: MinGW and Python
Ames Andreas wrote: > There remains one technical issue that isn't a killer but would > be inconvenient, IMHO: Can pywin32 be made working with a > mingw-python (I'm quite sure it can't be made building on it)? > I'd appreciate any datapoints about that ... It all depends on what CRT version you link Python with. If you use mingw32 to link Python with msvcr71.dll, nothing would change for pywin32 compared to Python 2.4. OTOH, nothing would change for anybody else, either. If you link Python with msvcrt.dll, you would need to build pywin32 with a version of MFC that also links with msvcrt.dll. I understand VC6 would work; not sure whether pywin32 can still be built with VC6. In any case, requiring an even older version of the MS compiler isn't such a tempting idea, either. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Converstion
Peter Otten wrote: > del x[-1:] # or del x[-1] if you are sure that len(x) > 0 > just deletes the last item (if any) from x whereas > x = x[:-1] > copies all but the last item of the original list into a new one. This can > take much longer: But his data is a string, which is immutable but heavily optimized: $ python -m timeit -n1 -s'data = range(1)' 'data = data[:-1]' 1 loops, best of 3: 41.9 usec per loop $python -m timeit -n1 -s'data = range(1)' 'del data[-1:]' 1 loops, best of 3: 0.244 usec per loop $ python -m timeit -n1 -s'data = "abcdefghij"*1000' 'data = data[:-1]' 1 loops, best of 3: 1.7 usec per loop $ python -m timeit -n1 -s'data = "abcdefghijklm"*1000' 'del data[-1:]' [traceback omitted] TypeError: object doesn't support slice deletion -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython problem
[EMAIL PROTECTED] wrote: > I'm a little confused. I installed wxPython on my Thinkpad T23, on > which I'm running Fedora Core 5. I did it using Yum and Yumex, and > everything installed fine. In fact, I now have PyShell and PyCrust in > my applications. Within those two apps I can use wx as a module. But > from the bash shell, when I use the same old Python interpreter, I > can't use the wx module. It's there, under > /usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/ (under that > directory there are several directories: wx, wxPython). I don't know > what to do now. Do I need to move the wx directory up directly under > the site-packages directory? Any chance that there is a python 2.3 interpreter running on the command-line? Debian for example has python2.4 & python2.3, and the latter is set as default. So try starting python2.4 Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython problem
No, it's python2.4. It says there's no module wx...hmm. -- http://mail.python.org/mailman/listinfo/python-list
RE: MinGW and Python
> -Original Message- > From: "Martin v. Löwis" [mailto:[EMAIL PROTECTED] > Sent: Friday, April 28, 2006 6:20 PM > Subject: Re: MinGW and Python > > It all depends on what CRT version you link Python with. If you > use mingw32 to link Python with msvcr71.dll, nothing would change > for pywin32 compared to Python 2.4. OTOH, nothing would change > for anybody else, either. I'm more concerned that it might expose some C++ code (symbols) to other python code but I haven't looked at pywin32's implementation so I can't really tell. If it does, one shouldn't use it with _any_ compiler other than the one used to build pywin32. Even a mix of different ms-compilers would be dangerous, IMHO. cheers, aa -- Andreas Ames | Programmer | Comergo GmbH | Voice: +49 69 7505 3213 | ames AT avaya . com -- http://mail.python.org/mailman/listinfo/python-list
wxPython, wxcombobox opening
Hi, Does somebody knows a way to automaticely open the list part of a wxCombobox when it gets the focus ? tia, Rony -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
"Tagore Smith" <[EMAIL PROTECTED]> wrote: > It's much easier to use a killfile than to complain to an ISP, and I > think that that should be the preferred response to messages you don't > like. No, since even if you kill file Xah Lee, he keeps wasting resources of people who have dedicated equipment to support Usenet. > Complaints to ISPs should be reserved for egregious abuse of the > Usenet infrastructure. I consider this abuse, and since the reports are taken serious atm, it looks like the ISP / USP / hosting provider *agree* with my POV. It's their call anyway. Maybe you like to look away when someone throws garbage on the street, thinking: who cares, it will be cleaned away by the end of the week. I don't like the sight of it, and also know that some garbage ends up in the sewer system, causing all kinds of problems. -- John Bokma Freelance software developer & Experienced Perl programmer: http://castleamber.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
"Chris Uppal" <[EMAIL PROTECTED]> wrote: > I'm inclined to agree. The problem is not Xah Lee (whom I have > killfiled), but the people who insist on making my killfile useless by > posting loads of follow-ups saying things amounting to "stop this > insane gibberish". Every bloody time. Yup, and since that never stops, I make sure the source is going to dry up. -- John Bokma Freelance software developer & Experienced Perl programmer: http://castleamber.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Awesome PySIG meeting last night
On Apr 28, 2006, at 10:31 AM, Ben Scott wrote: > I must say, the level of harrassment was fairly low. I expect a > higher quality of heckling from this group. Don't let it happen > again. Be careful what you wish for! Ted Roche Ted Roche & Associates, LLC http://www.tedroche.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython problem
What I'm wondering is, perhaps it has something to do with the wx.pth file? I can't seem to find anything in the documentation about what the path should be, which file it should be pointing to. Scott -- http://mail.python.org/mailman/listinfo/python-list
Urllib2 / add_password method
I'm working on learning how to use urllib2 to use a proxy server. I've looked through the postings on this group, and it's been helpful. I have not, however, found complete documentation on the add_password() functions. Here's what I've got so far: # import urllib2 url = 'http://some.server/form.php' proxy_url = 'http://202.62.252.3:8080' # A publicly available anonymous proxy server proxy_handler = urllib2.ProxyHandler( {'http': proxy_url } ) proxy_auth_handler = urllib2.HTTPBasicAuthHandler() proxy_auth_handler.add_password('realm', 'host', 'username', 'password') opener = urllib2.build_opener(proxy_handler, proxy_auth_handler) urllib2.install_opener(opener) try: handler = urllib2.urlopen(url) except urllib2.URLError: print "whoops!" else: print handler.read() #=== It works, but I don't really know what I'm doing with the proxy_auth_handler part. Specifying username and password make sense, but I haven't found documentation on what 'realm' and 'host' are for. Shouldn't username & password be sufficient? Thanks, --Steve ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list
Re: (was Re: Xah's Edu Corner: Criticism vs Constructive Criticism)
"Tagore Smith" <[EMAIL PROTECTED]> wrote: > > Chris Uppal wrote: > >> I'm inclined to agree. The problem is not Xah Lee (whom I have >> killfiled), but the people who insist on making my killfile useless >> by posting loads of follow-ups saying things amounting to "stop this >> insane gibberish". > > ... well, this is the problem with killfiles. Some clients do allow > you to kill all threads and subthreads that are started by anyone in > your killfile. Yup, in short: stop Xah, and many people don't have to keep their kill files up to date, or switch to a different usenet client. Isn't it crazy that one person is allowed to create such a huge mess everytime he posts? -- John MexIT: http://johnbokma.com/mexit/ personal page: http://johnbokma.com/ Experienced programmer available: http://castleamber.com/ Happy Customers: http://castleamber.com/testimonials.html -- http://mail.python.org/mailman/listinfo/python-list
Summer of Code mailing list
There's a new SoC mailing list. [EMAIL PROTECTED] You can sign up here: http://mail.python.org/mailman/listinfo/soc2006 This list is for any SoC discussion: mentors, students, idea, etc. Student can submit applications starting May 1, so now is the time to get students interested in your ideas! Please pass this information along. Cheers, n -- http://mail.python.org/mailman/listinfo/python-list