The Windows Powershell is available, fka Monad.
Any special Python tricks? Just breezing through the manual, they
seemed to have borrowed from any language they wanted in making a new
scripting language.
http://tinyurl.com/l9ghj
rd
--
http://mail.python.org/mailman/listinfo/python-list
Actually the best bit I found was a guy on Slashdot who said they could
have made the whole thing out of Python.
here's a good article, but it's old
http://arstechnica.com/guides/other/msh.ars/2
--
http://mail.python.org/mailman/listinfo/python-list
>> Patient: "Doctor! It hurts when I press here."
>> Doctor: "Well don't press there"
I told the doctor I broke my leg in two places.
He told me to quit going to those places.
--Henny Youngman
rpd
--
http://mail.python.org/mailman/listinfo/python-list
>> root, dirnames, filenames = os.walk(r"C:\").next()
Wow. How does that work? Just point me to where I can read about it. I
don't see it under os.walk.
That's cool.
Thanks,
Rick
--
http://mail.python.org/mailman/listinfo/python-list
Sorry that I was unclear.
I sorta know how os.walk works. It's the .next() trick that I had never
seen before. For instance, if you run that statement without the
.next() on it, it says "Too many items to unpack" but with the .next()
it stops it somehow, right where I want it to stop.
It's an ite
Thank you all for the great info and education.
rick
--
http://mail.python.org/mailman/listinfo/python-list
I'm picking this up via clp on Google Groups. I can't tell what Mr.
Lundh is referring to. The first line of his post is: "Tim Williams
wrote" but there's nothing that comes before. I had seen the article on
Django on Digg I think, but what is article Tim Williams is referring
to?
Thanks,
rick
-
For starters, you need the os and webbrowser modules
import os
import webbrowser
webbrowser.open("http://mail.google.com/mail";)
# need to know the shell keyword for starting the app
os.system('start ' + 'Winword')
# the equivalent of double-clicking on the doc or file
os.startfile("c:/MyFiles/
san,
Take a look at this thread which features some smart and helpful people
and good links.
http://tinyurl.com/ggn5e
I'm wagering you'll make more sense of it than I did. I have my hands
full just making my way through tutorials and books at the moment.
rick
--
http://mail.python.org/mailman
>> Pardon if . . . already discussed
Here is a link searching comp.lang.python for "best ide"
http://tinyurl.com/qqtaf
rick
--
http://mail.python.org/mailman/listinfo/python-list
Here's a shot of Komodo, albeit embedded in a pdf
http://www.activestate.com/Products/Komodo/ActiveState_Komodo_datasheet.pdf
--
http://mail.python.org/mailman/listinfo/python-list
I'm on Windows, but I think you need the shebang thing at the top of
your script, right?
Then, put whatever you want to import in a script or module called
testmod.py.
Then you should be able to import either into a script or at the
command line using simply:
import testmod
If it doesn't work t
Using Python on Windows XP, I am able to get almost all file and path
info using os.path or stat, but I don't see a way to retrieve the file
type? E.g. Microsoft Word file, HTML file, etc, the equivalent of what
is listed in the "Type" column in the Windows Explorer box.
Thanks,
rick
--
http://
I'm on Windows XP, and I like Komodo a lot. It does php, html, perl,
python, ruby etc. It's just a tad slow to load (takes about 10 seconds
on my AMD Athlon 2700), but I usually leave it on all day, so I don't
notice. If you're on Linux you might ask others.
rpd
--
http://mail.python.org/mailma
>> Vim
Yes, and enjoy the month off work while you are learning how to use it
;>
--
http://mail.python.org/mailman/listinfo/python-list
Right about now somebody usually jumps in and shows you how to do this
without using regex and using string methods instead.
I'll watch.
rd
--
http://mail.python.org/mailman/listinfo/python-list
I have to at least try :)
s = "abababababababab"
for x in range(len(s)):
... try:
... s.index("aba", x, x + 3)
... except ValueError:
... pass
rd
--
http://mail.python.org/mailman/listinfo/python-list
>> otherwise i might as well just use string
>> methods
I think you're supposed to use string methods if you can, to avoid the
old adage about having two problems instead of one when using regex.
rd
--
http://mail.python.org/mailman/listinfo/python-list
Thanks, Ben. Quite an education!
rick
--
http://mail.python.org/mailman/listinfo/python-list
John,
I had nothing but trouble connecting to my Access and MySql dbs until I
started using mxODBC. Search on it in this group, and you'll find the
links that were given to me and that I've shared with others. It works
like a charm.
If you come up short, I'll send you the links. I can't dig them
Add the mysql db to your datasources using Administrative
Tools/Datasources(ODBC). Once that's done it's simple to access it,
using mxODBC.
I'm assuing you are on Windows XP?
Here's mxODBC
http://www.egenix.com/files/python/mxODBC.html
and you'll need the MySql connector
http://dev.mysql.com/
John,
Yep, different module. I'll watch the thread. Perhaps once you get
connected, we should make a mini-HOWTO for XP users while it's fresh in
your mind, because this question seems to come up a lot, and beginners
would probably appreciate a short howto that would perhaps detail how
to set up e
>> driv="bbdatabank"
Oops, sorry, I meant,
driv='DSN=bbdatabank'
rick
--
http://mail.python.org/mailman/listinfo/python-list
>> But with the firewall off, everything
>> seems to work fine.
Whatever works. But I'm having trouble imagining how a firewall would
interfere with you accessing your own db on localhost.
--
http://mail.python.org/mailman/listinfo/python-list
Still new. I am trying to make a simple word count script.
I found this in the great Python Cookbook, which allows me to process
every word in a file. But how do I use it to count the items generated?
def words_of_file(thefilepath, line_to_words=str.split):
the_file = open(thefilepath)
fo
Thanks! And thanks for the Cookbook.
rd
"There is no abstract art. You must always start with something.
Afterward you can remove all traces of reality."--Pablo Picasso
--
http://mail.python.org/mailman/listinfo/python-list
>> True. Changing the except clause here to
>> except: return sum(1 for x in iterable)
>> keeps George's optimization (O(1), not O(N), for containers) and is a
>> bit faster (while still O(N)) for non-container iterables.
Every thing was going just great. Now I have to think again.
Thank you a
Using ActivePython 2.4.3 on Windows XP
While in the Pythonwin IDE, if I seek keyword help by issuing the
following command:
>>>help ('while')
I get:
Sorry, topic and keyword documentation is not available because the
Python HTML documentation files could not be found. If you have
installed the
I should add that if I type:
>>>help ('sys')
It works fine. So it's finding the module documentation, but not the
keyword or topic.
Thanks
rick
--
http://mail.python.org/mailman/listinfo/python-list
Peter,
>>> import pydoc
>>> pydoc.help.docdir
yields no result for me
But adding the "break" into the pydoc module didn't work either.
Mmm.
I'll toy with this later. Thanks for pointing me to the right spot in
the module.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Peter,
I filed a bug report.
Thanks,
rick
--
http://mail.python.org/mailman/listinfo/python-list
QOTW
"Programming is not just creating strings of instructions for a
computer to execute. It's also 'literary' in that you are trying to
communicate a program structure to other humans reading the code." Paul
Rubin
rpd
--
http://mail.python.org/mailman/listinfo/python-list
And others (including Fredrik Lundh) have found the same bug, it seems.
http://mail.python.org/pipermail/python-list/2005-September/297157.html
--
http://mail.python.org/mailman/listinfo/python-list
Art Haas posts from time to time regarding a program called PythonCad
that he maintains:
http://tinyurl.com/o36t8
Also, here is a search of this forum on "Cad":
http://tinyurl.com/nuobe
--
http://mail.python.org/mailman/listinfo/python-list
Are you able to connect to the DB using MySQL administrator?
--
http://mail.python.org/mailman/listinfo/python-list
At the commandline, run:
pydoc -g
In the interpreter:
help("modulename")
or help ()
for interactive.
Are you on Windows? Using ActivePython? Or the Python.org download?
rd
--
http://mail.python.org/mailman/listinfo/python-list
Hey, thanks. I got the writing thing down:
http://dooling.com
Now I'm trying to pick up the programming part.
Thanks for links.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Type:
create a new database with mysql
into google and see what happens
rd
--
http://mail.python.org/mailman/listinfo/python-list
I would learn basic, commandline SQL first and get comfortable creating
tables, querying your dbs etc. THEN, add Python. Otherwise you spin
your wheels not knowing whether it's your use of the Python modules or
your bad SQL commands that are fouling things up.
http://sqlcourse.com/intro.html
or I
I was hoping you'd find this earlier when I suggested that you type:
creating a new database with MySQL
into google.
It's the number one hit:
http://coronet.iicm.edu/mysql/create.html
If you send the commands listed there via the commandline or through
MySQLdb you should be in business.
--
h
>> This type of bug commonly bites neophyte programmers.
That IS weird. I'm new. I read it, I see how it works, but how come in
between calls of the function, you can't access the values being
stored? Or I guess you can, but I don't see the way.
How come you can't do something like :
>>>wtf.args
Sorry,
Never mind.
wtf.func_defaults
Thanks for the examples.
Rick
--
http://mail.python.org/mailman/listinfo/python-list
John,
I know you started out asking about .NET, but peruse this thread,
wherein some old hands recommend staying with what you know, if what
you know is VBA guis.
http://tinyurl.com/ehujm
rick
--
http://mail.python.org/mailman/listinfo/python-list
I have one suggestion. It's a beautiful page, and one day I'll know
enough to appreciate the help it provides, but until then it's always a
big help to the novice (in many fields of knowledge) if the first use
of an acronym includes the words it stands for in parenthesis.
In law and medicine and m
In the Python Cookbook, 2ed, page 25, there's a script by Andrew Dalke
that uses the same heureistic criteria that Perl does and analyzes a
string and deems it binary if it contains any nulls or if more than 30%
of its characters have the high bit set or are strange control codes.
There's a follow
We were doing something like this last week
thestring = "a_a_a_a_"
>>> for x in range(len(thestring)):
... try:
... thestring.count("_a_", x, x + 3)
... except ValueError:
... pass
--
http://mail.python.org/mailman/listinfo/python-list
If you are new to programming:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
If you already know at least one programming language:
http://wiki.python.org/moin/BeginnersGuide/Programmers
Your goal is to read, work the examples, and understand the Python
Tutorial by Guido von Rossum:
Can you recommend a book or a link for a person learning Python on
Windows who does not yet know C# or .NET?
Thanks,
rick
--
http://mail.python.org/mailman/listinfo/python-list
>> "Learning to Program" by Alan Gauld
>> (http://www.freenetpages.co.uk/hp/alan.gauld/)
The best by far, for a n00b, in my opinion.
--
http://mail.python.org/mailman/listinfo/python-list
First be sure she needs to install Python, if so, try:
7 Minutes To Hello World
http://www.richarddooling.com/index.php/category/geekophilia
These instructions are for people on Windows XP who don't even know
what a commandline is. They seem popular, based on the traffic they
attract.
Try them
Cameron,
The "7 Minutes To Hello World" IS the ActiveState distribution. It's
just hand-holding, click here, click there, for the person who doesn't
know what "Windows/x86" means on the install page, or perhaps doesn't
know what to do with the interpreter once it's installed.
--
http://mail.pyth
What about a console beep? How do you add that?
rpd
--
http://mail.python.org/mailman/listinfo/python-list
There are several of these writing quotes, all good in their own way,
because they emphasize concision as the first order of business for any
writer.
"If I had more time, I would write a short letter."--Blaise Pascal
"If the author had been less industrious, this book would be twice as
long."--Ev
>>You might also want to synchronize to a caesium clock, but the guy is
timing his laundry, <<
My morning coffee just streamed out of my nose. Air. I need air.
rpd
--
http://mail.python.org/mailman/listinfo/python-list
Gau,
I'm a beginner and had fits connecting to my Access 2003 DB of
quotations. The best advice that finally worked for me was to use
mxODBC. In fact, you might just search this forum for Access and
mxODBC.
I can't customize to fit your situation, but here is the connection
part of a script I use
>> I was hoping that your code would
>> return the column names for me, but it was expecting me to list the
>> columns to use. I want to know how to retrieve that list of columns
>> through python.
I think once you establish connection to the database using Python and
mxODBC, then your question
>> How can I get the names of the columns for each table??
SELECT * FROM mytable
--
http://mail.python.org/mailman/listinfo/python-list
Gau,
This prints the names of the columns in my database.
# Modification of
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/389535
# Instructions for customizing are at:
# http://www.egenix.com/files/python/mxODBC.html
import mx.ODBC.Windows as odbc
driv='DRIVER={Microsoft Access Driv
Armin,
Mike Meyer already took a crack at this, and his starts right up just
by clicking on the link.
http://www.mired.org/home/mwm/try_python/
Yours looks prettier, but I don't think novices are going to be able to
figure out how to start it.
Regards,
rick
--
http://mail.python.org/mailman/
John,
If your file has the .py or .pyc extension on it, it should just run at
the command line from its own directory, assuming your environment and
path variables are set correctly.
I use NoteTab which has a different way of doing it, but basically you
should be able to run:
c:\mydir>script.py
Philippe,
import webbrowser
webbrowser.open("http://groups.google.com/group/comp.lang.python";)
rpd
--
http://mail.python.org/mailman/listinfo/python-list
Works for me.
I get "abc def ghi" using your script on Windows XP and ActiveState
Python 2.4.3
rd
--
http://mail.python.org/mailman/listinfo/python-list
I'm still new at this. I can't get this to work as a script. If I just
manually insert the values for sys.argv[1] and sys.argv[2] it works
fine, but I can't pass the variables from the command line. What am I
doing wrong? On windows xp, python 2.4.3
Thank you
import os
import fnmatch
import sys
Duh! Headsmack.
Thanks. But also, I discovered something else. If I name the script
findmyfiles.py and run it from the command line while in the directory
where it is stored (on windows), I must run it as:
findmyfiles.py d:/notes notes*.*
I was used to being able to run scripts by just typing th
How about one of these that works on Windows XP? I know there's no
files.cache, but I wonder if your script could be combined with another
function that would generate a list of paths on a Windows XP machine.
Anyway, thanks for the script.
--
http://mail.python.org/mailman/listinfo/python-list
>> That is wrong on so many levels
Including the level where I observed that I'd already been running
scripts without typing the .py extension for months, it's just that on
some scripts (seems to be the ones with functions defined in them) you
can't pass arguments unless you type the .py extension
Tim,
I had not seen the thread you linked to. I learned something, but it
still doesn't explain whatever is happening on my machine. When I run
assoc and ftype I get exactly the results you say I need to run the
scripts properly. However, this simple script (printargs.py) seems to
work whether I t
Thanks, Duncan
Results of my ftype command
d:\python>ftype python.file
python.file="C:\Python24\python.exe" "%1" %*
See below, the response with examples to Tim. I'm not worried about it.
Thank you all for the education.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Tim,
No conflicting bat file.
Script name cbfindfiles.py
import os
import fnmatch
import sys
def all_files(root, patterns='*', single_level=False,
yield_folders=False):
"""walks the directory tree starting at root and finds all files
matching patterns"""
# Expand patterns from semicolon
Adonis,
Cool! I'm on it.
Thanks again.
rpd
--
http://mail.python.org/mailman/listinfo/python-list
>> print "running",__file__
Well, I tried to let this die because I just KNEW I was going to look
like an idiot before it was over. It's the .pyc versus the .py file.
Obviously I don't understand how that works yet. The .pyc file lags
behind the .py file? So when I run cbfindfiles.py I'm running
This script is COOL. It should be in the next cookbook. Maybe with some
tweaks and switches.
Thanks again.
Rick
--
http://mail.python.org/mailman/listinfo/python-list
Running the script you recommended, I get
d:\python>hansen.py cbfindfiles
.\cbfindfiles.pyc
.\cbfindfiles.py
d:\python\cbfindfiles.pyc
d:\python\cbfindfiles.py
If I use XP search, searching all drives for any file with cbfindfiles
in the name, I get just the two in d:\python.
It has something to
>> You missed the other option: if PATHEXT has .pyc in front of .py then you
>> get exactly the described behaviour.
That's it!!
Trust me, I didn't do it. It was either ActiveState, Wing, or Komodo
Dragon, or some combination thereof.
So remove .pyc from pathext?
Rick
--
http://mail.python.or
It's ActiveState. I just did a fresh install on an old machine.
It appends pyo;pyc;pyw;py in that order to PATHEXT
Thanks again to everyone for the generous help.
Rick
--
http://mail.python.org/mailman/listinfo/python-list
>>45.9 mb
Yikes.
I keep all of my data files on a separate logical drive. I indexed only
that one. I'm going to try and figure a way to store the results of
os.walk(root) as a shelve, and then search it that way.
In the meantime, you might try the script we were playing with in the
previous thre
>> Can someone tell me how to search this mailing list, short of
>> downloading every month's archive and searching manually?
Huh? How are you accessing it now?
Just point your browser to:
http://groups.google.com/group/comp.lang.python
and look in the upper right hand corner where there's a
Oh, sorry, Richard,
and to answer your question about Python and MySql, try searching on
mxODBC, or better, search on "mxODBC Holden" as Steve Holden seems to
answer every question on sql and Python.
Hope that helps.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Whoah, that's a nifty trick.
Thanks.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Peter Hansen wrote:
> But it is. To help others. Perhaps what you are encountering is a real
> bug, and solving it could avoid us having to deal with the same issue in
> the future (though it seems more likely it's something special to your
> case, but at least then we'll have a clear answer).
>> When all I started looking for was a more robust editor for Python ;-)
Both WingIDE and Komodo Dragon allow for customization of keyboard
bindings. They aren't free, but they cost only $30.00 or so. Cheap for
what you get, especially in the case of Komodo because it makes a nice
editor for many
Pretty tough to beat Alan Gauld, but the more examples the merrier for
me, and the infogami has plenty of those. Thanks.
http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
rpd
--
http://mail.python.org/mailman/listinfo/python-list
the editor work.
"BartlebyScrivener" <[EMAIL PROTECTED]> writes:
> I tried searching on this but I don't see exactly my error message.
> When I open a php file for editing, I get: "file mode specification
> error: (void-function run-mode-hooks)"
> What line do
Are you saying you're on Windows?
If so, try:
http://www.activestate.com/Products/ActivePython/
It's a one-click, msi install with everything you need for win32,
including IDE etc.
Only thing to watch for is that sometimes the msi file won't install
from a logical drive other than c:\. So if yo
Kent,
Running
path = "d:/emacs files/emacsinit.txt"
lines = open(path).readlines()
# my defun lines are lowercase,
# next two lines are all on one
starts = [i for i, line in enumerate(lines) if
line.startswith('(defun')]
for i, start in starts:
while start > 0 and lines[start-1].startswith(';
Yes, thanks. I was just going to reinstall anyway. That usually fixes
it.
Rick
--
http://mail.python.org/mailman/listinfo/python-list
That's it. Thank you! Very instructive.
Final:
path = "d:/emacs files/emacsinit.txt"
lines = open(path).readlines()
# next two lines all on one
starts = [i for i, line in enumerate(lines) if
line.startswith('(defun')]
for i, start in enumerate(starts):
while start > 0 and lines[start-1].start
>> Not sure if the .msi installers were broken before,
>> but they are now (on this installation)
Are you installing from c:\ ?
With administrator rights?
Check other requirements. It chokes if you are installing from another
logical drive, e.g., d:\
http://aspn.activestate.com/ASPN/docs/Active
This is very helpful.
I wasn't the OP. I'm just learning, but I'm on the verge of making my
own file searching scripts. This will be a huge help. Thanks for
posting, and especially thanks for the comments in the code. Big help!
rick
--
http://mail.python.org/mailman/listinfo/python-list
>> I'll try from C: but.
Definitely do that. None of the .msi installers are working for me from
any drive except C. Been that way for months.
Here's some helpful tips from an ActiveState email of a few months
back. Note especially that you need version 2.0 or greater of the
installer:
Here
I'm working on various backup scripts, using filecmp and shutil.
When I run a script to copy files to a mapped network drive, shutil
creates a backup file with a date of 2002 or so.
If I use shutil.copy2 it copies the dates of the original files, but
creates folders with similary old dates and ti
Thank you! I went into the set up of my network storage device and
found the time settings all wrong. Fixed it.
Sorry for the trouble.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Running Python on Win XP.
When running commands with the interpreter, if you get stuck in a while
loop, is there a keyboard command to break out of it?
Or is the only way out a triple-finger salute and End Task?
rd
--
http://mail.python.org/mailman/listinfo/python-list
Thank you, both. I'll put in on a sticky!
rick
--
http://mail.python.org/mailman/listinfo/python-list
Thank you, Scott. I'm still learning my exceptions (obviously, or I
wouldn't get stuck in a while loop ;).
That was instructive. On my machine, it is Ctrl + Break that does it.
Ctrl + C doesn't do anything.
What I should really do is figure out roughly how many times the while
loop should run, an
301 - 395 of 395 matches
Mail list logo