Re: NEWBIE

2005-10-26 Thread BartlebyScrivener
Start here

http://www.ibiblio.org/obp/thinkCSpy/

and here

http://wiki.python.org/moin/BeginnersGuide

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


mxODBC sql MSAccess

2005-11-21 Thread BartlebyScrivener
Hello, I'm new to python and trying to get records from an MSAccess
database using mxODBC. It works, but the output is not formatted the
way I want it.

Here's the script:

import mx.ODBC.Windows as odbc

driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:/Access
Databases/Quotations2005'

conn = odbc.DriverConnect(driv)
c = conn.cursor()
c.execute ("SELECT Author, Topic1, Topic2, Quote FROM QuotesToTxt WHERE
Author LIKE 'Mencken%'")

rows = c.fetchall()
for r in rows:
print r

And here's what I get:

('Mencken, H.L.', 'Americans', 'Democracy', 'Democracy is the theory
that the common people know what they want, and deserve to get it good
and hard.')
('Mencken, H.L.', 'Conscience', 'Mother-In-Law', 'Conscience is a
mother-in-law whose visit never ends.  The inner voice which warns us
that someone may be looking.')

Where are the parenthese and single quotes coming from? SQL or mxODBC?
And how can I get just simple tab-delimited records with a standard
carriage return separating the records?

Thanks so much for any help.

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mxODBC sql MSAccess

2005-11-21 Thread BartlebyScrivener
Works!!

Thank you all so much. I didn't know it was coming back as a tuple, and
I'm sure that would have taken me four hours to figure out.

Appreciate it!

bs



Chris Curvey wrote:
> mxODBC implements the Python DB-API spec, which states that each "row"
> of query results is  returned as a tuple.  If you want the data
> displayed differently, you can do it yourself.
> 
> for row in rows:
> print "\t".join(row)
> 
> should do it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python book for a non-programmer

2005-11-25 Thread BartlebyScrivener

Simon Brunning wrote:
> I have a non-programming friend who wants to learn Python. It's been
> so long since I've been in her shoes that I don't feel qualified to
> judge the books aimed at people in her situation. I know of two such
> books:
>
> 
> 
>
> Any recommendations, or otherwise?
>
> --
> Cheers,
> Simon B,
> [EMAIL PROTECTED],
> http://www.brunningonline.net/simon/blog/

If you want real (dead-tree) books, you will find Chris Fehily's Visual
Quickstart Guide recommended by others here  (though it's ageing -
2002). I'm about 2/3 through and it's been great for me:

http://www.amazon.com/exec/obidos/asin/0201748843/richarddooling/

And a brand new one which I just ordered: Beginning Python (Programmer
To Programmer) which despite the title has a great intro to programming
before it quickly accelerates:

http://www.amazon.com/exec/obidos/asin/0764596543/richarddooling/

Cheers,

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread BartlebyScrivener
Search this group for PythonCard and wxPython for gobs of opinions. For
descriptions of other resources, try:

http://www.fredshack.com/docs/python.html

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread BartlebyScrivener
Search this group for PythonCard and wxPython for many posts on this
subject. Also see the following link for descriptions of other
alternatives:

http://www.fredshack.com/docs/python.html

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread BartlebyScrivener

[EMAIL PROTECTED] wrote:
> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.
>
> I am not an experienced programmer - just someone who from time to
> time writes small programs for my use.  Over the years I have moved
> from GWBASIC to QBASIC to Visual Basic, and now trying to move across
> to a Linux platform.  Python seems to be the best compromise between
> the limitations of command line basic programming and the total
> incomprehensibility of C.
>
> Googling around it seems the best GUI is either Tkinter or PyGtk.  I
> found a book which recommended PyGtk, as it had a graphical design
> option,  Glade.  Coming from a VB background I latched onto that and
> bought the book (Beginning Python, Wrox), but it was a disappointment
> (or more accurately a complete waste of money) - there was
> insufficient detail in the text.
>
> I've found the tutorial and reference manual on the PyGtk web site,
> but although I've made some progress, I keep reaching points where I
> have insufficient background to understand them. Currently I'm stuck
> on dialog boxes (the code seems immensely complex for the equivalent of
>   MsgBox("Do you really want to do this ",vbYesNo) and I haven't
> got it to work properly yet) and loading graphical images in anything
> other than their original size, but every new step brings another
> struggle
>
> I've seen reference to a Tkinter book - something like 'Python
> and Tkinter Programming' but it seems to be out of print and
> unavailable.
>
> Can anyone offer any suggestions as to the least painful way forwards?
>
> (Email address was valid once but has long since been abandoned to
> spam. Please rely via newsgroup)

I responded twice to this but it didn't post. Weird. Anyway, search for
PythonCard and wxPython in this group. And then, for more options,
check this page:

http://www.fredshack.com/docs/python.html

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for good beginner's tutorial

2005-11-29 Thread BartlebyScrivener
It's deja vu all over again. If the link breaks, search the group
non-programming tutorial

http://groups.google.com/group/comp.lang.python/browse_frm/thread/4b7a01e1feb128fa/a6b51baa0ca01c19?q=fehily+&rnum=10#a6b51baa0ca01c19

Good luck

bs

Roy Smith wrote:
> My wife wants to learn Python.  Can anybody suggest a good tutorial
> for her to read?  She's a PhD molecular biologist who is a pretty
> advanced Unix user.  She mucks about with Perl scripts doing things
> like text processing and even some simple CGI scripts, but has no
> formal programming training.
>
> I looked at Dive Into Python, but it's going to be way over her head.
> I didn't think the tutorial on www.python.org would do it for her
> either.  Any other suggestions I might look at?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse best/good or bad IDE for Python?

2005-12-03 Thread BartlebyScrivener
>>if it is the *best* IDE for Python. <<

Nobody can answer this for you. Just try them all. The two I like that
I don't see mentioned in this thread are PythonCard (which is free) and
WingWare (which costs $30.00 but you can try for free.)

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Equivalent to Text::Autoformat

2005-12-03 Thread BartlebyScrivener
I'm new to both Perl & Python.

Is there a Python module or script somewhere comparable to the useful
Perl module - Text::Autoformat?

Thanks,

BS

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread BartlebyScrivener
>>try searching on text wrapping<<

I tried that before I posted. Text::Autoformat does a lot more than
textwrap.

"The fundamental task of the autoformat subroutine is to identify and
rearrange independent paragraphs in a text. Paragraphs typically
consist of a series of lines containing at least one non-whitespace
character, followed by one or more lines containing only optional
whitespace. This is a more liberal definition than many other
formatters use: most require an empty line to terminate a paragraph.
Paragraphs may also be denoted by bulleting, numbering, or quoting . .
."

Once a paragraph has been isolated, autoformat fills and re-wraps its
lines according to the margins that are specified in its argument list.
These are placed after the text to be formatted, in a hash reference:"

It's also sensitive to comment characters in code and so on.

But I'll keep looking. Thank you. 

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread BartlebyScrivener
Formatter and docutils both look promising.

Thanks for providing the terminology to search on.

-rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread BartlebyScrivener
>>Hmmm... I'm not an expert in this subject but isn't Ubuntu based on
Debian? <<

I'm no expert either. I've played with Ubuntu and Debian, and Debian
seemed infinitely more stable, and also, for me, Debian installed more
easily.

Since it's a python board I'm most interested in the python
implications. I thought you could use, say, a stable Debian
distribution, and still download the newest version of Python to run on
it. Is that not so?

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread BartlebyScrivener
Thank you, malv & Frederik, for the warnings. I am learning Python on
windows with the hope of moving to Linux. I would have just assumed the
new Python would be backward compatible and didn't realize how
dependent the os was on the old version.. At least now I am aware of
the issues.

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python...

2005-12-05 Thread BartlebyScrivener
Wow, That's one I hadn't seen before. Thanks. 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
>> It's tough to put yourself in the shoes of a
novice, so it's tough to write documentation that would be helpful for
new
users.  It's extremely helpful if new users submit documentation
patches as
they figure things out.  It's generally unnecessary to write large
tomes.
Often all that's needed is a few sentences or an example or two. <<

Yes, well, regardless of your beef with the person who complained about
documentation, I respectfully submit that it is not so easy to help out
with documentation. I'm a professional writer and author with a keen
interest in open source, but the moment you look to contribute or try
to help with the documentation you are asked to learn LaTex or DocBook,
which, I'm sorry, I am not going to do.  Authors and writers are
usually drawn to open source software by their love of plain text.
Even veteran Linux users have a lot of trouble with LaTex, so the
writers, who perhaps would be willing to help with writing in exchange
for help with programming, are unable to do so without learning yet
another arcane and foreign mark-up language, which frankly won't be
useful in any other writing endeavor. How about a compromise, like
having documents submitted in html or some other system that is more
cross platform than LaTex?

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
Go to Python.org

Click on DEVELOPERS

The lead sentence says:

Contributors and potential contributors should read Documenting Python,
which describes in details the conventions and markup used in creating
and maintaining the Python documentation. The CVS trunk version is the
recommended version for contributors, regardless of which Python branch
is being modified.

The link takes you straight to a primer on LaTex.

Did I miss something?

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
Thank you. I shall try that the next time I see something in the
documentation for beginners. Generally the Python docs are quite good,
in my opinion. I was merely taking issue with the poster who suggested
that Python novices and nonprogrammers should complain less and
contribute more. It's not immediately apparent how to contribute. And
if you go looking via the main page you end up in a LaTex tutorial.

bs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
>>Let me repeat this for the umpteenth time: You do not have to learn LaTeX to
contribute to docs. <<

Noted. And thanks again to all who responded. The tone of this whole
thing is really antagonistic in parts, which is unfortunate. I'll offer
my services through the proper channels, because I appreciate the
generosity of those who share their programming knowledge. In the
meantime, I think perhaps Bengt Richter's post is probably the most
constructive.

Meanwhile, if you have to keep repeating things for the umpteenth time
then it MIGHT be because the way it is laid out or organized is making
it difficult for the person seeking to VOLUNTEER to help. And we come
full circle to documentation.

Why do people continue getting the impression that they need to learn
LaTex to submit documentation?  A writer would look to his text. A
programmer would probably just accuse his audience of being obtuse.

rpd
www.dooling.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
>>The solution is clear: the distro maintainers should require that all
code contributions must come with good docs.  When a code submission
comes in, the distro maintainers should critically review the
accompanying docs, note any shortcomings and constructively ask for
improvements from the contributor until the docs are good.  <<

Well, that might be asking a bit too much of the programmers, who
perhaps don't exactly enjoy mucking about in the lowlands of English
grammar and syntax. All I was saying is you should court writers and
mid-level programmers with writing skills (not saying I'M mid-level,
I'm still learning) to HELP with creating good documentation. When a
writer thinks about helping they go to a page where they are greeted by
a bug report menu or CSV notices or some such. That's why most of your
really good stuff for beginners is on separately created web pages,
where writers simply take matters into their own hands. Also fine, not
saying it should be different.

Again, taking something like Bengt Richter's suggestion as just one
example. To me the module docs are almost incomprehensible without good
examples. Why not have a button where people could submit nice SHORT
examples illustrating otherwise pure theoretical code and geek-speak.
Of course, the editors would decide in a survival-of-the-fittest
contest which example gets used, but the point is you'd get good free
examples this way.

In general, I'd be happy to help a programmer with writing if it meant
I would learn programming along the way. It should be that easy. 

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread BartlebyScrivener
>>Or, better still, by an accomplished writer who has access to the code's
author. This was indeed my experience in writing the docs for
previously
undocumented modules. The author was happy to help me by answering
questions, and this did make the docs better than they'd otherwise have
been. <<

Now you're talking. The writer forces the programmer to explain how the
code works, in plain English, until the writer understands it. Then the
writer creates simple sentences written in the active voice with vivid
particular examples to illustrate. Voila. 

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-06 Thread BartlebyScrivener
>> A series of examples seems more concrete than a formal description,<<

Amen. This is why people buy the books:  The good ones have lots of
examples. The wizards glance at them in passing and think, "Duh." And
the rest of us (including the intermediate folks, I'll bet) are
grateful for the chance to see a real live example.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-06 Thread BartlebyScrivener
You are correct about the tutorial. Just try to look at the home page
through the eyes of a curious Windows user who wants to learn
programming and is trying to decide whether to take up Perl, Ruby,
Python, or Visual Basic, let's say.

On the home page, the first link that catches the eye for this user is:
"Beginner's Guide to Programming -  start here if you're new to
programming ." That's me. Click.

Now you are on a page with promising-looking links that all start with
"BeginnersGuide," but the first three are not warm welcomes, they are
housekeeping matters about where you can take courses or how to
download Python for people who don't know whether they want to or not
yet, or there's one that says "examples" which will take you to the
ActiveState Cookbook site so you can get really confused.

Then you hit the link that says "BeginnersGuide/Nonprogrammers" Ah!
That's me. 

The first prominent link says: "Python Tutorial" along with a notice at
the top of the page that tells you if you've never programmed before
this is the page for you.

Click on Python Tutorial. Some official business to start off. Then you
see, "Whetting Your Appetite" Ah, I am ready for that. 

The first sentence reads:

"If you ever wrote a large shell script, you probably know this
feeling: you'd love to add yet another feature, but it's already so
slow, and so big, and so complicated; or the feature involves a system
call or other function that is only accessible from C ...Usually the
problem at hand isn't serious enough to warrant rewriting the script in
C; perhaps the problem requires variable-length strings or other data
types (like sorted lists of file names) that are easy in the shell but
lots of work to implement in C, or perhaps you're not sufficiently
familiar with C."

Most of the site has been laid out by programmers, for programmers, who
apparently want to keep it that way, based upon what I've seen.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread BartlebyScrivener
Yep, Guido's tutorial belongs on the Python for Programmers page where
people know who he is and are able to understand him.

> Alan Gauld's tutorial is very popular on the
> tutor list, so is A Byte of Python (which is not listed on the
> NonProgrammers page). I would list them first. Or maybe take a vote on
> the tutor list for favorite beginner's tutorial.

And perhaps How To Think Like A Computer Scientist. Then maybe
introduce them with a single sentence like:

"Python is so easy to learn and immediately useful that many popular
tutorials use Python to teach computer programming."

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread BartlebyScrivener
Might be better as:

"Many popular tutorials use Python to teach computer programming,
because Python is free, easy to learn, immediately useful, and fun!"

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-08 Thread BartlebyScrivener
Andrew,

The site changes for the new-to-Python person are a big improvement in
terms of the sequence of exposures, but from a marketing perspective,
the first thing they read about Python is still aimed at a programmer.
The bulleted points in BeginnersGuide/Overview are, again, things that
are important to programmers ("Automatic garbage collection frees you
from the hassles of memory management" means nothing to me, even now
after reading a Python book and several tutorials).

I wish there were some sort of sexy exposure to Python before hitting
them with the download. Again you purport to be making a page for
someone who's never programmed before, so almost certainly a Windows
user. And a Windows user is not going to download any program until
he's absolutely sure it won't destabilize his fragile system or infect
it. So nobody new to programming and new to Python is going to download
at the point you present them with that opportunity. Too bad there
isn't something like what Ruby does with the "Try Ruby In Your Browser"
thing, which is a very effective marketing tool (although obviously I
chose Python).

http://tryruby.hobix.com/

The other thing I vividly recall struggling with was: Do I download
this Python.org version for my Windows XP machine, because it's the
official one, or do I use the one from ActiveState because others say
it comes with all sorts of goodies for Windows users? I don't know what
the politics are there, but if I were you I'd take a stand and put it
on the download page to help the new person out, who is uncertain about
what to do.

Ultimately I downloaded ActiveState because I found their site easier
to understand (again speaking as a person relatively new to programming
and absolutely new to Python).

Thanks,

rpd

"I read part of it all the way through."--Samuel Goldwyn

www.dooling.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-08 Thread BartlebyScrivener
The actress Margaret Anglin left this note in the dressing froom of
another actress:

'Margaret Anglin says Mrs. Fiske is the best actress in America.'

Mrs. Fiske added two commas and returned the note: 'Margaret Anglin,
says Mrs. Fiske, is the best actress in America.'

Or this, from a George Will column:

Huge doctrinal consequences flow from the placing of a comma in what
Jesus, when on the cross, said to the thief (Luke 23:43): 'Verily, I
say unto thee, This day thou shalt be with me in Paradise' or 'Verily,
I say unto thee this day, Thou shalt be with me in Paradise.' The
former leaves little room for purgatory.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-08 Thread BartlebyScrivener
You guys are all wizards from mars. If it's easy to do I can tell you
that it would very seductive to a prospective Pythoner, and you avoid
the problem of making them download before they can try out a tutorial.
Thanks for looking at it.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another newbie question

2005-12-09 Thread BartlebyScrivener
>>http://en.wikipedia.org/wiki/Law_of_Demeter <<

That was fun. Thanks, Kent.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to detect the presence of a html file

2005-12-09 Thread BartlebyScrivener
Even weirder,

os.path.isfile(r'c://bookmarks.html')

also seems to work. 

How is that?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to detect the presence of a html file

2005-12-09 Thread BartlebyScrivener
> Even weirder,

> os.path.isfile(r'c://bookmarks.html')

Never mind. It works that way from the command line, too. Never tried
it before.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-09 Thread BartlebyScrivener
Mike,

This is probably a dumb thing to suggest, but I'm interested in knowing
why it's dumb, if that makes sense?

Could you use one of those free VMWare players? It makes a virtual
operating system within an operating system as I understand it.

http://www.vmware.com/products/player/

I just think it's cool that somebody tries to make a Try Python In Your
Browser toy. You'll convert the multitudes to Python.

Let me know if you want any help creating the messages for the complete
idiot

rd
www.dooling.com

"The question is not whether machines think, but whether men do."--B.F.
Skinner

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reddit.com rewritten in Python

2005-12-10 Thread BartlebyScrivener
More

http://reddit.com/blog/2005/12/on-lisp.html

and more

http://www.findinglisp.com/blog/2005/12/reddit-and-lisp-psychosis.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Great books on Python?

2005-12-11 Thread BartlebyScrivener
http://www.awaretek.com/tutorials.html#regular

-- 
http://mail.python.org/mailman/listinfo/python-list


mxODBC argv sql query

2005-12-12 Thread BartlebyScrivener
This can't be the most elegant way to get a command line parameter into
an sql query. It works but I can't explain why. Is there another, more
correct way? Here sys.argv[1] is a topic like "laugher" or "technology"

import mx.ODBC.Windows as odbc
import sys

driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:/Access
Databases/Quotations2005'

conn = odbc.DriverConnect(driv)
c = conn.cursor()

c.execute ("SELECT Author, Topics.Topic1, Topic2, Quote FROM QUOTES7
WHERE Topics.Topic1 LIKE '%%%s%%'"  % sys.argv[1])

rows = c.fetchall()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern matching with string and list

2005-12-13 Thread BartlebyScrivener
Taking you literally, I'm not sure you need regex. If you know or can
find position n, then can't you just:

sentence = "the color is $red"
patterns = ["blue","red","yellow"]
pos = sentence.find("$")
for x in patterns:
if x==sentence[pos+1:]:
print x, pos+1

But maybe I'm oversimplifying.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern matching with string and list

2005-12-13 Thread BartlebyScrivener
Even without the marker, can't you do:

sentence = "the fabric is red"
colors = ["red", "white", "blue"]

for color in colors:
if (sentence.find(color) > 0):
print color, sentence.find(color)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how can i change the default python?

2005-12-13 Thread BartlebyScrivener
Another thread touched on the dangers of doing this, if other
applications depend on the older version of Python.

http://groups.google.com/group/comp.lang.python/browse_frm/thread/51c8fba4098879ad/734b6bdac1d74b89?lnk=st&q=&rnum=10#734b6bdac1d74b89

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between ActivePython and Python.org

2005-12-14 Thread BartlebyScrivener
I fretted about which to pick and have advised here that the difference
(if any) should be explained on the Python.org download page. I chose
ActiveState because I'm on Windows XP, which means that the Win32
Extensions get installed automatically, along with other goodies (the
PythonWin IDE, a pretty help file, etc).

If you look at the Python.org download page, the win32 extensions are a
separate download: "Windows users may also be interested in Mark
Hammond's win32all package, available from Sourceforge. win32all adds a
number of Windows-specific extensions to Python, including COM support
and the Pythonwin IDE."

I have never installed the Python.org binaries, maybe it has a whole
'nother set of goodies, but I'm sure someone here will jump in and
explain the difference, if any.

The ActiveState version lags behind for a month or two in versions,
probably so they can check to make sure everything works together, but
right now, both AS and PO are showing Python 2.4.2 

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python packages on OS X vs Windows

2005-12-14 Thread BartlebyScrivener
> And on a somewhat related note, do people find ipython to be a decent
> replacement
> on Windows for the fact that the Windows shell is braindead?

I'm curious about this part of the post. Any fluent Pythoners actually
happy using Windows XP and, if so, do they use ipython as a kind of
bash shell substitute? Other alternatives to compensate for the widely
derided command line in windows?

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python packages on OS X vs Windows

2005-12-15 Thread BartlebyScrivener
Mike,

I nosed around after reading the posts herein. Have you heard of monad,
the new Windows Command Shell in beta?

http://www.microsoft.com/downloads/details.aspx?FamilyID=2ac59b30-5a44-4782-b0b7-79fe2efd1280&DisplayLang=en

http://en.wikipedia.org/wiki/MSH_(shell)

Or a better article:

http://arstechnica.com/guides/other/msh.ars

Might be promising, esp if it could be downloaded and used with xp.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any good Python forums?

2005-12-15 Thread BartlebyScrivener
This is a helpful and active place.

It works in tandem with Python.org, so the polite thing to do is check
the FAQ at:
http://www.python.org/doc/faq/ before posting, and also maybe search
comp.lang.python first, especially if, for instance, you want to know
about good Python books, popular IDEs, and so on, as these get asked
and answered twice a week.

Otherwise it works best if you TRY code, and then when it doesn't work,
post it and ask for help.

Good luck

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text manipulation

2005-12-16 Thread BartlebyScrivener
John,

Martin is right. Always try to solve without regex first. However, for
those situations where you definitely need regex, use this tutorial:

http://www.amk.ca/python/howto/regex/

It's well-written, succinct, and Python-specific.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wingide is a beautiful application

2005-12-18 Thread BartlebyScrivener
If you're on Windows XP why not try Xemacs? That's free and does syntax
highlighting etc. Doesn't have a problem with large files and so on.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wingide is a beautiful application

2005-12-19 Thread BartlebyScrivener
Go to Options. Near the bottom, it will say "Edit Init.File"  Click on
it.

Make an entry on a separate line near the top as follows

(require 'python-mode)

Then save the init file.

When you open files with a .py extension xemacs should automatically go
into "python mode"

If you read the init.el file it will teach you a little about how to
configure it. If you don't care about that and only want a python
editor, then just add the line above.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread BartlebyScrivener
What's needed is STRICTER whitespace enforcement, especially on April
Fools Day. Some call it whitespace fascism.

http://www.artima.com/weblogs/viewpost.jsp?thread=101968

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread BartlebyScrivener
The PEP is not a joke. It's a sensible set of guidelines. The blog post
advocating enforcement is, shall we say, a sportive modest proposal?

rpd
www.dooling.com

"There is no human problem which could not be solved if people would
simply do as I advise."--Gore Vidal

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows and python execution

2005-12-26 Thread BartlebyScrivener
Well, can't help with the registry, but I suppose you could search
google for "edit system variables path registry" and find the hard way.
The easy way is:

You need to add the path of the directory where you keep myscript.py to
your system path. You do this by going to Control Panel | System |
Advanced | Environmental Variables. At the bottom under System
Variables, edit the variable PATH and add the directory where you want
to keep your Python scripts.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows and python execution

2005-12-26 Thread BartlebyScrivener
>> What you need to do is include the following line in autoexec.bat:
>> set .py=c:\python24\python.exe

Whatever works for you. I don't have that command in my autoexec.bat
file and my python scripts execute from any location because the
directory they are stored in is in my PATH variable.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows and python execution

2005-12-26 Thread BartlebyScrivener
The installer can put python.exe in his PATH but if he's storing his
scripts in some oddball place then he has to tell Windows where to find
them.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows and python execution

2005-12-26 Thread BartlebyScrivener
>>What I was trying to do was execute a  python script without
having to type the word "python" explicitly. For that, you need the
"set" command that I listed in a previous post.<<

I'm not confused and I like to keep my scripts in oddball places too.
Namely d:\python. All I'm saying is I don't use the set command. I
don't have an autoexec.bat file. I simply place d:\python in the path
variable and I can execute python scripts from the command line from
any directory without typing "python" first. I just type "myscript.py"
and it executes. Okay. You're welcome. 

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows and python execution

2005-12-28 Thread BartlebyScrivener
Some of the confusion probably comes from which installation people
use. I used the latest ActiveState distribution of Python. As one of
the other posters observed it automatically adds the .py extension in
the PATHEXT system variable. At least I didn't put it there. Then, as
we've discussed, as long as the directory containing your scripts is in
the path, you can type nothing by "myscript.py" at the command line and
your script will execute from any location on the machine.

rpd

Peter Hansen wrote:
> Peter Hansen wrote:
> > BartlebyScrivener wrote:
> >>>>What you need to do is include the following line in autoexec.bat:
> >>>>set .py=c:\python24\python.exe
> >>
> >>Whatever works for you. I don't have that command in my autoexec.bat
> >>file and my python scripts execute from any location because the
> >>directory they are stored in is in my PATH variable.
> ...
> > Merely adding the folder containing the EXE to PATH does *not* let you
> > avoid typing "python" before the script name, as your posts imply.
>
> D'oh... okay, people (including me) are reading others' posts with
> preconceptions about what they are talking about in mind.
>
> The PATHEXT thing is required to be able to type just "scriptname"
> _without_ the .py extension.  Alternatively, it appears there's yet
> another obscurely documented feature involving setting environment
> variables that resemble file extensions, as posted by others.  (Where do
> these things come from?  It's like Microsoft releases the OS, then
> periodically sends private emails to random people, pointing out obscure
> new features, so that they can tell others in some feeble effort to make
> using Windows look like a grassroots effort or something.  How are
> regular mortals supposed to find out about things like "set .py="?)
>
> The ability to run the script with just "scriptname.py" comes from, I
> believe, having a file association set up with "ftype" and "assoc" or
> the equivalent registry entries.  For this to work from _any_ location
> one must have the folder containing the *script* in the PATH, as with
> any executable, while the path specified by FTYPE points to the Python
> executable.  (This ftype/assoc file association is set up by the
> standard installer, which is why it works for BartlebyScrivener).
> 
> -Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spiritual Programming (OT, but Python-inspired)

2006-01-02 Thread BartlebyScrivener
"The highest activities of consciousness have their origins in the
physical occurrences of the brain just as the loveliest of melodies are
not too sublime to be expressed by notes."--Somerset Maugham

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie with some doubts.

2006-01-04 Thread BartlebyScrivener
Try this.

http://www.ibiblio.org/g2swap/byteofpython/read/oops.html

Best thing is to do a little reading, then wait until you have a
problem or a project that would provide the occasion to create your
first class. Then try it, and if it doesn't work, post it here with (1)
what you were trying to do; (2) the code you used; (3) the result,
including error messages that you got. Also, it usually helps to search
the group first, or even do a google search before posting.




Edgar A. Rodriguez wrote:
> Hi everybody,
>
> Im newbie to Python (I found it three weeks ago) , in fact Im newbie to
> programming. I'm being reading and training with the language, but I
> still wondering about what Classes are used to. Could you please give
> me some examples??
> 
> Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Scripts to logon to websites

2006-01-11 Thread BartlebyScrivener
New to Python and Programming. Trying to make scripts that will open
sites and automatically log me on.

The following example is from the urllib2 module.

What are "realm" and "host" in this example.

import urllib2
# Create an OpenerDirector with support for Basic HTTP
Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'host', 'username', 'password')
opener = urllib2.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib2.install_opener(opener)
urllib2.urlopen('http://www.example.com/login.html')

Does anyone have a simple example of a script that opens, say, gmail or
some other commonly accessed site that requires a username and password
so that I can see how one is made?

Thanks very much for any help.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Scripts to logon to websites

2006-01-11 Thread BartlebyScrivener
> but googling for "basic authentication" and
> maybe "realm" and/or "host" will find you other sites with less
> technically detailed material.

This looks promising, but it'll take me a week to understand it :)

http://www.voidspace.org.uk/python/articles/authentication.shtm

Thanks for your help with the search terms.

rpd
l
Peter Hansen wrote:
> BartlebyScrivener wrote:
> > New to Python and Programming. Trying to make scripts that will open
> > sites and automatically log me on.
> >
> > The following example is from the urllib2 module.
> >
> > What are "realm" and "host" in this example.
>
> http://www.ietf.org/rfc/rfc2617.txt probably provides more background
> than you want on that topic, but googling for "basic authentication" and
> maybe "realm" and/or "host" will find you other sites with less
> technically detailed material.  The first hit has a little summary
> amidst some Apache-specific detail.
>
> > Does anyone have a simple example of a script that opens, say, gmail or
> > some other commonly accessed site that requires a username and password
> > so that I can see how one is made?
>
> "realm" and "host" are associated with "basic authentication" and not
> all sites use that.  If the browser pops up a little dialog box of its
> own (i.e not some Javascript-triggered thing) and you have to enter your
> username and password there, that's probably a "basic auth" (or "digest
> auth") site.  If you fill that info into a form (as on gmail.com) you
> don't want any of that "realm/host" stuff.
>
> I'll leave it to others more expert in this to provide a more directly
> useful answer.
> 
> -Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Scripts to logon to websites

2006-01-11 Thread BartlebyScrivener
Thanks, Peter.

Peter Hansen wrote:
> BartlebyScrivener wrote:
> >>but googling for "basic authentication" and
> >>maybe "realm" and/or "host" will find you other sites with less
> >>technically detailed material.
> >
> > This looks promising, but it'll take me a week to understand it :)
> >
> > http://www.voidspace.org.uk/python/articles/authentication.shtm
>
> (Minor typo... needs an extra "l" on the end:
>
> http://www.voidspace.org.uk/python/articles/authentication.shtml
> )
>
> By the way, note that neither basic auth nor digest auth provide any
> real security, and in fact with basic auth the userid and password are
> sent *in cleartext*.  For any serious production site these techniques
> should probably not be used without additional security measures in
> place, such as HTTPS encryption.
> 
> -Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic wrappers for SQL?

2006-01-15 Thread BartlebyScrivener
Just to chime in with Steve Holden on taking the why-not-learn-SQL
route. Chris Fehily's new book, SQL, A Visual QuickStart Guide (2nd Ed)
is a masterpiece and goes well on the bookshelf with his equally lucid
Python QuickStart Guide.

Cheap, too, for what you get.

http://www.amazon.com/exec/obidos/asin/0321334175/richarddooling/

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Word

2006-01-16 Thread BartlebyScrivener
How to automate Word

http://www.faqts.com/knowledge_base/view.phtml/aid/37034/fid/244

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nit: please don't user "it's" unless you can substitute "it is" without changing your inteded meaning.

2006-01-18 Thread BartlebyScrivener
"The pronominal possessives hers, its, theirs, yours, and oneself have
no apostrophe."

Strunk & White, The Elements of Style. Section II.1

The Elements is a classic masterpiece of concision and lucidity, unlike
Eats, Shoots, Sells Books, and Leaves.

rpd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: access to submodules

2006-07-19 Thread BartlebyScrivener
>> > from tom import *

You CAN do this, but it's a bad habit.

Try:

>>import tom

Then call by tom.function()

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple file writing techiques ...

2006-07-19 Thread BartlebyScrivener
See also this recent discussion on techniques for making sure you get
the file closed, even if there is an exception.

http://tinyurl.com/fryrv

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: access to submodules

2006-07-19 Thread BartlebyScrivener
http://tinyurl.com/6yz2g

If you do

from tom import *

then you no longer need tom, you imported all of his FUNCTIONS (never
heard of submodule).

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


New Martelli Nutshell Out

2006-07-19 Thread BartlebyScrivener
My preordered copy of Python In A Nutshell just arrived from Amazon.

http://tinyurl.com/pkczm

Looking forward.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows vs. Linux

2006-07-30 Thread BartlebyScrivener
Windows XP is fine. I am learning Python on Windows first with an eye
toward moving to Linux.

If you like, get the ActivePython distribution, which comes with the
Win32 extensions.

If you start liking Python, consider adding the IPython shell. There
are commandline tweaks you can do to make the XP commandline bearable,
in fact, I found them on this forum, so perhaps search on XP
commandline.

Good luck,

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python help for Access database

2006-07-31 Thread BartlebyScrivener
John Machin wrote:

>> or mxODBC
>> [very good but not free].

I love mxODBC. It's free for noncommercial use.

http://www.egenix.com/files/python/mxODBC.html

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming newbie coming from Ruby: a few Python questions

2006-08-01 Thread BartlebyScrivener

[EMAIL PROTECTED] wrote:

>  'Clever is not considered a compliment in Python.' (don't know where I
> read that...)

"To describe something as clever is NOT considered a compliment in the
Python culture."--Alex Martelli, Python Cookbook 2nd Ed. pg. 230 (a
great book for learning by doing, after you have the basics down)

Do you have Python installed yet?

If not, consider

http://www.richarddooling.com/index.php/category/geekophilia.

You sound like a nonprogrammer (except for your Ruby experience), so
you probably want:

http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Good luck! Have fun.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming newbie coming from Ruby: a few Python questions

2006-08-02 Thread BartlebyScrivener

[EMAIL PROTECTED] wrote:

>> The Ruby crowd says you guys are no where
>>  near as friendly as them!

Slander! Defamation!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming newbie coming from Ruby: a few Python questions

2006-08-02 Thread BartlebyScrivener
Stand and fight, Python brothers. Fear not, the Ruby horde!

From this day to the ending of the world,
But we in it shall be remember'd;
We few, we happy few, we band of brothers;
For he to-day that sheds his blood with me
Shall be my brother; be he ne'er so vile,
This day shall gentle his condition:
And gentlemen in England now a-bed
Shall think themselves accursed they were not here,
And hold their manhoods cheap whiles any speaks
That fought with us upon Saint Crispin's day.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best way to print the usage string ?

2006-08-03 Thread BartlebyScrivener
Leonel Gayard wrote:
>
> Notice that the string messes the indentation in my script. The
> indentation is correct, and if the script is invoked without
> arguments, the usage string is printed correctly.
>
> Now, how can I achieve the same result while keeping a clean
> indentation ? How is this done in python world ? In C, I would do
> this:

> The whitespace at the beginning of the string helps me keep the
> indentation clean, and the construct "a" "b" is syntactic sugar that
> allows me to create a large string without concatenating them at
> runtime.
>
> How can I get this in Python ?

Not sure exactly what you are after, but it sounds like you need the
textwrap module:

http://docs.python.org/lib/module-textwrap.html

Or look at string formatting opeartions

http://docs.python.org/lib/typesseq-strings.html

rd

:

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: programming is hard

2006-08-03 Thread BartlebyScrivener

Tim Chase wrote:

> it may also be that "programmingishard...unless you use python" ;)
>
> -tkc

Or if somebody made a site called programmingisfun.com, then you might
find some Python snippets there.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a number for output

2006-08-07 Thread BartlebyScrivener
abcd wrote:
> if i have a number, say the size of a file, is there an easy way to
> output it so that it includes commas?
>
> for example:
>
> 1890284
>
> would be:
> 
> 1,890,284

see also this thread:

http://tinyurl.com/qf6ew

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a number for output

2006-08-07 Thread BartlebyScrivener

Paul Rubin wrote:

> "To iterate is human; to recurse, divine":
>
> def commafy(n):
>if n < 0: return '-' + commafy(-n)
>if n >= 1000: return '%s,%03d' % (commafy(n//1000), n % 1000)
>return '%s'% n
>
> I don't like the locale solution because of how messy locales are.

That's a keeper!

Thanks!

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A problem from a Vim user

2006-08-07 Thread BartlebyScrivener

manuhack wrote:

> However, when I run
> the same command in vim 7 as :py raw_input('Please type something.\n'),
> there is an EOFError: EOF when reading a line.  Is there a way to use
> that command within vim without raising errors?

I thought you might get more help here than in comp.editors ;)

Same thing happens if you put it in rawinput.py file and use :pyfile.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using python at the bash shell?

2006-08-08 Thread BartlebyScrivener

John Salerno wrote:

> I like using Python for everything, and if I don't need to learn the
> bash 'language', then I won't just yet.

And like vim, Ipython works on both windows and ubuntu.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question: what's with "self"?

2006-08-08 Thread BartlebyScrivener

donkeyboy wrote:

>> but no-one has really spelt it out

Go to:

http://www.freenetpages.co.uk/hp/alan.gauld/

Look down the left-hand frames page until you see Advanced Topics |
Object Oriented Programming

Then find "What is self?"

Good luck

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for an intellisense with good help IDE for Python

2006-08-08 Thread BartlebyScrivener
You don't say what platform you are using.

The PythonWin IDE has really good code completion. Not all that you
mention, but certainly methods etc. If you are on nix, then Komodo has
it; not free, but only $30 for Komodo personal.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.normpath

2006-08-09 Thread BartlebyScrivener

[EMAIL PROTECTED] wrote:

> But if this string is going into a webpage link

http://docs.python.org/lib/module-urlparse.html

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute beginner - is this feasible?

2006-08-10 Thread BartlebyScrivener

Michiel Sikma wrote:
> I don't know if writing to a
> Word file is possible. It's a proprietary format, afterall.

see:

Python To Word

Capture script output in MS Word

http://gflanagan.net/site/dotnet/05/RunPythonScriptFromWord.html

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recurse Directories and process files in directory

2006-08-12 Thread BartlebyScrivener
KraftDiner wrote:
> Hi I need help writing a python script that traverses (recursivly) a
> directory and its sub directories and processes all files in the
> directory.

There's a great os.walk + wrapper in the Python cookbook. I once had an
unrelated problem with it, but check it out and see if it meets your
needs.

http://tinyurl.com/zwbrb

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installed correctly

2006-08-13 Thread BartlebyScrivener

Ray wrote:
> are there any
> problems with this?

Apparently, yes ;)

>> Do you know how to set up the %PATH% variable in win2k?

In case you don't, this is from another thread:

Sequence on XP is Start | Control Panel | System | Advanced |
Environmental Variables. Then in the lower half of the dialogue box is
the "System Variables" Select Path, and then edit and enter the path to
Python.exe. I used ActiveState which puts it in c:\python24

>From what you've told us you should try c:\Program Files\Python

But as the wise man says, the spaces in path names will haunt you on
windows.

Good luck.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installed correctly

2006-08-13 Thread BartlebyScrivener

Rich wrote:
>> But command line still says "unrecognized command",

You don't say which installer you are using? I know the ActiveState
installer puts the python directory in your environment automatically,
and I bet the Python.org installer does too.

Do you see Python24 in your path?

If you get desperate, try:

http://dooling.com/index.php/category/geekophilia

It's a hand-holding install guide.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you get the name of a dictionary?

2006-08-18 Thread BartlebyScrivener
Tim Chase wrote:
> How would you ask for the object?
>
>  >>> print get_name(banana)
>
> you might as well write
>
>  >>> print "banana"
>
Or there used to be a guy in this group who said it was like asking a
cat for its name. He headbanged himself unconscious though, or so they
say.

http://tinyurl.com/hql6d 

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text editor suggestion?

2006-08-18 Thread BartlebyScrivener
John Salerno wrote:

> Ok, I know it's been asked a million times, but I have a more specific
> question so hopefully this won't be just the same old post.

You got 65 answers last time :)

http://tinyurl.com/rsfjq

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text editor suggestion?

2006-08-19 Thread BartlebyScrivener

>> Oh well, I'll just keep trying different ones.

If you demand power and cross-platform compatibility, I think you
already know your choices are Xemacs or Vim 7.0. They are both modal
and therefore difficult to learn, at first, but later you enjoy the
pleasures of interface Zen:

http://tinyurl.com/osys2

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you get the name of a dictionary?

2006-08-21 Thread BartlebyScrivener
>> im quite surprised at the arrogance laid
>> out by some of the above

Oh, nobody is being arrogant. They're having fun while answering your
question. Most remember having the same question, or at least making
the same discovery after careful reading.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you get the name of a dictionary?

2006-08-22 Thread BartlebyScrivener
>> how difficult would it be to assign a string name(s)
>> to an object upon creation (and upon referencing)?

Exactly the point that's being made. It's so easy just do it yourself:

banana={"name":"banana"}

Hey what is the name of my dictionary?

banana["name"]

But why build it into Python and force everyone else to do it, when
most of the time nobody cares what the name is, or they already know?

It's like forcing everybody everywhere always and forever to wear
"Hello My Name Is" tags.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


python 2.5 & sqlite3

2006-10-11 Thread BartlebyScrivener
Sorry, I have a knack for making things more difficult than they need
to be. I'm on Windows XP and waiting for the ActiveState release of
Python 2.5. I want to experiment with sqlite and I see that Python 2.5
has the "wrapper" but sqlite itself must be downloaded separately.

I see no installation instructions on the sqlite.org site for Windows
XP. I have downloaded sqlite3.exe, sqlite3.dll, and sqlite3.def. Must I
put them in a certain location, or will any folder do as long as it is
in path?

Anybody know if the ActiveState distribution will have sqlite itself
included?

As always, thank you for the generous help.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 2.5 & sqlite3

2006-10-11 Thread BartlebyScrivener
Fredrik Lundh wrote:

> wasting time on broken distributions?

It's not broken. I like Pythonwin better than IDLE. Either way I need
to know where to put the sqlite files, right? 

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 2.5 & sqlite3

2006-10-11 Thread BartlebyScrivener
>>  Looks like it could be from reading some
>>  build-Python-from-source instructions for Unix platforms ...

Yes, Sorry. I read the doc too hastily.

>> If you're compiling the Python source yourself,
>>  note that the source tree doesn't include the SQLite code,
>> only the wrapper module.

I'm playing with sqlite now, and awaiting the yet-to-be-issued 2.5
distro from ActiveState.

My apologies. Thank you, again.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE?

2006-10-13 Thread BartlebyScrivener
Ahmer wrote:
> What do you guys use?
> Why?

http://tinyurl.com/ybg6p5

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE?

2006-10-14 Thread BartlebyScrivener
Fuzzyman wrote:

> Hmm... only 31 results over a period of 8 years. That's a couple of
> orders of magnitude less than I would have guessed.

Well, if you take the quotes off of "best ide" then you get 342.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


help with my first use of a class

2006-10-19 Thread BartlebyScrivener
I am a mere hobbyist. Spent several hours trying to make a class,
because I think this is an occasion where I need one. But I can't make
it work.

This code "works" (only because of the global c, which I know I'm
supposed to avoid, by using a Class). I edited the rest to leave out
the irrelevant formatting and printing of the quotations.

I've read about Classes several times, but I don't "get" them yet.
Obviously. If I can solve one real life problem like this, then maybe
I'll see the light.

If I understand the power of Classes correctly, I could make one that
would allow me to make a new instance that would connect to, say, an
SQLite3 db instead of the Access db, as well as to create more methods
that will do different SQL searches.

Thank you for any help,

rd

--

import mx.ODBC.Windows as odbc
import sys
import random

def connect():
global c
db='DSN=Quotations'
conn = odbc.DriverConnect(db)
c = conn.cursor()

def random_quote():
"""
Counts all of the quotes in MS Access database Quotations2005.mdb.
Picks one quote at random and displays it using textwrap.
"""
c.execute ("SELECT COUNT(Quote) FROM PythonQuoteQuery")
# Yields the number of rows with something in the quote field
total_quotes = c.fetchone()
# Get a random number somewhere between 1 and the number of total
quotes
quote_number = (random.randint(1, total_quotes[0]),)
# Select a quote where the ID matches that number
c.execute ("SELECT Author, Quote FROM PythonQuoteQuery WHERE ID=?",
quote_number)
quote = c.fetchone()
blah blah blah

def print_quote()
code to format and print the quote (which will also have to be
global, unless I learn Classes!)


if __name__ == '__main__':
if len(sys.argv) == 1:
connect()
random_quote()
print_quote()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help with my first use of a class

2006-10-19 Thread BartlebyScrivener
Whoah. At least I got the connection. I think. Maybe I can figure more
on my own. Any help appreciated.

Thanks

-

class Connection:
def __init__(self, aDatasource):
self.db = aDatasource
self.conn = odbc.DriverConnect(self.db)
self.conn.cursor()

def random_quote():
"""
Counts all of the quotes in MS Access database Quotations2005.mdb.
Picks one quote at random and displays it using textwrap.
"""
c = Connection('DSN=Quotations')
c.execute ("SELECT COUNT(Quote) FROM PythonQuoteQuery")

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help with my first use of a class

2006-10-19 Thread BartlebyScrivener
Wow,

That's great, James.

Thanks. I shall put it together.

Appreciate it.

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help with my first use of a class

2006-10-20 Thread BartlebyScrivener
Thanks, Bruno. Very educational.

rd

Bruno Desthuilliers wrote:

> Think of a class as both a "blueprint" for objects and a factory
> creating these objects. The class lets you define the attributes and
> behaviors of it's instances.
>
> First, notice that you *don't* need a class here to avoid globals.
> Learning to use function as *functions* (ie: taking arguments and
> returning values) instead of procedure would help:
> 
> Now for an OO version - that won't buy you much IMHO:
>

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help with my first use of a class

2006-10-20 Thread BartlebyScrivener
Thank you all!

My main problem is going away from Python and programming for weeks or
months at a time, then picking up where I left off.  But Python is much
better in this regard than Perl.

I appreciate the help.

rd

-

Dennis Lee Bieber wrote:

> If using a db-api compliant adapter, and using minimal common
> features, the main thing one would have to worry about is the different
> placeholders used by the adapter.
>
>   I'd be more likely to do something like
>
> import  as db
>
> and then have a class query the db connection for what type of
> placeholder it uses, then modify any queries the class uses.
>
>   You might make a "class" for each database /table/, and each
> instance of that class would be one record in the table. The class would
> have the methods for retrieval/update/delete/insert, when given the key
> value, perhaps.
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use I the classes?

2006-10-20 Thread BartlebyScrivener
Fulvio wrote:

> Looking for documents (free download) which clearly explain the way of
> programming python classes and lots of examples as a bonus.

http://www.freenetpages.co.uk/hp/alan.gauld/

On the frames page, go down to "Advanced Topics" and "Object Oriented
Programming"

And from the other thread we were on:

> Think of a class as both a "blueprint" for objects and a factory
> creating these objects. The class lets you define the attributes and
> behaviors of it's instances. 

http://tinyurl.com/yd97t5

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


curious paramstyle qmark behavior

2006-10-20 Thread BartlebyScrivener
With

aColumn = "Topics.Topic1"'

The first statement "works" in the sense that it finds a number of
matching rows.

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE " + aColumn + " LIKE ?", ("%" + sys.argv[1] + "%",))

I've tried about 20 different variations on this next one. And it finds
0 records no matter what I do. Is there some violation when I use two
qmarks?

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE ? LIKE ?", (aColumn, "%" + sys.argv[1] + "%"))

I'm using mx.ODBC and Python 2.4.3 to connect to an MS Access DB.

Thank you,

rd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curious paramstyle qmark behavior

2006-10-20 Thread BartlebyScrivener
Thanks, Jon.

I'm moving from Access to MySQL. I can query all I want using Python,
but so far haven't found  a nifty set of forms (ala Access) for easying
entering of data into MySQL. My Python is still amateur level and I'm
not ready for Tkinkter or gui programming yet.

rd

--

Jon Clements wrote:

>
> I don't use mx.ODBC, and definately don't use Access (gagging sounds...
> but if you're stuck with it, so be it)...
> 
> hth,
> 
> Jon.

-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >