Thank you so much for the help.
I'm self-studying and watching tutorials on youTube. The problem was given
as an exercise after the tutorial.
I did modify my code based on the suggestions here and it helps.
Thank you!
On Tue, Aug 25, 2020 at 4:31 PM Schachner, Joseph <
joseph.schach...@teledyne.
On 8/24/2020 4:41 PM, Calvin Spealman wrote:
"None" is the default return value of all functions in Python. But, the
interpreter is supposed to suppress it as a displayed result.
In batch mode, expressions are not echoed. In interactive move,
expression values other than None are echoed. Th
The very first line of your function km_mi(): ends it:
def km_mi():
return answer
answer has not been assigned, so it returns None.
Advice: remove that "return" line from there. Also get rid of the last line,
answer = km_mi which makes answer refer to the function km_mi().
Put the "return a
On 25/08/2020 01:12, Py Noob wrote:
Hi!
i'm new to python and would like some help with something i was working on
from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
my code and the terminal is showing the word "None" everytime I execute my
code.
Many thanks!
print("Co
Thank you for the clarification.
What I'm trying to achieve here are:
User be able to choose miles or kilometers to convert.
When selected (mi/km), prints out the user input and the answer.
km to mi = km/1.609
mi to km = mi*1.609
Thank you again!
On Mon, Aug 24, 2020 at 1:41 PM Calvin Spealman
On 2020-08-24 at 06:12:11 -0700,
Py Noob wrote:
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.
> if sel
On Mon, Aug 24, 2020, at 09:12, Py Noob wrote:
> Hi!
>
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.
Th
How are you actually running your code?
"None" is the default return value of all functions in Python. But, the
interpreter is supposed to suppress it as a displayed result.
As a side note, both your km_mi() function and the line "answer = km_mi"
are certainly wrong, but it is not clear what you
On Monday, March 21, 2016 at 5:54:31 AM UTC+5:30, Mark Lawrence wrote:
> On 20/03/2016 23:37, :
> > I can't find a formatting way to get columns of data.
> >
>
> Take your pick from:-
>
> https://docs.python.org/3/library/stdtypes.html#string-methods
>
> https://docs.python.org/3/library/stdtype
On Monday, March 21, 2016 at 7:37:39 AM UTC+8, vernl...@gmail.com wrote:
> I can't find a formatting way to get columns of data.
I don't think this express is a question, or asking for help.
--
https://mail.python.org/mailman/listinfo/python-list
On 20/03/2016 23:37, vernleff...@gmail.com wrote:
I can't find a formatting way to get columns of data.
Take your pick from:-
https://docs.python.org/3/library/stdtypes.html#string-methods
https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting
https://docs.python.org
On Sun, Mar 20, 2016 at 7:37 PM, wrote:
> I can't find a formatting way to get columns of data.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
Welcome Vern. We're gonna need more than that -- os, python version, your
code, traceback if you get one, what results you get, what you
On Thursday, February 27, 2014 7:49:07 PM UTC-8, Alec Taylor wrote:
> Are there libraries for doing this?
>
> I would like to autogenerate JSON-schema for use inside an API explorer.
>
> However whenever there is a schema change; I would only like to change
> the schema in one place (where possib
On Fri, 28 Feb 2014 14:49:07 +1100, Alec Taylor wrote:
> Are there libraries for doing this?
>
> I would like to autogenerate JSON-schema for use inside an API explorer.
>
> However whenever there is a schema change; I would only like to change
> the schema in one place (where possible).
>
> E.
On 6/2/2013 3:09 PM, Mok-Kong Shen wrote:
Am 28.05.2013 17:35, schrieb Grant Edwards:
On 2013-05-26, Mok-Kong Shen wrote:
I don't understand why with the code:
for k in range(8,12,1):
print(k.to_bytes(2,byteorder='big'))
one gets the following output:
b'\x00\x08'
b'\x0
Am 28.05.2013 17:35, schrieb Grant Edwards:
On 2013-05-26, Mok-Kong Shen wrote:
I don't understand why with the code:
for k in range(8,12,1):
print(k.to_bytes(2,byteorder='big'))
one gets the following output:
b'\x00\x08'
b'\x00\t'
b'\x00\n'
b'\x00\x0b'
I mea
On May 29, 5:11 pm, Fábio Santos wrote:
> On 29 May 2013 12:25, "Avnesh Shakya" wrote:
>
>
>
>
>
>
>
>
>
> > hi,
> > I am trying to display my output with different colour on terminal,
> but it's
> > coming with that colour code.
> > Please help me how is it possible?
>
> > my code is -
> > fr
On 29 May 2013 12:25, "Avnesh Shakya" wrote:
>
> hi,
>I am trying to display my output with different colour on terminal,
but it's
> coming with that colour code.
> Please help me how is it possible?
>
> my code is -
> from fabric.colors import green, red, blue
> def colorr():
> a = red('T
On 2013-05-26, Mok-Kong Shen wrote:
> I don't understand why with the code:
>
> for k in range(8,12,1):
> print(k.to_bytes(2,byteorder='big'))
>
> one gets the following output:
>
> b'\x00\x08'
> b'\x00\t'
> b'\x00\n'
> b'\x00\x0b'
>
> I mean the 2nd and 3rd should be b'\
On 5/26/2013 8:02 AM, Mok-Kong Shen wrote:
for k in range(8,12,1):
print(k.to_bytes(2,byteorder='big'))
http://bugs.python.org/issue9951
http://bugs.python.org/issue3532
import binascii as ba
for k in range(8,12,1):
print(ba.hexlify(k.to_bytes(2,byteorder='big')))
>>>
b'0008'
b'0
On Sun, May 26, 2013 at 10:02 PM, Mok-Kong Shen
wrote:
> I don't understand why with the code:
>
>for k in range(8,12,1):
> print(k.to_bytes(2,byteorder='big'))
>
> one gets the following output:
>
>b'\x00\x08'
>b'\x00\t'
>b'\x00\n'
>b'\x00\x0b'
>
> I mean the 2nd and 3rd
On Mon, Apr 5, 2010 at 1:33 PM, hiral wrote:
> Hi,
> I am trying following script...
>
>
On Sep 8, 12:35 pm, MRAB wrote:
> Maggie wrote:
> > On Sep 8, 11:39 am, MRAB wrote:
> >> Maggie wrote:
> >>> My code is supposed to enumerate each line of file (1, 2, 3...) and
> >>> write the new version into the output file --
> >>> #!/usr/bin/python
> >>> import os.path
> >>> import csv
> >>>
Maggie wrote:
On Sep 8, 11:39 am, MRAB wrote:
Maggie wrote:
My code is supposed to enumerate each line of file (1, 2, 3...) and
write the new version into the output file --
#!/usr/bin/python
import os.path
import csv
import sys
#name of output file
filename = "OUTPUT.txt"
#open the file
test
On Tuesday 08 September 2009 17:22:30 Maggie wrote:
> My code is supposed to enumerate each line of file (1, 2, 3...) and
> write the new version into the output file --
>
> #!/usr/bin/python
>
> import os.path
> import csv
> import sys
>
> #name of output file
> filename = "OUTPUT.txt"
>
>
> #open
On Sep 8, 11:39 am, MRAB wrote:
> Maggie wrote:
> > My code is supposed to enumerate each line of file (1, 2, 3...) and
> > write the new version into the output file --
>
> > #!/usr/bin/python
>
> > import os.path
> > import csv
> > import sys
>
> > #name of output file
> > filename = "OUTPUT.txt
Maggie wrote:
My code is supposed to enumerate each line of file (1, 2, 3...) and
write the new version into the output file --
#!/usr/bin/python
import os.path
import csv
import sys
#name of output file
filename = "OUTPUT.txt"
#open the file
test = open ("test.txt", "r")
#read in all the d
On Jan 16, 8:24 am, "Jean-Paul VALENTIN" wrote:
> Feature? the output of below Hello program he0.py started from command
> line looks as follows:
> F:\prompt>he0.py
> Hello
> F:\prompt>
>
> 'Hello' was sent with sys.stdout.write, so "without newline".
> But why cannot be output (more logically):
>
IIRC, Windows automatically add a newline after the program output.
On Fri, Jan 16, 2009 at 4:24 PM, Jean-Paul VALENTIN
wrote:
> Feature? the output of below Hello program he0.py started from command
> line looks as follows:
> F:\prompt>he0.py
> Hello
> F:\prompt>
>
> 'Hello' was sent with sys.st
uair01 wrote:
I will try the python program outside of IDLE.
Yes, running the program from the Linux shell instead of from IDLE
produces all output correctly.
Now I'll have to look for a new simple development environment :-(
I think I'll try SPE that has worked well for me ...
Or you could t
> I will try the python program outside of IDLE.
Yes, running the program from the Linux shell instead of from IDLE
produces all output correctly.
Now I'll have to look for a new simple development environment :-(
I think I'll try SPE that has worked well for me ...
--
http://mail.python.org/mail
On Tue, 30 Sep 2008 20:48:12 -0700, Anh Khuong wrote:
> I am using pexpect and I want to send output of pexpet to both stdout
> and log file concurrently. Anybody know a solution for it please let me
> know.
One way is to create a file-like object that forked the output to stdout
and the logfil
On Sep 30, 8:48 pm, Anh Khuong <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am using pexpect and I want to send output of pexpet to both stdout and log
> file concurrently.
> Anybody know a solution for it please let me know.
spawn class takes a 'logfile' parameter:
__init__(self, command, args=[],
Cesar D. Rodas wrote:
> I am newbie in Python, but I like it very much.
>
> Right now I am having a problem, I am working with mod_python in apache.
> What I needing is a stdout buffering, that means that everything that I
> send to stdout keep it in a variable, then flush it and clear.
plug i
On Aug 13, 6:17 pm, Alex <[EMAIL PROTECTED]> wrote:
> Hello, I am rather new to python. Maybe my thinking is in the
> paradigm of C++, that makes me hard to make sense of some python
> scripts (interacting with C# code) written by my colleague. I am
> thinking of outputting all objects and their
Stefan Behnel wrote:
[---]
> lxml.etree already implements that, BTW.
>
> http://codespeak.net/lxml
Ok, thanks. I'll take a look at it.
[---]
> Some people propose just that if you really *want* a declaration. No need to
> have it, though, as ET will create well-formed XML anyway.
Yeah, I
Jan Danielsson wrote:
>I'm using ElementTree to create an XHTML page (mod_python, blah,
> blah, blah). When I use ElementTree.tostring(root) to create a buffer
> which I want to return to the client, it doesn't include the XML prolog
As Martin told you, this is spec-compliant behaviour. Still,
>I'm using ElementTree to create an XHTML page (mod_python, blah,
> blah, blah). When I use ElementTree.tostring(root) to create a buffer
> which I want to return to the client, it doesn't include the XML prolog
> (obvisouly, since tostring is merely traversing the tree from the node I
> supply
Jackie schrieb:
> On 6 15 , 2 01 , Stefan Behnel <[EMAIL PROTECTED]> wrote:
>> Jackie wrote:
>
>> import lxml.etree as et
>> url = "http://www.economics.utoronto.ca/index.php/index/person/faculty/";
>> tree = et.parse(url)
>>
>
>> Stefan- -
>>
>> - -
>
> Thank you. But when I t
On 6 15 , 2 01 , Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Jackie wrote:
> import lxml.etree as et
> url = "http://www.economics.utoronto.ca/index.php/index/person/faculty/";
> tree = et.parse(url)
>
> Stefan- -
>
> - -
Thank you. But when I tried to run the above part, the fo
Jackie wrote:
> I want to get the information of the professors (name,title) from the
> following link:
>
> "http://www.economics.utoronto.ca/index.php/index/person/faculty/";
That's even XHTML, no need to go through BeautifulSoup. Use lxml instead.
http://codespeak.net/lxml
> Ideally, I'd lik
[ Jackie <[EMAIL PROTECTED]> ]
> 1.The code above assume that each Prof has a tilte. If any one of them
> does not, the name and title will be mismatched. How to program to
> allow that title can be empty?
>
> 2.Is there any easier way to get the data I want other than using
> list?
Use BeautifulS
> Can you pull the same information from /proc/stat as opposed to using
> a pipe to top? The first line(s) should contain (at least):
>
> cpu usermode, lowprio, system, idle, hz.
Thanks a lot for the help. I finally decided to go with your suggestion.
--
warm regards,
Pradnyesh Sawant
--
Be yoursel
The code snippet prints "cpu usage: us,, " on my
workstation, bumping the splt index to 3 prints the correct sys.
usage. What does the header of your 'top' command look like? There's
a very good chance it's different than what I'm testing with.
As for the slice, assuming 'splt[2]' is '0.5%sy', t
En Mon, 09 Apr 2007 14:56:03 -0300, Pradnyesh Sawant <[EMAIL PROTECTED]>
escribió:
> Thanks for the pointer to use /proc/stat
> However, that does not answer my other question about string slicing
> Any pointers in that direction would be helpful...
>
>> > top = os.popen("top -n 1")
>> > rd = to
Thanks for the pointer to use /proc/stat
However, that does not answer my other question about string slicing
Any pointers in that direction would be helpful...
Thanks a lot!
On 4/9/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
> Can you pull the same information from /proc/stat as opposed to using
Can you pull the same information from /proc/stat as opposed to using
a pipe to top? The first line(s) should contain (at least):
cpu usermode, lowprio, system, idle, hz.
The 2.6 kernel adds iowait, irq, and soft irq. It seems that this
might be a better solution than executing that additional c
Hi,
http://spinecho.ifrance.com/frmouterr-py242-wxpy2621.zip
I use this gui windows written by jean marie fauth, which is very
easy: printing to stdout or stderr (gui windows written in wxpython).
You have only to translate frmouterr in pygtk.
ph DALET
FRANCE
On 17 fév, 01:19, [EMAIL
On Feb 16, 11:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Feb 16, 4:07 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On Feb 16, 3:28 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > > That's ok inside the same process, but the OP needs to use it "from a
> > > subprocess or spawn".
>
On Feb 17, 1:25 pm, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I'm going around in circles so I'm asking for help. I want to read a
> > simple text file and output the contents to a GUI window when I click
> > on a button. I have written a small python pr
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'm going around in circles so I'm asking for help. I want to read a
> simple text file and output the contents to a GUI window when I click
> on a button. I have written a small python program to read the
> contents of a file when a button is clicked but can on
On Feb 16, 4:07 pm, [EMAIL PROTECTED] wrote:
> On Feb 16, 3:28 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
>
>
> > That's ok inside the same process, but the OP needs to use it "from a
> > subprocess or spawn".
> > You have to use something like tee, working with real file handles.
>
> I'm
On Feb 16, 3:28 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> That's ok inside the same process, but the OP needs to use it "from a
> subprocess or spawn".
> You have to use something like tee, working with real file handles.
>
I'm not particularly familiar with this, but it seems to me
En Fri, 16 Feb 2007 14:04:33 -0300, Bart Ogryczak <[EMAIL PROTECTED]>
escribió:
> On Feb 14, 11:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>> I'm looking for a way to output stdout/stderr (from a subprocess or
>> spawn) to screen and to at least two different files.
>
> I'd derive
On Feb 14, 11:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I searched on Google and in this Google Group, but did not find any
> solution to my problem.
>
> I'm looking for a way to output stdout/stderr (from a subprocess or
> spawn) to screen and to at least two different fil
On Feb 15, 5:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Thu, 15 Feb 2007 19:35:10 -0300, Matimus <[EMAIL PROTECTED]> escribió:
>
>
>
> >> I think you should be able to use my or goodwolf's solution with the
> >> subprocess module. Something like this (untested):
>
> >> [code]
> >> c
En Thu, 15 Feb 2007 19:35:10 -0300, Matimus <[EMAIL PROTECTED]> escribió:
>> I think you should be able to use my or goodwolf's solution with the
>> subprocess module. Something like this (untested):
>>
>> [code]
>> class TeeFile(object):
>> def __init__(self,*files):
>> self.files = f
On Feb 15, 8:51 am, "Matimus" <[EMAIL PROTECTED]> wrote:
> On Feb 15, 7:53 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Feb 14, 5:10 pm, "goodwolf" <[EMAIL PROTECTED]> wrote:
>
> > > like this?
>
> > > class Writers (object):
>
> > > def __init__(self, *writers):
> > >
On Feb 15, 7:53 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Feb 14, 5:10 pm, "goodwolf" <[EMAIL PROTECTED]> wrote:
>
>
>
> > like this?
>
> > class Writers (object):
>
> > def __init__(self, *writers):
> > self.writers = writers
>
> > def write(self, string):
> >
On Feb 14, 6:52 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Wed, 14 Feb 2007 19:28:34 -0300, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> escribió:
>
> > I'm looking for a way to output stdout/stderr (from a subprocess or
> > spawn) to screen and to at least two different files.
>
> Look at
On Feb 14, 5:10 pm, "goodwolf" <[EMAIL PROTECTED]> wrote:
> like this?
>
> class Writers (object):
>
> def __init__(self, *writers):
> self.writers = writers
>
> def write(self, string):
> for w in self.writers:
> w.write(string)
>
> def flush(self):
>
En Wed, 14 Feb 2007 19:28:34 -0300, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> escribió:
> I'm looking for a way to output stdout/stderr (from a subprocess or
> spawn) to screen and to at least two different files.
Look at the tee command. If you control the subprocess, and it's written
in Python,
like this?
class Writers (object):
def __init__(self, *writers):
self.writers = writers
def write(self, string):
for w in self.writers:
w.write(string)
def flush(self):
for w in self.writers:
w.flush():
import sys
logfile = open('log
I took a look around and I couldn't find anything either. I will be
keeping an eye on this thread to see if someone posts a more standard
solution. In the mean time though, I will offer up a potential
solution. Duck typing is your friend. If you are only using the write
method of your files, it can
Fredrik Lundh wrote:
> Clodoaldo Pinto Neto wrote:
>
> > But I still don't understand what is happening. The manual says that
> > when shell=True the executable argument specifies which shell to use:
>
> no, it says that when shell=True, it runs the command "through" the
> default shell. that is,
Clodoaldo Pinto Neto wrote:
> But I still don't understand what is happening. The manual says that
> when shell=True the executable argument specifies which shell to use:
no, it says that when shell=True, it runs the command "through" the
default shell. that is, it hands it over to the shell fo
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > I can't see any obvious way to ask subprocess to use a shell other than
> > the default.
>
> -c ?
>
> >>> f = Popen(["/bin/bash", "-c", "set|grep IFS"], stdout=PIPE)
> >>> f.stdout.read()
> "IFS=$' \\t\\n'\n"
> >>> f = Popen(["/bin/sh", "-c",
[EMAIL PROTECTED] wrote:
> I can't see any obvious way to ask subprocess to use a shell other than
> the default.
-c ?
>>> f = Popen(["/bin/bash", "-c", "set|grep IFS"], stdout=PIPE)
>>> f.stdout.read()
"IFS=$' \\t\\n'\n"
>>> f = Popen(["/bin/sh", "-c", "set|grep IFS"], stdout=PIPE)
>>> f.st
Clodoaldo Pinto Neto wrote:
> Output from the shell:
>
> [EMAIL PROTECTED] teste]$ set | grep IFS
> IFS=$' \t\n'
>
> Output from subprocess.Popen():
>
> >>> import subprocess as sub
> >>> p = sub.Popen('set | grep IFS', shell=True, stdout=sub.PIPE)
> >>> p.stdout.readlines()[1]
> "IFS=' \t\n"
>
> B
Now we have 3 different outputs from 3 people to the command:
>>> f = subprocess.Popen("set | grep IFS", shell=True,
stdout=subprocess.PIPE)
>>> f.stdout.readlines()
>From me on FC5:
["BASH_EXECUTION_STRING='set | grep IFS'\n", "IFS=' \t\n"]
>From Fredrik Lundh on unknown
Clodoaldo Pinto Neto <[EMAIL PROTECTED]> wrote:
>Fredrik Lundh wrote:
>> this works for me:
>>
>> >>> f = subprocess.Popen("set | grep IFS", shell=True,
>> stdout=subprocess.PIPE)
>> >>> f.stdout.readlines()
>> ["IFS=$' \\t\\n'\n"]
>>
>> what does the above return on your machine?
>
f = subp
Fredrik Lundh wrote:
> this works for me:
>
> >>> f = subprocess.Popen("set | grep IFS", shell=True,
> stdout=subprocess.PIPE)
> >>> f.stdout.readlines()
> ["IFS=$' \\t\\n'\n"]
>
> what does the above return on your machine?
>>> f = subprocess.Popen("set | grep IFS", shell=True, stdout=subproce
Clodoaldo Pinto Neto wrote:
> Output from the shell:
>
> [EMAIL PROTECTED] teste]$ set | grep IFS
> IFS=$' \t\n'
>
> Output from subprocess.Popen():
>
import subprocess as sub
p = sub.Popen('set | grep IFS', shell=True, stdout=sub.PIPE)
p.stdout.readlines()[1]
> "IFS=' \t\n"
>
>
>So what you are saying is, if I enter a unit in feet, you automatically
>change that unit to some base unit (say, metres if you use SI) behind my
>back. So, assuming SI units as the base, if I say:
>print 2*ft + 1*ft
>you're going to give me an answer of 0.9144 metres, instead of the
>expected 3
On Fri, 07 Apr 2006 21:18:23 -0700, Russ wrote:
>> dist = 4 * ft
>> print >> out, dist/ft
>>> 4
>
>>> Note, however, that this requires the user to explicity ask for the
>>> conversion.
>
>>How is this any more explicit and any less safe than:
>
>>dist = 4 * ft
>>print float(dist)
>
>
Let me just revise earlier my reply slightly.
>But in any case, I suspect you do automatically convert units. What do you
>do in this case:
Yes, I do automatically convert units, but I only do correct
conversions. Conversion from any unit other than radian to a
dimensionless float is incorrect, s
> dist = 4 * ft
> print >> out, dist/ft
>> 4
>> Note, however, that this requires the user to explicity ask for the
>> conversion.
>How is this any more explicit and any less safe than:
>dist = 4 * ft
>print float(dist)
Because the former specifies the actual units and the latter does n
On Thu, 06 Apr 2006 17:14:22 -0700, Russ wrote:
>>I suggest another approach: play nice with the rest of Python by allowing
>>people to convert your units into strings and floats. Once they have
>>explicitly done so, it isn't your problem if they want to add 35 metres to
>>18 kilograms and convert
>I'm sorry, your system of units doesn't allow trig functions to operate on
>degrees? I presume you don't allow grads either. What about steradians or
>other arbitrary measures of angle or solid angle?
I should have stated that more clearly. You can enter the value in
degrees, but it will automati
On Thu, 06 Apr 2006 11:05:06 -0700, Russ wrote:
>>Really, your response seems a little bizarre to me, given that __float__
>>is the defined way in which float() gets a value from an instance, and
>>float() is what the % operator calls when it encounters a '%f' in the
>>format string.
>
> My class
>Yeah, how about we read your mind or make wild guesses about why it's
>not acceptable, and about what your requirements really are.
>Really, your response seems a little bizarre to me, given that __float__
>is the defined way in which float() gets a value from an instance, and
>float() is what th
Russ wrote:
> Thanks, but that is not acceptable for my application. Any other ideas?
Yeah, how about we read your mind or make wild guesses about why it's
not acceptable, and about what your requirements really are.
Really, your response seems a little bizarre to me, given that __float__
is th
Thanks, but that is not acceptable for my application. Any other ideas?
I thought I might be able to overload __rmod__, but apparently python
applies the % operator before __rmod__ is even invoked if the left-hand
argument is a string.
--
http://mail.python.org/mailman/listinfo/python-list
Russ wrote:
> I'd like to get output formatting for my own classes that mimics the
> built-in output formatting. For example,
>
>
x = 4.54
print "%4.2f" % x
>
>
> 4.54
>
> In other words, if I substitute a class instance for "x" above, I'd
> like to make the format string apply to an e
Steven D'Aprano wrote:
> On Fri, 10 Mar 2006 02:19:10 +0100, Schüle Daniel wrote:
>
>
>>yeah, i miss some things in complex implementation
>>for example c=complex()
>>c.abs = 2**0.5
>>c.angle = pi/2
>>
>>should result in 1+1j :)
>
>
> Smiley noted, but consider:
>
> c = complex()
> => what is
On Fri, 10 Mar 2006 02:19:10 +0100, Schüle Daniel wrote:
> yeah, i miss some things in complex implementation
> for example c=complex()
> c.abs = 2**0.5
> c.angle = pi/2
>
> should result in 1+1j :)
Smiley noted, but consider:
c = complex()
=> what is the value of c here?
c.abs = 2**0.5
=> wha
Russ wrote:
> I'd like to get output formatting for my own classes that mimics the
> built-in output formatting. For example,
>
>
x = 4.54
print "%4.2f" % x
>
> 4.54
>
> In other words, if I substitute a class instance for "x" above, I'd
> like to make the format string apply to an elem
Jens Bloch Helmers <[EMAIL PROTECTED]> writes:
> How can I control the number of digits in the exponent when writing
> floats to a file? It seems that Python2.4.2(winXP) prints three
> digits anyway.
>
> >>> print 1.0e50
> 1e+050
That's weird; must be version and/or OS dependent. On Fedora Core
'%.4e' % 1.0e50
--
http://mail.python.org/mailman/listinfo/python-list
On 2005-11-11, Larry Bates <[EMAIL PROTECTED]> wrote:
> This is something I wrote that might help.
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207
>
The solutions become better and better.
Thanks.
> -Larry Bates
>
> JD wrote:
>> Hello,
>>
>> When reading a large datafile, I wa
This is something I wrote that might help.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207
-Larry Bates
JD wrote:
> Hello,
>
> When reading a large datafile, I want to print a '.' to show the
> progress. This fails, I get the series of '.'s after the data has been
> read. Is ther
jd> When reading a large datafile, I want to print a '.' to show the
jd> progress. This fails, I get the series of '.'s after the data has
jd> been read. Is there a trick to fix this?
As Fredrik indicated, you need to flush the output buffer. You might also
want to check out the prog
On 2005-11-11, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> "JD" <[EMAIL PROTECTED]> wrote:
>
>> When reading a large datafile, I want to print a '.' to show the
>> progress. This fails, I get the series of '.'s after the data has been
>> read. Is there a trick to fix this?
>
> assuming that you're p
"JD" <[EMAIL PROTECTED]> wrote:
> When reading a large datafile, I want to print a '.' to show the
> progress. This fails, I get the series of '.'s after the data has been
> read. Is there a trick to fix this?
assuming that you're printing to stdout,
sys.stdout.flush()
should do the trick.
On 10/11/05, leewang kim <[EMAIL PROTECTED]> wrote:
> I wrote the following code and got the output:
> a 13 0
> None
> b 81 3
(snip)
> where are those 'none' from? and how can I remove them?
>
> class Point:
> def __init__(self,x,y,name):
> self.x = x
> self.y = y
> se
On Tue, 25 Oct 2005 10:10:39 -0500, Terry Hancock <[EMAIL PROTECTED]> wrote:
>On Monday 24 October 2005 09:04 pm, darren kirby wrote:
>> quoth the Fredrik Lundh:
>> > (using either on the output from glob.glob is just plain silly, of course)
>>
>> Silly? Sure. os.listdir() is more on point. Never
Terry Hancock <[EMAIL PROTECTED]> writes:
> I think Mr. Lundh's point was only that the output from glob.glob is already
> guaranteed to be strings, so using either '%s'%f or str(f) is superfluous.
Just for the record - this was why I asked what the point was in the
first place.
On Monday 24 October 2005 09:04 pm, darren kirby wrote:
> quoth the Fredrik Lundh:
> > (using either on the output from glob.glob is just plain silly, of course)
>
> Silly? Sure. os.listdir() is more on point. Never said I was the smartest.
> However, I will defend my post by pointing out that at
On 25/10/2005, at 3:36 PM, Steven Bethard wrote:
> I wouldn't fret too much about a sharp remark from Fredrik Lundh.
> They're pretty much all that way. ;) [...] It takes a little
> training to get used to
> him, but if you can look past the nasty bite, he's really a valuable
> resource around h
darren kirby wrote:
> quoth the Fredrik Lundh:
>
>>(using either on the output from glob.glob is just plain silly, of course)
>
[snip]
>
> It is things like this that make me wary of posting to this list, either to
> help another, or with my own q's. All I usually want is help with a specific
1 - 100 of 114 matches
Mail list logo