Re: xml-filter with XMLFilterBase() and XMLGenerator() shuffles attributes
def startElement(self, name, attrs): self.__downstream.startElement(name, attrs) return I want prevent it from shuffling attributes, i.e. preserve original file's attribute order. Is there any ContentHandler.features* responsible for that? I suspect not. attrs is a dictionary which does not maintain order, and XML attributes are unordered to begin with. Is there any reason other than aesthetics that you want the order preserved? It shouldn't matter to any upstream consumer of the filtered XML. -- http://mail.python.org/mailman/listinfo/python-list
draggable Tkinter.Text widget
Inspired by effbot's recent Vroom! editor, I have been toying with my own version. I'd like to make the Text widget draggable, kind of like how you can drag a PDF document up and down in Adobe Reader. Here's what I have so far: from Tkinter import * class Draggable(Text, object): def __init__(self, parent, **options): Text.__init__(self, parent, **options) self.config( borderwidth=0, font={Lucida Console} 10, foreground=green, background=black, insertbackground=white, # cursor selectforeground=green, # selection selectbackground=#008000, wrap=WORD, # use word wrapping undo=True, width=80, ) self.bind('Button-3', self.handle_mousedown3) self.bind('B3-Motion', self.handle_drag3) def handle_mousedown3(self, event=None): self._y = event.y def handle_drag3(self, event=None): self.yview_scroll(self._y - event.y, UNITS) self._y = event.y if __name__ == '__main__': root = Tk() root.protocol(WM_DELETE_WINDOW, root.quit) root.config(background='black') root.wm_state(zoomed) text = Draggable(root) text.delete(1.0, END) text.insert(END, '\n'.join(str(x) for x in xrange(1, 1001))) text.pack(fill=Y, expand=True) root.mainloop() This works fine, but because the mouse movements are in pixels and scroll actions are in lines, the 'magnitude' of the scrolling is much larger than the mouse movements causing them. This isn't all bad, it makes scanning a long document quickly easier, but I was wondering if there was a simple way to add some friction to the scrolling so a tiny mouse movement doesn't cause the text to go zipping by in a flash. Thanks, infidel -- http://mail.python.org/mailman/listinfo/python-list
Re: __call__ considered harmful or indispensable?
I find it useful in certain situations. In particular, I have used it along with cx_Oracle to provide a python module that dynamically mirrors a package of stored procedures in the database. Basically I had class StoredProcedure(object) and each instance of this class represented a particular stored procedure in the database. It just made sense to use the __call__ method to make these instances callable. Seemed silly to use some other method to actually call the stored procedure in the database from such an instance. -- http://mail.python.org/mailman/listinfo/python-list
Re: list.append not working?
On Jul 5, 8:58 am, Hardy [EMAIL PROTECTED] wrote: I experience a problem with append(). This is a part of my code: for entity in temp: md['module']= entity.addr.get('module') md['id']=entity.addr.get('id') md['type']=entity.addr.get('type') #print md mbusentities.append(md) #print mbusentities I want something like: [{'module': 'home', 'id': 123, 'type': 'core'}, {'module': 'work', 'id': 456, 'type': 'core'}] md is always correct, BUT:mbusentities is wrong. Length of mbusentities is same of temp, so it appended everything. BUT: mbusentities only shows the values of the last append: [{'module': 'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456, 'type': 'core'}] What's wrong? You're reusing the same md dictionary over and over, appending the same object to the list each time. So what you have is a list of references to the same dictionary. You need to set md = {} first thing each iteration. -- http://mail.python.org/mailman/listinfo/python-list
Help building GUI with Tix
I am trying to build a GUI using the Tix module. What I want is a paned window with a tree in the left pane and a notebook in the right pane. I keep getting an error that I don't understand when adding these widgets to the panes: PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information. import Tix app = Tix.Tk(Demo) panes = Tix.PanedWindow(app) panes.pack(fill=Tix.BOTH, expand=True) tree = Tix.Tree(panes) panes.add(tree) Traceback (most recent call last): File interactive input, line 1, in module File C:\Program Files\Python25\lib\lib-tk\Tix.py, line 1220, in add self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) TclError: bad window path name .16442432..16442432 What am I missing? TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: Help building GUI with Tix - solution
I figured it out after finding an example somewhere: import Tix app = Tix.Tk(Demo) panes = Tix.PanedWindow(app) left = panes.add('left') right = panes.add('right') tree = Tix.Tree(left) notebook = Tix.NoteBook(right) tree.pack() notebook.pack() panes.pack() app.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: SimplePrograms challenge
# writing/reading CSV files, tuple-unpacking, cmp() built-in import csv writer = csv.writer(open('stocks.csv', 'wb')) writer.writerows([ ('GOOG', 'Google, Inc.', 505.24, 0.47, 0.09), ('YHOO', 'Yahoo! Inc.', 27.38, 0.33, 1.22), ('CNET', 'CNET Networks, Inc.', 8.62, -0.13, -1.49) ]) stocks = csv.reader(open('stocks.csv', 'rb')) for ticker, name, price, change, pct in stocks: print '%s is %s (%s%%)' % ( name, {-1: 'down', 0: 'unchanged', 1: 'up'}[cmp(float(change), 0.0)], pct ) -- http://mail.python.org/mailman/listinfo/python-list
Re: REALLY need help with iterating a list.
On Jun 11, 11:30 am, Radamand [EMAIL PROTECTED] wrote: This has been driving me buggy for 2 days, i need to be able to iterate a list of items until none are left, without regard to which items are removed. I'll put the relevant portions of code below, please forgive my attrocious naming conventions. Basically i'm trying to spin up some subprocesses that will ping a group of servers and then wait until all of them have completed (good or bad), store the ping result and the return code, and move on. The problem comes in the second block, when i try to iterate the list of servers and remove the ones that are finished, for some reason Python appears to re-index the list when I remove an item and the next step through the loop it cant find the item its expecting because the indexes have changed. Any assistance would be appreciated... = for server in serverlist: ping[server] = subprocess.Popen(ping -c 1 + str(server) + 5, shell=True, stdout=subprocess.PIPE) while len(serverlist) 0: for server in serverlist: if ping[server].returncode==None: ping[server].poll() else: pingresult[server] = ping[server].stdout.read() pingreturncode[server] = ping[server].returncode serverlist.remove(server) How about something like this? while serverlist: server = serverlist.pop(0) pinger = ping[server] if pinger.returncode==None: pinger.poll() serverlist.append(server) else: pingresult[server] = pinger.stdout.read() pingreturncode[server] = pinger.returncode Basic idea: as long as there are servers in the list, pop the first one out of the list, see if it's done, and if it isn't, put it back on the end of the list. -- http://mail.python.org/mailman/listinfo/python-list
Re: SimplePrograms challenge
# reading CSV files, tuple-unpacking import csv #pacific.csv contains: #1,CA,California #2,AK,Alaska #3,OR,Oregon #4,WA,Washington #5,HI,Hawaii reader = csv.reader(open('pacific.csv')) for id, abbr, name in reader: print '%s is abbreviated: %s' % (name, abbr) -- http://mail.python.org/mailman/listinfo/python-list
Re: A bug in cPickle?
ActivePython 2.5.1.1 as well: PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information. from pickle import dumps from cPickle import dumps as cdumps print dumps('10') S'10' p0 . print dumps(str(10)) S'10' p0 . print cdumps('10') S'10' p1 . print cdumps(str(10)) S'10' . -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate report containing pdf or ps figures?
On Apr 23, 9:30 am, Grant Edwards [EMAIL PROTECTED] wrote: I need to be able to generate a PDF report which consists mostly of vector images (which I can generate as encapsulated Postscript, PDF, or SVG). What I need is a way to combine these figures into a single PDF document. Right now the reports consist entire of these figures, so I just write the figures out to temp files and then use os.system() to run ghostscript with appropriate options to combine them into a single PDF file. I'd like to be able to add some text and/or place the figures in a manner other than one per page in the output document. I've looked at ReportLab's documentation, but although it appears to be able to use bitmap images (e.g jpeg) it doesn't appear to be able to use vector images (EPS/PDF/SVG). Is there a PDF generation library that can place EPS or PDF figures on a page? I've had great success using Apache's FOP utility (http:// xmlgraphics.apache.org/fop) to generate PDFs out of XSL-FO, which can contain SVG graphics (at least the 0.20.5 version can, the newer rewrite version doesn't yet). FOP is a java library but has a suitable command line interface. -- http://mail.python.org/mailman/listinfo/python-list
Re: The decentralized nature of the Python community is driving me crazy
And then you have discussion and yet again, there is no perlmonks.org for Python. We have this, IRC, and what else? There's also http://planet.python.org, which is an aggregator of python blogs that I check many times a day for new posts. -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance?
Yes I believe so but in fromfile I want to call the appropriate method depending on the in a parameter in fromfile... like: class baseClass: def fromfile(self, fileObj, byteOrder=None, explicit=False): if explicit: call fromfile of explicit class else: call fromfile of implicit class class baseClass: def fromfile(self, fileObj, **kwargs): raise NotImplementedError() class implicitClass: def fromfile(self, fileObj, **kwargs): byteOrder = kwargs.get('byteOrder', None) # do something class explicitClass: def fromfile(self, fileObj, **kwargs): # do something -- http://mail.python.org/mailman/listinfo/python-list
Re: converting a nested try/except statement into try/except/else
try: if int(text) = 0: raise ValueError Hmm, I'm actually not so sure about this line now. It doesn't seem right to raise a ValueError when the result of the expression is negative, because even though it's a problem for my program, it isn't really a ValueError, right? It's an invalid value to your program, so yes, it is a ValueError. -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
One of the most stupid language-definition decisions that most people have come across is the Makefile format. snippage/ Hope that goes some way to explaining one possible reason why rational people can consistently react in horror to the issue. Ah, thanks for that. This peek into history makes the irrational fear of significant whitespace seem a little less irrational. -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
All societies demonise outsiders to some extent. It's an unfortunate human (and animal) trait. Which is why I questioned it. So just block your ears when the propaganda vans with the loud-speakers on top drive past your dwelling :-) Funny how using python makes me feel like a member of some kind of rebellion against the empire. Where I work it's all VB, VB.NET, and ASP.NET. I've been the lone voice in the wilderness for so long that I've become an inside joke. I actually have a certificate that says Most likely to re-write the system in Python. *sigh* -- http://mail.python.org/mailman/listinfo/python-list
Re: newb question: file searching
Also, I've noticed that files are being found within hidden directories. I'd like to exclude hidden directories from the walk, or at least not add anything within them. Any advice? The second item in the tuple yielded by os.walk() is a list of subdirectories inside the directory indicated by the first item in the tuple. You can remove values from this list at runtime to have os.walk skip over them. -- http://mail.python.org/mailman/listinfo/python-list
do people really complain about significant whitespace?
Where are they-who-hate-us-for-our-whitespace? Are they really that stupid/petty? Are they really out there at all? They almost sound like a mythical caste of tasteless heathens that we have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe. -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming newbie coming from Ruby: a few Python questions
The time to crush our enemies has come. This is the Jihad! Death to the infidels Whoa, dude, let's not get carried away now, 'k? Looking-over-his-shoulder-ly y'rs, infidel -- http://mail.python.org/mailman/listinfo/python-list
Re: cleaner way to write this try/except statement?
Here's how I would do it: def Validate(self, parent): try: text_ctrl = self.GetWindow() text = text_ctrl.GetValue() if not text: raise ValueError if int(text) = 0: raise ValueError return True except ValueError, error: wx.MessageBox('Enter a valid time.', 'Invalid time entered', wx.OK | wx.ICON_ERROR) return False -- http://mail.python.org/mailman/listinfo/python-list
Re: Determining if an object is a class?
import types class OldStyle: pass ... type(OldStyle) == types.ClassType True -- http://mail.python.org/mailman/listinfo/python-list
Re: Generator naming convention?
Any idea? Do you have a naming convention for generators? Sometimes I use the prefix 'iter', like dictionaries have .items() and .iteritems(). sometimes I use 'x', like range() vs. xrange(). You could simply use 'i' like some of the functions in the iteritems module (imap(), izip(), etc). I guess it depends on the project, what you're doing, your mood at the moment, and the alignment of Jupiter and Mercury in Aquarius. -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python: Do we have the concept of Hash in Python?
Is there any built-in Hash implementation in Python? I am looking for a container that I can access to it's items by name. Something like this: Print container[memeberName] You obviously haven't read the tutorial, they're called dictionaries in Python I am asking this because I learned that DB-API in Python doesn't offer access to cursor columns by name. The only option is access by index. I hope that I've got it wrong! That's because the DB-API uses tuples to represent records. I learned Ruby perfectly supports that. Yay for Ruby. -- http://mail.python.org/mailman/listinfo/python-list
Re: what is the difference between tuple and list?
is there any typical usage that shows their difference? I think the general idea is to use lists for homogenous collections and tuples for heterogenous structures. I think the database API provides a good usage that shows their differences. When you do cursor.fetchall() after executing a query, you get back a list of tuples. Each tuple is one record from the cursor. tuple is even the term used in relational database theory when talking about a table row. You shouldn't be able to add or remove fields from a query result, so using a tuple is a perfect match for this. On the other hand, you can certainly add, delete, or replace entire tuples in the result set, so it makes sense to use a list to hold the set of tuples. -- http://mail.python.org/mailman/listinfo/python-list
Re: String Exceptions (PEP 352)
You could also use the assert statement: if foo and bar: ... assert i = 10, if foo and bar then i must not be greater than 10 ... -- http://mail.python.org/mailman/listinfo/python-list
Re: send pdf or jpg to printer
Bell, Kevin wrote: Does anyone have any suggestions on printing pdf's? These pdf's don't change much, so if it be more straight forward to convert them to jpgs, or another format, then that'd be fine too. I use GhostScript and GSPrint to send PDFs to our printer in a Windows environment. It's been a while since we set it up, but I believe GSPrint comes with GSView. GSPrint basically wraps GhostScript for you and provides a much friendlier command line interface than GhostScript. It's worked very well in a high-volume production environment for a few years now. -- http://mail.python.org/mailman/listinfo/python-list
Re: function prototyping?
If you want the user to be able to (re)define them in config.py, why not just define them there in the first place? I may be wrong, but I think global means module level rather than interpreter level. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to create file with spaces
dirpath is just a string, so there's no sense in putting it in a list and then iterating over that list. If you're trying to do something with each file in the tree: for dir, subdirs, names in os.walk(rootdir): for name in names: filepath = os.path.join(dir, name) + -dummy if not os.path.exists(filepath): f = open(filepath, 'w').write('') -- http://mail.python.org/mailman/listinfo/python-list
Re: CGIHTTPServer threading problems
Alvin A. Delagon wrote: I'm a simple python webserver based on CGIHTTPServer module: import CGIHTTPServer import BaseHTTPServer import SocketServer import sys import SQL,network from config import * class ThreadingServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer): pass cfg = params() print XBOX Server started on port %s. Press Ctrl+C to kill Server % cfg.port server = ThreadingServer((cfg.name,cfg.port),CGIHTTPServer.CGIHTTPRequestHandler) try: while 1: sys.stdout.flush() server.handle_request() except KeyboardInterrupt: print Server killed The my cgi scripts are stored in the cgi-bin folder. One cgi script in particular implements multi-threading and is supposed to be asynchronous but it's not working. The browser that requests on the cgi script tends to wait until the cgi script is done. I checked multi-threaded cgi script but I'm 100% percent sure that it has no problem since it worked as a mod_python script before. Anyone came across with this problem? CGI doesn't run asynchronously. All you've done with a multithreaded CGI server is have each CGI script run on a separate thread. But that doesn't change the fact that a browser is going to sit there and wait as the CGI script runs to completion (which is how the server knows it's done). -- http://mail.python.org/mailman/listinfo/python-list
Re: SimpleXMLRPCServer
I'm doing some experiments with the SimpleXMLRPCServer in Python, and I've found it to be an excellent way to do high-level network operations. However, is there a way to enable two-way communication using XML-RPC? By that I mean, can the server contact all the clients? To do that you'd want to use a protocol that maintains connections between the server and clients, like the asyncore and async_chat modules do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Print a PDF transparently
Daniel Crespo wrote: Hi to all, I want to print a PDF right from my python app transparently. With transparently I mean that no matter what program handles the print petition, the user shouldn't be noticed about it. For example, when I want to print a PDF, Adobe Acrobat fires and keep opened. This is what I don't want to happen (and I thing there are a lot of people who want this too). So I just want to send the PDF to the right handler and print it. That's all. I've seen some things like Adobe's Postscript driver that can read a PDF, or Ghostscript, but I still don't know how to use it. Any help for printing a PDF transparently? The only way I was able to find to do it (for free) was to install GhostScript and GSView. GSView comes with GSPrint.exe, which you can call with a regular command line to send PDF files to a printer. It uses GhostScript for you behind the scenes because GhostScript is not exactly the friendliest program to work with. -- http://mail.python.org/mailman/listinfo/python-list
Re: indentation messing up my tuple?
i am using a tuple because i am building lists. I don't understand if i just use (food + drink) then while drink is unique food remains the same do i get this: (burger, coke) (burger, 7up) (burger, sprite) I don't understand what you're saying here. food and drink are both strings. adding them together gives you a new string. putting parentheses around a string does not give you a tuple, you need that magic comma to get python to recognize the expression as a tuple. As I said: (food + drink + '\n') is not a tuple, (food + drink + '\n',) is And since all you're doing with the data list is joining into a single string, I still don't see where you need any tuples. -- http://mail.python.org/mailman/listinfo/python-list
Re: indentation messing up my tuple?
tuple is the name of the built-in type, so it's not a very good idea to reassign it to something else. (food + drink + '\n') is not a tuple, (food + drink + '\n',) is There's no reason to use tuples here, just do this: data.append(food + drink) f.write('\n'.join(data)) -- http://mail.python.org/mailman/listinfo/python-list
Have a very Pythonic Christmasolstihanukwanzaa
Happy holidays to my fellow Pythonistas. Love, Saint Infidel the Skeptic -- http://mail.python.org/mailman/listinfo/python-list
Re: Why my modification of source file doesn't take effect when debugging?
I'm using the Windows version of Python and IDLE. When I debug my .py file, my modification to the .py file does not seem to take effect unless I restart IDLE. Saving the file and re-importing it doesn't help either. Where's the problem? import only reads the file the first time it's called. Every import call after that looks up the module in memory. This is to prevent circular dependencies between modules from creating infinite loops. You need to use the reload() function: import foo #change the contents of foo foo = reload(foo) -- http://mail.python.org/mailman/listinfo/python-list
Re: creating package question
[EMAIL PROTECTED] wrote: I think I have an answer to my own question. In the WindowsComponents/__init__.py file, I have the following, that feels like a better answer for the problem. Is there a better answer than this? import os, sys sys.path.append(os.path.join(os.getcwd(), 'Common')) My solution to this is to use a .pth file. In my site-packages folder under the python installation, I have a file named infidel.pth. This file contains the path to the folder where I put all my python source code (C:\src\py). In your case, you could have the path to your 'root' folder. One of my projects is structured like this: C:\src\py infidel\ __init__.py models\ __init__.py basemodel.py views\ __init__.py baseview.py controllers\ __init__.py Now the controllers package can do imports like this: from infidel.models import basemodel from infidel.views import baseview The point is that the .pth file in site-packages adds custom paths to your sys.path -- http://mail.python.org/mailman/listinfo/python-list
Re: CherryPy not playing nicely with win32com?
Just an idea: because in CherryPy it is running in multithreading mode? If you are using threads together with COM stuff, you will have to add pythoncom.CoInitialize() and pythoncom.CoUninitialize() calls in your code -- for each thread. That worked perfectly. Thanks a million! I used to hate COM just because of our huge VB project. Now I can hate it for this too! -- http://mail.python.org/mailman/listinfo/python-list
CherryPy not playing nicely with win32com?
I've been trying to get my CherryPy server to authenticate users against our network. I've managed to cobble together a simple function that uses our LDAP server to validate the username and password entered by the user: # ldap.py from win32com.client import GetObject ADS_SECURE_AUTHENTICATION = 1 def login_valid(username, password): ldap = GetObject(LDAP:) try: ldap.OpenDSObject( 'LDAP://.US', '\\' + username, password, ADS_SECURE_AUTHENTICATION ) return True except: return False This function works great if I call it from the interactive prompt: import ldap ldap.login_valid('mylogin', '') # pass incorrect network password False ldap.login_valid('mylogin', '') # pass correct network password True But as soon as I have my CherryPy filter call this exact same function, I get an invalid syntax COM error: Traceback (most recent call last): File C:\Python24\Lib\site-packages\cherrypy\_cphttptools.py, line 77, in _run applyFilters('beforeMain') File C:\Python24\Lib\site-packages\cherrypy\_cphttptools.py, line 461, in applyFilters method() File filters\authenticate.py, line 29, in beforeMain if ldap.login_valid(username, password): File K:\src\py\\filters\ldap.py, line 6, in login_valid ldap = GetObject(LDAP:) File C:\Python24\Lib\site-packages\win32com\client\__init__.py, line 73, in GetObject return Moniker(Pathname, clsctx) File C:\Python24\Lib\site-packages\win32com\client\__init__.py, line 88, in Moniker moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) com_error: (-2147221020, 'Invalid syntax', None, None) I don't get it. How can it be ok at the prompt but invalid under CherryPy? -- http://mail.python.org/mailman/listinfo/python-list
cx_Oracle callproc output parameters
I have a stored procedure that has a single output parameter. Why do I have to pass it a string big enough to hold the value it is to receive? Why can't I pass an empty string or None? import cx_Oracle as oracle connection = oracle.connect('usr/[EMAIL PROTECTED]') cursor = connection.cursor() network_name, = cursor.callproc('my_pkg.get_network_name_sp', ('',)) Traceback (most recent call last): File interactive input, line 1, in ? DatabaseError: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at USR.MY_PKG, line 35 ORA-06512: at line 1 The following works fine, but I don't like having to do it: network_name, = cursor.callproc('my_pkg.get_network_name_sp', (' ' * 32,)) Am I missing something obvious here? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and PL/SQL
vb_bv wrote: Does Pyton PL/SQL programming language of Oracle support? Thx PL/SQL is only supported *inside* Oracle databases. Python can be used to call PL/SQL procedures (I recommend the cx_Oracle module), but you can't run Python inside the database like PL/SQL. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and PL/SQL
Thanks for your answers. I would like to document with Python PL/SQL of programs, so similarly as javadoc for Java. I do not know whether it is possible. If yes, I would like to know how. All of the source code for procedures and packages in an oracle database can be retreived from the USER_SOURCE view. It's just plain text, though, and one record per line. Parsing it for documentation would be up to you. There are other views that might be useful too, like USER_TABLES, USER_TAB_COLUMNS, USER_OBJECTS, USER_PROCEDURES, USER_ARGUMENTS, etc etc etc -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning multiple languages (question for general discussion)
Python has spoiled me. I used to periodically try out new languages just for fun, but since learning Python, it's become a lot less interesting. I find myself preferring to just try new ideas or techniques in Python rather than searching for new languages to dabble in. The last few I've downloaded were, in no particular order: Perl, Ruby, Lisp, Io, and Scheme. I usually get as far as installing the necessary interpreters/compilers and opening up a tutorial or two before I lose interest. -- http://mail.python.org/mailman/listinfo/python-list
pythonic
http://dictionary.reference.com/search?q=pythonic http://thesaurus.reference.com/search?r=2q=pythonic -- http://mail.python.org/mailman/listinfo/python-list
Re: Instantiating Classes in python (newbie)
Hello, I am learning python for work from knowing java,c#,c. I had a couple questions. 1) IntegerClass - to instantiate this class how come I use i = IntegerClass.IntegerClass() and then this works while i = IntegerClass() i.method. I receive an error. It depends on what IntegerClass is. If you have a module named IntegerClass with a class named IntegerClass within it, then you must use IntegerClass.IntegerClass to refer to the class, because IntegerClass is the module. You could also change the import statement to: from IntegerClass import IntegerClass ... in which case, IntegerClass in your current namespace will be the class and not the module. This is all an educated guess because you didn't specify what the error was. 2) Also using self in the method (self, dataVal). What does this do differently from using (dataval). I am a little confused about the bound and unbound methods. What does passing self do different? Thank-you for all your help A bound method is kind of like an instance method in java, it's bound to a particular instance object. Python automatically inserts a reference to the object itself as the first argument to a bound call. self is just like this in Java, but you have to explicitly account for it in the method signature. -- http://mail.python.org/mailman/listinfo/python-list
Re: xml-rpc - adodb - None type - DateTime type
I can replace all None values with the string 'Null', there's no problem, but I can't detect the DateTime type object I retrieve from the database. I have something like this: def xmlrpc_function(): conn = adodb.NewADOConnection('postgres') conn.Connect(host,user,password,database) rs = conn.Exec(select * from table) result = [] i = 0 while not rs.EOF: row = rs.GetRowAssoc(False) for key, value in row.items(): if value==None: row[key]='Null' result.append(row) i = i + 1 rs.MoveNext() rs.Close() print result return result The problem here is that if row[key] == type 'DateTime' object etc..., then I don't know what to do for detect it and make the appropriate change to string. Console output: [{'name': 'Null', 'date': DateTime object for '2005-09-01 00:00:00.00' at 1515f60}] If you consult the python manual, you'll see that there's no 'DateTime' type object, so I can't do something like: if value==DateTimeType: ... I only need to know which type of data is a field for make the change according to what can I pass through the xml-rpc. Well, there is the possibility of passing null values through xml-rpc. I believe there is an optional keyword argument in some of the xmlrpclib functions to allow it. Basically it translates None to nil/ in the xml. The DateTime type must be defined somewhere. Is it an adodb type? If so, you could do something like this: if type(value) == adodb.DateTime: ... -- http://mail.python.org/mailman/listinfo/python-list
Re: possible bug in cherrypy.lib.autoreload
Ok, so it turns out that the problem the cherrypy.lib.autoreload module is having, is that kid imports elementtree and on my machine the elementtree modules are inside a zip file (.egg). So the path to the elementtree __init__.py file is not a valid OS path because everything after the .egg file is inside the file. Is there a quick way of determining that a module was imported from a zip file, or that a module's __file__ attribute is a valid path as far as Python is concerned, even though it doesn't exist to the OS? -- http://mail.python.org/mailman/listinfo/python-list
infinite cherrypy autoreloader loop
I did an svn update of cherrypy this morning, and now when I try running a server, the log window just keeps reporting the autoreloader restarting over and over: 2005/10/19 12:42:33 HTTP INFO SystemExit raised: shutting down autoreloader 2005/10/19 12:42:33 HTTP INFO CherryPy shut down 2005/10/19 12:42:34 CONFIG INFO Server parameters: 2005/10/19 12:42:34 HTTP INFO SystemExit raised: shutting down autoreloader 2005/10/19 12:42:34 HTTP INFO CherryPy shut down 2005/10/19 12:42:34 CONFIG INFO Server parameters: 2005/10/19 12:42:34 HTTP INFO SystemExit raised: shutting down autoreloader 2005/10/19 12:42:34 HTTP INFO CherryPy shut down It seemed to be working fine this morning. Any ideas what I may have done to cause this? -- http://mail.python.org/mailman/listinfo/python-list
Re: infinite cherrypy autoreloader loop
Ok, the problem seems to be with my cherrypy importing Kid. If I import the kid module or any of my compiled kid template modules, then I get the autoreloader infinite loop. Is anyone else experiencing this effect? -- http://mail.python.org/mailman/listinfo/python-list
possible bug in cherrypy.lib.autoreloader
I may have found the source of my infinite loop when importing kid modules from my cherrypy server. Here is some code from the autoreloader module of cherrypy: def reloader_thread(): mtimes = {} def fileattr(m): return getattr(m, __file__, None) while RUN_RELOADER: for filename in map(fileattr, sys.modules.values()) + reloadFiles: if filename: if filename.endswith(.pyc): filename = filename[:-1] try: mtime = os.stat(filename).st_mtime except OSError: sys.exit(3) # force reload if filename not in mtimes: mtimes[filename] = mtime continue if mtime mtimes[filename]: sys.exit(3) # force reload time.sleep(1) So what happens if one of my modules is a kid template named 'login.kid'? kid compiles the template to login.pyc, which means the os.stat call in this function will be passed 'login.py' which does not exist. -- http://mail.python.org/mailman/listinfo/python-list
Python, alligator kill each other
By Denise Kalette Associated Press MIAMI - The alligator has some foreign competition at the top of the Everglades food chain, and the results of the struggle are horror-movie messy. A 13-foot Burmese python recently burst after it apparently tried to swallow a live 6-foot alligator whole, authorities said. ... ... It is unknown how many pythons are competing with the thousands of alligators in the Everglades, but at least 150 have been captured in the past two years ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem SQL ADO
SELECT VA_MK_YEAR,VA_MK_DESCRIP,VO_VIN_NO,VO_MODEL,VO_BODY,VO_DESCRIPTION + \ FROM D014800 LEFT OUTER JOIN D014900 ON (VA_MK_NUMBER_VER = VO_MAKE_NO) AND (VA_MK_YEAR = VO_YEAR) + \ WHERE (((VA_MK_YEAR)=?) AND ((VA_MK_DESCRIP)=?) AND ((VO_MODEL)=?)) Doesn't look like you have a space between VO_DESCRIPTION and FROM SQL statements are a good place to use Python's triple-quote feature: sql = \ SELECT VA_MK_YEAR, VA_MK_DESCRIP, VO_VIN_NO, VO_MODEL, VO_BODY, VO_DESCRIPTION FROM D014800 LEFT OUTER JOIN D014900 ON ( VA_MK_NUMBER_VER = VO_MAKE_NO AND VA_MK_YEAR = VO_YEAR ) WHERE VA_MK_YEAR = ? AND VA_MK_DESCRIP = ? AND VO_MODEL = ? -- http://mail.python.org/mailman/listinfo/python-list
Re: error processing variables
import shutil #variables s = shutil toHPU = /etc/sysconfig/network/toHPU.wifi wlan = /etc/sysconfig/network/ifcfg-wlan-id-00:0e:38:88:ba:6d toAnyWifi = /etc/sysconfig/network/toAny.wifi wired = /etc/sysconfig/network/ifcfg-eth-id-00:0b:db:1b:e3:88 def toHPU(): s.copy2(toHPU,wlan) s.copy2(toAnyWifi,wired) #end #execute function toHPU() Your problem is that the def statement reassignes the name toHPU to a function instead of a string. So when the code runs, you're passing a function object to s.copy2. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CGI and Firefox vs IE
I see what's happening, but I'm at a loss to figure out what to do about it. Any help would be appreciated. Try giving the buttons different name attributes. -- http://mail.python.org/mailman/listinfo/python-list
Re: File parser
Angelic Devil wrote: I'm building a file parser but I have a problem I'm not sure how to solve. The files this will parse have the potential to be huge (multiple GBs). There are distinct sections of the file that I want to read into separate dictionaries to perform different operations on. Each section has specific begin and end statements like the following: KEYWORD . . . END KEYWORD The very first thing I do is read the entire file contents into a string. I then store the contents in a list, splitting on line ends as follows: file_lines = file_contents.split('\n') Next, I build smaller lists from the different sections using the begin and end keywords: begin_index = file_lines.index(begin_keyword) end_index = file_lines.index(end_keyword) small_list = [ file_lines[begin_index + 1] : file_lines[end_index - 1] ] I then plan on parsing each list to build the different dictionaries. The problem is that one begin statement is a substring of another begin statement as in the following example: BAR END BAR FOOBAR END FOOBAR I can't just look for the line in the list that contains BAR because FOOBAR might come first in the list. My list would then look like [foobar_1, foobar_2, ..., foobar_n, ..., bar_1, bar_2, ..., bar_m] I don't really want to use regular expressions, but I don't see a way to get around this without doing so. Does anyone have any suggestions on how to accomplish this? If regexps are the way to go, is there an efficient way to parse the contents of a potentially large list using regular expressions? Any help is appreciated! Thanks, Aaron Some time ago I was toying around with writing a tool in python to parse our VB6 code (the original idea was to write our own .NET conversion tool because the Wizard that comes with VS.NET sucks hard on some things). I tried various parsing tools and EBNF grammars but VB6 isn't really an EBNF-esque syntax in all cases, so I needed something else. VB6 syntax is similar to what you have, with all kinds of different Begin/End blocks, and some files can be rather big. Also, when you get to conditionals and looping constructs you can have seriously nested logic, so the approach I took was to imitate a SAX parser. I created a class that reads VB6 source line by line, and calls empty event handler methods (just like SAX) such as self.begin_type or self.begin_procedure and self.end_type or self.end_procedure. Then I created a subclass that actually implemented those event handlers by building a sort of tree that represents the program in a more abstract fashion. I never got to the point of writing the tree out in a new language, but I had fun hacking on the project for a while. I think a similar approach could work for you here. -- http://mail.python.org/mailman/listinfo/python-list
Re: a dummy python question
If that were so, Pythonistas could never write a recursive function! No, presumably at the writing of the edition of _Learning Python_ that he is reading, Python did not have nested scopes in the language, yet. One could always write a recursive function provided it was at the top-level of the module. One could not write a recursive function inside another function because inside inner(), it could only access two namespaces, the one local to inner() and the module's namespace, not the namespace of outer() where inner() is defined. Ah, that makes sense. Thanks for the clarification. -- http://mail.python.org/mailman/listinfo/python-list
Re: question on import __main__
import __main__ if __name__!='__main__': print 1 print 2 when i run test.py, i got 2 on the screen. now, i have some question about the code, 1. since no __main__ module at all, why it's legal to write import __main__? __main__ is the module that the interpreter starts executing. So import __main__ is legal, though I'm guessing it doesn't really do anything because the module is already loaded (since it's running). 2. since if running a script independently, the __name__ should be '__main__', why it's not in the above code? But it is. -- http://mail.python.org/mailman/listinfo/python-list
Re: a dummy python question
Learning Python wrote: A example in learning Python by Mark Lutz and David Ascher about function scope example like this: def outer(x): def inner(i): print i, if i: inner(i-1) inner(x) outer(3) Here supposely, it should report error, because the function inner cannot see itself since inner is only in local namespace of outer. If that were so, Pythonistas could never write a recursive function! -- http://mail.python.org/mailman/listinfo/python-list
Re: pipes like perl
but... i see it doesn't work for some commands, like man python (it gets stuck on the if line)... .readlines() won't return until it hits end-of-file, but the man command waits for user input to scroll the content, like the more or less commands let you view pages of information on a terminal. -- http://mail.python.org/mailman/listinfo/python-list
Re: pipes like perl
Here's one technique I use to run an external command in a particular module: stdin, stdout, stderr = os.popen3(cmd) stdin.close() results = stdout.readlines() stdout.close() errors = stderr.readlines() stderr.close() if errors: raise Exception(''.join(errors)) Maybe this will get you going in a better direction? -- http://mail.python.org/mailman/listinfo/python-list
threadsafety in cherrypy with kid
I have just recently discovered CherryPy and Kid (many kudos to the respective developers!) and am tinkering with them to see what I can come up with. The application I eventually want to write will eventually require the python code to call stored procedures in a database which means I'll need to run CherryPy with a threadPool so individual database calls don't block the whole server. I'm not to that point yet, I'm just getting a feel for what is possible, and I wanted to make sure the following usage of my Kid template (named index) is threadsafe: from cherrypy import cpg import kid; kid.enable_import() from infidel.web import index class Root(object): @cpg.expose def index(self, *args, **kwargs): count = cpg.request.sessionMap.get('count', 0) + 1 cpg.request.sessionMap['count'] = count template = index.Template(times=count) return template.serialize(output='html-strict') if __name__ == '__main__': cpg.root = Root() cpg.server.start(configFile = 'web.ini') Does it matter that I've done the import of index at the module level instead of inside the index method? The example at the CherryPy recipes site does this: from cherrypy import cpg import kid class HomePage: def index(self): test = kid.Template(file='test.kid') test.title = Test Kid Page test.lines = ['qwe','asd','zxc'] return test.serialize(output='xhtml') index.exposed = True if __name__ == __main__: cpg.root = HomePage() cpg.server.start() Is there a qualitative difference between what I've done and what the examle does? -- http://mail.python.org/mailman/listinfo/python-list
Re: len(sys.argv) in (3,4)
It might make more sense if you could find out exactly what that one argument contains. -- http://mail.python.org/mailman/listinfo/python-list
Re: What are modules really for?
I am very new to Python, but have done plenty of development in C++ and Java. And therein lies the root of your question, I believe. One thing I find weird about python is the idea of a module. Why is this needed when there are already the ideas of class, file, and package? One reason is that functions need a place to exist too. In Java, every function, even static ones has to be a class method. In Python, static functions are best kept in a module. Another thing is that packages were a later addition to the language. To my mind, although one CAN put many classes in a file, it is better to put one class per file, for readability and maintainability. Personally I find it easier to maintain a set of related classes when they're all in the same file. I've got a few modules that I'm currently hacking on, each of which contains a handful of classes. Maybe it's just a matter of scale, since these are both fairly small libraries, but I just don't see any advantage to splitting them up into multiple files. One can then create packages and libraries, using groups of files, one class per file. Since Java's compiler enforces this, perhaps you've just come to accept it as normal. Python seems to let you group classes together in one file and call it a module, but what for? What if one of your classes creates/manipulates other classes. If they're in the same module then they all exist in the same namespace and you don't have to have modules importing each other or such things. I find that this, combined with mixins, makes it difficult to find out where code is inherited from. Perhaps you are relying too much on inheritance, then? With single inheritance in C++ or Java, if you wanted to see what a method did and it appeared to be inherited, you would simply look in the base class's file, and if necessary recurse up the inheritance hierarchy until you found the method. With Python an inherited method could be in one of many base classes and/or mixins and there seems no particular logic as to what the filename would be. It shouldn't be too hard to figure out, unless someone was being intentially vague. You could always fire up the interpreter, import your class, and check it's .mro property (method resolution order), which lists the classes in the order they will be examined to find a method named at runtime. Am I missing something? I just think you're thinking in terms of Java. You'll pick things up quickly, though :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to function - (The fundamentals are confusing me)
in Python equality rebinds the name Assignment (=) rebinds the name. Equality (==) is something else entirely. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does __init__ not get called?
I think you have to call type.__new__ like this: def __new__(cls, year, month, day, *args, **kw): print new called try: return _datetime.__new__(cls, year, month, day, *args, **kw) except ValueError: return type.__new__(cls, ...) Are you sure you can specify arbitrary arguments to the __new__ method? I thought they had to be the class object, the tuple of bases, and the dictionary of names. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does __init__ not get called?
Are you sure you can specify arbitrary arguments to the __new__ method? I thought they had to be the class object, the tuple of bases, and the dictionary of names. Nevermind, I think I was imagining metaclasses rather than just regular overriding of __new__ -- http://mail.python.org/mailman/listinfo/python-list
Re: Conditionally implementing __iter__ in new style classes
I'm not sure I understand why you would want to. Just don't define __iter__ on your newstyle class and you'll get the expected behavior. -- http://mail.python.org/mailman/listinfo/python-list
Re: Conditionally implementing __iter__ in new style classes
Why not define an Iterator method in your Base class that does the iteration using __getitem__, and any subclass that wants to do something else just defines its own Iterator method? For that matter, you could just use the __iter__ methods of Base and Concrete instead of a separate method. -- http://mail.python.org/mailman/listinfo/python-list
Re: Conditionally implementing __iter__ in new style classes
Something like this: class Base(object): ... def __getitem__(self, key): ... return key ... def __iter__(self): ... yield self[1] ... yield self['foo'] ... yield self[3.0] ... class ConcreteIterable(Base): ... def __iter__(self): ... yield True ... yield 'Blue' ... yield 'Foo' ... class ConcreteNotIterable(Base): ... pass ... [x for x in Base()] [1, 'foo', 3.0] [x for x in ConcreteIterable()] [True, 'Blue', 'Foo'] [x for x in ConcreteNotIterable()] [1, 'foo', 3.0] -- http://mail.python.org/mailman/listinfo/python-list
Re: pulling multiple instances of a module into memory
Do you have control over the eggs.so module? Seems to me the best answer is to make the start method return a connection object conn1 = eggs.start('Connection1') conn2 = eggs.start('Connection2') -- http://mail.python.org/mailman/listinfo/python-list
Re: Favorite non-python language trick?
def class Colour: def __init__(self, blue=0, green=0, red=0): # pseudo-Python code borrowing concept with from Pascal with self: blue = blue green = green red = red And now you can see why Python doesn't support this idiom. Maybe it would make more sense if it was done a la Visual Basic with self: .blue = blue .green = green .red = red requiring a dot to be typed removes the ambiguity and gives the IDEs a chance to Intellisense-ify your coding. -- http://mail.python.org/mailman/listinfo/python-list
Re: a dictionary from a list
dict((x, None) for x in alist) -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
Why in the name of all that is holy and just would you need to do such a thing? -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
I don't think that makes any sense. How could you possibly create such a circular relationship between things in any language? Besides, if I understand metaclasses at all, only other metaclasses can be bases of a metaclass. Why not use python classes to represent the other system's types with a python metaclass as the type type? -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
God made me an atheist, who are you to question His wisdom? -- Saint Infidel the Skeptic -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
because i need the representations of the other systems types to themselves be python classes, and so i need a metaclass to make sure they follow certain rules. This metaclass is for that system what type is for python I think that's exactly the same thing I just said. More or less. Although depending on exactly what you mean by follow certain rules, you might only need a common base class rather than a metaclass. same thing, no? Uh, no, I don't think so. type is, from my trivial understanding, the base type and base metaclass for everything else in python. Saying type is an object is only confusing you into thinking it is a subclass of object, which is not the case. object is a class, which I believe has type as it's metaclass (though I could be mistaken - this gets terribly confusing very quickly). -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
Oh great, just when I thought I was starting to grok this mess. -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclass that inherits a class of that metaclass?
Ok, forget everything I've said. The more I think about this the less I understand it. I'm way out of my league here. sitting-down-and-shutting-up-ly y'rs, infi -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Polymorphism
carlos Supose that I want to create two methos (inside a carlos class) with exactly same name, but number of carlos parameters different That isn't polymorphism, that's function overloading. carlos Look, I don't want to use things like: carlos carlos def myMethod(self, myValue=None): carlosif(not myValue): carlos self.myAttribute += 1 carloselse: carlos self.myAttribute += myValue Pick another language then. Or try: def myMethod(self, myValue=1): self.myAttribute += myValue -- http://mail.python.org/mailman/listinfo/python-list
Re: lists in cx_Oracle
I think perhaps you are asking for something that the OCI doesn't provide. At least I'd be rather surprised if it did. I know that the SQL syntax doesn't provide for such a mechanism. And really, it all boils down to the list comprehension: in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))]) ... elegance is certainly subjective, and the above statement isn't the cleanest ever, but it solves your main problem while avoiding the other problem you mentiong (sql injection). Seems elegant enough to me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the sender widget's name in function (Tkinter)
Here's a slight variation of tiissa's solution that gives the callable a reference to the actual widget instead of just it's name: from Tkinter import Tk, Button class say_hello: def __init__(self, widget): self.widget = widget def __call__(self): print 'Hello,', self.widget['text'] def run(): root = Tk() b1 = Button(root, text='Button 1') b1.configure(command=say_hello(b1)) b1.pack() b2 = Button(root, text='Button 2') b2.configure(command=say_hello(b2)) b2.pack() root.mainloop() run() -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the sender widget's name in function (Tkinter)
from Tkinter import Tk, Button def say_hello(event): print 'hello!' print event.widget['text'] root = Tk() button1 = Button(root, text='Button 1') button1.bind('Button-1', say_hello) button1.pack() button2 = Button(root, text='Button 2') button2.bind('Button-1', say_hello) button2.pack() root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: EOF-file missing
You can use the Content-Length header to tell the server how long the string is. -- http://mail.python.org/mailman/listinfo/python-list
Re: oracle interface
cx_Oracle rocks -- http://mail.python.org/mailman/listinfo/python-list
Re: AttributeError: 'module' object has no attribute 'setdefaulttimeout'
That just means the urllib.socket module doesn't have any function named setdefaulttimeout in it. It appears there might be something wrong with your socket module as mine has it: py import urllib py f = urllib.socket.setdefaulttimeout py f built-in function setdefaulttimeout -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding attributes in a list
You can use the new 'sorted' built-in function and custom compare functions to return lists of players sorted according to any criteria: players = [ ... {'name' : 'joe', 'defense' : 8, 'attacking' : 5, 'midfield' : 6, 'goalkeeping' : 9}, ... {'name' : 'bob', 'defense' : 5, 'attacking' : 9, 'midfield' : 6, 'goalkeeping' : 3}, ... {'name' : 'sam', 'defense' : 6, 'attacking' : 7, 'midfield' : 10, 'goalkeeping' : 4} ... ] def cmp_attacking(first, second): ... return cmp(second['attacking'], first['attacking']) ... [p['name'] for p in sorted(players, cmp_attacking)] ['bob', 'sam', 'joe'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Pattern matching from a text document
First, if you're going to loop over each line, do it like this: for line in file('playerlist.txt'): #do stuff here Second, this statement is referencing the *second* item in the list, not the first: match = ph.match(list[1]) Third, a simple splitting of the lines by some delimiter character would be easier than regular expressions, but whatever floats your boat. If you insist on using regexen, then you should compile the pattern before the loop. No need to do it over and over again. Fourth, if you want to create a list of players in memory, then you need either a class or some other structure to represent each player, and then you need to add them to some kind of list as you go. Like this: pat = ([a-z]+)(\s+)([a-z]+)(\s+)([a-z]+)(\s+)(\d{1})(\d{1})(\d{1})(\d{1})(\d{1})([a-z]+) ph = re.compile(pat,re.IGNORECASE) players = [] for line in file('playerlist.txt'): match = ph.match(line) player = { 'forename' : match.group(1), 'surname' : match.group(3), 'attacking' : match.group(7), 'defending' : match.group(8), 'fitness' : match.group(9) } players.append(player) -- http://mail.python.org/mailman/listinfo/python-list
Re: _conditionally_ returning to point where exception was raised?
There's no Resume Next in python. Once you catch an exception, the only way you can go is forward from that point. So if B.CallingMethod catches an exception that was raised in A.CalledMethod, all it could do is try calling A.CalledMethod again, it can't jump back to the point where the exception was raised. About the best you could, I think, would be to break A.CalledMethod up into smaller function and let B.CallingMethod call each one in sequence, deciding whether or not to continue if an exception is raised in any of them. -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing: parseString confusion
I've notice the same thing. It seems that it will return as much as it can that matches the grammar and just stop when it encounters something it doesn't recognize. -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32api shellexecute Bshow
Acrobat is stupid like this. I haven't yet found a way to prevent it from launching a new window, so I gave up and went with GhostScript and GSPrint instead. Works fabulously. -- http://mail.python.org/mailman/listinfo/python-list
Re: delay and force in Python
Of course I meant to put a break out of the loop after the print statement. Duh on me. -- http://mail.python.org/mailman/listinfo/python-list
Re: delay and force in Python
It took me a while to figure out what the translated code was trying to do. Here's a quick example that I think accomplishes the same thing: for i, n in enumerate(x for x in xrange(998) if x % 2 == 0): ... if i == 1: ... print n ... 2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Not that my opinion is worth anything in these matters, but I like the upper-left example at http://exogen.cwru.edu/python.png the best (out of the samples I've seen thus far). I don't like the gear shape, and I think adding a coil or circle around the head detracts somewhat from the look. I like the clean, sharp lines - seems very metaphorical for the language. My only critique would be that it appears (to me) much like a clan insignia from Battletech. Not that such is a bad thing, mind you. I think people are a little over-anxious regarding copyright infringement. I think a snake around a holy grail would be a fine logo, the holy grail of programming languages seems appropriate to me. There's no way that MPFC can have rights over all possible combinations of Python and Holy Grail. Chill out, people. -- http://mail.python.org/mailman/listinfo/python-list