Re: Building Web Site Using Python

2006-06-28 Thread Simon Forman
Roman wrote: > I am new to python. > > I am looking to read in a 12mb csv file, parse it, generate web pages, > summarize on a column and make drop down bottons. > > Where would I be able to find sample code that does something similar > to this? > > Also, I know that microsoft has put out .net be

Re: Building Web Site Using Python

2006-06-28 Thread Simon Forman
wisted, ... there are lots of them- search this news group, IIRC they've been mentioned recently. Google is your friend, Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Module executed twice when imported!

2006-06-28 Thread Simon Forman
es not use the module administration --" I don't know why the globals dict you're passing in would change the behavior though. Hopefully someone else can enlighten us both. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: for and while loops

2006-06-28 Thread Simon Forman
/node6.html), a quick search an google can turn up more. (Hint: you're probably gonna want to use a while loop for the first program and a for loop for the second.) Hope that helps, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug reporting impossible

2006-06-29 Thread Simon Forman
Nick Maclaren wrote: ... > Create a file called '' in your current directory containing > 'print "Oh, yeah?\n"' and then import a module that doesn't exist. > Don't include the single quotes. Why would you have a file named '' in

Re: Bug reporting impossible

2006-06-29 Thread Simon Forman
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > "Simon Forman" <[EMAIL PROTECTED]> writes: > |> Nick Maclaren wrote: > |> ... > |> > Create a file called '' in your current directory containing > |> > 'print "O

Re: list comprehension

2006-06-29 Thread Simon Forman
sion) The list comprehension version: results = [some expression for var in some_iterable if some condition] There's more to it, but that's the basic idea. Hope this helps, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get indices of a two dimensional list

2006-06-29 Thread Simon Forman
;1' > > This only gives me the index in one dimension. Is there any method by > which I can get (1,1) as the answer. When you sort out what you're actually trying to do, the answer to your question may be in this thread: http://groups.google.ca/group/comp.lang.python/browse_frm/thread/2f82408e1bcaa02e/27925504b2a4eb4a > > Thanks in advance. Hope this helps, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: FIXED: Re: optparse multiple arguments

2006-06-30 Thread Simon Percivall
Ritesh Raj Sarraf wrote: > Ritesh Raj Sarraf wrote: > > I just noticed that the args variable is holding values b and c. > > the args variables comes from: > > (options, args) = parser.parse_args() > > > > I guess I only need to figure out now is why args isn't storing > > argument "a" also... > >

Re: Newb Tkinter Question: Object has no attribute 'tk'

2006-06-30 Thread Simon Forman
> open but none of the widgets appear. The console gives me: > > AttributeError: 'NewWindow' object has no attribute 'tk' > > Here's my code: Please post the entire traceback, not just the error message, thanks. ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension

2006-06-30 Thread Simon Forman
a wrote: > hi simon thanks for your reply You're most welcome > what if i want to do this > feed_list=[] > feed_id=[] > for ix in feeds_list_select: > global feeds_list >

Re: list comprehension

2006-06-30 Thread Simon Forman
Bruno Desthuilliers wrote: > Andy Dingley <[EMAIL PROTECTED]> wrote: > > Simon Forman wrote: > > > >>There's more to it, but that's the basic idea. > > > > This much I knew, but _why_ and _when_ would I choose to use list > > compreh

Re: Newb Tkinter Question: Object has no attribute 'tk'

2006-06-30 Thread Simon Yau
ed...] You're referencing self (object) instead of a Frame when creating the Label. Change self to self.frame in both the Label and Button initialization and it'll work. Hope it helps, Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-02 Thread Simon Forman
an ask for a set of the keys easily enough if you want it: >>> d = dict(a=1, b=2, c=3) >>> set(d) set(['a', 'c', 'b']) So, IMHO, there's not much point to having keys() return a set. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: xpath question

2006-07-02 Thread Simon Forman
bruce wrote: > hi > > is there anyone with XPath expertise here? i'm trying to figure out if > there's a way to use regex expressions with an xpath query? i've seen > references to the ability to use regex and xpath/xml, but i'm not sure how > to do it... > > i have a situation where i have somethi

Re: xpath question

2006-07-02 Thread Simon Forman
bruce wrote: > simon.. > > you may not.. but lot's of people use python and xpath for html/xml > functionality.. check google "python xpath"... > > later.. > ... > > i have a situation where i have something like: > > /html/table//[EMA

Re: how to stop python...

2006-07-02 Thread Simon Forman
bruce wrote: > hi... > > perl has the concept of "die". does python have anything similar. how can a > python app be stopped? > > the docs refer to a sys.stop.. but i can't find anything else... am i > missing something... > > thanks > > -bruce What you want is sys.exit() See: http://docs.python.o

Re: Classes and global statements

2006-07-03 Thread Simon Forman
; this problem is to make the variable I need global in the class that > they are created. Does anyone have a better way in mind? I'm not sure, but I think there's no such thing as "global to a class", although you can make class attributes just like for objects. There are some complexities to doing this though so you should probably stick to instance objects rather than mucking about with class attributes.. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: xpath question

2006-07-03 Thread Simon Forman
://4Suite.org > Articles: http://uche.ogbuji.net/tech/publications/ Well shut my mouth! There *is* an xml/xpath python Guru here. *sigh* Sorry Bruce, (and everybody else on this newsgroup) I apologize for mouthing off and not contributing to a greater signal-to-noise ratio. I guess that should teach me not to post so quickly when I'm in a bad mood. I'll do better in the future. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension

2006-07-03 Thread Simon Forman
ix.url, ix.id) tuples as the "for index, url, id" loop iterates through them, thus saving the overhead of a list construction and additional iteration. I hope this makes sense and indeed answers something like your question. ;-) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
bruce wrote: > hi... > > i'm running into a problem where i'm seeing non-ascii chars in the parsing > i'm doing. in looking through various docs, i can't find functions to > remove/restrict strings to valid ascii chars. > > i'm assuming python has something like > > valid_str = strip(invalid_str) >

Re: sending binary data over sockets

2006-07-03 Thread Simon Forman
Grant Edwards wrote: > On 2006-07-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > My problem now, is that I need to send certain binary data over a > > socket. That is, I want to make some bytes, and stuff them in a TCP > > packet, send them down the pipe, and then listen for a response. ...

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
gt; import htmlentitydefs, pprint >>> pprint.pprint(htmlentitydefs.entitydefs) {'AElig': 'Æ', 'Aacute': 'Á', 'Acirc': 'Â', . . . 'nbsp': '\xa0', . . . etc... HTH, ~Simon "You keep using that word. I do not think it means what you think it means." -Inigo Montoya, "The Princess Bride" -- http://mail.python.org/mailman/listinfo/python-list

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
bruce wrote: > simon... > > the ' ' is not to be seen/viewed as text/ascii.. it's a representation > of a hex 'u\xa0' if i recall... Did you not see this part of the post that you're replying to? > 'nbsp': '\xa0', My point was

finding items that occur before or after an item in lists

2006-07-04 Thread Simon Forman
le when the data are modified, see 6) whatever. 8) Building auxiliary data structures is fine (like a dict mapping targets to lists they appear in, or to the sets that the function returns ("memoizing")) but while speed is the main concern, memory usage shouldn't be flagrant. Changing

Re: Sudoko solver

2006-07-04 Thread Simon Forman
r for the gui. I'll send it to you or post it here if you really want. But try google first. ;-) there are certainly bound to be better ones out there. ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: finding items that occur before or after an item in lists

2006-07-04 Thread Simon Forman
Simon Forman wrote: > I've got a function that I'd like to improve. > > It takes a list of lists and a "target" element, and it returns the set > of the items in the lists that appear either before or after the target > item. (Actually, it's a generator, an

Re: problems with midi programming in python

2006-07-05 Thread Simon Forman
is can be > result[-1] -= 128 Those are two of my favorite things about python. :-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Error type for shelve.open()

2006-07-05 Thread Simon Forman
nt format_exc() Traceback (most recent call last): File "", line 2, in ? ZeroDivisionError: integer division or modulo by zero Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: use var to form name of object

2006-07-05 Thread Simon Forman
;", line 1, in -toplevel- f.k AttributeError: foo instance has no attribute 'k' >>> f.wow(23) Traceback (most recent call last): File "", line 1, in -toplevel- f.wow(23) File "", line 4, in wow self.k += n AttributeError: foo instance has no attribute 'k' >>> BTW, that's a weird place to put import statements. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: searching for strings (in a tuple) in a string

2006-07-06 Thread Simon Forman
): # do whatever here In your case though, if I were doing this kind of thing a lot, I would use a little helper function like the findany() function Fredrik Lundh posted. IMHO if findany(a, tup): ... is much clearer and readily understandable than mucking about with generator comprehensions... Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: looping question 4 NEWB

2006-07-06 Thread Simon Forman
nd = ('bc', 'ab'), ('aa', 'bb') data = 'abc' then data2 = 'aab' # First iteration, data2 = 'bbb' # Second iteration replaces 'aa' even though 'aa' isn't in original data. Have fun, ~Simon > > # If f

Re: Activate a daemon several times a day

2006-07-06 Thread Simon Forman
Convert seconds since the Epoch to a time tuple expressing local time. When 'seconds' is not passed in, convert the current time instead. That takes care of the "now(hours)" part of your pseudocode. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Activate a daemon several times a day

2006-07-06 Thread Simon Forman
Yves Glodt wrote: > while True: > if now(hours) in runat: > act() > sleep(60) > sleep(10) > Note that, if "now(hours)" *is* in runat, this loop will sleep 70 seconds, not 60. It probably doesn't matter. -- http://mail.python.org/mailman/listinfo/python

Re: Very practical question

2006-07-06 Thread Simon Forman
madpython wrote: > ... > self.b=Tkinter.Button(root,txt="Button",command=self.doSmth).pack() > self.l=Tkinter.Label(root,txt="default").pack() > def doSmth(self): > var=globals()["m"].__dict__["progLogic"].func("some > input") > self.l.config(txt=var) > self.l.update_

Re: Error type for shelve.open()

2006-07-07 Thread Simon Forman
> try: ... db = shelve.open("meh", "r") ... except Exception, err: ... E = err ... Exception exceptions.AttributeError: "DbfilenameShelf instance has no attribute 'writeback'" in ignored >>> E So: >>> from anydbm import error

Re: how can I avoid abusing lists?

2006-07-07 Thread Simon Forman
def increment(value): map[value] += 1 And instead of, print type1[0], type2[0], type3[0] say, print map[0], map[1], map[2] Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea/request for new python mailing list/newsgroup.

2006-07-07 Thread Simon Forman
Kenneth McDonald wrote: > Would a mailing list and newsgroup for "python contributions" be of > interest? I currently have a module which is built on top of, and is ... > I'd very much likes a ML/newsgroup wherein potential python contributors > could > > * Post alphas/betas and seek feedback. > *

Re: how can I avoid abusing lists?

2006-07-07 Thread Simon Forman
eally do want more than "type code" (i.e. key to your map dict) to map to the same type counter then IMHO your original method is very apt. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: how can I avoid abusing lists?

2006-07-07 Thread Simon Forman
Thomas Nelson wrote: > Thanks to everyone who posted. First, I don't think my question was > clear enough: Rob Cowie, Ant, Simon Forman, [EMAIL PROTECTED], and Jon > Ribbens offered solutions that don't quite work as-is, because I need > multiple values to map to a singl

Re: Tkinter problem

2006-07-07 Thread Simon Forman
e file not being found, but that is what is > sounds like. > > I did a search on this on the web and got some hits, but none of them > provide a solution to my problem. > > Can anyone help with this problem? > > Jim Anderson Just an idea, but if you're sure that /usr/lib/python2.4/lib-dynload/_tkinter.so exists, check it's permissions and the permissions of /usr/lib/python2.4/lib-dynload/ HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: 2 problems

2006-07-07 Thread Simon Forman
ings.Ive tried using the normal [:1],[:2],etc but I need a function > that can do that a variable amount of times due to the varying number > of letters in the input. I'm sorry, but I don't know what you mean here. > > This would be of great help,as python is new to me. It's a great language! Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: check uploaded file's file size?

2006-07-08 Thread Simon Forman
gt; fileitem = form["datafile"] > print str(fileitem.filesize) > > -h3m4n Try this fileitem.seek(0, 2) # Seek to the end of the file. filesize = fileitem.tell() # Get the position of EOF. fileitem.seek(0) # Reset the file position to the beginning. If the fileitem is

Re: Inheritance error: class Foo has no attribute "bar"

2006-07-08 Thread Simon Forman
f I do a print out of the dictionary > just for Character, the attributes are listed. > Without a sample of your code and the actual tracebacks you're getting it is difficult to know what's going wrong. Are you writing your class like this: class Character: def __init__(

Re: function that modifies a string

2006-07-09 Thread Simon Forman
placid wrote: > quick hack > > def thefunc(s): > return s = "||" + s + ">>" >>> def thefunc(s): return s = "||" + s + ">>" SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list

Re: function that modifies a string

2006-07-09 Thread Simon Forman
a function locals() that returns a similar dict but for locals.) The answer to your second question is no. The inputed *name* (the changeString() function must be passed a string, not a variable) must be the name of an object in the global scope for the function to work. You almost certainly want to use a function like the thefunc() function that Jason posted. One other thing, you could define it like so: def thefunc(s): return '||%s>>' % s Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: type comparison and wxpython

2006-07-10 Thread Simon Forman
borris wrote: > ive been trying to do a test for type with wxpython objects > > like > > passing in a wx.TextCtrl into > > def XXX(obj) > if type(obj) is type(self.Button) > > I have to make an object self.Button to get its type. > as I tried is type("wx.Button") which didnt work. type("wx.Butt

Re: Error type for shelve.open()

2006-07-10 Thread Simon Forman
[EMAIL PROTECTED] wrote: > I reported the bug to python.org and apparently it has already been > fixed in the latest SVN build :). Awesome! Open Source at work! :D -- http://mail.python.org/mailman/listinfo/python-list

Re: Global "except" condition

2006-07-10 Thread Simon Forman
/docs.python.org/lib/module-sys.html) but that would then be called for all uncaught exceptions, even those that were raised from modules other than your myFile.py. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Full splitting of a file's pathname

2006-07-10 Thread Simon Forman
le.txt'] > > rd There's also os.path.sep, from the docs: "The character used by the operating system to separate pathname components." But a recursive function like the one Iain King posted is likely the best way to go. ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Identifying apparently unused globals

2006-07-11 Thread Simon Forman
> Thx, > > Skip I haven't used it myself, but pychecker (http://pychecker.sourceforge.net/) is supposed to be able to perform such stunts. From the page: "Types of problems that can be found include: Unused globals and locals (module or variable)" HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: When is a subclass not right?

2006-08-24 Thread Simon Forman
rence of B2 having an attribute 't', I can't > see any other obvious differences. Is there something I am missing? > > TIA > Chaz When the developer *tells* you it won't work, that's a good indication. :-) You haven't missed anything: the developer

Re: Python editor

2006-08-24 Thread Simon Forman
Jason Jiang wrote: > Hi, > > Could someone recommend a good Python editor? Thanks. > > Jason There have just been one or two long-ish threads on exactly this question. Search the google groups version of this group for them. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: lazy arithmetic

2006-08-24 Thread Simon Forman
__init__(self, a, b=None): > print self, a, b > self.a = a > self.b = b > > Item.__add__ = Add > > x = Item() > y = Item() > > print x, y > > c = x+y > > # This time, the Add constructor gets only the first two arguments: > "self"

Re: RE Module

2006-08-24 Thread Simon Forman
ta. What results are you getting for what input strings. Also, if you're just trying to strip html markup to get plain text from a file, "w3m -dump some.html" works great. ;-) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: lazy arithmetic

2006-08-24 Thread Simon Forman
The self argument to __add__ ends > up being the Add instance, not the Item instance: No, that's *exactly* true. "x+y" does mean "x.__add__(y)" and "x.__add__" *is* the class Add, so you're really calling "Add(y)", nothing more nor less. x+y =

Re: lazy arithmetic

2006-08-24 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Simon Forman wrote: > > > > > "Item.__add__ = Add" is a very strange thing to do, I'm not surprised > > it didn't work. > > Yes it is strange. > I also tried this even stranger thing: > > class Item(object): &g

Re: Is this a good idea or a waste of time?

2006-08-24 Thread Simon Forman
BTW, speaking of "strictness", "more stricter" is invalid English, just "stricter" is the "correct" form. ;-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Open Office and Python

2006-08-25 Thread Simon Brunning
heet > will do. Have you looked at the csv module? <http://docs.python.org/lib/module-csv.html>. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
"off-list"..) is that really how ruby sums a list? How does that work? Doesn't the '*' mean multiply? and what are the pipe symbols for? (Feel free to ignore these questions. I should really go look it up myself if I'm so curious..) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: List comparison help please

2006-08-25 Thread Simon Forman
Bucco wrote: > Simon Forman wrote: > > > 1) Don't use "dir", "file", and "list" as variable names, those are > > already python built in objects (the dir() function, list type, and > > file type, respectively.) > > Thanks. My

Re: Fw: Is this a good idea or a waste of time?

2006-08-25 Thread Simon Forman
Hendrik van Rooyen wrote: > "Simon Forman" <[EMAIL PROTECTED]> wrote: > > 8<- > > | BTW, speaking of "strictness", "more stricter" is invalid English, > | just "stricter&qu

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: > What was i thinkinng repace * with + i was'nt thinking i origanaly > thaught of sum of squares so i put a * insted of a + But again, what's your question? -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding if..elsif statements

2006-08-25 Thread Simon Forman
unexpected wrote: > I have a program where based on a specific value from a dictionary, I > call a different function. Currently, I've implemented a bunch of > if..elsif statements to do this, but it's gotten to be over 30 right > now and has gotten rather tedious. Is there a more efficient way to

Re: rollover effect

2006-08-26 Thread Simon Forman
t n hence > giving information about the type of text(event). > > Another thign i am looking for is to have a right click on that very > text as well > If somebody can put some light on it, then it would be really great for > my project. > Thank you in advance. What GUI system

Re: Out-dated compiled modules (*.pyc)?

2006-08-26 Thread Simon Forman
se has this problem but it might. There are at least three ways of dealing with this: 1) Restart the interpreter (manually or through some IDE option), 2) call reload() on your modules, or 3) del the modules from sys.modules before re-importing them. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: rollover effect

2006-08-26 Thread Simon Forman
groves wrote: > Simon Forman wrote: > > groves wrote: > > > hi > > > I am trying to get a roll over effect on my canvas.(this is a virtual > > > program which will eventually fit into my final program) > > > > > > Exactly i have a text on

Re: rollover effect

2006-08-26 Thread Simon Forman
;IDE" and "GUI" are terms that are not specific to python. But you still haven't answered my question? Are you using Tkinter? wxWidgets? Gtk bindings? Assuming that you're using Tkinter, what prevents you from using Pmw? Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: rollover effect

2006-08-26 Thread Simon Forman
SuperHik wrote: > groves wrote: > > Simon Forman wrote: > >> groves wrote: > >>> Sorry, as I am new to python so couldn't understand what yu were > >>> asking. > >>> Now the problem is that i annot use pmw in my project..is thre anyo

Re: Dive into Python question

2006-08-26 Thread Simon Forman
7;s working fine. The thing is dicts do not guarantee any particular order to their data when you access it. If you were to delete a key-value pair and then set it again and print out your dict again it would quite likely appear in a different order. I've only ever skimmed DiP, but I'

Re: import function from user defined modules

2006-08-27 Thread Simon Forman
clicks on it, the option COMMAND should > invoke a function defined in some other module say Y. > > thanks a lot to all who will look into problem, any help would be > appreciated. from X import func Then you can call func() in your module. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question. Class definitions on the fly.

2006-08-27 Thread Simon Forman
a single session, be sure to call reload() on your new (modified) file (rather than just importing it again) otherwise you won't get the changes. See http://docs.python.org/ref/exec.html for the exec statement and http://docs.python.org/lib/built-in-funcs.html#l2h-59 for the reload() function. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: eval() woes

2006-08-27 Thread Simon Forman
ion (actually int type.. but not important here), and includes the invalid input so you don't have to guess at it: |>> int('wombat') Traceback (most recent call last): File "", line 1, in ? int('wombat') ValueError: invalid literal for int(): wombat So, from what's visible in your post, it looks like int is getting passed a bare '-', i.e. at some point you're calling int('-')... HTH Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Segmentation Fault

2006-08-27 Thread Simon Forman
e of the code that causes the seg fault? Python standard lib is fairly robust but of course not bullet-proof. If there's a way to make it seg fault (and it's in the standard lib and not your C code) people will want to know. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Middle matching - any Python library functions (besides re)?

2006-08-27 Thread Simon Forman
have to be lots and lots of them... :-) More information on your actual use case would be helpful in narrowing down the best options. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: newbe question about removing items from one file to another file

2006-08-27 Thread Simon Forman
in one go: open(orcfilename, 'w').writelines(lines) of course stripping out your unwanted data from that last line using find() as shown above. I hope this helps. Check out the docs on file objects: http://docs.python.org/lib/bltin-file-objects.html, but like I said, if you're dealing with html or html-like files, be sure to check out beautifulsoup. Also, there's the elementtree package for parsing XML that could help here too. ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Firewire comms using Python?

2006-08-27 Thread Simon Forman
Fraggle69 wrote: > Hi, > Does anyone have any idea of how I can use Python to get images from my > firewire camera?? > I am using python under winXP pro > > Cheers > Fraggle Have you tried google? Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Segmentation Fault

2006-08-28 Thread Simon Forman
[EMAIL PROTECTED] wrote: > "Simon Forman" <[EMAIL PROTECTED]> writes: > > > pycraze wrote: > >> I would like to ask a question. How do one handle the exception due to > >> Segmentation fault due to Python ? Our bit operations and arithmetic > >

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Simon Forman
Andrew Robert wrote: > Simon Forman wrote: > > Paul Rubin wrote: > >> "EP" <[EMAIL PROTECTED]> writes: > >>> Given that I am looking for matches of all files against all other > >>> files (of similar length) is there a better bet than usi

Re: Firewire comms using Python?

2006-08-28 Thread Simon Forman
PetDragon wrote: > yeah man no joy there > > "Simon Forman" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Fraggle69 wrote: > >> Hi, > >> Does anyone have any idea of how I can use Python to get images from my > >

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Simon Forman
Andrew Robert wrote: > Because I was lazy.. > > The checksume_compare came from something else I wrote that had special > logging and e-mailer calls in it. > > Should have ripped the reference to caller and file name out.. Aaaahh the subtle joys of cut-and-paste programming... :-D (I've done it

Re: Twisted server and protocol question

2006-08-28 Thread Simon Forman
Benry wrote: > Hi guys. I hope I can discuss Twisted here. If not, direct me to the > correct place please. Twisted mailing list: http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python ;-) ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching for text

2006-08-28 Thread Simon Forman
% i return False except StopIteration: print 'File ended before FSType found.' return False return True if checkfile(f): # File passes... pass Be sure to close your file object when you're done with it. And you might want fewer or different print statements. HTH Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: eval() woes

2006-08-28 Thread Simon Forman
rdrink wrote: > Hey Simon, Thanks for the reply. > > Simon Forman wrote: > > You must be doing something weird, that equation works for me: > > Try posting the minimal code example that causes the error and the > > full, exact traceback that you get. > > I ap

Re: eval() woes

2006-08-28 Thread Simon Forman
ell > which. The traceback tells you, unambiguously, that it's the latter, the variable cast. That's *why* tracebacks exist, and why python prints them by default: to tell you as much as it can about exactly what went wrong. > > (BTW, as a footnote: For each of the above 'equations' the function > equate() was called 500 times... in some cases with the list 'parts' > equaling things like ['0',2','3','0'], so I have no reason to believe > that the problem is with the way the list is being passed in... but I > could be wrong) > > Can anyone see something I can't? Learn to read tracebacks. They're your friends. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Simon Forman
Antoon Pardon wrote: > On 2006-08-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Antoon Pardon wrote: > >> There seem to be enough problems that work with ints but not with > >> floats. In such a case enforcing that the number you work with > >> is indeed an int seems fully appropiate. > > >

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Simon Forman
Antoon Pardon wrote: > On 2006-08-28, Scott David Daniels <[EMAIL PROTECTED]> wrote: > > Antoon Pardon wrote: > >> On 2006-08-25, Simon Forman <[EMAIL PROTECTED]> wrote: > >>> ... > >>> Generally asserts should be used to "enforce" i

Re: naive misuse? (of PyThreadState_SetAsyncExc)

2006-08-29 Thread Simon Forman
'll take that then as proof that it's impossible to misuse the > function. > > Thanks, > Johan I *was* going to say that if you didn't already know the answer to that question then your use would almost certainly be naive. But I thought that'd be more nasty than f

Re: newbe question about removing items from one file to another file

2006-08-29 Thread Simon Forman
> > > > > > http://www.dexrow.com > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > I need to take it between the blocks only I also need to make sure I > only take one instrument > defined in this example with the code instr 1 I also need the code > > > > ; originally tone.orc > > sr = 44100 > > kr = 4410 > > ksmps = 10 > > nchnls = 1 > > regardless of what instrument I take. The function would have to > except the instrument number as an argument > > http://www.dexrow.com Using BeautifulSoup and the interactive interpreter, I figured out the following script in about 15 minutes: # s is a string containing the example file from above. from BeautifulSoup import BeautifulStoneSoup soup = BeautifulStoneSoup(s) csin = soup.contents[0].contents[5] lines = csin.string.splitlines() print csin.string It prints: ; originally tone.orc sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 instr 1 a1 oscil p4, p5, 1 ; simple oscillator out a1 endin and of course you could say "lines = csin.string.splitlines()" to get a list of the lines. That doesn't take you all the way, but it's something. Hope that helps, Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess woes

2006-08-29 Thread Simon Forman
P://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ You can also pass data to a subprocess like this: p1 = sp.Popen(["fasta34","-q","@",s],stdin=sp.PIPE, stdout=sp.PIPE) p1.stdin.write(x) p1.stdin.close() But I think communicate() would be better for you in this case. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: TNEF decoder

2006-08-29 Thread Simon Forman
e I once worked at had a project that included some TNEF handling. There was one developer assigned fulltime to it. He was the one who sat at his desk hurling curses at his workstation at the top of his lungs, later he developed a pretty severe drinking problem. Good luck. HTH, ~Simon -- ht

Re: psycopg2 features

2006-08-30 Thread Simon Forman
uld probably ask this in the psycopg mailing list: http://lists.initd.org/mailman/listinfo/psycopg Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: TNEF decoder

2006-08-30 Thread Simon Forman
Hendrik van Rooyen wrote: > "Simon Forman" <[EMAIL PROTECTED]> wrote: > > 8<- > > > | A place I once worked at had a project that included some TNEF > | handling. There was one developer assigned fulltime to it. He was the >

Re: Assignment-in-conditional

2006-08-31 Thread Simon Forman
are two recipies in the cookbook for doing this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/202234 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66061 HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax suggestion.

2006-09-01 Thread Simon Forman
samir wrote: > Bonan tagon! > > George Sakkis wrote: > > > It's been done; it's called "IPython": > > http://ipython.scipy.org/doc/manual/manual.html > > Thank you for the link! It's just what I've needed but... > > Roberto Bonvallet wrote : > > > ...so finally you get something that is exactly lik

Re: pictures as characters in a Tk text box?

2006-09-01 Thread Simon Forman
mt.edu/tcc/help/pubs/tkinter/text-window.html HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: disgrating a list

2006-09-01 Thread Simon Forman
jwaixs wrote: > Thank you for all your reply and support. Neil's fits the most to me. I > shrinked it to this function: > > def flatten(x): > for i in range(len(x)): > if isinstance(x[i], list): > x[i:i+1] = x[i] > > Thank you all again. If someone could find even a cuter wa

Re: CONSTRUCT -

2006-09-02 Thread Simon Forman
ou want to do is implement a less "ugly" verision of "if __name__ == '__main__':", a quick search on google should turn up several ways. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: str.isspace()

2006-09-03 Thread forman . simon
inking when I reach for isspace(), it's never occurred to me to use strip() for this task. Compare: if offset >= len(line) or line[offset].isspace(): if offset >= len(line) or line[offset].strip(): * it's "symetrical" with the rest of the isfoo() string metho

Re: CONSTRUCT -

2006-09-05 Thread Simon Forman
Fredrik Lundh wrote: > Simon Forman wrote: > > > I'm sorry, your post makes very little sense. > > you're somewhat new here, right ? ;-) > > Yah, I've been posting here about three months now. Why, did I miss something? :-) Peace, ~Simon -- http://

<    4   5   6   7   8   9   10   11   12   13   >