Re: Output showing "None" in Terminal

2020-08-27 Thread Py Noob
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.

Re: Output showing "None" in Terminal

2020-08-26 Thread Terry Reedy
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

RE: Output showing "None" in Terminal

2020-08-25 Thread Schachner, Joseph
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

Re: Output showing "None" in Terminal

2020-08-25 Thread dn via Python-list
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

Re: Output showing "None" in Terminal

2020-08-24 Thread Py Noob
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

Re: Output showing "None" in Terminal

2020-08-24 Thread 2QdxY4RzWzUUiLuE
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

Re: Output showing "None" in Terminal

2020-08-24 Thread Random832
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

Re: Output showing "None" in Terminal

2020-08-24 Thread Calvin Spealman
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

Re: Output format

2016-03-20 Thread Rustom Mody
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

Re: Output format

2016-03-20 Thread Alphwe
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

Re: Output format

2016-03-20 Thread Mark Lawrence
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

Re: Output format

2016-03-20 Thread Joel Goldstick
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

Re: Output JSON-schema from bottle application?

2014-02-28 Thread donarb
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

Re: Output JSON-schema from bottle application?

2014-02-28 Thread Alister
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.

Re: Output from to_bytes

2013-06-02 Thread Ned Batchelder
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

Re: Output from to_bytes

2013-06-02 Thread Mok-Kong Shen
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

Re: Output is not coming with defined color

2013-05-29 Thread rusi
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

Re: Output is not coming with defined color

2013-05-29 Thread Fábio Santos
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

Re: Output from to_bytes

2013-05-28 Thread 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 mean the 2nd and 3rd should be b'\

Re: Output from to_bytes

2013-05-26 Thread Terry Jan Reedy
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

Re: Output from to_bytes

2013-05-26 Thread Chris Angelico
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

Re: output from popen

2010-04-05 Thread Kushal Kumaran
On Mon, Apr 5, 2010 at 1:33 PM, hiral wrote: > Hi, > I am trying following script... > >

Re: Output file formatting/loop problems -- HELP?

2009-09-08 Thread Maggie
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 > >>>

Re: Output file formatting/loop problems -- HELP?

2009-09-08 Thread MRAB
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

Re: Output file formatting/loop problems -- HELP?

2009-09-08 Thread Hendrik van Rooyen
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

Re: Output file formatting/loop problems -- HELP?

2009-09-08 Thread Maggie
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

Re: Output file formatting/loop problems -- HELP?

2009-09-08 Thread MRAB
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

Re: output problem

2009-01-18 Thread 7stud
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): >

Re: output problem

2009-01-18 Thread Pierre Bourdon
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

Re: Output to file gets lost - don't know where to look ...

2008-12-14 Thread Scott David Daniels
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

Re: Output to file gets lost - don't know where to look ...

2008-12-14 Thread uair01
> 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

Re: Output of pexpect

2008-10-01 Thread Lie Ryan
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

Re: Output of pexpect

2008-09-30 Thread Karthik Gurusamy
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=[],

Re: Output buffer

2007-12-22 Thread Fredrik Lundh
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

Re: output object fields into a file

2007-08-13 Thread Zentrader
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

Re: Output XML buffer?

2007-06-26 Thread Jan Danielsson
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

Re: Output XML buffer?

2007-06-25 Thread Stefan Behnel
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,

Re: Output XML buffer?

2007-06-25 Thread Martin v. Löwis
>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

Re: Output of HTML parsing

2007-06-19 Thread Stefan Behnel
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

Re: Output of HTML parsing

2007-06-19 Thread Jackie
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

Re: Output of HTML parsing

2007-06-15 Thread Stefan Behnel
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

Re: Output of HTML parsing

2007-06-15 Thread Sebastian Wiesner
[ 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

Re: output of top on a linux box

2007-04-13 Thread Pradnyesh Sawant
> 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

Re: output of top on a linux box

2007-04-09 Thread Jeff McNeil
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

Re: output of top on a linux box

2007-04-09 Thread Gabriel Genellina
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

Re: output of top on a linux box

2007-04-09 Thread Pradnyesh Sawant
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

Re: output of top on a linux box

2007-04-09 Thread Jeff McNeil
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

Re: Output to a text window

2007-02-17 Thread pdalet
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

Re: output to console and to multiple files

2007-02-16 Thread Fuzzyman
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". >

Re: Output to a text window

2007-02-16 Thread google
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

Re: Output to a text window

2007-02-16 Thread Joshua J. Kugler
[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

Re: output to console and to multiple files

2007-02-16 Thread [EMAIL PROTECTED]
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

Re: output to console and to multiple files

2007-02-16 Thread garrickp
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

Re: output to console and to multiple files

2007-02-16 Thread Gabriel Genellina
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

Re: output to console and to multiple files

2007-02-16 Thread Bart Ogryczak
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

Re: output to console and to multiple files

2007-02-16 Thread [EMAIL PROTECTED]
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

Re: output to console and to multiple files

2007-02-15 Thread Gabriel Genellina
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

Re: output to console and to multiple files

2007-02-15 Thread Matimus
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): > > >

Re: output to console and to multiple files

2007-02-15 Thread Matimus
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): > >

Re: output to console and to multiple files

2007-02-15 Thread [EMAIL PROTECTED]
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

Re: output to console and to multiple files

2007-02-15 Thread [EMAIL PROTECTED]
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): >

Re: output to console and to multiple files

2007-02-14 Thread Gabriel Genellina
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,

Re: output to console and to multiple files

2007-02-14 Thread goodwolf
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

Re: output to console and to multiple files

2007-02-14 Thread Matimus
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

Re: Output from subprocess.Popen()

2006-10-17 Thread Clodoaldo Pinto Neto
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,

Re: Output from subprocess.Popen()

2006-10-16 Thread Fredrik Lundh
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

Re: Output from subprocess.Popen()

2006-10-16 Thread Clodoaldo Pinto Neto
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",

Re: Output from subprocess.Popen()

2006-10-16 Thread Fredrik Lundh
[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

Re: Output from subprocess.Popen()

2006-10-16 Thread [EMAIL PROTECTED]
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

Re: Output from subprocess.Popen()

2006-10-16 Thread Clodoaldo Pinto Neto
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

Re: Output from subprocess.Popen()

2006-10-16 Thread Sion Arrowsmith
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

Re: Output from subprocess.Popen()

2006-10-15 Thread Clodoaldo Pinto Neto
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

Re: Output from subprocess.Popen()

2006-10-15 Thread Fredrik Lundh
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" > >

Re: output formatting for user-defined types

2006-04-08 Thread Russ
>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

Re: output formatting for user-defined types

2006-04-08 Thread Steven D'Aprano
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) > >

Re: output formatting for user-defined types

2006-04-07 Thread Russ
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

Re: output formatting for user-defined types

2006-04-07 Thread Russ
> 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

Re: output formatting for user-defined types

2006-04-07 Thread Steven D'Aprano
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

Re: output formatting for user-defined types

2006-04-06 Thread Russ
>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

Re: output formatting for user-defined types

2006-04-06 Thread Steven D'Aprano
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

Re: output formatting for user-defined types

2006-04-06 Thread Russ
>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

Re: output formatting for user-defined types

2006-04-06 Thread Peter Hansen
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

Re: output formatting for user-defined types

2006-04-05 Thread Russ
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

Re: output formatting for user-defined types

2006-04-05 Thread Peter Hansen
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

Re: Mutable complex numbers [was Re: output formatting for classes]

2006-03-11 Thread Schüle Daniel
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

Mutable complex numbers [was Re: output formatting for classes]

2006-03-10 Thread Steven D'Aprano
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

Re: output formatting for classes

2006-03-09 Thread Schüle Daniel
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

Re: Output: Number of digits in exponent?

2005-12-06 Thread Paul Rubin
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

Re: Output: Number of digits in exponent?

2005-12-06 Thread danplawson
'%.4e' % 1.0e50 -- http://mail.python.org/mailman/listinfo/python-list

Re: output buffering

2005-11-11 Thread JD
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

Re: output buffering

2005-11-11 Thread Larry Bates
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

Re: output buffering

2005-11-11 Thread skip
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

Re: output buffering

2005-11-11 Thread JD
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

Re: output buffering

2005-11-11 Thread Fredrik Lundh
"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.

Re: output question 1

2005-11-10 Thread Simon Brunning
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

Re: [OT] Re: output from external commands

2005-10-25 Thread Bengt Richter
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

Re: [OT] Re: output from external commands

2005-10-25 Thread Mike Meyer
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.

Re: [OT] Re: output from external commands

2005-10-25 Thread Terry Hancock
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

Re: [OT] Re: output from external commands

2005-10-24 Thread Tony Meyer
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

Re: [OT] Re: output from external commands

2005-10-24 Thread Steven Bethard
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   2   >