PDB scope problem
While debugging with PDB earlier, I discovered this idiosyncracy: (Pdb) lstValues [[Decimal("1"), Decimal("47.0")]] (Pdb) agg [0, 1] (Pdb) print list([sum(v[i] for i in range(len(agg))) for v in lstValues]) *** NameError: global name 'v' is not defined (Pdb) However, the Python interpreter is happy with it if entered directly: >>> lstValues [[Decimal("1"), Decimal("47.0")]] >>> agg = [0,1] >>> print list([sum(v[i] for i in range(len(agg))) for v in lstValues]) [Decimal("48.0")] >>> There seems to be some sort of scope problem in PDB. -- Dale Strickland-Clark -- http://mail.python.org/mailman/listinfo/python-list
Re: MIMEText breaking the rules?
Tim Roberts wrote: > Dale Strickland-Clark <[EMAIL PROTECTED]> wrote: >> >>The email module's mimetext handling isn't what you might expect from >>something that appears to behave like a dictionary. >>... >>Having apparently REPLACED my recipient, what I've ended up with is both >>of them. > > This behavior is documented in Message.Message, from which MIMEText > eventually inherits. If you want to start over, delete the item: > > del Msg["To"] > > I would have to say that the existing behavior is more intuitive for an > email object. Thanks for the info. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
MIMEText breaking the rules?
The email module's mimetext handling isn't what you might expect from something that appears to behave like a dictionary. $ python Python 2.5 (r25:51908, May 25 2007, 16:14:04) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from email.mime.text import MIMEText >>> msg = MIMEText("A message") >>> msg["To"] = "[EMAIL PROTECTED]" >>> msg["To"] = "[EMAIL PROTECTED]" >>> print msg.as_string() Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] A message >>> Having apparently REPLACED my recipient, what I've ended up with is both of them. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: list of range of floats
Steve wrote: > I'm trying to create a list range of floats and running into problems. > I've been trying something like: > > a = 0.0 > b = 10.0 > > flts = range(a, b) > > fltlst.append(flts) > > When I run it I get the following DeprecationWarning: integer argument > expected, got float. How can I store a list of floats? > > TIA > Steve range only does ints. If you want floats, you'll have to write your own version. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's going on here?
Thanks for the answers. I am informed but I don't feel enlightened. It does strike me as odd that an apparently empty subclass should add extra function to the base class. Not at all obvious. -- Dale Strickland-Clark We are recruiting Python programmers. Please see the web site. Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
What's going on here?
Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = object() >>> a >>> a.spam = 1 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'object' object has no attribute 'spam' >>> class b(object): ...pass ... >>> a = b() >>> a <__main__.b object at 0xb7b4dcac> >>> a.spam = 1 >>> What is subclassing adding to the class here? Why can't I assign to attributes of an instance of object? -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Providing full interaction with the run time
Thanks for the info. I didn't know about that module. I'll take a look. Fredrik Lundh wrote: > Dale Strickland-Clark wrote: > >> We have a system we're developing which runs as a server. It has an >> xml-rpc interface which I've extended to provide some debugging >> facilities. This has already proved very useful and will continue to be >> so as the system is prepared for live deployment. >> >> The debugging interface attempts to emulate the Python interactive shell. >> You type expressions, you get an answer. You type statements, they get >> executed. >> >> The problem is these two types of input are handled differently by >> Python. You don't seem to be able to pass statements (which includes >> assignments) and expressions through the same calls. >> >> There are three keywords that support this type of function: EXEC, EVAL >> and COMPILE. We can ignore EXEC for this because it doesn't support >> saving and restoring a local environment and EVAL can do it better. > > huh? both exec and eval take optional execution contexts: > > http://effbot.org/pyref/eval.htm > http://effbot.org/pyref/exec.htm > >> Or am I going about this all wrong? > > yes, you're trying to reinvent the "code" module (and badly, it seems > ;-). see the library reference to details, this page for some examples: > > http://www.effbot.org/librarybook/code.htm > > -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Hooking file open
You might consider trapping calls to file() too, which is an alias for open(). Also, I think I'd do my logging before calling the real function. It depends how you want to deal with exceptions. Farshid Lashkari wrote: > Hi, > > My goal is to detect all (or most) file dependencies of a script (i.e. > modules, dlls, data files). Currently, after a script is finished > executing I use sys.modules to determine all module dependencies, and I > use win32process.EnumProcessModules to determine DLL dependencies. This > works reasonably well, however I would still like to detect dependencies > from regular file open calls. > > I did a little test by modifying __builtins__.open to point to a custom > function that forwards the call to the original open function and saves > the filename to a list. It seemed to work for simple test cases. Here is > the code: > > def open_hook(*args,**kwargs): > r = open_real(*args,**kwargs) > saveFileName(args[0]) > return r > > open_real = __builtins__.open > __builtins__.open = open_hook > > Is this a safe approach? Is there a more efficient way of doing this? I > realize that some dependencies will still fall through my checks, > especially file opens from C extensions, which is fine. I just want to > be able to detect the most common use cases. Any other suggestions are > appreciated. > > -Farshid -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Providing full interaction with the run time
We have a system we're developing which runs as a server. It has an xml-rpc interface which I've extended to provide some debugging facilities. This has already proved very useful and will continue to be so as the system is prepared for live deployment. The debugging interface attempts to emulate the Python interactive shell. You type expressions, you get an answer. You type statements, they get executed. The problem is these two types of input are handled differently by Python. You don't seem to be able to pass statements (which includes assignments) and expressions through the same calls. There are three keywords that support this type of function: EXEC, EVAL and COMPILE. We can ignore EXEC for this because it doesn't support saving and restoring a local environment and EVAL can do it better. When you COMPILE code for EVAL, you have to say what sort of statement it is. You can't pass an assignment as an expression: >>> lcls={} >>> r = eval(compile('a=1', '<>', 'eval'), globals(), lcls) Traceback (most recent call last): File "", line 1, in ? File "<>", line 1 a=1 ^ SyntaxError: invalid syntax However, changing option 'eval' to 'single' is OK for statements: >>> lcls={} >>> r = eval(compile('a=1', '<>', 'single'), globals(), lcls) >>> lcls {'a': 1} >>> But if I use 'single', I can't get expression results because the stupid function prints them on the console. >>> r = eval(compile('a', '<>', 'single'), globals(), lcls) 1 >>> print r None I can use the 'eval' option but that doesn't take assignments, remember? >>> r = eval(compile('a', '<>', 'eval'), globals(), lcls) >>> print r 1 The compile function also supports an 'exec' parameter in place of 'eval' or 'single' but this throws away expression results so that's no help. At the moment, I'm making a crude attempt to distinguish between statements and expressions but it's easily fooled. So the question is: how does my debug interface (which operates over RPC) decide which type of COMPILE it wants? Or am I going about this all wrong? (I don't need warnings about the obvious security implications of this interface.) Thanks -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's CRT licensing on Windows
To paraphrase an applicant for a job vacancy we're currently filling when asked to give an example of their problem solving skills: A client had a problem with Windows XP on his laptop. I reformatted his hard disk and installed Red Hat. Problem solved. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
We're recruiting Python programmers
I'll keep this brief. Please see the web site for details Thanks. -- Dale Strickland-Clark We are recruiting Python programmers. Please see the web site. Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: PostgreSQL, psycopg2 and OID-less tables
Tim N. van der Leeuw wrote: > > Hi, > > select lastval(); > Thanks, that was useful. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: PostgreSQL, psycopg2 and OID-less tables
Hi Harald Thanks for that, somewhat comprehensive, answer. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
PostgreSQL, psycopg2 and OID-less tables
Now that OIDs have been deprecated in PostgreSQL, how do you find the key of a newly inserted record? I've tried three Python client libraries, including psycopg2, and where they support cursor attribute 'lastrowid' (Python DB API 2.0), it is always zero. Anyone figured this out? Thanks. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Delete items in nested dictionary based on value.
Brian L. Troutwine wrote: > I've got a problem that I can't seem to get my head around and hoped > somebody might help me out a bit: > > I've got a dictionary, A, that is arbitarily large and may contains > ints, None and more dictionaries which themselves may contain ints, > None and more dictionaries. Each of the sub-dictionaries is also > arbitrarily large. When pretty printing A, in the context I'm using A > for, it's rather helpful to remove all key:value pairs where value is > None. So I'd like to be able to define a function dict_sweep to recurse > through A and del all the keys with None as a value. > > I feel like the solution is right on the tip of my tounge, so to speak, > but I just can't quite get it. Anyway, here's the best I've come up > with: How about this: def dict_sweep(dictionary): for k, v in dictionary.items(): if v is None: del dictionary[k] if type(v) == type({}): dict_sweep(v) #if len(v) == 0: # del dictionary[k] A_in = {1: {2: 2, 3: {1: None, 2: 2}}, 2: 2, 3: None} B_in = {1: {1: {1: None, 2: {1: None}}, 2: 2, 3: None}} dict_sweep(A_in) dict_sweep(B_in) print A_in print B_in >>> {1: {2: 2, 3: {2: 2}}, 2: 2} >>> {1: {2: 2}} It doesn't produce the output you expect for B_in, but your brackets didn't match and I'm not sure where the extra close should be. Also, I suspect you're wanting to delete empty dictionaries but I don't see that mentioned in the text. If that is so, include the two commented statements. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Inter process signalling
Duncan Booth wrote: > Dale Strickland-Clark <[EMAIL PROTECTED]> wrote: > >> In Linux this is easy with 'signal' and 'kill' but how can I get one >> Python process to signal another (possibly running as a service)? >> >> All I need is a simple prod with no other data being sent and none >> being returned - except that the signal was delivered. >> >> Receiving a signal should generate an interrupt. I'm not looking for a >> solution the involves polling. >> > Lots of ways. Basically all involving creating a thread which waits on an > event and then calls your code when the event is generated. > > You can use semaphores, named pipes &c.; you could create a windows > message queue and simply send the process a message when you want to alert > it; you could create a COM server and call a method on it; you could use > asynchronous procedure calls (APCs) (but you still need to ensure that > there is a thread in an alertable wait state). > > If the code you want to signal is running as a service then the easiest > way to signal it is to call win32service.ControlService with a user > defined service code. That gives you 127 signals to play with, and > Python's win32 library will simply call the SvcOther method within your > service code (although not of course using the same thread as the actual > service is running on). Thanks Duncan. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Inter process signalling
Dennis Lee Bieber wrote: > Unfortunately... You are on Windows... > > I think your choices become: Block, or Poll > > Check the Win32Api modules... > > win32event may be a candidate... > CreateEvent() > OpenEvent() > PulseEvent() > SetEvent() > ResetEvent() > WaitForSingleObject() or WaitForMultipleObjects() Thanks. We'll look into those. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Inter process signalling
Dale Strickland-Clark wrote: > In Linux this is easy with 'signal' and 'kill' but how can I get one > Python process to signal another (possibly running as a service)? > > All I need is a simple prod with no other data being sent and none being > returned - except that the signal was delivered. > > Receiving a signal should generate an interrupt. I'm not looking for a > solution the involves polling. > > Thanks The essential bit of information missing from this is: on Windows. I want to signal between processes running *on Windows*. That's what happens when you try to rush a post before going home. Thank you for your tolerance. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Inter process signalling
In Linux this is easy with 'signal' and 'kill' but how can I get one Python process to signal another (possibly running as a service)? All I need is a simple prod with no other data being sent and none being returned - except that the signal was delivered. Receiving a signal should generate an interrupt. I'm not looking for a solution the involves polling. Thanks -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Design Patterns in Python
Gabriel Genellina wrote: > Hello > > Most authors talk about Java/C++, and describe patterns used as a > workaround to their static class model; the dynamic nature of Python > allows for trivial implementations in some cases. > I've seen some design patterns examples on the ActiveState site, and > some discussions some time ago on this list. > But does anyone know of a complete discussion/analysis of patterns in > Python? Books, articles, web pages... > Unfortunately the pattern-SIG is now defunct... > > > Gabriel Genellina > Softlab SRL > Something like this? http://tinyurl.com/q7uyt (www.amazon.co.uk) -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: write()
manuhack wrote: > Then is there any way to create a directory under XP using Python? import os os.mkdir("C:\\myosisbroken") -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: XML/HTML Encoding problem
Thanks, Duncan. That did the trick. If you're EuroPythoning, I'll buy you a drink. Cheers. Duncan Booth wrote: > First up, when I repeat what you did I don't get the same output. toxml() > without an encoding argument produces a unicode string, and no encoding > attribute in the > > toxml() only takes a single encoding argument, so unfortunately there > isn't any way to tell it what to do for unicode characters which are not > supported in the encoding you are using. However, if you then encode the > unicode output to ascii with entity escapes, I think you should be alright > (unless I've missed something): > You lose the encoding at the top of the output, but since the output is > entirely ascii I don't think that matters. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32: Detecting when system is locked or sleeping
[EMAIL PROTECTED] wrote: > > rod> I have written an application which works perfectly when the > rod> machine is operating under normal conditions, however when the > rod> screen becomes locked it imediately starts to fill up several > rod> hundred MB's of memory. > > What do you mean by "locked"? Unresponsive to mouse or keyboard activity? > Blue screen? What is your application doing while it's filling up memory? > Which memory, disk or RAM? I think he means locked by the user for security. Keyboard/mouse lock. As in ctrl-alt-del -> [Lock Computer] Not the blue-screen, hung, rogered type of lock which is not voluntary and rather more frequent. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk We're recruiting. See the web site for details. -- http://mail.python.org/mailman/listinfo/python-list
XML/HTML Encoding problem
A colleague has asked me this and I don't know the answer. Can anyone here help with this? Thanks in advance. Here is his email: I am trying to parse an HTML document using the xml.dom.minidom parser and then outputting a valid HTML document, all using the ISO-8859-1 charset. For example: My input: € Desired output: € Note that it doesn't matter if the '' header gets stripped. What does matter is that the input document has the 'ISO-8859-1' charset and is an ANSI encoded file. The problem I get is that when I run, for example: from xml.dom.minidom import parseString output = parseString(strHTML).toxml() The output is: € So it encodes the entity reference to € (Euro sign). I need it to remain as € so that the resulting HTML can render properly in a browser. Is there a way to make the parser not convert the entity references? Or is there a convenient post processing function that will do the conversion? -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python editor recommendation.
Vim. Everything else is Notepad. DeepBlue wrote: > Hi all, > > Can any one please recommend me an editor for coding Python. Thank u. > I have Komodo (www.activestate.com) in my mind. Is the editor any good? > > regards. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk We're recruiting. See the web site for details. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 3.0/5.0 = 0.59999...
Have you looked at the decimal module? python Python 2.4 (#1, Mar 22 2005, 21:42:42) [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import * >>> Decimal("3")/Decimal("5") Decimal("0.6") >>> I don't suppose it is quick but it might do what you want. Davy wrote: > Hi all, > > I used to be a Matlab user. And want to use Python to replace some > Matlab work. > > When I type 3.0/5.0, the result is 0.5... > > Is there some precision loss? And how to overcome it? > > Any suggestions will be appreciated! > Best regards, > Davy -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Enumerating Regular Expressions
Any regular expression that has an asterisk in it has an infinite number of possible matches. If it has two asterisks, that's an infinite number squared and that's a really big number. You wouldn't want to print them out. [EMAIL PROTECTED] wrote: > Hi all, > > Does anybody know of a module that allows you to enumerate all the > strings a particular regular expression describes? > > Cheers, > -Blair -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Import data from Excel
Try this: from win32com.client import GetObject, constants def GetExcelData(self, strFilePath): """ Extract the data from the Excel sheet. Returns tuple of tuples representing the rows and cells.""" # The following line extracts # all the data from sheet 1 of the spreadsheet return GetObject(strFilePath).Sheets(1).UsedRange.Value N/A wrote: > Hi, > Is it possible to import data from Excel for doing numerical analysis in > Python? If so how? Thank u! -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning for numerals / letters
What about this? import re if not form.get('date'): print "Tsk! No date entered." raise Exception if re.search('[a-zA-Z]', form.get('date')): print "Tsk! No fancy date words." raise Exception date = form.get('date') if not form.get('purchases'): print "Tsk! Are you buying or not?" raise Exception if re.search('[0-9]', form.get('purchases')): print "Tsk! For some reason, you can't buy anything with numbers in it." raise Exception purchases = form.get('purchases') Kun wrote: > I have the following if statement that checks if a form is empty: > > if form.has_key("date") and form["date"].value != "": > date=form['date'].value > > else: > print "ERROR: No date entered!" > raise Exception > > I would also like to add another if statement checking if 'date' has any > letters (a-z) in it, and if so, would like to say that "you have to > enter a date with numbers". I am not sure how to alter my current if > statement to do that check so any assistance would be appreciated. > > > On the flip side, I also have a field called 'purchases' where the user > must enter non-numerals, thus i would also like to know how to scan to > see if their entry has numerals and print 'please do not use numbers' if > they did. > > Thanks for your help. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk We're recruiting programmers. Please see the web site. -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting a substring
You don't need a regex for this, as long as the prefix and suffix are fixed lengths, the following will do: >> "a53bc_531.txt"[6:-4] '531' >>> "a53bc_2285.txt"[6:-4] '2285' [EMAIL PROTECTED] wrote: > Hi, > I have a bunch of strings like > a53bc_531.txt > a53bc_2285.txt > ... > a53bc_359.txt > > and I want to extract the numbers 531, 2285, ...,359. > > One thing for sure is that these numbers are the ONLY part that is > changing; all the other characters are always fixed. > > I know I should use regular expressions, but I'm not familar with > python, so any quick help would help, such as which commands or idioms > to use. Thanks a lot! -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: sending ctrl C to a program
[EMAIL PROTECTED] wrote: > hi > i have a program that works very similar to tail -f in Unix > It will need a Ctrl-C in order to break out of the program. > I wish to run this program using python (either thru os.system() or > some other subprocess modules) and how can i pass Ctrl-C to this > program to terminate it in python? > thanks Isn't SIGINT the same as ctrl-c? So something like import os os.kill(1234, 2) would send ctrl-c to process 1234. If you just want the process to quit, you could probably just send it a SIGTERM, which is signal 15. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk We're recruiting programmers. Please see the web site. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Evangelism
Steve Holden wrote: > Any suggestions for improvement? > > regards > Steve Get rid of the scarey face? :-) -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk We're recruiting. See the web site for details. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Evangelism
rtilley wrote: > Psychology is important. Just as important as good design. I think this > fact doesn't sink in to the Python community. You speak of fluff and ribbons and glitter. I think most people here are less concerned with psychology and more interested in pychology. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk We're recruiting. See the web site for details. -- http://mail.python.org/mailman/listinfo/python-list
Re: beta.python.org content
Michael Tobis wrote: > I like the design, though I'd prefer stronger colors. I think it would > be a major improvement except for the logo. > > So, are you saying you don't like the new logo? I'm with you. I don't like it either. It looks like a diagram out of the well known Anguine Kama Sutra. The new site, however is very nice. Top marks for that. -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there anybody using python as the script engine for ASP?
[EMAIL PROTECTED] wrote: > Hi everyone, I'm planning using python with asp, and wonder if some > people do use python/asp in real life projects. (I'm going to) > > cheers, > > === > > kychan Guys at my company do. I think there were some issues which they either worked around or that went away after an upgrade. I'm not sure. But we're running live web sites with it right now, as far as I know. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the extension of a filename from the path
Lad wrote: > Hello, > what is a way to get the the extension of a filename from the path? > E.g., on my XP windows the path can be > C:\Pictures\MyDocs\test.txt > and I would like to get > the the extension of the filename, that is here > txt > > > I would like that to work on Linux also > Thank you for help > L. Like this, you mean? >>> import os.path >>> os.path.splitext("c:\\pictures\\mydocs\\test.txt") ('c:\\pictures\\mydocs\\test', '.txt') -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem printing in Win98
Maravilloso wrote: > Hi > > I'm trying to automatically send a postscript file to be printed to the > default printer in a Win98 PC, by means of using the instrucction: > > win32api.ShellExecute (0, "print", "file.ps", None, ".", 0) > > but it raises an exception with the message: > > error: (31, 'ShellExecute', 'A device attached to the system is not > functioning.') > > > Curiously, that instruction does works on Win2K/XP, but trying to use > this shortcut for easy printing in Win98 provokes such error. I've > tried in different machines (all of them running with Win98) and I > obtain the same output. > > Does anybody knows what happens with Win98 printing automation? > Any idea? > > Thanks in advance I presume this .ps file is a preformed postscript file that should be sent to a postscript printer without further modification? In this case, I think you should use copy instead of print. Something like this: win32api.ShellExecute(0, "copy", "file.ps prn", None, ".", 0) It has been a long time since I used Windows, especially 98, but if 'prn' doesn't work, you might try one of: 'lpt', 'lpt1', 'lpt:', 'lpt1:'. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: creating/altering the OpenOffice spredsheet docs
Andy Leszczynski wrote: > Any idea how to do that the way ActiveX would be used on M$? > > A. http://udk.openoffice.org/python/python-bridge.html -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Config parser module
The Config Parser module is for extracting data from and writing to a specific format of file, generally known as a config file. As explained in the documentation, a config file is in the same format as .ini files frequently found on windows - especially used by older software. It is a very handy file format for all sorts of jobs, more so on Linux these days than Windows, probably. However, it isn't much use for your particular need as described here. [EMAIL PROTECTED] wrote: > Hi all > I am a newbie and I just saw a ongoing thread on Fileprocessing which > talks abt config parser. > I have writen many pyhton program to parse many kind of text files by > using string module and regex. But after reading that config parser > thread I feel stunned. > > Can somebody tell me some intro info how to parse huge data (most of > them are input data to application softwares like nastran, abaqus etc) > > Recently I saw a great work by John on Nastran file parser (i am still > trying to understand the program, > http://jrfonseca.dyndns.org/svn/phd/python/Data/Nastran/ > > An example of dat may be like this, (part of) > (say point id coordinateSysNo x,y,z ...) > GRID 1 12478.0 0.0 256.75 1 > GRID 2 12357.25 0.0 256.75 1 > GRID 3 12357.25 0.0 199.0 1 > (say Elementtype id property point1 point 2 point3 point4 etc) > CQUAD4 7231 2156915700570156920.0 > > CQUAD4 7232 2156925701570256930.0 > > CQUAD4 7233 2156935702570356940.0 > > the data file is very complex if i consider all complexities) > > Is is possible to use config parser module insome way for this. I also > have few perl parser (for some part for some particular tasks) and now > changing them to python. (I feel perl regex combination is very easy to > learn and very powerfull) > > Any information will be appreciated. > > -jiro -- Dale Strickland-Clark Riverhall Systems www.riverhall.co.uk We're recruiting Python programmers. See web site. -- http://mail.python.org/mailman/listinfo/python-list
Re: Validating XML parsers
Robert Kern wrote: > Dale Strickland-Clark wrote: >> A few days ago there was a discussion about which XML parser to use with >> Python. >> However, the discussion didn't cover validating parsers, at least, not >> w3.org XML Schemas. >> >> I looked into all the parsers that came up in the discussion but found no >> mention of w3.org schemas. > > Apparently not all that came up. > > http://codespeak.net/lxml/ > That's great. Thanks. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Validating XML parsers
A few days ago there was a discussion about which XML parser to use with Python. However, the discussion didn't cover validating parsers, at least, not w3.org XML Schemas. I looked into all the parsers that came up in the discussion but found no mention of w3.org schemas. It seems there are a few DTD validating parsers but that's all. I'm not concerned about speed so much as a reasonably sound implementation. What's out there? Have I missed something? Thanks. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list