473,804 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python vs Visual Basic

I want to create a program that will ask a user a series of questions
and then generate a Microsoft Word document whose content is dictated
by the answers. I am not a professional programmer, and I understand
only a little about OO programming. Should I

a) stick to -- *gasp* -- Visual Basic to accomplish my goal;

b) use Python, with which I am somewhat familiar, and which I would
prefer to use; or

c) find another hobby because I am only going to end up hurting
myself?

I am aware of the COM tools within Python, but I have not been able to
find documentation that makes much sense. Any pointers to good,
basic-level documentation would be much appreciated.
Jul 18 '05 #1
8 10704
Orange Free wrote:
I want to create a program that will ask a user a series of questions
and then generate a Microsoft Word document whose content is dictated
by the answers. I am not a professional programmer, and I understand
only a little about OO programming. Should I

a) stick to -- *gasp* -- Visual Basic to accomplish my goal;

b) use Python, with which I am somewhat familiar, and which I would
prefer to use; or

c) find another hobby because I am only going to end up hurting
myself?

I am aware of the COM tools within Python, but I have not been able to
find documentation that makes much sense. Any pointers to good,
basic-level documentation would be much appreciated.


I'm sure either language will be fine for the "asking questions"
part. In either case the hard times come in order to generate the
word document -- if you want to drive Microsoft Word for the purpose,
which is marginally easier from VB but not so much as to matter,
you need to learn something about the MS Word object model, which
IS quite rich and complicated.

May I suggest an alternative? Perhaps you might be satisfied with
generating a foo.rtf rather than foo.doc file. Now, the RTF format
isn't much easier or better documented than the DOC format, but it
has the advantage that RTF format files are TEXT. Thus, you could
prepare a "TEMPLATE" RTF file, using recognizable placeholders for
or around the parts of contents you may want to change; the
process of "generating the output" then becomes quite simple:
read the template RTF file, remove placeholders and contained
text around pieces you want to omit, substitute placeholders for
parts you need to substitute, remove all other placeholders only,
emit the resulting text, done. There are many templating systems
you can find on the net for Python, but, really, doing your own
is no biggie either.
Alex

Jul 18 '05 #2
Alex Martelli wrote:

Orange Free wrote:

May I suggest an alternative? Perhaps you might be satisfied with
generating a foo.rtf rather than foo.doc file. Now, the RTF format
isn't much easier or better documented than the DOC format, but it
has the advantage that RTF format files are TEXT.


I just looked at some RTF's, and they contain Ascii character 10's (\n)
not paired with Ascii character 13's (\r). This is not a TEXT
format file according to MS's OS's. If you try to write this data from
Python as a text file, you'll get the \r's inserted automatically, the
contents of the file will change, and who knows what will result.

Still, the rtf format is a good one because other programs more
affordable than MS Word do a reasonably good job of reading and
writing it.

Al
Jul 18 '05 #3

"Orange Free" <or**********@y ahoo.ca> wrote in message
news:sl******** *************** **@localhost.lo caldomain...
I want to create a program that will ask a user a series of questions and then generate a Microsoft Word document whose content is dictated by the answers. I am not a professional programmer, and I understand only a little about OO programming. Should I

a) stick to -- *gasp* -- Visual Basic to accomplish my goal;

b) use Python, with which I am somewhat familiar, and which I would
prefer to use; or

c) find another hobby because I am only going to end up hurting
myself?

I am aware of the COM tools within Python, but I have not been able to find documentation that makes much sense. Any pointers to good,
basic-level documentation would be much appreciated.


Mark Hammond, who wrote the Windows extensions that include the COM
tools, also wrote Python Programming on Win 32. Oreilly's page
http://www.oreilly.com/catalog/pythonwin32/
has a link to the following sample chapter
http://www.oreilly.com/catalog/pytho...pter/ch12.html
Chapter 12 Advanced Python and COM.

Several c.l.py posts have given other examples of COM programming.

TJR
Jul 18 '05 #4
On Mon, 13 Oct 2003 07:56:45 -0700, ac*****@easystr eet.com wrote:
Alex Martelli wrote:

Orange Free wrote:

May I suggest an alternative? Perhaps you might be satisfied with
generating a foo.rtf rather than foo.doc file. Now, the RTF format
isn't much easier or better documented than the DOC format, but it
has the advantage that RTF format files are TEXT.


I just looked at some RTF's, and they contain Ascii character 10's (\n)
not paired with Ascii character 13's (\r). This is not a TEXT
format file according to MS's OS's. If you try to write this data from
Python as a text file, you'll get the \r's inserted automatically, the
contents of the file will change, and who knows what will result.


I just looked at an RTF file generated by MS Word. It had standard
MS-DOS line ends.

I believe that RTF doesn't much care which line-end convention you
use. RTF is meant to be a platform independent interchange file, so I
suspect programs importing them are expected to handle all common
conventions and the programs creating them probably use whatever line
end convention is normal on that platform.

Line ends are actually mostly irrelevant in RTF files. Paragraph
breaks, for instance, are specified by the '\par' RTF command. Even if
you put a line break in the middle of a text word, it doesn't seem to
break the word up once imported into Word.

I believe the line end counts as whitespace where RTF requires
whitespace, but that is its only significance. Other than that it is
ignored. Though I haven't double checked, so don't sue me if there are
some cases where that isn't true.

Certainly in the context of Alex Martellis suggestion, the "what will
result" is basically no problems whatsoever. Well, OK, I suppose the
file size will get a few bytes shorter ;-)
--
Steve Horne

steve at ninereeds dot fsnet dot co dot uk
Jul 18 '05 #5
<posted & mailed>

Alex Martelli wrote:
Orange Free wrote:
I want to create a program that will ask a user a series of
questions and then generate a Microsoft Word document whose
content is dictated
by the answers. I am not a professional programmer, and I
understand
only a little about OO programming. Should I

[snip]
May I suggest an alternative? Perhaps you might be satisfied with
generating a foo.rtf rather than foo.doc file. Now, the RTF
format isn't much easier or better documented than the DOC format,
but it
has the advantage that RTF format files are TEXT.


I've read that the latest version of MS Word (or MS Office?) heavily
uses XML. If that's true, perahps you should consider generating
foo.xml that follows the MS Word XML document definition (again, if
there is such a thing).

Here is a quote from Tim Bray:

<quote>When asked how XML-enabling will make a difference in MS
Office, Bray quickly zeroes in on what in his view is the key
differentiator in an XML-enabled Office suite vs the current one.
"The important thing," he explains, "is that Word and Excel (and of
course the new XDocs thing) can export their data as XML without
information loss. It seems Word can also edit arbitrary XML
languages under the control of an XML Schema, but I'm actually more
excited by the notion of Word files also being XML files."</quote>

And here is a link to the complete article:

http://www3.sys-con.com/xml/rotate.cfm

[snip]

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
dk******@rexx.c om
Jul 18 '05 #6
Stephen Horne wrote:

Certainly in the context of Alex Martellis suggestion, the "what will
result" is basically no problems whatsoever. Well, OK, I suppose the
file size will get a few bytes shorter ;-)


That's good. I've seen some RTF's that end with a binary 0 byte.
That's not text either, but the RTF's I looked at today, probably
created by Abiword or Open Office, don't have it.

Can't RTF's contain arbitrary binary data embedded within (eg images)?
Al
Jul 18 '05 #7
Can't RTF's contain arbitrary binary data embedded within (eg images)?

From the RTF specification:

Pictures
An RTF file can include pictures created with other applications. These
pictures can be in hexadecimal (the default) or binary format.
Jul 18 '05 #8
Dave Kuhlman wrote:
...
questions and then generate a Microsoft Word document whose
... May I suggest an alternative? Perhaps you might be satisfied with
generating a foo.rtf rather than foo.doc file. Now, the RTF
... I've read that the latest version of MS Word (or MS Office?) heavily
uses XML. If that's true, perahps you should consider generating
foo.xml that follows the MS Word XML document definition (again, if


If it's OK to generate a MS Word document file that's only readable
by Windows/XP or however they call their latest version, Dave is most
probably right. In most cases in which I've been asked to generate
Office files, compatibility to previous releases (generally back to
Office'97) was a requirement, expressed or implied (many non-techies don't
realize this requirement isn't _automatically_ satisfied...) so I tend to
assume it -- sorry, I should have made it explicit (but then so should the
OP have, so we're even:-).
Alex

Jul 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35568
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
65
6768
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
8
2293
by: Will | last post by:
I just discovered Python and looked briefly at one of the tutorials for beginners... It looks a lot like the old Command line Basic... I'm sure it does much more but... 1 - Can you create windows, buttons, user input fields, etc as you can with Visual Basic? 2 - Can you call Windows Procedures or what ever they call them
14
4533
by: BOOGIEMAN | last post by:
Well that's it, how do I make Windows Application with Python ??? Is there simple way that works 100% ? How can I rework visual design done in VS 2003 to use it for my python program ?
32
8101
by: Mike Cox | last post by:
As you may or may not know, Microsoft is discontinuing Visual Basic in favor of VB.NET and that means I need to find a new easy programming language. I heard that Python is an interpreted language similar to VB. This means that it doesn't have all the hard stuff like pointers, classes and templates like C, C++ and assembly language. Where I work we use Microsoft Office with a lot of customization using Visual Basic. I would like to...
12
12288
by: Rex Eastbourne | last post by:
Hi, I'm interested in running a Python interpreter in Emacs. I have Python extensions for Emacs, and my python menu lists "C-c !" as the command to run the interpreter. Yet when I run it I get the message "Spawning Child Process: invalid argument." What do I need to do/download to fix this? I read in a post in this group from a while back where someone had the following lines in his .emacs file:
35
2392
by: John Coleman | last post by:
Greetings, I have a rough classification of languages into 2 classes: Zen languages and tool languages. A tool language is a language that is, well, a *tool* for programming a computer. C is the prototypical tool language. Most languages in the Algol family are tool languages. Visual Basic and Java are also tool languages. On the other hand, a Zen language is a language which is purported to transform your way of thinking about...
23
2413
by: gord | last post by:
As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list processing, arithmetic calculations - all in a DOS-like environment. What is particularly disappointing is the absence of a Windows IDE, components and an event driven paradigm. How does Python stand relative to the big 3, namely Visual C++,...
122
7454
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection outside of that class. This structured way allows visual tools to host components, and allows programmers to build applications and libraries visually in a RAD environment. The Java language has JavaBeans as its component model which allows Java...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.