Hey everyone,
First post to this list. I hope I'm doing it right.
Let's say I want to run func 10 times Is there a more pythonic way to do it
than this:
for i in xrange(10):
func()
Thanks.
___
Tutor maillist - Tutor@python.org
http://mail.python.org
xml.etree.ElementTree. This makes no sense to me, since it works fine
normally.
Thank you very much. Any and all help or pointers are appreciated.
~Matt
db.py ###
from xml.etree import ElementTree as ET
import os
class Database(object):
def __init__(self, path):
self.__d
efficient.
On Mon, Apr 20, 2009 at 1:27 PM, Alan Gauld wrote:
> "Matt" > wrote
>
> Let's say I want to run func 10 times Is there a more pythonic way to do
>> it
>> than this:
>> for i in xrange(10):
>> func()
>>
>
> Yes, use r
I'm trying to calculate the derivative of a function in Python like so:
def D5(func,h=1e-5):
""' Return derivative of function func'''
def df(x):return (func(x+h)-func(x))/h
df.__name__ = func.__name__ + '_dx'
return df
However, I run into the problem of limited float precisio
ght
I'd like to be able to automate something closer to the a=MyClass("a")
but don't know how to do it....It may be that I'm trying to do it very
badly, which is Python seems to make it hard for me.
Thanks,
Matt
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
you need to take the nth root of the absolute value of c (this
can be ignored when we're doing it for 1, as of course the nth root of 1
is 1).
Obviously I haven't included any code....but I hope this helps a bit.
Matt
P.S. Thrilled to be able to answer something on the tutor list, instea
Further to my previous post, please find some code below:
Hope this helps,
Matt
#Complex number Roots
#Matt Williams 9.12.04
import math
number=complex(0.5,0)
n=float(3)
size=math.sqrt((number.real**2)+(number.imag**2))
arg=math.radians(360/n)
root=1/n
modulus=size**root
theta=float(0
I'd be interested,
Matt
On Fri, 2004-12-17 at 11:01, [EMAIL PROTECTED] wrote:
> Send Tutor mailing list submissions to
> [EMAIL PROTECTED]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/tutor
> or, vi
y.
HTH,
Matt
Robert Jackiewicz wrote:
On Wed, 13 Oct 2010 14:16:21 -0600, Ara Kooser wrote:
Hello all,
I am working on merging two text files with fields separated by
commas.
The files are in this format:
File ONE:
*Species, Protein ID, E value, Length* Streptomyces sp. AA4,
ZP_
Hello,
I have a series of lists that I need to output into files with a
specific format. Specifically, I need to have line breaks after each
entry of the list, and I need to do away with the ['..'] that
accompany the data after I transform the list into a string. Can I
simply append a '\n
ase of the print
function setup that you suggested with write? Or could I somehow use
the print function itself to write to the file (rather than just
output to my shell/prompt)?
Thanks!
Quoting W W :
On Fri, Apr 24, 2009 at 10:57 PM, Matt Domeier wrote:
Hello,
I have a series of lists t
Hey All.
All I need to do in this script is scp or sftp a bunch of files to a remote
server. This script will run from a cron job eventually.
For whatever reason, paramiko can't cope with a list.
---
AttributeError
On Fri, May 08, 2009 at 02:30:22PM -0400, Kent Johnson wrote:
> On Fri, May 8, 2009 at 1:04 PM, Matt Herzog wrote:
> > Hey All.
> >
> > All I need to do in this script is scp or sftp a bunch of files to a remote
> > server. This script will run from a cron job event
Hello again.
This code comes straight from the http://oreilly.com/catalog/9780596515829/
book.
The only actual code I changed was s/get/put on the second to last line. The
author says I ought to be able to do this and have it Just Work. There are
several things I don't understand. Would be nic
On Sun, May 10, 2009 at 12:53:49AM +0100, Alan Gauld wrote:
> Have you used normal ftp in its command line version?
> The put command specifies the location on the remote machine
> where you want to store the files. This is normal ftp behaviour.
The server supports only sftp. Yeah, I could turn o
Should be simple, right? Not for me, heh.
def schmove(src,dst):
... src = '/home/datasvcs/PIG/cjomeda_exp/'
... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/'
... listOfFiles = os.listdir(src)
... for filez in listOfFiles:
... os.system("mv"+ " " + src
ectory, it'll move the
file there."
Example: If I use: "os.rename(src, dst)" where I had "os.system("mv"+ " " + src
+ " " + dst)" no files are coppied.
os.renames happily renames the source directory, but that's not what I want.
Hello All.
I need to use paramiko to sftp get a single file from a remote server.
The remote file's base name will be today's date (%Y%m%d) dot tab.
I need help joining the today with the .tab extension. Do I need globbing?
example: 20090716.tab
#!/usr/bin/env python
import paramiko
import glob
g is missing.
Traceback (most recent call last):
File "./scpgetter.py", line 20, in ?
sftp(remotepath,localpath)
TypeError: 'SFTPClient' object is not callable
I tried using the paramiko.SFTP.get method too. Failed.
-- Matt H
>
> Kent
--
I fear you speak u
On Mon, Jul 20, 2009 at 10:22:37PM +0200, Sander Sweers wrote:
> I do not know paramiko but looking over the client documentations...
>
> 2009/7/20 Matt Herzog :
> > if __name__ == "__main__":
> >t = paramiko.Transport((hostname, port))
> >t.connect
On Mon, Jul 20, 2009 at 11:02:52PM +0200, Sander Sweers wrote:
> 2009/7/20 Matt Herzog :
> > Traceback (most recent call last):
> > ??File "./scpgetter.py", line 20, in ?
> > ?? ?? ??sftp.get(remotepath, localpath)
> > ?? ?? ?? ??File "build/bdis
If I change
remotepath = 'datestr'
to
remotepath = datestr
I get:
sftp.get(remotepath, localpath)
File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 587, in get
IOError: [Errno 21] Is a directory: '/tmp/testor/'
So remotepath is really more like a path + filname.
So I ne
A user of the paramiko mailing list said,
"Paramiko has an SFTPClient class and an SSHClient that can be used to
transfer files, why complicate it by using a Transport directly. The
easiest thing is to open an SSHClient:
On Mon, Jul 20, 2009 at 11:57:57PM +0200, Sander Sweers wrote:
> Please reply to the list.
>
> 2009/7/20 Matt Herzog :
> > Yeah. I have no idea if I am able to do this. The jail makes it ambiguous.
>
> There is no difference, the jail just moves the root directory as
On Mon, Jul 20, 2009 at 05:26:09PM -0500, Wayne wrote:
> On Mon, Jul 20, 2009 at 5:18 PM, Matt Herzog wrote:
>
> > On Mon, Jul 20, 2009 at 11:57:57PM +0200, Sander Sweers wrote:
> > > Please reply to the list.
> > >
> > > 2009/7/20 Matt Herzog :
> >
Hi All.
The below script seems to work well enough to use but I'm wondering if I'm
doing the file edit stuff in a "kosher" manner. I was just reading the Lutz
O'Reilly "Learning" book and remembered that strings are immutable. So how was
I able to change the strings for my dotted quad? I did no
On Mon, Oct 19, 2009 at 08:07:47PM +0100, Alan Gauld wrote:
>
> "Matt Herzog" wrote
>
> >remembered that strings are immutable.
> >So how was I able to change the strings for my dotted quad?
>
> You didn't.
>
> >LASTKNOWN = '173.48.204
On Mon, Oct 19, 2009 at 07:51:06PM -0400, Matt Herzog wrote:
> On Mon, Oct 19, 2009 at 08:07:47PM +0100, Alan Gauld wrote:
> >
> > "Matt Herzog" wrote
> >
> > >remembered that strings are immutable.
> > >So how was I able to change the
On Tue, Oct 20, 2009 at 08:29:59AM +0100, Alan Gauld wrote:
> "Matt Herzog" wrote
>
> >Anyway, I'd like a hint as to how I could convert this:
> >
> >ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines()
> >x = string.split(ifcfg_lines[3
On Tue, Oct 20, 2009 at 02:49:53PM +, Tiago Saboga wrote:
> On Tue, Oct 20, 2009 at 2:44 PM, Matt Herzog wrote:
> > Yes, thanks. What failed was the invocation of PIPE. Apparently I had to
> > explicitly import PIPE from subprocess or python had no clue as to what
> > P
On Tue, Oct 20, 2009 at 07:53:17AM -0700, Steve Willoughby wrote:
> On Tue, Oct 20, 2009 at 10:44:16AM -0400, Matt Herzog wrote:
> > Yes, thanks. What failed was the invocation of PIPE. Apparently I had to
> > explicitly import PIPE from subprocess or python had no clue as to wha
;http://www.instamapper.com/fe?page=track&device_key=abc
')
print resp.read()
resp.close()
The ValueError is raised each time. If I remove this and read the response,
the page thinks I have disabled cookies and blocks access. Why isn't cj
grabbing the InstaMapper cookie?
Are there
I would recommend KirbyBase as a quick starter - it's nice and simple,
and outputs text files, so you can always check things manually.
http://www.netpromi.com/kirbybase.html
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
get a reference to an element in a list? Is it
really Example B?
Thanks,
Matt
(My apologies if this double-posts; I accidentally sent it previously
from a non-subscribed address. Moderator, please deny the other copy.)
___
Tutor maillist - Tutor@python.or
If anyone is interested in an invitation to Google GMail, let me know
and I will send you a free invitation to join. It works great for
organizing mailing lists and with 1000 MB of storage, you don't have
to manage your inbox.
--
Have you seen the dog lately?
Email - [EMAIL PROTECTED]
Blog - i
of my slowness:
This is my first programming language
I couldn't get the tutor list to work for ages - until I realised I was
sending all the desperate pleas for help to tutor-request. Perhaps there
is no hope..
Matt Williams
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
the
second loop does - but is very ugly.
x = "200% inv_nodes=0-2 node_caps=no"
y=x.split()
for i in y:
i="z"
print y
for i in range(len(y)):
y[i]="z"
print y
Surely there must be a better way than this ?
Thanks,
Matt
__
ty as my programs are
fairly small and don't do a whole lot. I would imagine that there would
be a penalty, but for now I'm happy with keeping my namespaces distinct
and knowing what came from where at a glance.
Matt
--
Matt Richardson
IT Consultan
r, but I was curious about it. Going
through the library reference I found a bunch of modules that would
replace some ugly (but working) code I had, then started to wonder if
importing a bunch of different modules would have much of an effect. In
any case, I'm more concerned with readabilit
have often been questions along
the lines of "Where can I find projects to get involved in", and I
thought this might help.
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I get the line above to work.
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
not a leap year"
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
k...). I cannot think of a way of checking each of
the 8 cells surrounding the one being tested without doing it this way.
Is there a better way of doing this?
Thanks in advance, Matt.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ould suppress_the_error() actually call?
Cheers,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> > Is there a better way of doing this?
>
> Perhaps something like this:
>
> for n in (x, x+1, x-1):
> for m in (y, y+1, y-1):
> if matrix[n, m]:
> neighbour_count = neighbour_count + 1
>
I need to not text matrix[x][y] is there a simple way to exclude this from the
possible combi
> the possible combinations of values from the two tuples?
> see my other reply, Matt.
> -Luke
Hi Luke,
Sorry if I'm missing something but which other reply?
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Fri, 2007-05-18 at 17:03 -0500, Luke Paireepinart wrote:
> see my other reply, Matt.
> -Luke
Apologies Luke,
I have found your earlier post in the tutor archives - I don't seem to
have received it from the list yet.
Thanks for the
ted. The program does use curses to
display the board so I guess it won't be any good for Windows users.
I hope someone can see where I am going wrong here.
Thanks,
Matt
#! /usr/bin/env python
import curses
def read_start():
# Read the starting configuration from a text file
file = op
d:
#! /usr/bin/env python
# Curses based Game of Life program
# Written by Matt Smith
import curses
from copy import deepcopy
def read_start():
# Read the starting configuration from a text file
file = open('/home/matt/Python/game_of_life/r-pentomino.txt', 'r&
odule under Linux (see my posts about the game of
life program). The game of life program might also show the kind of
stage I am at with my learning of Python at the moment.
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
as using.
Looking at my code - I can see it will break if the lists within the
big list making up the matrix are not all the same length. Maybe this
is something I need to test for in the program.
Cheers,
Matt
___
Tutor maillist - Tutor@python.org
ht
:
map :w\|!python %
This doesn't work for GVim which I prefer to use.
Do any Vim users have a better way of running a Python program while it
is being edited in Vim?
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Check out geany. It's fairly simple but I've found it very neat and simple.
http://geany.uvena.de/
On 6/11/07, scott <[EMAIL PROTECTED]> wrote:
Could someone suggest a few good IDE's for me to look at. I would
need
a IDE that haves syntax highlighting and I also really like type
compl
Hi there,
I am currently working on a noughts and crosses program to try and teach
myself some very simple AI programming and also to start to use OOP in
Python.
I am currently writing the framework for the game so I can then write a
number of functions or a class to deal with the strategy sid
velocity > 0:
impactvel = sqrt(velocity ** 2 + (2 * gravity * (ypos - 384 * 160)))
...
Traceback (most recent call last):
File "", line 32, in
ValueError: math domain error
This one has me stumped as the usage of the module looks straight forward from
the documentation.
Matt Smith wrote:
> import sys, pygame, math
>
> ...
>
> if ypos >= 384 and velocity > 0:
> impactvel = sqrt(velocity ** 2 + (2 * gravity * (ypos - 384 *
> 160)))
>
> ...
>
>
> Traceback (most recent call last):
> File "",
o square root a number less than 0.
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I just started attempting to program and thought i would try python as my
first tool. However following the beginners guide on their page it says to
insert python as a command and that it should come up with the program
information. When i insert python it says it is not recognizable as an
inte
tor to run...
As regards using wxPython - I thought it was ok, but frankly Glade was s
much easier..
(all IMHO)
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
nice and simple, and has the advantages of text-
based files) or ZODB. I have a bit of an allergy to SQL, even if
mediated via SQLObject (which looks very nice)
These seem to be at the opposite end of the spectrum - so do others have
either comments on these options, or other suggestions.
Thanks,
eds to have a simple GUI frontend. The nice
thing about ZODB is that I could just map the eventhandlers to functions
on objects..
If people have more comments in the light of the bigger spec. above, I'd
still love to hear them...
Matt
___
Tutor mail
Dear List,
Could someone explain how, in very general terms, one would use python
to wrap some C libraries/ API.
I ask because there are a few bits of C software that look quite
interesting, and I know that Python can be used to wrap the C - but how
does it work?
Thanks,
Matt
ke some classes & objects, and
then they can easily pass parameters to each other, but I just thought
I'd check.
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
would be a reasonable default.
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
turn all of the variables
in an instance?
I'm sure I'm not the first person to ask, but I couldn't find an answer
anywhere else...
Thanks,
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7384 899570
___
overlooking, so I'll go get a cup of
coffee and see if someone with better eyes spots my error.
thanks,
Matt
--
Matt Richardson
IT Consultant
College of Arts and Letters
CSU San Bernardino
(909)537-7598
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Danny Yoo wrote:
> Hope this helps!
Helped a lot. Shows that syntax errors aren't always visible (like
whitespace) and that I should know better than to attempt anything
before having at least one cup of coffee.
Thanks!
Matt
--
Matt Richardson
IT Consultant
College of Arts and Let
t the moment, I have something like:
def __init__ (self, a, b, c):
if type(a) == type("a")
then.
elif type(a) == type(["a"])
then
I'm sure there must be a better way to do this (both the polymorphism
and the type testing) - but I
There's some extra info here:
http://comments.gmane.org/gmane.comp.python.announce/5658
HTH,
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspo
sked, I thought people might like
to know...
http://daboenv.com/
HTH,
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com
___
ially interested in the idea of being able to write different bits
in different languages, and then run them all on Mono.
Thanks,
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspo
#x27;m looking for a pythonic version of something like Protege or
SWOOP
Thanks,
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com
___
Tuto
h the Protege OWL
plugin) and SWOOP, but both are Java based.
HTH.
Matt
--
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com
___
Tutor mai
The suprising thing about Latin Perl is that it's more
readable than normal Perl....
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I don't know if this will do anywhere near what you want...
http://swiginac.berlios.de/
is a set of Python bindings to GiNaC, which handles symbolic maths in
C/C++.
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/lis
and del.icio.us tagged sites/blogs. Where else do other
people look?
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I think the Wiki's a great idea.
del.icio.us already has a Python tagged page: http://del.icio.us/tag/python
Other pages I use are:
http://mechanicalcat.net/pyblagg.html
http://www.planetpython.org/
I've added a couple of things to the Wiki - SQLObject and RSPy
FC4 (the latest finished one) has python 2.4.1 as part of the distro (I
think RedHat actually use python for some of their scripts).
Just pull up a terminal and type 'python' and you should get the
prompt...
If you _are_ running FC4 and have more probs, feel free to drop me a
line.
You might also want to have a look at DABO; I don't know how well it
work on a handheld, though.
http://dabodev.com/about
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I'm using xmltramp to process some U.S. House of Rep. vote data. I can get it to print what I want but when I try to write it to a text file I had all sorts of problems. Can someone tell me what I'm doing wrong? I've done quite a bit of searching for the solution but as a novice to Python I'm at a
I'm having a new problem with my House vote script. It's returning the following error: Traceback (most recent call last): File "C:/Python24/evenmorevotes", line 20, in -toplevel- f.write(nm+'*'+pt+'*'+vt+'*'+md['vote-result'][0]+'*'+md['vote-desc'][0]+'*'+'\n')
UnicodeEncodeError: 'ascii' code
Just verifying what I looked up earlier: are strings and binary
(through struct.pack) the only data types that can be sent through a
socket? This is my first crack at socket programming, so I'll probably
have lots of questions to bug you with.
thanks,
pear' either through theft or people taking them home to do 'work
from home' or whatever. Makes annual inventory a huge pain.
Matt
--
Matt Richardson
IT Consultant
College of Arts and Letters
CSU San Bernardino
(909)537-7598
___
Tutor
could be just a simple string, sent via UDP, that
would happen after networking was established but before log in. I had
done something simpler before using a bash script and sendmail, but I
really don't want my inbox plugged up with a bunch of 'phone home'
messages :)
Matt
in and
run as you code, which saved me from making lots of silly mistakes.
--
Matt Richardson
IT Consultant
College of Arts and Letters
CSU San Bernardino
work: (909)537-7598
fax: (909)537-5926
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ENAME
> print TESTARTICLENAME
> print cur.execute(FIXEDARTICLENAME),
> print cur.execute(TESTARTICLENAME),
> # cannot get this to work
> print cur.execute(SQLARTICLENAME, (ARTICLES,))
> print
> print FIXEDPID
>
programming, pickling, and interfacing with MySQL.
Showing how particular things were done in python in clear, concise
examples is it's big strength. Thanks for not getting sucked in to
using lots of source code :)
--
Matt
Waiting for the second edition
__
could someone explain _very_ slowly?
Apologies for the gross stupidity,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it__(self,**kw)
self.property1 = self.kw['property1']
self.property2 = self.kw['property2']
etc
Does anyone know of an example of this ?
Thanks,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ot sure why there should be any
difference between the two - but I'm sure it's very simple.
Thanks for any tips,
Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
tc}, but I don't don't know how to take it on from
here. I was thinking of looking up the filename in the dictionary (using
.startswith() to get some basic rough-matching capacity) and then using
that to return the order that the files should be
I just used it a couple of weeks ago to produce a histogram of
randomly generated numbers. Read the documentation, it's well written
and has good examples.
Matt
On 10/22/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
>
> Folks,
>
> Has anyone tried matplotlib ..//???
te("System Report for: ")
report.write(system_name)
...
Is there a better way of doing this ? It works for what I want to do,
but I would
like to know if there's another way of doing things....
Thanks in advance.
Matt E
matt.erasmus (at) gmail (dot) com
hostname()
>
> I hope this helps
Thanks so much Michael
-Matt
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ecision based on all the
results. I've tried coding it as if...elif statements, but that all gets
horrible.
Given a list of the form [1,0,0,1,-1] I need to make decision (in this,
it is undecided, so we drop down to the next criteria).
Any ideas/ pointers as to how I implement this?
Thanks,
M
- Forwarded message from Tiago Katcipis -
i forgot, this might help you
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
I can't help wondering how to do this in python:
perl -wnl -e '/string/ and print;' filename(s)
Not that I want to forget the pre
Hi All.
I want to write a script that will emulate grep to some extent. This is just an
exercise for me. I want to run the script like this:
./pythongrep directory searchstring
Just like grep, I want it to print: filename, instance_of_match
As of now, the script can't find anything I tell it t
On Wed, Dec 24, 2008 at 01:12:55AM -, Alan Gauld wrote:
>
> "Kent Johnson" wrote
>
> >> for filename in os.listdir(directory):
> >> result = re.match(s, filename)
> >> print result
> >
> >You never open and read the files. You are searching for the pattern
> >in the filenam
> Do you want to use optparse, or get the command line arguments yourself?
> It seems the pattern string will be the first arg, will it?
Again I am confused. I assumed that optparse was the best way to pass in
arguments (such as filenames) from the command line. Like so:
./script.py -x r
#x27;ve been able to get
what I need by just defining __setattr__ in both classes. Whether I did
that correctly is a story for another thread ...
matt
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
1 - 100 of 162 matches
Mail list logo