Re: raw_input passing to fun

2006-04-27 Thread Gary Wessle
John Machin <[EMAIL PROTECTED]> writes: > On 28/04/2006 2:04 PM, Gary Wessle wrote: > > the output of this code below is not what one would expect, it > > outputs > > all kind of numbers and it never stops, I want to ask the user for a > > number and then print o

print out each letter of a word

2006-04-27 Thread Gary Wessle
I am going through this tut from http://ibiblio.org/obp/thinkCS/python/english/chap07.htm I am getting errors running those 2 groups as below as is from the tut thanks index = 0 while index < len(fruit): letter = fruit[index] print letter index = index + 1 or for char in fruit:

TypeError: 'module' object is not callable

2006-04-28 Thread Gary Wessle
dear python users I am not sure why I am getting Traceback (most recent call last): File "my.py", line 3, in ? urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') TypeError: 'module' object is not callable **

convert a int to a list

2006-04-28 Thread Gary Wessle
Hi can type conversion work to convert an int to a list? I am trying to solve an problem in one tutorial. a = ['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]] As an exercise, write a loop that traverses the previou

file open "no such file"

2006-04-30 Thread Gary Wessle
I am getting this error when I try to run the code below f = open("~/m", "r") print f.read() :~$ python python/my.py Traceback (most recent call last): File "python/my.py", line 1, in ? f = open("~/m", "r") IOError: [Errno 2] No such file

string.find first before location

2006-05-02 Thread Gary Wessle
Hi I have a string like this text = "abc abc and Here and there" I want to grab the first "abc" before "Here" import string string.find(text, "Here") # I am having a problem with the next step. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: string.find first before location

2006-05-02 Thread Gary Wessle
Peter Otten <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > > I have a string like this > > > > text = "abc abc and Here and there" > > I want to grab the first "abc" before "Here" > > > > import string >

redemo.py with Tkinter

2006-05-02 Thread Gary Wessle
Hi I was reading the Regular Expression HowTo, it refers to redemo.py if you have Tkinter installed. a quick #locate redemo.py returned none on my debian/testing, however #locate Tkinter returned many. any body out there is using it, is it a separate download? thanks -- http://mail.python.org/ma

Re: simultaneous assignment

2006-05-02 Thread Gary Duzan
g for the other spy. The details are left as an exercise for the reader. :-) Gary Duzan Motorola CHS -- http://mail.python.org/mailman/listinfo/python-list

data regex match

2006-05-02 Thread Gary Wessle
Hi I am having an issue with this match tx = "now 04/30/2006 then" data = re.compile('(\d{2})/\1/\1\1', re.IGNORECASE) d = data.search(tx) print d Nono I was expecting 04/30/2006, what went wrong? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: string.find first before location

2006-05-02 Thread Gary Wessle
"Serge Orlov" <[EMAIL PROTECTED]> writes: > Peter Otten wrote: > > Gary Wessle wrote: > > > > >> These days str methods are preferred over the string module's functions. > > >> > > >> >>> text = "abc abc and

assignment in if

2006-05-02 Thread Gary Wessle
Hi is there a way to make an assignment in the condition of "if" and use it later, e.g. nx = re.compile('regex') if nx.search(text): funCall(text, nx.search(text)) nx.search(text) is evaluated twice, I was hoping for something like nx = re.compile('regex') if x = nx.search(text): funCall(

scope of variables

2006-05-03 Thread Gary Wessle
Hi is the code below correct? b = 3 def adding(a) print a + b it seams not to see the up-level scope where b is defined. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of variables

2006-05-03 Thread Gary Wessle
"Steve R. Hastings" <[EMAIL PROTECTED]> writes: > On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote: > > b = 3 > > def adding(a) > > print a + b > > > > it seams not to see the up-level scope where b is defined. > > Assuming you p

Re: scope of variables

2006-05-04 Thread Gary Wessle
Ryan Forsythe <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > the example was an in-accuretlly representation of a the problem I am > > having. my apologies. > > > > a = [] > > def prnt(): > >print len(a) > > > >>>> pr

Re: scope of variables

2006-05-04 Thread Gary Wessle
thank you -- http://mail.python.org/mailman/listinfo/python-list

print formate

2006-05-05 Thread Gary Wessle
Hi import string import re accumulator = [] pattern = '(\S*)\s*(\S*)\s*(\S*)' for each text file in dir openfile and read into text data = re.compile(pattern, re.IGNORECASE).findall(text) accumulator = accumulator + data gives a list of tuples which when printed looks like ('jack', '

combined files together

2006-05-05 Thread Gary Wessle
Hi is there a module to do things like concatenate all files in a given directory into a big file, where all the files have the same data formate? name address phone_no. or do I have to open each, read from old/write-or-append to new ... thanks -- http://mail.python.org/mailman/listinfo/python

Re: combined files together

2006-05-06 Thread Gary Herron
Gary Wessle wrote: >Hi > >is there a module to do things like concatenate all files in a given >directory into a big file, where all the files have the same data >formate? >name address phone_no. > >or do I have to open each, read from old/write-or-append to new ... &

sort a list of files

2006-05-06 Thread Gary Wessle
Hi I am trying to print out the contents of a directory, sorted. the code 1 import os, sys 2 3 if len(sys.argv) < 2: 4 sys.exit("please enter a suitable directory.") 5 6 print os.listdir(sys.argv[1]).sort() **

os.isfile() error

2006-05-06 Thread Gary Wessle
Hi could someone help me to find out whats wrong with this code? code import os, sys if len(sys.argv) < 2: sys.exit("please enter a suitable directory.") dpath = sys.argv[1] for name in os.listdir(dpath): if os.isfile(dpath+name): infile = open(

Re: combined files together

2006-05-06 Thread Gary Wessle
Gary Herron <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > >Hi > > > >is there a module to do things like concatenate all files in a given > >directory into a big file, where all the files have the same data > >formate? > >name address phone

Re: python rounding problem.

2006-05-07 Thread Gary Wessle
Erik Max Francis <[EMAIL PROTECTED]> writes: > chun ping wang wrote: > > > Hey i have a stupid question. > > How do i get python to print the result in only three decimal > > place... > > Example>>> round (2.9954254, 3) > > 2.9951 > > but i want to get rid of all trailing 0's.

NumTut view of greece

2006-05-07 Thread Gary Wessle
Hi not sure if this would be the right place to ask this question! using the shell prompt :~$ python Python 2.3.5 (#2, Mar 6 2006, 10:12:24) [GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Numeric >>

Re: NumTut view of greece

2006-05-07 Thread Gary Herron
Gary Wessle wrote: >Hi > >not sure if this would be the right place to ask this question! >using the shell prompt >:~$ python >Python 2.3.5 (#2, Mar 6 2006, 10:12:24) >[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 >Type "help", "copy

Re: printing list

2006-05-07 Thread Gary Herron
>10 >15 > >Thanks. > > Well, first, if you just print alist you'll get [1, 2, 5, 10, 15] which may be good enough. If that's not what you want then you can suppress the automatic RETURN that follows a print's output by adding a trailing comma to

Numerical Python Tutorial errors

2006-05-07 Thread Gary Wessle
Hi is the Numerical Python tutorial maintained? http://www.pfdubois.com/numpy/html2/numpy.html seams to have some errors and no email to mail them to when found. if interested, read about the errors below (1) http://www.pfduboi

evaluation of >

2006-05-07 Thread Gary Wessle
Hi what does the i > a in this code mean. because the code below is giving False for all the iteration. isn't suppose to evaluate each value of i to the whole list? thanks a = range(8) i = 0 while i < 11: print i > a i = i + 1 False False False False False False False False False False F

Re: Numerical Python Tutorial errors

2006-05-07 Thread Gary Wessle
Robert Kern <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > Hi > > > > is the Numerical Python tutorial maintained? > > http://www.pfdubois.com/numpy/html2/numpy.html > > seams to have some errors and no email to mail them to when found. > > No

reading a column from a file

2006-05-07 Thread Gary Wessle
Hi I have a file with data like location pressure temp str flootfloot I need to read pressure and temp in 2 different variables so that I can plot them as lines. is there a package which reads from file with a given formate and returns desired variables? or I need to open, while not EO

two of pylab.py

2006-05-09 Thread Gary Wessle
Hi I use debian/testing linux Linux debian/testing 2.6.15-1-686 I found some duplicate files in my system, I don't if the are both needed, should I delete one of the groups below and which one? -rw-r--r-- 1 root root 80375 2006-01-24 00:28 /usr/lib/python2.3/site-packages/matplotlib/pylab.py -

installing numpy

2006-05-09 Thread Gary Wessle
Hi I am trying to install NumPy in my debian/testing linux 2.6.15-1-686. with no numpy for debian/testing, I am left alone, since the experimental version available by debian will result in a dependency nightmares, so after unpacking the downloaded file "numpy-0.9.6.tar.gz" which crated a direc

Re: installing numpy

2006-05-09 Thread Gary Wessle
Christoph Haas <[EMAIL PROTECTED]> writes: > On Tue, May 09, 2006 at 09:03:31PM +1000, Gary Wessle wrote: > > I am trying to install NumPy in my debian/testing linux > > 2.6.15-1-686. > > > > with no numpy for debian/testing, I am left alone, since the >

Re: multiline strings and proper indentation/alignment

2006-05-09 Thread Gary Herron
Gary John Salerno wrote: >How do you make a single string span multiple lines, but also allow >yourself to indent the second (third, etc.) lines so that it lines up >where you want it, without causing the newlines and tabs or spaces to be >added to the string as well? > >Exa

Re: installing numpy

2006-05-09 Thread Gary Wessle
"Raymond L. Buvel" <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > Hi > > > > I am trying to install NumPy in my debian/testing linux > > 2.6.15-1-686. > > > > > When installing from source on a Debian system, you want the insta

Re: Shadow Detection?

2006-05-09 Thread Gary Herron
Michael Yanowitz wrote: >Hello: > > Many times, people are warning things like >"Don't use 'str' as a variable name as it will shadow the >built in str function." > Is there some way to determine if a string is already >defined in some higher scope? >Maybe something like > > >if isdefined ('st

Re: installing numpy

2006-05-10 Thread Gary Wessle
Robert Kern <[EMAIL PROTECTED]> writes: > Raymond L. Buvel wrote: > > > Since you are a new Linux user, you should definitely follow Robert's > > advice about building as an ordinary user separately from the install. > > I sometimes take a shortcut and just do the install as user root. > > Howeve

Re: combined files together

2006-05-10 Thread Gary Wessle
Eric Deveaud <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > > > I need to traverse those files in the order they were created > > chronologically. listdir() does not do it, is there a way besides > > build a list then list.sort(), then for element i

Re: installing numpy

2006-05-10 Thread Gary Wessle
thanks I followed your suggestions, it built the package ok, while it was building, I noticed lots of lines going by the screen in groups of different colors, white, yellow, red. the red got my attention: Could not locate executable gfortran Could not locate executable f95 *

2 books for me

2006-05-10 Thread Gary Wessle
Hi I am about to order 2 books, and thought I should talk to you first. I am getting Python Cookbook by Alex Martelli, David Ascher, Anna Martelli Ravenscroft, Anna Martelli Ravenscroft, since Bruce Eckel's Thinking in Python is not finished and didn't have any new revisions since some time in 200

Re: find all index positions

2006-05-11 Thread Gary Herron
ng)] [10, 31] And so on Of course, if you wish, the re module can work with vastly more complex patterns than just a constant string like your '1234'. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: find all index positions

2006-05-11 Thread Gary Herron
Paul Rubin wrote: >[EMAIL PROTECTED] writes: > > >>say i have string like this >>astring = 'abcd efgd 1234 fsdf gfds abcde 1234' >>if i want to find which postion is 1234, how can i achieve this...? i >>want to use index() but it only give me the first occurence. I want to >>know the positions o

TkTable for info gathering

2006-05-12 Thread Gary Wessle
Hi I just finished with 1.5 tutorials about Tkinter, my thought is to use a table "maybe TkTable" to gather info from the user as to what file to chart data from, as well as info provided by the TkTable properties. each cell of the table will be either empty or contains a file path, let x=1 be t

Re: Python Translation of C# DES Encryption

2006-05-12 Thread Gary Doades
ypting in a way compatible with thwe C# methods. http://twhiteman.netfirms.com/des.html Regards, Gary. -- http://mail.python.org/mailman/listinfo/python-list

retain values between fun calls

2006-05-13 Thread Gary Wessle
Hi the second argument in the functions below suppose to retain its value between function calls, the first does, the second does not and I would like to know why it doesn't? and how to make it so it does? thanks # it does def f(a, L=[]): L.append(a) return L print f('a') print f('b')

copying files into one

2006-05-13 Thread Gary Wessle
Hi I am looping through a directory and appending all the files in one huge file, the codes below should give the same end results but are not, I don't understand why the first code is not doing it. thanks combined = open(outputFile, 'wb') for name in flist: if os.path.isdir(file): continu

continue out of a loop in pdb

2006-05-14 Thread Gary Wessle
Hi using the debugger, I happen to be on a line inside a loop, after looping few times with "n" and wanting to get out of the loop to the next line, I set a break point on a line after the loop structure and hit c, that does not continue out of the loop and stop at the break line, how is it down,

Re: copying files into one

2006-05-14 Thread Gary Wessle
thanks, I was able 'using pdb' to fix the problem as per Edward's suggestion. -- http://mail.python.org/mailman/listinfo/python-list

Re: continue out of a loop in pdb

2006-05-14 Thread Gary Wessle
"Paul McGuire" <[EMAIL PROTECTED]> writes: > "Gary Wessle" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi > > > > using the debugger, I happen to be on a line inside a loop, after > > looping few times with "

Re: Process forking on Windows

2006-05-17 Thread Gary Herron
appreciated. > >Thanks > > The "subprocess" module gives a (mostly) platform independent way for one process to start another. It provides a number of bells and whistles, and is the latest module on a long history of older modules to provide such functionality. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Process forking on Windows

2006-05-17 Thread Gary Herron
igger monitor. > > The windows CreateProcess call has many of the same semantics as the Unix fork, i.e., a new process is created sharing all the resources of the original process. The "subprocess" modules uses CreateProcess, but if that does not give you sufficient control ove

getting the value of an attribute from pdb

2006-05-17 Thread Gary Wessle
Hi how can I "using pdb" get a value of an attribute?, read the docs and played around with pdb 'p' for no avail. thanks class main: def __init__(self, master): self.master = master self.master.title('parent') self.master.geometry('200x150+300+225') ... root = Tk() ***

Re: Complex evaluation bug

2006-05-18 Thread Gary Herron
that functionality. So, putting them together, you could expect eval(repr(a)) to reproduce a, and in fact it does so. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: import woe

2006-05-18 Thread Gary Herron
[EMAIL PROTECTED] wrote: >hello, > >i have a problem. i would like to import python files above and below >my current directory. > >i'm working on /home/foo/bar/jar.py > >i would like to import /home/foo/car.py and > /home/foo/bar/far.py > >how can i do this? > >thank you, >

Re: who can give me the detailed introduction of re modle?

2006-05-18 Thread Gary Herron
tried to solve, your solution attempt, and what failed, you will likely get lots of useful answers here. But you have to take the first step. P.S. The re module is really not all *that* difficult. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Tk.iconname still there?

2006-05-21 Thread Gary Wessle
Hi I am going through a tutorial on Tkinter http://doctormickey.com/python/pythontutorial_201.html, it referees to Tk.iconname() but I could not locate one after googleing and browsed and searched the Tkinter On-line reference material in the Tkinter reference: a GUI for Python, 84 pp. pdf from

Re: Choosing a new language

2007-12-28 Thread Gary Scott
ot;confusion" stage of Lisp parentheses, so they don't bother me at all. > > I need advice from people who have been coding in all three, and who > can share some views and experiences. > > Please, if you don't know ALL three by deep experience, don't respond

Re: ctypes

2008-01-06 Thread Gary Herron
via ctypes. If you can be more specific about your problem and how it fails, then perhaps you'll get more specific answers. Also, please read this: http://www.catb.org/~esr/faqs/smart-questions.html Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: HOW TO HANDLE POINTERS FROM NON-LOCAL HEAPS??

2008-01-11 Thread Gary Herron
der) C/C++ days -- ya, that's it. Thankfully, this is Python and the modern era -- we don't use no stinking POINTERS here. Seriously, this group deals with Python. There are no pointers in Python. Now please, what did you *really* mean to ask? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: python recursive function

2008-01-11 Thread Gary Herron
: > This sounds very much like a homework assignment, and so should probably not be answered here. (Neither should it have been asked here.) If, in your attempt to write this program, you have some questions about Python, then I encourage to ask those questions here. Gary Herron > If n is

Re: Simple List division problem

2008-01-12 Thread Gary Herron
larger sublist. >>> x = [1,2,3,4,5,6,7,8,9,10] >>> y = 3 >>> s = len(x)/y >>> s# size of normal sublists 3 >>> e = len(x) - y*s # extra elements for last sublist >>> e 1 >>> z = [x[s*i:s*i+s] for i in

Re: sqlite3 is it in the python default distro?

2008-01-12 Thread Gary Herron
access an sqlite installation, but it does not include the sqlite installation itself. That should be installed separately. (I suppose a distro of Linux could package them together, but I don't know of one that does, and such is not the intent of Python.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-formatting

2008-01-12 Thread Gary Herron
row into the hundreds or thousands or higher. If you want to try one of the floating point formats, then your first number must be large enough to account for digits (before and after) the decimal point, the 'E', and any digits in the exponent, as well as signs for both the number and th

Re: NotImplimentedError

2008-01-14 Thread Gary Herron
27;s it not yet implemented, and mistakenly tries to call it, an error will be raised. It's not so useful in a small application, or a single person project, but it does become useful if several people are writing different parts (say a library and an application) at the same time. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
ach won't scale very well since the whole string would be re-created anew for each stop_list entry. In that case, I'd look into the regular expression (re) module. You may be able to finagle a way to find and replace all stop_list entries in one pass. (Finding them all is easy -- not so sure you could replace them all at once though. ) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
Karthik wrote: > How about - > > for s in stoplist: > string.replace(mystr, s, "") > That will work, but the string module is long outdated. Better to use string methods: for s in stoplist: mystr.replace(s, "") Gary Herron > Hope this s

Re: Python too slow?

2008-01-17 Thread Gary Duzan
hrown out by the compiler in favor of non-generic types, and casts are inserted as necessary. Practicality wins over Purity again. Gary Duzan Motorola HNM -- http://mail.python.org/mailman/listinfo/python-list

Re: Max Long

2008-01-21 Thread Gary Herron
icit (defined) limit. The amount of available address space forms a practical limit. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'?

2008-01-23 Thread Gary Herron
second produces an int value, but since one is a subclass of the other, you'd have to write quite perverse code care about the difference. Gary Herron > I hope, I made clear, what I want... > Quite. > CU > > Kristian > -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'?

2008-01-23 Thread Gary Herron
Boris Borcic wrote: > I am surprised nobody pointed out explicitely that > > True==1 and False==0 > Several of us did indeed point this out by saying that bool's are a subclass of ints. > so that for instance > > 5*(True+True)==10 > > and even (but implementation-dependent) : > > 5*(True+True) i

Re: Beginner String formatting question

2008-01-26 Thread Gary Herron
convert it to a string within the function with str()? > Of course you can pass any type into a function. Then you have to write the program to operate correctly on whatever the input type is. > I've been at this for a while, so I may not be able to see the forest > through the trees at this point. I'd greatly appreciate any > suggestions or instruction on these mistakes. > My guess is that's why the code you show does not match the output you present. > Best, > > Jimmy > Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: dict comprehension

2008-01-31 Thread Gary Herron
st (or iterator or generator creating a list) of tuples. Put them together and get what you might be tempted to call a dictionary comprehension. For instance: >>> dict((i,i*i) for i in range(10)) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81} Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: dict comprehension

2008-01-31 Thread Gary Herron
Ryan Ginstrom wrote: >> On Behalf Of Daniel Fetchinson >> What does the author mean here? What's the Preferably One Way >> (TM) to do something analogous to a dict comprehension? >> > > I imagine something like this: > > keys = "a b c".split() values = [1, 2, 3] D = dict([(a

Re: Python GUI toolkit

2008-02-03 Thread Gary Herron
any other toolkit is capable of creating good-looking GUI's, like in other > apps, for e.g, .net apps. > Not true! There are *many* more widget toolkits out there. Dozens! See: http://en.wikipedia.org/wiki/List_of_widget_toolkits Gary Herron > i m a noob, and willing to

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-03 Thread Gary Herron
with the next step # If it needs to wait for the child to complete, it can call os.waitpid else: # New fork continues here, independently of the original process # doing whatever the fork was create for Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Too many open files

2008-02-04 Thread Gary Herron
ng, writing, and closing. This will keep the open/write/closes operations to a minimum, and you'll never have more than 2 files open at a time. Both of those are wins for you. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not a Python compiler?

2008-02-07 Thread Gary Duzan
r Wars reference, which is quite on topic for this subthread. http://starwars.wikia.com/wiki/Kessel_Run Gary Duzan Motorola H&NM -- http://mail.python.org/mailman/listinfo/python-list

Re: which one is more efficient

2008-02-08 Thread Gary Herron
final code shows that the differences in the test is a small fraction of 1% of the total execution time -- then your time would be better spent worrying about how to optimize the other portions of you code. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: different key, same value in dictionaries

2008-02-09 Thread Gary Herron
] would index the same element. See http://docs.python.org/lib/module-sets.html for details of the set module. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Better way to negate a boolean list?

2008-02-10 Thread Gary Herron
ot; is not a function. > > Thanks in advance, > > David > But import module operator, and find operator.not_ which is a function and does what you want. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python equivt of __FILE__ and __LINE__

2008-02-11 Thread Gary Herron
ff you see in a traceback -- including file and line information. *How* you extract that stuff, I'll leave as an exercises for the reader. (Meaning I haven't a clue.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to access object attributes given a string

2008-02-12 Thread Gary Herron
> PS: I need it for a concrete case in a game scripting language I'm > writing, so that I can call functions like "CHANGE_PLAYER_VALUES( "x", > 100 )". > You want getattr and setattr: setattr(ob, 'blah', 123) and getattr(ob, 'blah') Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy PIL question

2008-02-16 Thread Gary Herron
d also be helpful. > Basically I'm trying to make a: > if pixel == color: > do_this() > else: > pass > > And have it do this as fast as my pc can handle (that is why only > grabbing 1px would be helpful) > Try image.getpixel((x,y)) to retrieve the pixel at

Re: Sys.exit() does not fully exit

2008-02-17 Thread Gary Herron
gt; threads + os.system. > > Christian > That's a good answer. However, it you *do* want threads, and you don't want the main thread to wait for the threads to quit, you can make the threads "daemon threads". See setDaemon method on Thread objects in the threading modul

Re: Python 3.0

2008-02-18 Thread Gary Herron
e intent is to keep the incompatibilities to a minimum, but subject to the larger goal of producing a cleaner/better language unhindered by the need of absolute compatibility. Gary Herron > David Blubaugh > > > > > > > -Original Message- > From: Bill Hart [ma

Re: Understanding While Loop Execution

2008-02-18 Thread Gary Herron
ted anywhere that list is referred to. >>> sub = [1,2,3] >>> full = [sub,sub,sub] >>> full [[1, 2, 3], [1, 2, 3], [1, 2, 3]] >>> sub[0] = 123 >>> full [[123, 2, 3], [123, 2, 3], [123, 2, 3]] So in you code, the single list mylist is shuffle

Re: packing things back to regular expression

2008-02-20 Thread Gary Herron
rds. The re module does have functions to do string substitution. One or more occurrences of a pattern matched by an re can be replaces with a given string. See sub and subn. Perhaps you can make one of those do whatever it is you are trying to do. Gary Herron > e.g > >

Re: simpleparse - what is wrong with my grammar?

2008-02-24 Thread Gary Herron
any knowledgeable volunteers to actually volunteer their time. Good luck. Gary Herron > Thanks, > >Laszlo > > > from simpleparse.common import numbers, strings, comments > from simpleparse.parser import Parser > > declaration = r''' > expr

Re: Newbie: How can I use a string value for a keyword argument?

2008-02-25 Thread Gary Herron
> y = 'trials=32' > x.foo(y)# doesn't work > Keyword args are represented during the calling process as a dictionary, You can create the dictionary yourself, and slip it into the calling arguments with a ** notation: kw = {somestring:32} x.foo(**kw) Gar

Re: String compare question

2008-02-25 Thread Gary Herron
Robert Dailey wrote: > Hi, > > Currently I have the following code: > > > ignored_dirs = ( > r".\boost\include" > ) You expect this is creating a tuple (or so I see from your "in" test in the following code), but in fact the parenthesis do *not* make a tuple. If you look at ignored_dirs, y

Re: Question on importing and function defs

2008-03-02 Thread Gary Herron
o take, as a parameter, the "a" function to call. In mod: def a(): ... def b(fn=a): # to set the default a to call ... And you main program: from mod import * def my_a(): ... b(my_a) Hope that helps Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Short confusing example with unicode, print, and __str__

2008-03-05 Thread Gary Herron
een how __str__ and __repr__ act on strings. Here's s simpler example >>> d=unicode("Caf\xe9", "Latin-1") >>> repr(d) "u'Caf\\xe9'" >>> str(d) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 3: ordinal not in range(128) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: parralel downloads

2008-03-08 Thread Gary Herron
Far easier than threads. Gary Herron > You can have more information here. > http://artfulcode.nfshost.com/files/multi-threading-in-python.html > > > On Sat, Mar 8, 2008 at 1:11 PM, John Deas <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> I would like

Re: is operator

2008-03-10 Thread Gary Herron
ght? Why? Thanks. > > > Yes that is true, but it's an implementation defined optimization and could be applied to *any* immutable type. For larger ints, such a thing is not true. >>> x=1000 >>> y=1000 >>> x is y False If either is a surpris

Re: how to pass the workspace ?

2008-03-11 Thread Gary Herron
) > execfile ( node2 ) > etc.. > > Now how do I pass the workspace created in node1, to node 2, etc ? > > thanks, > Stef Mientki > RTFM! In particular: http://docs.python.org/lib/built-in-funcs.html#l2h-26 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Weight Problem

2008-03-16 Thread Gary Herron
t better. > Can anyone come with good solution, and maybe solution showing usage > of Sets. > -- > -=Ravi=- This sounds like a homework problem, something you should be solving yourself. If, however, you have any Python questions, then please ask. We'll be glad to answe

Re: Is this valid ?

2008-03-19 Thread Gary Herron
ys. You usually see it in test like this: if a < b < c: but any comparison operators work. The meaning is the same as the AND of each individual test. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: NameError: name 'guess' is not defined

2008-03-22 Thread Gary Herron
break # this causes the while loop to stop elif guess < number: print 'No, it is a little higher than that.' else: print 'No, it is a little lower than that.' print 'The while loop is over.' print 'Done' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Time module is not behaving.

2008-03-25 Thread Gary Herron
kstation. > > Here's my little program > > [EMAIL PROTECTED]:~/tmp$ more < time.py > > import time > * Right there is the problem. Your program, named time.py, is hiding the Python supplied module. So that import of time is finding and re-importing itself. Rename

Re: Is subprocess.Popen completely broken?

2008-03-27 Thread Gary Herron
;> should work. >> > > Why should I need to set shell=True? I'm not globbing anything. The > second case still fails: > > >>>> proc = subprocess.Popen (["/usr/bin/ls" "/tmp"]) >>>> This line fails because of a

<    1   2   3   4   5   6   7   8   9   10   >