Re: string.lstrip stripping too much?

2005-05-16 Thread M.E.Farmer
q ('D:\\music\\D', 'Daniel Lanois') >>> q = os.path.split(q[0]) >>> q ('D:\\music', 'D') And another idea might be to do a split using os.sep: >>> import os >>> d = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona' >>> d.split(os.sep) ['D:', 'music', 'D', 'Daniel Lanois', 'For the beauty of Wynona'] Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
It looks like the docs could use some examples of the various assignments it refers to. I think something like Bengt posted would be a nice addition if it included assignments with slices and dicts too. Just a thought. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
Fredrik and Bengt: Thank you for the time. I will study the docs and play with the shell till this is firm. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
etting overloaded. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: incorrect(?) shlex behaviour

2005-05-15 Thread M.E.Farmer
s is not ordinarily a useful entry point, and is documented here only for the sake of completeness.) # Just like in my first post >>> from StringIO import StringIO >>> from shlex import shlex >>> t = shlex(StringIO("2>&1")) >>> t.get_token() '2' >>> t.get_token() '>' >>> t.get_token() '&' >>> t.get_token() '1' >>> t.get_token() '' # Your way >>> t = shlex(StringIO("2>&1")) >>> t.read_token() '2' >>> t.read_token() '&' >>> t.read_token() '1' >>> t.read_token() '' >>> Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: incorrect(?) shlex behaviour

2005-05-14 Thread M.E.Farmer
t; sh.get_token() etc... Python 2.2 and maybe lower: >>> import shlex >>> import StringIO >>> s = StringIO.StringIO('$(which sh)') >>> sh = shlex.shlex(s) >>> sh.get_token() '$' >>> sh.get_token() '(' >>> sh.get_token() 'which' >>> sh.get_token() 'sh' >>> sh.get_token() ')' >>> sh.get_token() etc... Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
I think they that should be avoided for clarity. Steve thanks for your time. I always learn a little from you ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
es sense >>> w = 1,2,3 >>> w.__doc__ """tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items If the argument is a tuple, the return value is the same object.""" Thanks for your time Bengt! M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
. The problem is why should this be the same: a,b,c=(1,2,3) (a,b,c)=(1,2,3) Seems weird, non-intuitive that a tuple unpacking and tuple creation have the same bytecode. So why is this done? What is the reason, I am sure there are a few ;) p.s. I am leaving out for a while and will read/followup later if needed. Thank you all for your time. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
27;__name__', 'a', 'b', 'c', 'd', 'f', 'shell'] >>> del a,b,c,d >>> # Where is the tuple (a,b,c,d)? There isn't one. >>> # assign to a single name ( don't do tuple unpacking ) >>> tup=f(1,2,3,4) >>> dir() ['__builtins__', '__doc__', '__name__', 'f', 'shell', 'tup'] Now there is. Steve since you are closer to expert than novice you understand the difference. I feel this can be confusing to newbies, maybe you disagree. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
ltins__', '__doc__', '__name__', 'a', 'b', 'c', 'd', 'f', 'shell'] >>> del a,b,c,d >>> # Where is the tuple (a,s,d,f)? There isn't one. >>> # assign to a single name ( don't do tuple

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
(x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv) This will only create a tuple in memory that has no name to reference it by! How would you access the returned value? If you want a tuple you need to assign all the return vales to a single name. mytup = abc(x,y,dotp,sumx,maxv) M.E.Farmer -- http

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
abc(x,y,0,0,0) > print 'Calling function abc' > print 'Array X:',abcinfo[0] > print 'Array Y:',abcinfo[1] > print 'Dot Product of X and Y:',abcinfo[2] > print 'Sum of array X:',abcinfo[3] > print 'Max value of array Y:',abcinfo[4] Or you could use a dictionary, or etc... The possibilities are endless. Be sure to study up on namespaces, it will ease your Python woes. Namespaces are the most fundamental part of Python that new users don't understand. Namespace mastery will take you far. Just remember there are only two scopes local and global ;) http://docs.python.org hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Mouseclick

2005-05-02 Thread M.E.Farmer
This could be fun! # random clicks # play with values to maximize annoyance if __name__ == "__main__": import random for i in range(1000): x = random.randint(0,800) y = random.randint(0,600) Click(x,y) time.sleep(random.randint(0,20)) -- http://mail.python.

Re: Can't get compression in Python zip script.

2005-05-02 Thread M.E.Farmer
't logical till you see the full issue. In plain english: I couldn't refuse the temptation to guess( and guessed wrong ). +1 on the bzip2 Thanks, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout question

2005-05-02 Thread M.E.Farmer
ring.','\n'] It would be hard to get to the next prompt after a print "dsfdfdssd", if the shell didn't add the \n to get it there. Also note most shells use repr or str behind the scenes for output to sys.stdout sys.stderr. >>> def g(): ... pass ... &g

Re: Can't get compression in Python zip script.

2005-05-02 Thread M.E.Farmer
Thank you! """ZIP_DEFLATED The numeric constant for the usual ZIP compression method. This requires the zlib module. No other compression methods are currently supported.""" That is where I got the 'only compression type'. It all makes sense

Re: Can't get compression in Python zip script.

2005-05-02 Thread M.E.Farmer
ot;C:\Python22\Lib\zipfile.py", line 169, in __init__ raise RuntimeError, "That compression method is not supported" RuntimeError: That compression method is not supported >>> a = zipfile.ZipFile('c:\tmp\z.zip', 'w', compression=8) I saw compression=0 and assumed that 1 would mean true, but no! zipfile.ZIP_DEFLATED = 8, defies logic, it is the only compression type why not accept any non zero as compression. Got any answers to the problems I outlined or have they been fixed yet ? M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't get compression in Python zip script.

2005-05-02 Thread M.E.Farmer
n overwrite the original. You can have mulitple files with the same name! Obviusly that can cause problems. This can be very confusing. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: MRO problems with diamond inheritance?

2005-05-02 Thread M.E.Farmer
No book just these lectures that cover everything you want ' I knew I was asking the right person ;) Now I just need to read your lectures...but first I am going to wrap my head in duct tape. ( prevents/contains explosions ) Thanks for your time, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: MRO problems with diamond inheritance?

2005-05-02 Thread M.E.Farmer
oved from the language; a part for that consideration, > the typical > use for classmethods is as object factories, to provide alternative > constructors. > >Michele Simionato Thank you, I had a feeling that it was just extra fluff. But I felt/feel that way about list comprehensions and decorators too ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Webbrowser On Windows

2005-05-01 Thread M.E.Farmer
amp;lr=') webbrowser('http://python.org') ##### M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Webbrowser On Windows

2005-05-01 Thread M.E.Farmer
Awesome! works perfectly on win2k -> I.E 6 Python makes COM almost readable ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: MRO problems with diamond inheritance?

2005-05-01 Thread M.E.Farmer
. Michele Simionato wrote: > > M.E.Farmer: > > >Your answer lies somewhere in this page ;) > >http://www.python.org/2.2.2/de­scrintro.html > > Yes, when it refers to > > http://www.python.org/2.3/mro.html > > (section Bad Method Resolution

Re: MRO problems with diamond inheritance?

2005-05-01 Thread M.E.Farmer
Your answer lies somewhere in this page ;) http://www.python.org/2.2.2/descrintro.html M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout question

2005-05-01 Thread M.E.Farmer
bsequent expressions are printed to this file object. If the first expression evaluates to None, then sys.stdout is used as the file for output. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple threads in a GUI app (wxPython), communication between worker thread and app?

2005-05-01 Thread M.E.Farmer
Look inthe demo that comes with wxPython it is in tree process and events -> threads . There is a nice demo of PostEvent(). Another way would be to use Queues as others have mention . You can create a new frame and have it call the queue for data. M.E.Farmer -- http://mail.python.org/mail

Re: Webbrowser On Windows

2005-05-01 Thread M.E.Farmer
t open a new window. Have not looked into it but you can probably do this easily with win32api . Search MSDN and then translate that into win32api for Python. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: compare two voices

2005-05-01 Thread M.E.Farmer
l signals. """ Be sure to check out the examples. Might be worth a look: http://www.speech.kth.se/projects/speech_projects.html http://www.speech.kth.se/cost250/ You might also have luck with Windows using Microsoft Speech SDK ( it is huge ). Combined with Python scrtiptng you can go far

Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread M.E.Farmer
er ! For what it is worth +1 ;) On another note why is maketrans in the string module I was a bit lost finding it the first time should it be builtin? transtable = "abcdefg".maketrans("qwertyu") Probably missing something. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: interactive web graphics

2005-04-30 Thread M.E.Farmer
eventually be revamped when the 'new' game engine is stable. Until then you might be able to use the old one but I have had many problems getting it to work reliably on Firefox or Mozilla, it works well with I.E. but Have fun and experiment. M.E.Farmer -- http://mail.python.o

Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-29 Thread M.E.Farmer
What's wrong with : s = s.replace('badchars', "") It seems obvious to replace a char ( to me anyway ) with a blank string, rather than to 'translate' it to None. I am sure you have a reason what am I missing ? M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to write CGI script with python...

2005-04-29 Thread M.E.Farmer
I found an excellent example that was posted by the F-bot. Fredrik Lundh May 26 2000 From: "Fredrik Lundh" <[EMAIL PROTECTED]> Date: 2000/05/26 richard_chamberl...@ wrote: > I'm having great difficulties getting Python to work via CGI. > Is there anyway I can get the traceback on to the web p

Re: Trying to write CGI script with python...

2005-04-29 Thread M.E.Farmer
Just in case you don't have a clue what they are talking about ;) import traceback try: #your stuff here except: traceback.print_exc() That should return any exceptions you may be throwing. -- http://mail.python.org/mailman/listinfo/python-list

Re: names of methods, exported functions

2005-04-27 Thread M.E.Farmer
Appears that most of the relevant code is in the Helper and TextDoc classes of pydoc also might need the doc() function. My head hurts every time I stare at the internals of pydoc ;) I guess it is time for a lunch break. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: names of methods, exported functions

2005-04-27 Thread M.E.Farmer
se? > > I think we don't need the mro, or any of the magic methods inherited > from the builtin. > -- > Michael Hoffman The help code is part of pydoc, IIRC, feel free to have a go at it ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: about Frame.__init__(self)

2005-04-27 Thread M.E.Farmer
def __init__(self): """Python calls me if I am defined""" base.__init__(self) You will see this in more than GUI code, it is part of Python's OO design. I first saw this in some threading code , thru me for a loop too ;) search strategy: Python OO Python i

Re: Pickle an image?

2005-04-25 Thread M.E.Farmer
t; im = Image.open(c) >>> im.show() Alternatively you can create a StringIO object and pickle that in your dictionary so you can just load it later with PIL. Pickling will bloat the size of your file so you might want to use some compression, although most formats will compress very little the pickling overhead can __mostly__ be avoided. There are boundless ways to do this and this just one of them. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: PDF Printing support from Python

2005-04-23 Thread M.E.Farmer
> You're use of the word "driver" is one with which I'm not > familiar. But I don't really "do windows" so it's probably a > Widnowism. It is a windowism but not exclusively ;). http://www.collaborium.org/onsite/romania/UTILS/Printing-HOWTO/winprinters.html This is the first link I found that men

Re: whitespace , comment stripper, and EOL converter

2005-04-22 Thread M.E.Farmer
## u'People do this sometime for a block comment type of thing' \ r"This type of string should be removed also" \ """ and this one too! """ # did I forget anything obvious ? # When the docstring is removed it should also consume the blank line that is left behind. Got to go to work, I'll think about it over the weekend. If anyone else wants to play you are welcome to join. Can pyparsing do this easily?( Paul probably has a 'six-line' solution tucked away somewhere ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Python instances

2005-04-20 Thread M.E.Farmer
e names are not shared. Also this next bit can bite you. Don't use list it is builtin name and can cause problems when you rebind it. Others to avoid are keywords and file, dict, tuple, object, etc... They can be tempting to use, resist, it will save you debug time later. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2005-04-19 Thread M.E.Farmer
uses Python for it's scripting. You can create a game and never touch a piece of code if you use the builtin actuators and sensors, or you can script with Python. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-17 Thread M.E.Farmer
in.isatty(): "direct" else: "redirected" This snippet can determine if you have redirected IO. I just found this and it looks informative. http://www.jpsdomain.org/windows/redirection.html hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding name of running script

2005-04-17 Thread M.E.Farmer
I have the feeling that I came a cross some very simple way to extract > the filename, but I can't find my mental note ;-) Maybe you found some black magic ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding name of running script

2005-04-17 Thread M.E.Farmer
ys import argv > > print argv[0].split(sep)[-1] > # or > print locals()['__file__'].split(sep)[-1] > # or > print globals()['__file__'].split(sep)[-1] M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
... Updates available at > The script is located at: > http://bellsouthpwp.net/m/e/mefjr75/python/stripper.py > > M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
Google has now 'fixed' there whitespace issue and now has an auto-quote issue argggh! The script is located at: http://bellsouthpwp.net/m/e/mefjr75/python/stripper.py M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
hanges. > ## > > # Python source stripper > > > ## > > > > import os > > import sys > > import token > >

Re: whitespace , comment stripper, and EOL converter

2005-04-16 Thread M.E.Farmer
## import os import sys import token import keyword import StringIO import tokenize import traceback __credits__ = ''' Jürgen Hermann M.E.Farmer Jean Brouwers ''' __version__ = '.8' __author__ = 'M.E.Farmer' __date__ = 'Apr 1

Re: whitespace , comment stripper, and EOL converter

2005-04-16 Thread M.E.Farmer
method so tokenize sends really sends the five part info to __call__ for every token. If this was obvious then ignore it ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-15 Thread M.E.Farmer
Sounds good should work fine ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Pyrex colorizer please review

2005-04-15 Thread M.E.Farmer
tokens missing that should be added, or extra tokens that should be removed please comment. If all is well I will post the updated PySourceColor module and PyrexColor script to my website for download. http://bellsouthpwp.net/m/e/mefjr75/python/PyrexTest_XHTML2.htm M.E.Farmer -- http

Re: Compute pi to base 12 using Python?

2005-04-14 Thread M.E.Farmer
t believe GNU "bc" is available for Windows, is it? > > Thanks, > > Dick Moores > [EMAIL PROTECTED] Nice collection of unix tools, Cygwin not needed. http://unxutils.sourceforge.net/ hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

whitespace , comment stripper, and EOL converter

2005-04-13 Thread M.E.Farmer
sends multiline strings and comments as a single token. ## # python comment and whitespace stripper :) ###### import keyword, os, sys, traceback i

Re: Docorator Disected

2005-04-02 Thread M.E.Farmer
to be a nested function, it really depends on what you are trying to achieve. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Search-and-delete text processing problem...

2005-04-01 Thread M.E.Farmer
'abc\n'] Notice that it does not modify the list in any way. You are trying to loop thru the list and modify the items in place, it just won't work. When you rebind the item name to a new value ' ' it does not rebind the element in the list just the current item. It is also

Re: Search-and-delete text processing problem...

2005-04-01 Thread M.E.Farmer
Lines = theInFile.readlines() theInFile.close() outLines = [] for line in allLines: if not line.startswith('Bill'): outLines.append(line) theOutFile.writelines(outLines) theOutFile.close() # hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Controling the ALU

2005-03-31 Thread M.E.Farmer
h more content and detail. Py> you = 'Cesar Andres Roldan Garcia' Py> answer = PyAnswers(you) Py> print answer For further help please repost answer or the error message ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help: Server to pass py objects

2005-03-29 Thread M.E.Farmer
jects hth, M.E.Farmer Sells, Fred wrote: > I have a legacy system with data stored in binary files on a remote server. > I need to access and modify the content of those files from a webserver > running on a different host. (All Linux) > > I would like to install a server on the l

Re: left padding zeroes on a string...

2005-03-25 Thread M.E.Farmer
', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] Py> help(''.zfill) Help on built-in function zfill: zfill(...) S.zfill(width) -> string Pad a numeric string S with zeros on the left, to fill a field of the specified width. The string S is never truncated. Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Please help for Python programming

2005-03-22 Thread M.E.Farmer
ult, so no need to click it. Proportional still retains spaces but is less tidy. M.E.Farmer >> Terry, >> This was posted from google groups, can you see the indents? >Yes, looks good >> # code snippet >>convertpage = 0 >>form = None >>f

Re: Please help for Python programming

2005-03-22 Thread M.E.Farmer
ot;--out"]: output = a if o in ["-i", "--input", "--in"]: input = a if input in [".", "cwd"]: input = os.getcwd() Notice the 'fixed font / proportional font' link in the top r

Re: sorting a dictionary?

2005-03-21 Thread M.E.Farmer
This comes up so often on this list that there are many examples and recipes. You are looking for a dictionary sort by value. search strategy: Python sorting dictionary 44,000+ hits on google. First entry: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52306 hth, M.E.Farmer -- http

Re: Simple account program

2005-03-18 Thread M.E.Farmer
re appropriate for you right now till you are up and running. http://www.python.org/mailman/listinfo/tutor -Just keep reading and writing Python , you will 'get it'. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple account program

2005-03-17 Thread M.E.Farmer
l","w"]: self.withdraw(amount) else: self.deposit(amount) hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: How to allow events during long processing routine?

2005-03-09 Thread M.E.Farmer
Survey says. ...wxYield() ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: An Odd Little Script

2005-03-09 Thread M.E.Farmer
#x27;) eos = f.seek(107).read(1) r = f.read() f.close() r = r.replace('\r', '') r = r.replace('\n', '') r = r.replace(eos, '\n') f = open('yourrecord', 'w') f.write(r) f.close() hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: function namespaces

2005-03-08 Thread M.E.Farmer
the question : #contents of myfile.py: testvar = [1,2,3,4] # someother.py # the problem is you are executing a script # then searching in the wrong namespace. def myfunction(filename): execfile(filename, globals()) print testvar hth, M.E.Farmer -- http://mail.python.org/mailman/listi

Re: File call error message (double backslash)

2005-03-08 Thread M.E.Farmer
that works ;) "c:/windows/dir" Windows uses '\' as a path sep but it also understands '/'. *nix uses '/' as a path sep. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie getting confused again

2005-03-05 Thread M.E.Farmer
__mul__', '__ne__', '__new__', '__reduce__', '__repr__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] Then you can try and get some help from Python. Py>help(a.extend) Help on built-in function extend: extend(...) L.extend(iterable) -- extend list by appending elements from the iterable And finally use pydoc it is very helpful. Cl> python pydoc -g hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Identify and perform actions to data within stated limits

2005-03-01 Thread M.E.Farmer
Your welcome for the help , be sure to pass it on ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Identify and perform actions to data within stated limits

2005-03-01 Thread M.E.Farmer
eter and try playing with them and see what they do. If you weant to know what an object or methods docs say, use help(). Py> help(q.count) Help on built-in function count: count(...) L.count(value) -> integer -- return number of occurrences of value If you want to know the number of items in a list ( or most builtins ) use len(). Py> len(q) 8 Spend time reading the docs. It will save you months of work. Also learn the library it has many modules that will simplify your code and save your mind. http://www.python.org/doc/ hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to pass a parameter by reference?

2005-02-26 Thread M.E.Farmer
le): ...print 'you have %s apples' % apple py>f1(4) 'you have 5 apples' Read the docs this is pretty basic, it will save you time. If in doubt try it out. Use the interpreter, it is your friend. hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: remove strings from source

2005-02-26 Thread M.E.Farmer
02': "''' Store the source text & set some flags.\n'''", 's03': "'unix'"} You can also strip out comments with a few line. It can easily get single comments or doubles. add this in your __call__ function

Re: Thread scheduling

2005-02-26 Thread M.E.Farmer
This may help. http://linuxgazette.net/107/pai.html Also be sure to google. search strategy: Python threading Python threads Python thread tutorial threading.py example Python threading example Python thread safety hth, M.E.Farmer -- http://mail.python.org/mailman

Re: remove strings from source

2005-02-26 Thread M.E.Farmer
ewpos + len(toktext) if toktype in [token.NEWLINE, tokenize.NL]: self.out.write('\n') return if newpos > oldpos: self.out.write(self.raw[oldpos:newpos]) if toktype in [token.INDENT, token.DEDENT]: self.pos = newpos return if (toktype == token.STRING): sname = self.StringName.next() self.StringMap[sname] = toktext toktext = sname self.out.write(toktext) self.out.flush() return hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question - exception processing

2005-02-20 Thread M.E.Farmer
_init__(self, msg) def __repr__(self): return self._msg __str__ = __repr__ class PathError(PSCError): def __init__(self, msg): PSCError.__init__(self, 'Path error! : %s'% msg) class InputError(PSCError): def __init__(self, msg): PSCError.__init__(self, 'Input error! : %s'% msg) # and you use it like this raise PathError, 'Please check path' raise InputError, 'Improper input try again' hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Text files read multiple files into single file, and then recreate the multiple files

2005-02-13 Thread M.E.Farmer
x27;myrecords.txt') Py> first_record = records.next() Py> second_record = records.next() Py> # or you can do this Py> for record in records: Py> print record Getting them in a single file is easy, and will be an excercise left to the reader. The fileinput module is your f

Re: listerator clonage

2005-02-12 Thread M.E.Farmer
line 95, in copy > return _reconstruct(x, rv, 0) > File "C:\Python24\lib\copy.py", line 320, in _reconstruct > y = callable(*args) > File "C:\Python24\lib\copy_reg.py", line 92, in __newobj__ > return cls.__new__(cls, *args) > TypeError: objec

Re: Memory Allocation?

2005-02-07 Thread M.E.Farmer
details. If I am wrong someone correct me ;) If you search around you can find many pointers to memory effecient coding style in Python( never add a string together, use a list and append then join, etc.) Stick to profiling it will serve you better. But do not let me stop you from writing a memory

Re: def __init__ question in a class definition

2005-02-07 Thread M.E.Farmer
Steve Holden wrote: > M.E.Farmer wrote: > > >>Jeffrey Borkent > >>Systems Specialist > >>Information Technology Services > > > > > > With that kind of credentials, and the fact that you claim you are a > > system specialists > >

Re: Memory Allocation?

2005-02-06 Thread M.E.Farmer
to take out the garbage or look at it? Python does it for you so you don't have too. But don't let me stop you. You can probably still find some way to do it. It is open source after all. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI POST problem was: How to read POSTed data

2005-02-06 Thread M.E.Farmer
Sweet! Glad you fixed it, and documented it all! Thanks for the followups. Now the next poor soul to stumble in can get the right fix. Never know when it could be me ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame.mixer.music not playing

2005-02-06 Thread M.E.Farmer
py hacking, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: def __init__ question in a class definition

2005-02-06 Thread M.E.Farmer
7;t ask a 2nd grade question yet claim/pretend to be some sorta system specialists. You tried searching the archives first I am sure. Go here http://www.python.org and *read*, come back when you are really stuck. M.E.Farmer P.S. YES the __ matter, they identify special methods ! __init__ is the class CON

Re: pygame.mixer.music not playing

2005-02-06 Thread M.E.Farmer
Just curious what is not suitable about FMOD ? It seems to be exactly what you are looking for. Cross platform, free, great sound, python bindings, no compiler needed. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame.mixer.music not playing

2005-02-06 Thread M.E.Farmer
http://sourceforge.net/projects/uncassist the people who wrote pyFMOD (lots of stuff there) http://www.cs.unc.edu/~parente/tech/tr01.shtml Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie wants to compile python list of filenames in selected directories

2005-02-06 Thread M.E.Farmer
return pathlist . . def list_dir(dir): . ''' Another way to filter a dir ''' . import os . pathlist = os.listdir(dir) . # Now filter out all but py and pyw . filterlist = [x for x in pathlist .if x.endswith('.py') .or x.endswith('.pyw')] .return filterlist hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame.mixer.music not playing

2005-02-06 Thread M.E.Farmer
game Py> pygame.mixer.init() Py> pygame.mixer.music.load('c:/everyday.mp3') Py> pygame.mixer.play() Py> pygame.mixer.music.fadeout(4000) You have a typo in the code you posted that may be your problem. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI POST problem was: How to read POSTed data

2005-02-05 Thread M.E.Farmer
u have had a bit of a snag , sorry to hear that. I am glad you are at least learning new things, 'cause if you had used CherryPy2 you would have be done by now :P M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: who can tell me BASICS of Python

2005-02-04 Thread M.E.Farmer
I guess it depends :) Let us know what works for you. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: PythonWin and PyWin32

2005-02-04 Thread M.E.Farmer
th Python. hth , M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-04 Thread M.E.Farmer
that do exactly one thing each and use them as your interface. Py> def fun_helper(d): ... d['z'] = func(d['x']+d['y']+d['whatever']['as']+d[a][0]) ... return d and use them as needed. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: WYSIWYG wxPython "IDE"....?

2005-02-04 Thread M.E.Farmer
Yes you can use absolute positioning. You do not need sizers ( but they are very nice ) Most all the widgets have a pos keyword in there constructor. Just use them. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-04 Thread M.E.Farmer
them in the dictionary they come in and acess the members as needed. I really don't see your need. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-04 Thread M.E.Farmer
Hello Bo, Don't use dict it is a builtin ;) Also try this stuff out in an interpreter session it is easy and fast to get your own answers. >>> def fun(d): ... __dict__ = d ... return __dict__ hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: why are LAMP sites slow?

2005-02-04 Thread M.E.Farmer
ioned it. Overall I agree with your statement you *should* not nest div inside of span, BUT... Div *can* be nested inside a span. I just tried it in Firefox , I.E. , and Opera to be sure and it does work ;) Probably not w3c compliant though. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
ound-color:#11;} hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
ound-color:#11;} hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
ound-color:#11;} hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >