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

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

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/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 clearer. Thanks for the opinions everyone! Derek Basch

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

2006-03-15 Thread Derek Basch
? 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
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-13 Thread Derek Basch
! 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 --

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

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 scale

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: 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! /dTb -- 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 to do

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

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

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

Re: List comprehension and FieldStorage

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

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

List comprehension and FieldStorage

2005-04-26 Thread Derek Basch
? 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

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

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=enlr=c2coff=1q=xml+comment+pythonqt_s=Search+Groups --

Minidom output of XML escaped characters

2005-03-24 Thread Derek Basch
: !--#include virtual=/top.html -- Any suggestions? Thanks, 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, I think there is a simple solution: add an empty Text node

Minidom empty script element bug

2005-03-15 Thread Derek Basch
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 resources site

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 empty title or paragraph) do not use the minimized form

Re: CGI and HTTP Header Location redirects

2005-02-04 Thread Derek Basch
for 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 but I can't find any reference to such problems

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

2005-01-20 Thread Derek Basch
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 tell me why? Thank You Mighty Python Guru's, Derek Basch __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage

CGI, anydbm.open() and linux file permissions

2005-01-11 Thread Derek Basch
of changing everything to root. Thanks everyone, Derek Basch __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list