Re: for and while loops

2006-06-28 Thread Simon Forman
[EMAIL PROTECTED] wrote: > i was wondering if anyone could point me to some good reading about the > for and while loops > > i am trying to write some programs > "Exercise 1 > > Write a program that continually reads in numbers from the user and > adds them together until the sum reaches 100. Write

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 your current directory? ~Simon -- http://mail.python.org/mailman

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
a wrote: > can someone tell me how to use them > thanks basically, a list comprehension is just like a for loop, if you wrote it out the "long way" it would be something like this: results = [] for var in some_iterable: if some condition: results.append(some expression) The list co

Re: How to get indices of a two dimensional list

2006-06-29 Thread Simon Forman
[EMAIL PROTECTED] wrote: > I have a list > > x = [0] * 2 > x = x * [2] You're certainly not doing that. >>> x = [0] * 2 >>> x = x * [2] Traceback (most recent call last): File "", line 1, in ? TypeError: can't multiply sequence by non-int And even if you *do* do what it looks like you think y

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

2006-06-30 Thread Simon Forman
python programming newb wrote: > Hi all, first post. > > I'm new to python and tkinter. I'm trying to write a program that > opens the root window with a button that then opens a toplevel window > that then has it's own widgets. I can get the new toplevel window to > open but none of the widgets

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 > global feeds_id >

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: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-02 Thread Simon Forman
Nick Vatamaniuc wrote: > Robert Kern wrote: > > [EMAIL PROTECTED] wrote: > > > The same thing goes for the values(). Here most people will argue that ... > > > > This part is pretty much a non-starter. Not all Python objects are hashable. ... > > Also, I may need keys to map to different objects th

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//[EMAIL PROTECTED]'foo'] > > > > is it possible to do soomething

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
Sheldon wrote: > Hi, > > I have a series of classes that are all within the same file. Each is > called at different times by the main script. Now I have discovered > that I need several variables returned to the main script. Simple, > right? I thought so and simply returned the variables in a tupl

Re: xpath question

2006-07-03 Thread Simon Forman
[EMAIL PROTECTED] wrote: > bruce wrote: > > 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

Re: list comprehension

2006-07-03 Thread Simon Forman
[EMAIL PROTECTED] wrote: > I woulkdn't interate at the same time. zip takes two lists, and makes > a single list of tuples, not the other way around. The easilest > solution is > feed_list = [ix.url for ix in feeds_list_select] > feed_id = [ix.id for ix in feeds_list_select] The zip built-in fun

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
bruce wrote: > hi... > > update. i'm getting back html, and i'm getting strings like " foo  " > which is valid HTML as the ' ' is a space. &, n, b, s, p, ; Those are all ascii characters. > i need a way of stripping/removing the ' ' from the string > > the   needs to be treated as a single char.

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
i'm looking to remove or replace the insances with a ' ' (space) Simplicity: s.replace(' ', ' ') ~Simon "You keep using that word. I do not think it means what you think it means." -Inigo Montoya, "The Princess Bride" > > -bru

finding items that occur before or after an item in lists

2006-07-04 Thread Simon Forman
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, and I use the set class outside of it to collect the unique items, but y

Re: Sudoko solver

2006-07-04 Thread Simon Forman
Rony Steelandt wrote: > Hi all, > > I wonder if somebody had a Sudoko solver written in Python ? > > Rony Dude, there's like a million of them. Try "Sudoko solver Python" in google. I wrote one myself based on Knuth's Dancing Links algorithm and using Tkinter for the gui. I'll send it to you or

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
Not related to your actual question, but note: > if len(result) == 0: empty lists test as False, so this can just be > if not result: and > result[len(result)-1] -= 128 you can index lists with negative ints, backwards from the end of the list, so this can be >

Re: Error type for shelve.open()

2006-07-05 Thread Simon Forman
[EMAIL PROTECTED] wrote: > I wanted to write the following code: > > import shelve > try: >db = shelve.open(file, "r") > except SomeError: >print "Oh no, db not found" > > Only, I'm not sure what SomeError should be. I tried error, > anydbm.error, shelve.open.anydb.error, etc. but can't fin

Re: use var to form name of object

2006-07-05 Thread Simon Forman
gel wrote: > class testclass: > import wmi > import time > global d_software > global l_notepad > global d_licence_numbers > d_licence_numbers = {"notepad.exe":1, "Adobe":1} > l_notepad =[] > d_software = {"notepad.exe":[[],[]], "Adobe":[[],[]]} > Wow! For a se

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

2006-07-06 Thread Simon Forman
manstey wrote: > Hi, > > I often use: > > a='yy' > tup=('x','yy','asd') > if a in tup: ><...> > > but I can't find an equivalent code for: > > a='xfsdfyysd asd x' > tup=('x','yy','asd') > if tup in a: >< ...> > > I can only do: > > if 'x' in a or 'yy' in a or 'asd' in a: ><...> > > but

Re: looping question 4 NEWB

2006-07-06 Thread Simon Forman
[EMAIL PROTECTED] wrote: > manstey: > > is there a faster way of implementing this? Also, does the if clause > > increase the speed? > > I doubt the if increases the speed. The following is a bit improved > version: > > # Original data: > data = 'asdfbasdf' > find = (('a', 'f'), ('s', 'g'), ('x', '

Re: Activate a daemon several times a day

2006-07-06 Thread Simon Forman
Yves Glodt wrote: > Hi, > > I have a daemon which runs permanently, and I want it to do a special > operation at some specifiy times every day, consider this configfile > extract: > > [general] > runat=10:00,12:00 > > > What would be the easiest and most pythonic way to do this? > Something like th

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
[EMAIL PROTECTED] wrote: > I tried what you said and it looked like maybe AttributeError, but that > didn't work either. > > This code snippet: > > import shelve > from traceback import format_exc > > try: >db = shelve.open("meh", "r") > except: >print format_exc() > > Gave me this output:

Re: how can I avoid abusing lists?

2006-07-07 Thread Simon Forman
Thomas Nelson wrote: > I have this code: > type1 = [0] > type2 = [0] > type3 = [0] > map = {0:type1, 1:type1, 2:type3, 3:type1, 4:type2} # the real map is > longer than this > > def increment(value): > map[value][0] += 1 > > increment(1) > increment(1) > increment(0) > increment(4) > #increm

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
Tim Chase wrote: > > You'll notice that the OP's code had multiple references to the > same counter (0, 1, and 3 all mapped to type1) > > The OP's method was about as good as it gets. One might try to D'oh! Didn't notice that. Yeah, Thomas, if you really do want more than "type code" (i.e. k

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
Jim Anderson wrote: > I'm running Kubuntu a derivative of Debian Linux. I'm using > Python 2.4 and tcl/tk 8.4. I'm running Tkinter programs and > they were running about a month ago. When I tried them again > yesterday, I got the following message: > > > python ~/prog/python/iodef/iodef.py > > Tr

Re: 2 problems

2006-07-07 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Hello,Im using Python 2.4.2 and I'm starting a few very basic > programs,but theres two problems I've not found the answers for. > My first problem is I need code that will count the number of letters > in a string and return that number to a variable. Do you mean like t

Re: check uploaded file's file size?

2006-07-08 Thread Simon Forman
h3m4n wrote: > i have a short script that allows users to upload files, but when i try > to check for a valid filesize (using fileitem) i get '-1' i can't find > information about using filesize anywhere. any ideas? > > code: > > form = cgi.FieldStorage() > fileitem = form["datafile"] > print str

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

2006-07-08 Thread Simon Forman
crystalattice wrote: > I've finally figured out the basics of OOP; I've created a basic character > creation class for my game and it works reasonably well. Now that I'm > trying to build a subclass that has methods to determine the rank of a > character but I keep getting errors. > > I want to "re

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
greenflame wrote: > Jason wrote: > > > > There /are/ a few hacks which will do what you want. However, if you > > really need it, then you probably need to rethink your program design. > > Remember, you can't change a string since a string is immutable! You > > can change a variable to bind to an

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
Ernesto wrote: > Within the scope of one Python file (say myFile.py), I'd like to print > a message on ANY exception that occurs in THAT file, dependent on a > condition. > > Here's the pseudocode: > > if anyExceptionOccurs(): > if myCondition: > print "Here's my global exception

Re: Full splitting of a file's pathname

2006-07-10 Thread Simon Forman
BartlebyScrivener wrote: > I don't know if it's "standard," but why not just: > > dir = './foo/bar/moo/lar/myfile.txt' > dir.split('/') > > ['.', 'foo', 'bar', 'moo', 'lar', 'myfile.txt'] > > rd There's also os.path.sep, from the docs: "The character used by the operating system to separate pathna

Re: Identifying apparently unused globals

2006-07-11 Thread Simon Forman
[EMAIL PROTECTED] wrote: > At work we have a fairly large application (about 20 packages, 300+ modules) > that looks like we might be heading into a bit of a plateau stage. Now > seems like a good time to identify and delete old, unused code that's flown > under the radar screen for awhile simply

Re: When is a subclass not right?

2006-08-24 Thread Simon Forman
Chaz Ginger wrote: > I was writing some code that used someone else class as a subclass. He > wrote me to tell me that using his class as a subclass was incorrect. I > am wondering under what conditions, if ever, does a class using a > subclass not work. > > Here is an example. For instance the ori

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
[EMAIL PROTECTED] wrote: > # This is what I have in mind: > > class Item(object): > def __add__(self, other): > return Add(self, other) > > class Add(Item): > def __init__(self, a, b): > self.a = a > self.b = b > > a = Item() > b = Item() > > c = a+b > > # Now, I am going absolutely

Re: RE Module

2006-08-24 Thread Simon Forman
Roman wrote: > I am trying to filter a column in a list of all html tags. What? > To do that, I have setup the following statement. > > row[0] = re.sub(r'<.*?>', '', row[0]) > > The results I get are sporatic. Sometimes two tags are removed. > Sometimes 1 tag is removed. Sometimes no tags are

Re: lazy arithmetic

2006-08-24 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Gabriel Genellina wrote: > > At Friday 25/8/2006 00:36, [EMAIL PROTECTED] wrote: > > > > ># This is what I have in mind: > > > > > >class Item(object): > > > def __add__(self, other): > > > return Add(self, other) > > > > And this works fine... why make thinks compl

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
asincero wrote: > Would it be considered good form to begin every method or function with > a bunch of asserts checking to see if the parameters are of the correct > type (in addition to seeing if they meet other kinds of precondition > constraints)? Like: > > def foo(a, b, c, d): >ass

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: > lets say you want a generic numerical algorithom like sum > > Ruby > > def sum lst > lst.inject(0){|total,current| total*current} > end > > Java // i dont know if there is a numeric super class for numbers > > class Sum{ > public static int sum(int[] lst){ > int t

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
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 my screen and I want to have a brief > discription across it whenever the user takes the mouse on it n hence > giving in

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

2006-08-26 Thread Simon Forman
Anastasios Hatzis wrote: > Hi folks, > > how can I prevent Python from adding or using *.pyc files if executing a > Python module? I have the strong feeling that the interpreter uses > out-dated pyc file instead more recent py files. At least I already had > some cases where application behaviour c

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
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 anyother > alternative by which I can have a rollover mouse effect on the canvas. > thanks Not a problem. Although "IDE" and "GUI" are terms

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
Fred C. Dobbs wrote: > I feel like an idiot. I'm going thru "Dive Into Python" and running the > first program - odbchelper.py > > My output is "pwd=secret;database=master;uid=sa;server=mpilgrim" which > has all the substrings reversed from the output documented in the book. > I've run the download

Re: import function from user defined modules

2006-08-27 Thread Simon Forman
groves wrote: > Can anybody give me an example of how to import a function of module X > in module y. And please if yu can use classes(Object oriented approach) > would be great. > > The problem is that I have created a text on canvas, and now I want > that whenever a user right clicks on it, the o

Re: Newbie Question. Class definitions on the fly.

2006-08-27 Thread Simon Forman
ishtar2020 wrote: > Hi everyone > > I'm sure this question is kinda stupid and has been answered a few > times before... but I need your help! > > I'm writing a small application where the user can analyze some text > based on a set of changing conditions , and right now I'm stuck on a > point whe

Re: eval() woes

2006-08-27 Thread Simon Forman
rdrink wrote: > n.n.h. (noob needs help) > Ok, I've been beating my head against this for a day... time to ask > others. > To explain things as simply as possible: > I am trying to use eval() to evaluate some simple equations, such as-- > pow(AB,2) > pow(AB,2)+A > pow(A+B,2) > pow(A+B,2)+A > and so

Re: Segmentation Fault

2006-08-27 Thread Simon Forman
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 > manipulations are written in C and to some of our testcases we > experiance Segmentation fault from the python libraries. > > If i know h

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

2006-08-27 Thread Simon Forman
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 using re.search? > > The initial application concerns files in the 1,000's, and I could use > > a good solution for a

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

2006-08-27 Thread Simon Forman
[EMAIL PROTECTED] wrote: > def simplecsdtoorc(filename): > file = open(filename,"r") > alllines = file.read_until("") > pattern1 = re.compile(" orcfilename = filename[-3:] + "orc" > for line in alllines: > if not pattern1 > print >>orcfilename, line > > I am

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
robinsiebler wrote: > The other thing I failed to mention is that I need to ensure that I > find the fsType *before* I find the next FontName. Given these requirements, I'd formulate the script something like this: f = open(filename) NUM_LINES_BETWEEN = 7 Fo = '/FontName /ACaslonPro-Semibold'

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
rdrink wrote: > Ok, maybe now I can make some more sense of this, with an example of > real code (sorry if it's a bit dense): > This is the basic function... > > def equate(parts,new_eq): > > oL = int(parts[0]) > iL = int(parts[1]) > iR = int(parts[2]) > oR = int(parts[3]) >

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
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > The documentation for PyThreadState_SetAsyncExc says "To prevent naive > > misuse, you must write your own C extension to call this". Anyone care > > to list a few examples of such naive misuse? > > No? I'll take that then as proof that it's

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

2006-08-29 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Anthra Norell wrote: > > Dexter, > > > > I looked at the format specification. It contains an example: > > > > --- > > > > ; > > ; test.csd - a Csound structured data file > > > > > > -W -d -o tone.wav > > > > > > ;opt

Re: subprocess woes

2006-08-29 Thread Simon Forman
Dennis Lee Bieber wrote: > On Tue, 29 Aug 2006 18:17:47 +0530, km <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > ##code start ## > > import subprocess as sp > > x = 'GSQIPSHYWKKNLWYYSHEIDGGCHNMW' > > p0 = sp.Popen(["echo",x], stdout=sp.PIPE) > > Why use this

Re: TNEF decoder

2006-08-29 Thread Simon Forman
David Isaac wrote: > I'm aware of > http://cheeseshop.python.org/pypi/pytnef/ > but it uses the tnef utility, and I'd like a pure Python solution > (along the lines of http://www.freeutils.net/source/jtnef/ ). > > Is there one? > > Thanks, > Alan Isaac A place I once worked at had a project that

Re: psycopg2 features

2006-08-30 Thread Simon Forman
Maxim Sloyko wrote: > Hello, clp and all people reading it! > Recently I was porting my (small) app from psycopg to psycopg2 (they > got me with this "2"). > I read, that psycopg2 supports all features of psycopg and plus many > more, however, when I started to port, I discovered, that psycopg2 >

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
xamdam wrote: > Thanks for the FAQ, and for the 'casm ;) > > What do you think about using alternative syntax (something like 'as') > > - max > > Fredrik Lundh wrote: > > xamdam wrote: > > > > > I am not sure if this came up before, but I would love to have an > > > 'assignment-in-conditional' form

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
Jay wrote: > This may be really obscure, but I had a dream about programming > something like this, so don't blame me. Is it possible to take a small > image or icon and display it as a character in a Tk text box? Think > how Thunderbird displays text smilies as actual smiley icons. Or how > in

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
lazaridis_com wrote: > I would like to fulfill the following task: > > The construct: > > if __name__ == '__main__': > > should be changed to something like: > > if identifier.name == '__main__': > > The term "identifier" should be selected based on the meaning of the > __double-underscore-enclosur

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://

Re: convert loop to list comprehension

2006-09-09 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Thanks for that, Carl. I think that using the loop is probably what > I'll end up doing. I had no idea that the listcomp thing would be quite > a complicated as it is appearing. I had it in my mind that I was > missing some obvious thing which would create a simple solut

Re: Map with an extra parameter

2006-09-09 Thread Simon Forman
ml1n wrote: > [EMAIL PROTECTED] wrote: > > This may be what you need: > > > > class foo: > > def __init__(self, a, b): > > self.a = a > > self.b = b > > > > vars = [1,2,3,4,5,6] > > objects = [foo(a, 1) for a in vars] > > > > > > Note that in Python the new is expressed wit the () at th

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Simon Forman
Brendon Towle wrote: > I need to simulate scenarios like the following: "You have a deck of > 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, > replace it, and repeat N times." > > So, I wrote the following code, which works, but it seems quite slow > to me. Can anyone point out

Re: Converting a varargs tuple to a list - a definite pitfall for new comers to Python

2006-09-14 Thread Simon Forman
[EMAIL PROTECTED] wrote: > The following program does not work if you uncomment #lis = > ["xmms2"] + list(args) > > Evidently Python is opting for the nullary constructor list() as > opposed to the other one which takes a sequence. But no newcomer would > know this. And the Python docs dont gi

Re: What is the most efficient way to test for False in a list?

2007-07-08 Thread Simon Forman
On Jul 8, 7:43 pm, lex <[EMAIL PROTECTED]> wrote: > Of course there is the always the iteration method: > > list = [1, True, True, False, False, True] > status = True > for each in list: > status = status and each > > but what is your best way to test for for False in a list? False in list

Tkinter pack difficulty

2007-09-12 Thread Simon Forman
Hi all, I realize this is more of a Tk question than a python one, but since I'm using python and don't know Tcl/Tk I figured I'd ask here first before bugging the Tcl folks. I am having a terrible time trying to get a pack() layout working. I have three frames stacked top to bottom and stretchi

Re: Tkinter pack difficulty

2007-09-16 Thread Simon Forman
Thanks everyone for the incredibly helpful replies! I got the effect I wanted, no problem. I don't know why I didn't think to remove the expand option. I thought the sticky option would constrain the expansion. Thanks again, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   >