I'm trying to do invoke the mail merge functionality of MS Word from a
Python script. The situation is that I have a template Word document,
and a record that I've generated in Python, and I want to output a new
Word .doc file with the template filled in with the record I've
generated.
(To refresh
I was finally able to get things working right, so I thought I'd stick
an example here for posterity.
"""An example of a MS Word mail merge using the COM interface.
In order for this script to work you must first run the COM Makepy
utility and select
"Microsoft Word 10.0 Object Library (8.2)" or w
Here's another one:
>>> d = {}
>>> for x in [1,2,3]:
... d[x] = (lambda z: lambda y: y * z) (x)
...
>>> d[1](3)
3
>>> d[2](3)
6
--
http://mail.python.org/mailman/listinfo/python-list
When I use the COM Makepy utility on one computer with WindowsXP,
ActivePython 2.3 and I select the library Microsoft Word 10.0 Object
Library (8.2), things work fine.
When I have WindowsXP, ActivePython 2.4 (build 247) and Microsoft Word
11.0 Object Library (8.3), then I get the following SyntaxEr
After exploring the bug database I discovered that this bug has been
reported since March, and appears to derive from a bug in Python
itself.
http://bugs.activestate.com/show_bug.cgi?id=38052
It apparently only happens when the code generated by Makepy is really
big (which it is for Word or Excel
Hello,
I've been trying to change the text color on a windows console
program I've been working on with no luck. I should mention that I'm
a novice so please dummy up your replies.
Thanks-in-Advance
Steve
--
http://mail.python.org/mailman/listinfo/python-list
Thank you. I appreciate the help.
Steve
Larry Bates wrote:
> You can use this module to control console windows background and
> text colors.
>
> http://www.effbot.org/zone/console-index.htm
>
> -Larry Bates
>
> Steve M wrote:
>> Hello,
>>
>>
output.write(wrkmisc(ifile,2582))
output.write(wrkviol(ifile,2774,16))
output.write(wrkaccid(ifile,3270,16))
output.write(wrkmisc2(ifile,3638))
output.write(wrkcov(ifile,3666,6))
Here is an article discussing the coding style of BitTorrent.
http://www.onlamp.com/pub/a/python/2003/7/17/pythonnews.html
Maybe that code is worth looking at.
--
http://mail.python.org/mailman/listinfo/python-list
According to my "Python in a Nutshell":
q.get(block=True)
is the signature, so, as you use it above, the call will hang until
something is on the queue. If block is false and the queue is empty,
q.get() will raise the exception Empty.
q.get_nowait is apparently synonymous with q.get(block=False)
I'd say that the tutorial text (by Dan Shafer) and the file starter1.py
are not in sync.
The word 'self' doesn't appear in the source file, it isn't a keyword
(just a convention) or a literal, and it isn't imported by wildcard or
some other trickery. So just by inspection you can tell that the nam
I was under the impression that IronPython is like CPython and Jython,
namely an implementation of the Python language. So in that sense it is
exactly like normal Python, although I don't know how convenient it is
to deploy.
I was also under the impression that Python for .NET is like an API
wrapp
I don't know exactly what a COM object is, but those aren't them. The
win32com package takes care of converting everything to Python types.
The excel call returns a tuple of tuples. That is, the outer tuple is
the sequence of rows, and each such row is itself a tuple with one
member per column requ
There is a new gratis VMWare player at
http://www.vmware.com/download/player/
You can download an image http://www.vmware.com/vmtn/vm/browserapp.html
that they call a Browser Appliance, but if I remember correctly it is
Ubuntu.
--
http://mail.python.org/mailman/listinfo/python-list
Max wrote:
> (Mark Shuttleworth, ...
> really loves Python - he gave me quite a lot of money for using it).
Please elaborate.
--
http://mail.python.org/mailman/listinfo/python-list
Even though its for any (not just Tcl) experienced programmer, and even
though you've got all the appropriate resources, I'll mention that you
should get a lot out of the book Dive Into Python, at
http://www.diveintopython.org/
--
http://mail.python.org/mailman/listinfo/python-list
The file C:\Python24\Lib\sitecustomize.py (which I think doesn't exist
by default) executes every time Python starts. (This means not just
your IDLE session but every time you run any Python script.)
One use for this file is to invoke sys.setdefaultencoding because that
name gets deleted during in
Another way to simulate the ternary operator is this:
a = (quantity > 90 and "It is very huge") or "The value is correct"
You have to be careful of semantics of 'and' and 'or'. But in this case
I wonder why you don't just test whether quantity is greater than 90
and assign the corresponding value
You should buy the book in hardcopy, that one looks fine.
--
http://mail.python.org/mailman/listinfo/python-list
First, in your intro you say you want to remove all strings of the form
"f=n;" where n can be 0-14. So you want to remove "f=0;" and "f=1;" and
... Later, you appear to be trying to remove "f=;" which may be what
you want but it doesn't match your described intentions.
Second, the formatting (whit
>I have the executable of a script that I wrote, that has been erased.
>Is there any way to retrieve the uncompiled python script from the
>executable that was created with py2exe?
You're gonna need a case of 20-weight ball bearings and several quarts
of antifreeze. Preferably Quakerstate. No, be
Harlin Seritt wrote:
> I have a remote linux server where I can only access it via ssh. I have
> a script that I need to have run all the time. I run like so:
>
> python script.py &
>
> It runs fine. When I log off ssh I notice that the script died when I
> logged off. How do I make sure it stays r
PythonWin 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.
>>> locals()['OSCAR'] = 'the grouch'
>>> OSCAR
'the grouch'
>>>
--
http://mail.python.or
>You were right, the HTMLParser of htmllib is more permissive. He just
ignores the bad tags !
The HTMLParser on my distribution is a she. But then again, I am using
ActivePython on Windows...
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I'm having problems sending information from a python
script to a printer. I was wondering if someone might send me
in the right direction. I wasn't able to find much by Google
TIA
Steve
--
http://mail.python.org/mailman/listinfo/python-list
Kristian Zoerhoff wrote:
> On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>>I'm having problems sending information from a python
>> script to a printer. I was wondering if someone might send me
>> in the right direction. I w
> First, I tried the usual "python setup.py install" but that did not work.
How exactly did it fail? Perhaps you can paste the error output from
this command.
--
http://mail.python.org/mailman/listinfo/python-list
You might find the Python Style Guide to be helpful:
http://www.python.org/doc/essays/styleguide.html
--
http://mail.python.org/mailman/listinfo/python-list
ees or warranties.
>
> Hope it helps.
>
> Larry Bates
>
> Steve M wrote:
>> Hello,
>>
>> I'm having problems sending information from a python
>> script to a printer. I was wondering if someone might send me
>> in the right direction. I wasn
Kristian Zoerhoff wrote:
> On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
>> Kristian Zoerhoff wrote:
>>
>> > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
>> >> Hello,
>> >>
>> >>I'm having problems sending in
> c/codegen.h:19:3: #error "sorry -- I guess it won't work like that on 64-bits
> machines"
The first error output by gcc suggests the 64-bit OS might be the
problem. But I don't actually know what that error means.
--
http://mail.python.org/mailman/listinfo/python-list
"when i attempted [to load 150MB xml file] my PC goes to lala land,
theres much HDD grinding followed by "windows runnign low on virtual
memory" popup after 10-15mins. Then just more grinding...for an hour
before i gave up"
I have had great success using SAX to parse large XML files. If you use
ca
[diegueus9] Diego Andrés Sanabria <[EMAIL PROTECTED]> wrote:
> Hello!!!
>
> I want know if python have binary trees and more?
You might be interested that ZODB comes with some B-tree
implementations. They can be used alone or you can persist them in the
ZODB quite easily.
http://www.zope.org/Wi
I agree with you in part and disagree in part.
I don't see the point to making the distribution any smaller. 10MB for
the installer from python.org, 16MB for ActiveState .exe installer. How
is 5MB "lightweight" while 10MB isn't? The Windows XP version of Java
at java.com is 16+ MB, and the .NET fr
There are some Python packages that I prefer to get from the developer
instead of from my Linux distribution (Debian).
Usually it is because I intend to upgrade the package before, or more
often than, my distribution releases a new version. (A likely scenario
if you use Debian - zing!)
So I downlo
You can approximate it by doing this at the command prompt:
# mkdir /z
#mount //blah/data /z
I assume 'blah' is the hostname for a Windows machine and 'data' is the
name of a share on blah. You might need to install smbfs and/or use
'mount.smb' and/or use 'mount -t smbfs'. Of course this can all b
You can check for membership in a list at least these ways:
my_list.index(candidate)
-returns the index into my_list of the first occurrence of candidate.
Raises ValueError if candidate doesn't occur in my_list.
my_list.find(candidate)
-returns the index into my_list of the first occurrence of ca
>My goal is to combine two different numbers and
encrypt them to create a new number that cann't be traced back to the
originals.
Here's one:
def encrypt(x, y):
"""Return a number that combines x and y but cannot be traced back
to them."""
return x + y
--
http://mail.python.org/mailman/l
The PYTHONPATH environment variable is good for that. For general
customizing beyond the path, you can make a file called:
C:\Python24\Lib\site-packages\sitecustomze.py
and it will be executed every time python runs. It might look like
this:
import sys
sys.path.insert(0, r'C:\Python24\mypython')
This is a heck of a can of worms. I've been thinking about these sorts
of things for awhile now. I can't write out a broad, well-structured
advice at the moment, but here are some things that come to mind.
1. Based on your description, don't trust the client. Therefore,
"security", whatever that a
Does anybody know:
Is this book fully up to date with Twisted 2.0?
Does the book cover Nevow at all?
Does the book cover general programming concepts related to
concurrency? I'm reminded of those high quality articles about
Deferreds and event programming by one of the Twisted developers?
What
I'm trying to invoke a Java command-line program from my Python program
on Windows XP. I cannot get the paths in one of the arguments to work
right.
The instructions for the program describe the following for the
command-line arguments:
java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFI
Well, apparently I fried my brain trying to sort this out. There is a
typo in my example code in the post but not in my real program. (I know
it is a no-no when asking help on c.l.py but I simplified some details
from the real code in order not to confuse the issues. Probably
backfired by this poin
What about PyInstaller that was announced the other day? The feature
list looks great, and it appears the developers intend to maintain and
enhance the program indefinitely.
http://groups.google.com/group/comp.lang.python/browse_thread/thread/b487056b7b1f99bc/583da383c1749d9f?q=ANN&rnum=1&hl=en#58
Thank you. I was able to fix it by putting the '-Dwhatever=x' bit
before the '-jar y.jar' bit. I had no idea this could matter.
Thanks all for the help.
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I'm trying to figure out the index position of a tuple member.
I know the member name, but I need to know the members index position. I
know that if I use the statement print tuple[4] that it will print the
contents of that location. What I don't understand is if I know that foo is
John Machin wrote:
>
> Steve M wrote:
>> Hello,
>>
>> I'm trying to figure out the index position of a tuple
> member.
>> I know the member name, but I need to know the members index
> position.
>
> Tuples, like lists, don't have
Steven Bethard wrote:
> Steve M wrote:
>> I guess I explained my problem incorrectly. Let me try again.
>>
>> tuple = ("fred", "barney", "foo")
>>
>> I know that foo is an element of tuple, but what I need to know is what
>> t
Michael Hartl wrote:
> I actually find it strange that tuples don't have an index function,
> since finding the index doesn't involve any mutation. Anyone know why
> Python doesn't allow a statement like t.index('foo')?
>
> In any case, you can use the index method of list objects if you
> conve
John Machin wrote:
>
> Steve M wrote:
>> I'm actually doing this as part of an exercise from a book. What the
> program
>> is supposed to do is be a word guessing game. The program automaticly
>> randomly selects a word from a tuple.
>
> Care to tell us whi
Steven Bethard wrote:
> Steve M wrote:
>> I'm actually doing this as part of an exercise from a book. What the
>> program is supposed to do is be a word guessing game. The program
>> automaticly randomly selects a word from a tuple. You then have the
>> oportun
I recently saw this:
http://www.egenix.com/files/python/mxTools.html
mx.Tools.verscmp(a,b)
Compares two version strings and returns a cmp() function
compatible value (<,==,> 0). The function is useful for sorting lists
containing version strings.
The logic used is as follows: the string
import sys, traceback
def e2str(id):
"""Return a string with information about the current exception. id
is arbitrary string included in output."""
exc = sys.exc_info()
file, line, func, stmt = traceback.extract_tb(exc[2])[-1]
return("%s: %s line %s (%s): %s" % (id, func, line, rep
I just happened across the page linked to below, and remembered this
thread, and, well... here you go:
http://www.lyra.org/greg/python/
Executable .pyc files
Ever wanted to drop a .pyc file right into your web server's
cgi-bin directory? Frustrated because the OS doesn't know what to do
with
Man, I don't even know where to start. There is no way this will work
if you don't have a web browser that can interpret Python. I don't know
of one, and I don't think anybody wants one because using a browser
that would execute arbitrary Python code provided by the server would
be an obscene secur
"""Derived from _Python Programming on Win32_ by Mark Hammond and Andy
Robinson"""
import win32com.client
import win32com.client.dynamic
class Excel:
def __init__(self, filename=None):
self.xlApp =
win32com.client.dynamic.Dispatch('Excel.Application')
if filename:
In case you haven't heard Microsoft is suing SCO for stealing his
Internet concepts and letters and numbers, so you should probably just
ditch OpenServer and get Debian like all the smart people have done.
I guess the quality of SCO software has declined over the last forty or
fifty years and they
Ben Edwards (lists) wrote:
> I am using python 2.4 on Ubuntu dapper, I am working through Dive into
> Python.
>
> There are a couple of inconsictencies.
>
> Firstly sys.setdefaultencoding('iso-8859-1') does not work, I have to do
> sys.setdefaultencoding = 'iso-8859-1'
When you run a Python script
[EMAIL PROTECTED] wrote:
> I must ask, in the interest of learning, what is
>
> [file for file in files if file.endswith(extension)]
>
> actually doing? I know that 'file' is a type, but what's with the set
> up and the brackets and all?
Other people explained the list comprehension, but you m
[EMAIL PROTECTED] wrote:
> Okay. This is almost solved. I just need to know how to have each
> entry in my final list have the full path, not just the file name.
from http://docs.python.org/lib/os-file-dir.html:
walk() generates the file names in a directory tree, by walking the
tree either top
I see you've had success with elementtree, but in case you are still
thinking about SAX, here is an approach that might interest you. The
idea is basically to turn your program inside-out by writing a
standalone function to process one myID node. This function has nothing
to do with SAX or parsing
> [Dermot Doran]
>
> | I'm very new to using win32com! I just want to send an email
> | message via Outlook. However, I keep getting an annoying
> | message box (generated by Outlook) indicating that my program
> | could be a virus. Does anybody know how to get around this?
The users in our of
I'm surprised you didn't recommend to use ZODB. Seems like an ideal way
to manage this large amount of data as a collection of Python objects...
--
http://mail.python.org/mailman/listinfo/python-list
This thread:
http://mail.python.org/pipermail/python-dev/2005-January/051255.html
discusses the problem with memory allocation in CPython. Apparently
CPython is not good at, or incapable of, releasing memory back to the
operating system. There are ways to compensate for this. I guess the
comment
class ExtendedTupleTable(Persistent):
def __init__(self):
self.interning = ObjectInterning()
# This Set stores all generated ExtendedTuple objects.
self.ets = Set() # et(s): ExtendedTuple object(s)
# This dictionary stores a mapping of elements to Sets of
Do you actually need to 'press' the button? Or do you just need the
effect that pressing the button would bring about (e.g., submitting a
Google search query and receiving the results page)?
If the latter, then you might want to search for, e.g., "html form get
post" and check out some results. Pu
This link seems to be about Closures in Python, but I am not feeling
sharp enough at the moment to evaluate the correctness of the
discussion.
http://en.wikipedia.org/wiki/Python_programming_language#Closures
As others have said, you might get more useful responses if you can
elaborate upon what
Below is some code adapted from something I think was written by Mark
Hammond. Originally I needed to create a Windows shortcut (link), and
this code does the trick, requiring only the target filename and the
desired shortcut name.
Now, I find I need to open a shortcut and extract the target filena
On Dec 6, 12:25 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> The rename works, but here is my problem: after getting what I thought
> was an exclusive lock on the new file, but before calling os.rename(), I
> can still over-write it from another process:
>
> $ echo "this com
I believe "Python in a Nutshell" has a couple of clear examples using
Queue and Threading, including one with a pool of worker threads that
wait for entries in one queue and place results in another.
Also you should look at the Python Cookbook, which probably includes
the same or similar examples
I think it means that names, not objects, are weakly typed. So you can
have:
a = 4
a = 'hello'
and there is no problem. The name 'a' doesn't have any type associated
with it. This contrasts with strongly typed language like C where you
declare the type of the name (variable) and the compiler objec
You have two lines inside the loop that ought to be outside the loop -
the initial assignment to fiveNumbers and the return statement. Also,
the line that appends new numbers to fiveNumbers is not quite correct -
the append() method modifies the list in place, rather than return a
new list.
Here's
An alternative is to use ZODB. For example, you could use the BTree
class for the outermost layers of the nested dict, and a regular dict
for the innermost layer. If broken up properly, you can store
apparently unlimited amount of data with reasonable performance.
Just remember not to iterate ove
73 matches
Mail list logo