Re: Converting a float to a formatted outside of print command

2009-11-30 Thread stephen_b
On Nov 23, 3:17 pm, Dan Bishop  wrote:
> You meant:
>
> x = '%.1f' % y

Thanks, I'm a dufus today.
-- 
http://mail.python.org/mailman/listinfo/python-list


Converting a float to a formatted outside of print command

2009-11-23 Thread stephen_b
I'd like to convert a list of floats to formatted strings. The
following example raises a TypeError:

y = 0.5
x = '.1f' % y
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with OS X installation

2009-11-09 Thread stephen_b
Thanks all. That did it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Help with OS X installation

2009-11-08 Thread stephen_b
I have  python 2.6 on OS X 10.5.8:

$ python --version
Python 2.6.2

$ which python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python

When installing an egg, python 2.5 shows up:

"""
$ sudo easy_install ipython-0.10-py2.6.egg
Password:
Processing ipython-0.10-py2.6.egg
removing '/Library/Python/2.5/site-packages/ipython-0.10-
py2.6.egg' (and everything under it)
creating /Library/Python/2.5/site-packages/ipython-0.10-py2.6.egg
Extracting ipython-0.10-py2.6.egg to /Library/Python/2.5/site-packages
"""

But 2.6 is not here:

$ ls /Library/Python
2.3/ 2.5/

Launching ipython happens with Python 2.5.1 though. Is there something
I did incorrectly when installing python 2.6?

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
On Jun 9, 10:43 am, Carl Banks  wrote:
> You need a % in there, chief.
>
> Carl Banks
You are so right. Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
I'd like to convert a list of floats to a list of strings constrained
to one .1f format. These don't work. Is there a better way?

[".1f" % i for i in l]
or
[(".1f" % i) for i in l]

StephenB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Default location of python on OS X

2008-01-08 Thread Stephen_B
On Jan 8, 11:33 pm, Tommy Nordgren <[EMAIL PROTECTED]> wrote:
> > I still have a "/Library/Python/2.3" and a "/Library/Python/2.5".
>
> > Thanks.
>
> > Stephen
> Leopard INCLUDES Python 2.5, there is no need to install it.

Thanks -- that made the decision easy. I didn't need all those
MacPythons.

Stephen

-- 
http://mail.python.org/mailman/listinfo/python-list


Default location of python on OS X

2008-01-08 Thread Stephen_B
I've installed the latest 2.5 python today from python.org, and I
think it ended up in "/Applications/MacPython 2.5".

I also have a "/Applications/MacPython 2.4" and a "/Applications/
MacPython-2.4". Can I delete these, or did one of them come with
Leopard?

I still have a "/Library/Python/2.3" and a "/Library/Python/2.5".

Thanks.

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Clearing a DOS terminal in a script

2007-12-13 Thread Stephen_B
On Dec 13, 11:21 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> It opens "clear" with it's own virtual terminal and clears that
> instead.

Even when I launch the script from a cmd shell with "python
myscript.py"?

> There's an ANSI control code you can use to reset the screen, try printing 
> that.

I googled "[2J" as an ascii sequence that it is supposed to clear
the screen. How do I send that?

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Clearing a DOS terminal in a script

2007-12-13 Thread Stephen_B
This doesn't seem to work in a dos terminal at the start of a script:

from os import popen
print popen('clear').read()

Any idea why not? Thanks.

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


pyshell and unum hint

2007-05-15 Thread Stephen_B
I like to have unum units imported automatically on my PYTHONSTARTUP
since I'm always converting things, and I also like to use pyshell.

They conflict for some reason I don't understand (pyshell doesn't like
the Unum.as method, maybe since it will be a keyword):

1.0*IN.as(M)
  File "", line 1
1.0*IN.as(M)
^
SyntaxError: invalid syntax

Instead I put this in my PYTHONSTARTUP:

from unum.tools.calc import *
Unum.to = Unum.as

Which gives:

1.0*IN.to(M)
0.0253999368687 [m]

Stephen

-- 
http://mail.python.org/mailman/listinfo/python-list


Help with 'popen'

2007-01-21 Thread stephen_b
Can someone let me know why this won't work? Thanks.

>>> from os import popen
>>> popen('export asdfasdf=hello').read()
''
>>> popen('echo $asdfasdf').read()
'\n'

Thanks.

Stephen

-- 
http://mail.python.org/mailman/listinfo/python-list