Re: Remove integer from float number

2006-03-23 Thread Derek Basch
Ahh yes you have to put parenthases around the string formatting to remove the integer using indexes. Thanks, that's just what I needed! Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Remove integer from float number

2006-03-23 Thread Derek Basch
How can I return: ".666" from float: "0.666" This is what I have so far: >>> "%.6f" % x Thanks Everyone, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch
Carl Banks wrote: > But even the clear version isn't as nearly clear and straightforward as > the nested fors with the counter. I wouldn't forsake that clarity just > so it isn't "kludgy". > > > Carl Banks Yeah, looks like using the counters is cleare

Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch
> Depending on the types of the containers in question, you could use: > > len(zoo) * len(animal) I think this would give me the total iterations but I wouldn't be able to get a running count. Correct? Thanks for the reply, Derek Basch -- http://mail.python.org/mailman/l

Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch
Fredrik Lundh wrote: > what's kludgy with using a counter to count things ? Ohhh, nothing in particular. Just seeing if there is a better way to do it. > (the real question here is of course why you need the counter. what's > the loop doing? if the code you posted is all you have, you can rep

Counting nested loop iterations

2006-03-16 Thread Derek Basch
What is the best way to count nested loop iterations? I can only figure to use an index but that seems kludgy. index = 0 for animal in zoo: for color in animal: index += 1 Thanks, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it better to use class variables or pass parameters?

2006-03-15 Thread Derek Basch
s variables is bad because they are not related to the state of the "PeptideEvaluator". How can I avoid having to pass the same parameters all over a class? I can';t quite seem to wrap my head around this one. Thanks again everyone, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it better to use class variables or pass parameters?

2006-03-15 Thread Derek Basch
assed parameter value. Am I on the right track? Thanks, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it better to use class variables or pass parameters?

2006-03-13 Thread Derek Basch
Again! Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib logarithmic scatter plot

2006-03-01 Thread Derek Basch
Good tip John. Hopefully it will help someone out. Thanks again. Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Is it better to use class variables or pass parameters?

2006-03-01 Thread Derek Basch
This one has always bugged me. Is it better to just slap a "self" in front of any variable that will be used by more than one class method or should I pass around variable between the methods? FlamewarNOW! jk, I really do want other opinions. Thanks, Derek -- http://mail.python.org/mai

Re: Rounding up to the nearest exact logarithmic decade

2006-02-28 Thread Derek Basch
Thanks effbot. I knew their had to be something buried in the math module that could help. ceil() it is! -- http://mail.python.org/mailman/listinfo/python-list

Rounding up to the nearest exact logarithmic decade

2006-02-28 Thread Derek Basch
Given a value (x) that is within the range (1e-1, 1e7) how do I round (x) up to the closest exact logarithmic decade? For instance: 10**3 = 1000 x = 4978 10**4 = 1 x = 1 Thanks Everyone! Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib logarithmic scatter plot

2006-02-28 Thread Derek Basch
Thanks again. Here is the finished product. Maybe it will help someone in the future: from pylab import * def log_10_product(x, pos): """The two args are the value and tick position. Label ticks with the product of the exponentiation""" return '%1i' % (x) ax = subplot(111) # Axis sca

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Derek Basch
Great! That worked fine after I played with it for a bit. One last question though. How do I label the ticks with the product of the exponentiation? For instance: 100 instead of 10**2 Thanks for all the help, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Derek Basch
Thanks for the reply. I need a scatter plot though. Can that be done? -- http://mail.python.org/mailman/listinfo/python-list

Matplotlib logarithmic scatter plot

2006-02-27 Thread Derek Basch
Can anyone give any suggestions on how to make a logarithmic (base 10) x and y axis (loglog) plot in matplotlib? The scatter function doesn't seem to have any log functionality built into it. Thanks, Derek Basch P.S. I suck at math so feel free to make me feel stupid if it is really easy

Multiple Inheritence and data attributes

2005-05-06 Thread Derek Basch
Hello Everyone, Given: class A: def __init__(self): super(A, self).__init__() self.dog = "fluffy" def changeDog(self): self.dog = "spike" class B: def __init__(self): super(B, self).__init__() class C(object, A, B): def __init__(self): sup

Re: List comprehension and FieldStorage

2005-04-27 Thread Derek Basch
Sorry Peter. I will refrain from nudging in the future. I did spend time at the interactive prompt and got nothing. Maybe I will have better luck next time. -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension and FieldStorage

2005-04-27 Thread Derek Basch
bump -- http://mail.python.org/mailman/listinfo/python-list

List comprehension and FieldStorage

2005-04-26 Thread Derek Basch
f either type from a FieldStorage object? Here is my attempt at creating the double tuple list (It sucksI know): print [(key, value) for key, value in form.keys() and form[key].value] Thanks for the help, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting iterations

2005-04-10 Thread Derek Basch
. You guys always rip my code apart and correct my style. Even if it is just a stupid one off example. Thanks everyone, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting iterations

2005-04-08 Thread Derek Basch
ooops you are right. Should have been: pets = ["cat", "dog", "bird"] num_pets = 0 for i in pets: num_pets += 1 print "pet" + "#" + num_pets That's the problem with one offs. I don't read them :). -- http://mail.python.org/mailman/listinfo/python-list

Counting iterations

2005-04-08 Thread Derek Basch
Is there a better way to count iterations that this?: pets = 0 for i in pets: pets += 1 print "pet" + "#" + pets Thanks, Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Minidom output of XML escaped characters

2005-03-25 Thread Derek Basch
Thanks effbot. I haven't had much use for XML comments so far and I guess other people haven't either because it seems they are hardly ever mentioned. http://groups-beta.google.com/groups?hl=en&lr=&c2coff=1&q=xml+comment+python&qt_s=Search+Groups -- http://mail.python.org/mailman/listinfo/python

Minidom output of XML escaped characters

2005-03-24 Thread Derek Basch
Hello, If I want minidom to output XHTML that includes normally XML escaped characters how would I do it? For instance if I use doc.createCDATASection() I get: and without the CDATASection: <!--#include virtual="/top.html" --> when I really need: Any suggestions? Tha

string join() method

2005-03-23 Thread Derek Basch
enceScore A01 1: 1-8 8 1410538.0 A01 1: 2-9 8 1410538.0 - Thanks everyone. Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Minidom empty script element bug

2005-03-16 Thread Derek Basch
Cross post from XML-SIG: --- Walter Dörwald <[EMAIL PROTECTED]> wrote: > Martin v. Löwis sagte: > > Derek Basch wrote: > > >[...] > >> How do I get minidom to NOT render an empty script element? Should I > submit a bug report? > > > > That said,

Re: Minidom empty script element bug

2005-03-15 Thread Derek Basch
Martin v. Löwis wrote: > Derek Basch wrote: > > XHTML 1.0 specs, Appendix C > > [EMAIL PROTECTED] > > C.3 Element Minimization and Empty Element Content > > > > Given an empty instance of an element whose content model is not EMPTY (for > > example, an e

Minidom empty script element bug

2005-03-15 Thread Derek Basch
ndles the element incorrectly and instantiates the javascript. How do I get minidom to NOT render an empty script element? Should I submit a bug report? Thanks for the help, Derek Basch __ Do you Yahoo!? Yahoo! Small Business - Try our new resour

Re: CGI and HTTP Header Location redirects

2005-02-04 Thread Derek Basch
r the help. Paul Rubin wrote: > Derek Basch <[EMAIL PROTECTED]> writes: > >>Also, after enabling suEXEC on the apache server the script executes >>perfectly with the redirect. Can anyone explain this behavior? I >>would guess that it is related to apache user rights

CGI and HTTP Header Location redirects

2005-02-03 Thread Derek Basch
r? I would guess that it is related to apache user rights but I can't find any reference to such problems via Google. Thanks everyone!, Derek Basch - #! /usr/bin/python import sys import cgitb class Trainer: def

spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection

2005-01-20 Thread Derek Basch
immediatly. Perhaps I am calling the sleep.py script incorrectly? Shouldn't it take 10sec to execute since the spawn mode argument is os.P_WAIT? *Third question* If I uncomment the second spawn call in test.py I do not get any output to /tmp/test.out and it also returns immediatly. Can anyone

CGI, anydbm.open() and linux file permissions

2005-01-11 Thread Derek Basch
on the target DBM creation directory (/var/www/bp/predictor/) are: drwxr-xr-x 2 bpeters bpeters 4096 Jan 11 14:45 predictor Can anyone tell me what I need to do to allow the CGI script to create the DBM in the target directory? That is short of changing