Re: Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
On Mar 17, 11:34 am, Bruno Desthuilliers wrote: > Wes Santee a écrit : > > > I am very new to Python, and trying to figure out how to create an > > object that has values that are accessible either by attribute name, > > or by index.  For example, the way os.stat()

Re: Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
On Mar 17, 11:14 am, Christian Heimes wrote: > Wes Santee wrote: > > I am very new to Python, and trying to figure out how to create an > > object that has values that are accessible either by attribute name, > > or by index.  For example, the way os.stat() ret

Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
ng an answer. Cheers, -Wes -- http://mail.python.org/mailman/listinfo/python-list

Re: WANTED: Regular expressions for breaking TeX/LaTeX document into tokens

2010-02-24 Thread Wes James
it might help: http://plastex.sourceforge.net/plastex/sect0025.html -wes -- http://mail.python.org/mailman/listinfo/python-list

Re: python dowload

2010-02-23 Thread Wes James
> > > NEW QUESTION if y'all are still reading: > > Is there an integer increment operation in Python? I tried > using i++ but had to revert to 'i = i + 1' i+=1 -- http://mail.python.org/mailman/listinfo/python-list

Re: string to list when the contents is a list

2010-02-18 Thread Wes James
On Thu, Feb 18, 2010 at 12:32 PM, Wes James wrote: > On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase > wrote: >> Wes James wrote: > > >> >> Just to add to the list of solutions I've seen, letting the built-in csv >> module do the heavy lifting: >

Re: string to list when the contents is a list

2010-02-18 Thread Wes James
On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase wrote: > Wes James wrote: > > Just to add to the list of solutions I've seen, letting the built-in csv > module do the heavy lifting: > >  >>> s = "['a','b']" >  >>> import

Re: error trying to join #python on irc.freenode.net

2010-02-17 Thread Wes James
On Wed, Feb 17, 2010 at 4:53 PM, Wes James wrote: > When I try to join #python on irc.freenode.net it keeps saying: > > You need to identify with network services to join the room "#python" > on "irc.freenode.net". > > Server Details: > Cannot join chan

error trying to join #python on irc.freenode.net

2010-02-17 Thread Wes James
When I try to join #python on irc.freenode.net it keeps saying: You need to identify with network services to join the room "#python" on "irc.freenode.net". Server Details: Cannot join channel (+r) - you need to be identified with services What does this mean?

string to list when the contents is a list

2010-02-17 Thread Wes James
h "['a','b']" I have tried and get: a="['a','b']" b=a[1:-1].split(',') returns [ " 'a' "," 'b' " ] when I want it to return ['a','b']. How can I do this? thx, -wes -- http://mail.python.org/mailman/listinfo/python-list

Re: socket.MSG_WAITALL flag broken on Windows XP in Python 2.5.4?

2009-09-16 Thread Wes McKinney
On Sep 16, 3:53 pm, Irmen de Jong wrote: > Tim Roberts wrote: > > Wes McKinney wrote: > >> I noticed the flag socket.MSG_WAITALL seems to have crept its way into > >> Python 2.5 on Windows (it's in 2.5.4, but not in 2.5.1, not sure about > >> inter

socket.MSG_WAITALL flag broken on Windows XP in Python 2.5.4?

2009-09-15 Thread Wes McKinney
ailable in the socket module. Does anyone know more about this? Thanks, Wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Best Python Web Framework ?

2009-04-21 Thread Wes James
On Tue, Apr 21, 2009 at 12:46 PM, SKYLAB wrote: > Greetings.. > > First , my english is not good . > > I heard that was written in python ( Youtube Programming Language : > PYTHON :S ) Correct ? > > That's not correct ? Then youtube is PHP application ? > > That's correct ; Which python web framew

python twitter

2009-04-15 Thread Wes James
Anyone know if there is a twit for python? I did http://twitter.com/python, but nope on that I was looking for twit py announcements, etc... thx, -wj -- http://mail.python.org/mailman/listinfo/python-list

Re: file open fails.

2009-03-24 Thread Wes James
On Tue, Mar 24, 2009 at 4:32 PM, Wes James wrote: > On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels > wrote: >> Atul. wrote: > > > >> In your case, '\r' is a return (a single character), not two >> characters long. I think its sad that 'C:\Th

Re: file open fails.

2009-03-24 Thread Wes James
On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels wrote: > Atul. wrote: > In your case, '\r' is a return (a single character), not two > characters long. I think its sad that 'C:\Thesis' doesn't cause > an error because there is no such character as '\T', but I am > probably excessively peda

Re: Upgrade Python on a Mac

2009-03-02 Thread Wes James
On Mon, Mar 2, 2009 at 2:53 PM, Rey Bango wrote: > Hi, > > I'd like to upgrade the installed version of Python that came standard > on OS X (Leopard) with either 2.6.1 or 3.0.1. Before I stick my foot > in it, I just wanted to get a better understanding of the process. I'd recommend you put your

Re: how to conditionally add a dict in-line

2009-02-23 Thread Wes James
Steven. Thx (see my question below...) On Mon, Feb 23, 2009 at 9:47 PM, Steven D'Aprano wrote: > On Mon, 23 Feb 2009 21:35:38 -0700, Wes James wrote: > >> I have this line: >> >> navs.append(A(' '+str(i+1)+' >> ',_href=self.action(arg

Re: how to conditionally add a dict in-line

2009-02-23 Thread Wes James
On Mon, Feb 23, 2009 at 9:35 PM, Wes James wrote: > I have this line: > > navs.append(A(' '+str(i+1)+' > ',_href=self.action(args=request.args,vars={'_page':i,'_query':request.vars._query > or ''}))) > > How do I do somethi

how to conditionally add a dict in-line

2009-02-23 Thread Wes James
I have this line: navs.append(A(' '+str(i+1)+' ',_href=self.action(args=request.args,vars={'_page':i,'_query':request.vars._query or ''}))) How do I do something like this: vars={'_page':i, if request.vars._query not None then insert this key/value pair ('_query':request.vars._query) else insert

parsing text from a file

2009-01-29 Thread Wes James
If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" with this code: f=open('fwrules.reg2

Re: Python Genetic Algorithm

2008-01-28 Thread wes
Max, def GeneticNextGen(self): numsets = len(self.WtSets) numwts= len(self.WtSets[0].Lis) self.WtSets.sort(CompByCurrentFitness) index_lis = [] K = 100.0 N= float(numwts) #if RISE(slope) is too high, concentration occ

Re: problem with global var

2008-01-03 Thread wes
Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0"

Re: MySQLdb syntax issues - HELP

2007-12-16 Thread wes
. Ive been stuck on this all > week and have read numerous tutorials, the DB-API specification sheet, the > MySQL manual, the MySQLdb documentation, and a few books... none of which > seem to adress my problem since they are all only assigning variables to > the table name OR the values of the query, not both. Please help me figure > this out. Luke, It would be most helpful if you assigned the sql to a string, printed the string, executed the string, and posted the error message. sql = "INSERT INTO %s (name, gender, job, level, str, dex, intel, cha, luc) VALUES \ (%s, %s, %s, %s, %s, %s, %s, %s, %s) \ " % (CharAccount, CharName, CharGender, CharJob, CharLevel, Strength,\ Dexterity, Inteligence, Charm, Luck) print "sql=",sql cursor.execute(sql) -then show the error message here wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary help

2007-11-01 Thread wes weston
Steve wrote: > I'm currently working on a little database type program is which I'm > using a dictionary to store the information. The key is a component a and > the definition is a list of parts that make up the component. My problem > is I need to list out several components, but not all, and

Re: python under earthlink hosting?

2006-08-01 Thread wes weston
No, but before I signed up with them I asked if it was available and they said yes. wes mbstevens wrote: > I keep chatting with the tech support people at Earthlink, asking where > the location of the Python interpreter is. They don't seem to know where > it is. They don'

Re: Parsing HTML--looking for info/comparison of HTMLParser vs. htmllib modules.

2006-07-07 Thread wes weston
from HTMLParser import HTMLParser class MyHTMLParser(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.TokenList = [] def handle_data( self,data): data = data.strip() if data and len(data) > 0: self.TokenList.append(data)

Re: Class probkem - getting msg that self not defined

2006-05-22 Thread wes weston
Andrew Robert wrote: > wes weston wrote: >> Andrew Robert wrote: >>> Hi Everyone, >>> >>> I am having a problem with a class and hope you can help. >>> >>> When I try to use the class listed below, I get the statement that self >>> is

Re: Class probkem - getting msg that self not defined

2006-05-22 Thread wes weston
Andrew Robert wrote: > Hi Everyone, > > I am having a problem with a class and hope you can help. > > When I try to use the class listed below, I get the statement that self > is not defined. > > test=TriggerMessage(data) self is not known here; only inside the class. > var = tes

Re: Basic coin flipper program - logical error help

2006-02-21 Thread wes weston
with: for x in range(100): if random.randint(0,1) == 0: heads += 1 else: tails += 1 Inside the loop you need to "flip" on each pass. You're "flipping" once before the start of the loop now. wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Walking through a mysql db

2005-06-04 Thread wes weston
nting it prior to the fetchone() w/o effect. > > Thanks for any pointers. > > Jeff Elkins > > > > > > Jeff, You just check for a fetchone return of None. "list" is a list of tuples here. ... cursor.execute( sql ) list = [] while

Re: Rotating arbitrary sets of elements within a list

2005-04-08 Thread wes weston
[EMAIL PROTECTED] wrote: I'm trying to come up with a good algorithm to do the following: Given a list 'A' to be operated on, and a list 'I' of indices into 'A', rotate the i'th elements of 'A' left or right by one position. Here's are some examples: A = [a, b, c, d, e, f] I = [0, 3, 4] rotate(A, I

Re: Rotating arbitrary sets of elements within a list

2005-04-08 Thread wes weston
phil, Could you do a circlular buffer where the front starts at 'a' (0) and rotate left increments front. The i'th element is gotten as mod 6 (front+i) where 6 would be the length of the list. wes -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQL problem

2005-03-18 Thread wes weston
Dennis Lee Bieber wrote: On Thu, 17 Mar 2005 16:45:57 GMT, wes weston <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: str = "INSERT INTO produkt1 (MyNumber) VALUES(%d)" % (MyNumber) cursor.execute(str) Think you meant "MyValue" for the second item

Re: Simple account program

2005-03-17 Thread wes weston
nyone trying to help you. Why have transactions not associated with accounts? All transactions are related to an account; have a self.TransActList in Account. You have "amount" in both Withdrawl and Deposit both derived from Transaction. If Transactions always have an amou

Re: MySQL problem

2005-03-17 Thread wes weston
1 (MyNumber) VALUES(MyValue) """) # Program says OperationalError: (1054, "Unknown column 'MyValue' in 'field list'") Where is a problem. Thanks for help Lad. Lad, Try str = "INSERT INTO produkt1 (MyNumber) VALUES(%d)" % (MyNumber) cursor.execute(str) wes -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the cost of using hundreds of threads?

2005-03-01 Thread wes weston
spawning so many threads - but it's the simplest solution to this problem :) ). PR, I notice there's a resource module with a getrusage(who) that looks like it would support a test to get what you need. wes -- http://mail.python.org/mailman/listinfo/python-list

Re: String Replace Problem...

2005-02-28 Thread wes weston
ut in "keywords.reverse()" after getting keywords, things may work better. Though not a good fix, it illustrates part of the problem. If you replace "@PERMX1" you also replace part of "@PERMX10". Wouldn't it be better to read the file as lines instead of strings? wes -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace collisions

2005-02-17 Thread wes weston
is? If I put it in a common location in my Python path, should I call it willsutil.py? TIA, Will McGugan Will, See http://www.boost.org/libs/python/doc/tutorial/doc/html/python/techniques.html 'about page 30 of google search. It gives an example that should help. wes -- http://mai

Re: broke tkinter

2005-02-08 Thread wes weston
e! Regards, Philippe Phillipp, Might you be getting the wrong header file/tk version? http://wiki.tcl.tk/3669 talks about it. wes -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you do arrays

2005-02-01 Thread wes weston
t with for x in jMatrix: print x Is it basic that indexes from 1 vs. 0? 'just about completely forgotten basic. wes Thomas Bunce wrote: Tryed it and this is what I got (I did go to the web sight) tom(h=500)$ /tmp/501/Cleanup\ At\ Startup/ptesting-128981347.87.py.command; exit Input the

Re: How do you do arrays

2005-02-01 Thread wes weston
1 k = random.choice(listvalues) + 1 iMatrix[index] = k The book statement of array(typecode, initializer) does not make sence to me how it henerates ore relaes to the org name for the array. Thank You Tom Thomas, You can do >>> m = [4] >>> m [4] wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Where are list methods documented?

2005-02-01 Thread wes weston
have figured out I can do list.sort.__doc__ 'L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1' Grant, For a quick, short doc string list: >>> help(list) wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Where can I find sample "beginner" programs to study?

2005-01-28 Thread wes weston
as all the pieces you use most often. wes -- http://mail.python.org/mailman/listinfo/python-list

Re: A completely silly question

2004-12-17 Thread wes weston
modules don't make much sence to me... Amir Amir, >>> import tkSimpleDialog >>> ch = tkSimpleDialog.askstring("","ch?") wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Find index of item in list

2004-12-07 Thread wes weston
Sean Berry wrote: Given myList = ['cat', 'dog', 'mouse' ... 'bear'] what is the easiest way to find out what index 'dog' is at? Sean, >>> myList = ['cat', 'dog', 'mouse','bear'] >>> myList.index('dog') 1 >>> wes -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on sorting

2004-11-29 Thread wes weston
have a function name as an arg. You could do: def mycompare(s1,s2): #return -1 to put s1's at front; 1 to put s1's at back; 0 for a tie #if s1=="" and s2<>"": return 1 lines.sort(mycompare) wes -- http://mail.python.org/mailman/listinfo/python-list