IDLE has an output format like this:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
How can I customize it to become like that:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
or that:
>>object
: <type 'object'>
>>type
: <type 'type'>
>>object.__class__
: <type 'type'>
>>object.__bases__
(preferably without modifying code)
..
-- http://lazaridis.com 20 1773
Ilias Lazaridis wrote:
IDLE has an output format like this:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
How can I customize it to become like that:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
or that:
>>object
: <type 'object'>
>>type
: <type 'type'>
>>object.__class__
: <type 'type'>
>>object.__bases__
(preferably without modifying code)
I assume this is not possible.
I am wondering that other users are not annoyed by this reduced
readability.
anyway.
..
-- http://lazaridis.com
Ilias Lazaridis wrote:
Ilias Lazaridis wrote:
>>IDLE has an output format like this:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
How can I customize it to become like that:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
or that:
>>object
: <type 'object'>
>>type
: <type 'type'>
>>object.__class__
: <type 'type'>
>>object.__bases__
(preferably without modifying code)
I assume this is not possible.
I am wondering that other users are not annoyed by this reduced
readability.
And I am wondering at your continual surprise when the rest of the world
fails to share your perceptions. Doesn't this carry *any* information?
anyway.
Indeed.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Steve Holden wrote:
Ilias Lazaridis wrote:
Ilias Lazaridis wrote:
>IDLE has an output format like this:
object <type 'object'> type <type 'type'> object.__class__ <type 'type'> object.__bases__
How can I customize it to become like that:
object
<type 'object'> type
<type 'type'> object.__class__
<type 'type'> object.__bases__
or that:
object
: <type 'object'> type
: <type 'type'> object.__class__
: <type 'type'> object.__bases__
(preferably without modifying code)
I assume this is not possible.
I am wondering that other users are not annoyed by this reduced
readability.
And I am wondering at your continual surprise when the rest of the world
fails to share your perceptions. Doesn't this carry *any* information?
not the rest of the world, but the rest of the python community.
That's a big difference.
So it looks that I have to code to change the output format.
Reminds me 'good old days'.
anyway.
Indeed.
>And I am wondering at your continual surprise when the rest of the world
>fails to share your perceptions. Doesn't this carry *any* information?
not the rest of the world, but the rest of the python community.
That's a big difference.
So it looks that I have to code to change the output format.
Reminds me 'good old days'.
Gosh. Shocking. A programmer is supposed to program if he wants a
program to behave differently. When the heck has this world mutated from
a place where uttering nonsense made it immediately happen, as if by magic?
I can recall two times that has been the case before:
- paradise. Ended presumably 6000 years ago, according to your local
intelligent designer outlet.
- dot-com era, unfortunately only for funding ideas, not so much
developing or even successfully deploying them. Ended 2001.
Obviously historians have to consider a third period: the golden times
of Illias wishful thinking reign, a collectively unnoticed time which
only records could be found if brain scanning was more developed in just
one brain in the world. Yours.
Diez
Ilias Lazaridis wrote:
Steve Holden wrote:
>And I am wondering at your continual surprise when the rest of the world fails to share your perceptions. Doesn't this carry *any* information?
not the rest of the world, but the rest of the python community.
Remember back when you first came to comp.lang.python and I told you that this
was not the community that you were looking for? http://mail.python.org/pipermail/pyt...ry/266629.html
Good times.
Anyways, against my better judgement, I will tell you that you can customize the
output by replacing sys.displayhook with your own function: http://www.python.org/doc/current/lib/module-sys.html
>>import sys 1
1
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f 1
1
>>>
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
At Sunday 24/9/2006 18:55, Robert Kern wrote:
>Anyways, against my better judgement, I will tell you that you can customize the output by replacing sys.displayhook with your own function:
http://www.python.org/doc/current/lib/module-sys.html
>>import sys
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f
Sometimes I enable a similar approach on my sitecustomize.py, using
the pprint module. But I don't *always* like the output format.
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas
Ilias Lazaridis wrote:
Ilias Lazaridis wrote:
>IDLE has an output format like this:
> >>object
<type 'object'>
> >>type
<type 'type'>
> >>object.__class__
<type 'type'>
> >>object.__bases__
How can I customize it to become like that:
> >>object
<type 'object'>
> >>type
<type 'type'>
> >>object.__class__
<type 'type'>
> >>object.__bases__
or that:
> >>object
: <type 'object'>
> >>type
: <type 'type'>
> >>object.__class__
: <type 'type'>
> >>object.__bases__
(preferably without modifying code)
I assume this is not possible.
I am wondering that other users are not annoyed by this reduced
readability.
I'm sure its quite unpopular to agree with you, but I do. I am
tremendously annoyed the format of the interactive interpreter. Lovely
would be output as you describe, but with the option, when selecting for
copy-paste, to include the prompts and/or your suggested whitespace
margin (e.g. select in doctest mode).
James
Robert Kern wrote:
Ilias Lazaridis wrote:
Steve Holden wrote:
And I am wondering at your continual surprise when the rest of the world
fails to share your perceptions. Doesn't this carry *any* information?
not the rest of the world, but the rest of the python community.
Remember back when you first came to comp.lang.python and I told you that this
was not the community that you were looking for?
http://mail.python.org/pipermail/pyt...ry/266629.html
Good times.
yes, good times, for the memory: http://case.lazaridis.com/wiki/PythonAudit
but now I produce (using python): http://dev.lazaridis.com/base
Anyways, against my better judgement, I will tell you that you can customize the
output by replacing sys.displayhook with your own function:
http://www.python.org/doc/current/lib/module-sys.html
>>import sys
>>1
1
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f
>>1
1
>>>
I've placed this code within /Lib/sitecustomize.py, but have one
strange result:
>>from talker import * t = Talker() t.sayHello
: <bound method Talker.sayHello of <talker.Talker instance at
0x00DEA198>>
>>t.sayHello()
Hello world
: None
>>>
1st: "Hello world" comes still on the beginning.
2nd: I got this "None"
class Talker:
def sayHello(self):
print 'Hello world'
def talk(self):
self.sayHello()
Gabriel Genellina wrote:
At Sunday 24/9/2006 18:55, Robert Kern wrote:
Anyways, against my better judgement, I will tell you that you can
customize the
output by replacing sys.displayhook with your own function: http://www.python.org/doc/current/lib/module-sys.html
>>import sys
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f
Sometimes I enable a similar approach on my sitecustomize.py, using
the pprint module. But I don't *always* like the output format.
Can you please show this approach using "pprint"?
..
Ilias Lazaridis wrote:
Robert Kern wrote:
>Anyways, against my better judgement, I will tell you that you can customize the output by replacing sys.displayhook with your own function:
http://www.python.org/doc/current/lib/module-sys.html
> >>import sys 1
1
> >>def f(obj):
print ' ' + repr(obj)
> >>sys.displayhook = f 1
1
> >>>
I've placed this code within /Lib/sitecustomize.py, but have one
strange result:
>>>from talker import * t = Talker() t.sayHello
: <bound method Talker.sayHello of <talker.Talker instance at
0x00DEA198>>
>>>t.sayHello()
Hello world
: None
1st: "Hello world" comes still on the beginning.
Yes. Read the doc for sys.displayhook() and you will understand why.
2nd: I got this "None"
Yes. Read the doc for sys.displayhook() and you will understand why.
I did not give you an all-singing, all-dancing solution, just showed you that
you *can* customize the output that you said you wanted customized.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
James Stroud wrote:
Ilias Lazaridis wrote:
....
I am wondering that other users are not annoyed by this reduced
readability.
I'm sure its quite unpopular to agree with you, but I do. I am
tremendously annoyed the format of the interactive interpreter. Lovely
would be output as you describe, but with the option, when selecting for
copy-paste, to include the prompts and/or your suggested whitespace
margin (e.g. select in doctest mode).
James
I am not sure I understand what you meen with the option.
copy includes both, the ">>>" and the " :"
possibly you can elaborate a little, as this could be an important
factor.
-
As for a solution to the output, just follow this ticket: http://case.lazaridis.com/ticket/10
..
At Tuesday 26/9/2006 15:31, Ilias Lazaridis wrote:
>Anyways, against my better judgement, I will tell you that you can
>customize the
>output by replacing sys.displayhook with your own function:
> http://www.python.org/doc/current/lib/module-sys.html
>
>>import sys
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f
Sometimes I enable a similar approach on my sitecustomize.py, using
the pprint module. But I don't *always* like the output format.
Can you please show this approach using "pprint"?
Sure. Put these two lines into your sitecustomize.py:
import sys, pprint
sys.displayhook = pprint.pprint
and see what happens when you eval things inside the interpreter.
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas
At Tuesday 26/9/2006 15:29, Ilias Lazaridis wrote:
>>def f(obj):
print ' ' + repr(obj)
>>sys.displayhook = f
I've placed this code within /Lib/sitecustomize.py, but have one strange result:
>from talker import * t = Talker() t.sayHello
: <bound method Talker.sayHello of <talker.Talker instance at 0x00DEA198>>
>t.sayHello()
Hello world
: None
>>
1st: "Hello world" comes still on the beginning. 2nd: I got this "None"
The replacement should be a bit more complicated, taking None into
account - see the original PEP for details http://www.python.org/dev/peps/pep-0217/
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas
Ilias Lazaridis wrote:
James Stroud wrote:
>>Ilias Lazaridis wrote:
>>>I am wondering that other users are not annoyed by this reduced readability.
I'm sure its quite unpopular to agree with you, but I do. I am tremendously annoyed the format of the interactive interpreter. Lovely would be output as you describe, but with the option, when selecting for copy-paste, to include the prompts and/or your suggested whitespace margin (e.g. select in doctest mode).
I am not sure I understand what you meen with the option.
copy includes both, the ">>>" and the " :"
possibly you can elaborate a little, as this could be an important
factor.
Well, for example, the output (I'm indenting manually for visual clarity):
>>print 'bob'
: bob
>>print [i for i in xrange(3)]
: [0, 1, 2]
Would create the following selection in "doctest" mode (again manually
adding whitespace):
>>print 'bob'
bob
>>print [i for i in xrange(3)]
[0, 1, 2]
But, say for 'code copy' mode, this selection would be appended to the
clipboard (again manually adding whitespace for clarity):
print 'bob'
print [i for i in xrange(3)]
This way you could either make doctest blocks or copy code drafted in
the interactive interpreter. I often get carried away and write complete
useful functions in the interpreter then have to do commands like the
following in vim:
:.,+8s/^....//
to fix ">"s and ellipses, etc., in the copied function. Or if I want to
tweak a function I'm writing in the interpreter, I painfully copy it one
line at a time. This may or may not be the best way to use the
interpreter (to draft actual code) but I find myself doing it all of the
time.
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095 http://www.jamesstroud.com/
James Stroud wrote:
Ilias Lazaridis wrote:
....
Well, for example, the output (I'm indenting manually for visual clarity):
>>print 'bob'
: bob
>>print [i for i in xrange(3)]
: [0, 1, 2]
Would create the following selection in "doctest" mode (again manually
adding whitespace):
>>print 'bob'
bob
>>print [i for i in xrange(3)]
[0, 1, 2]
http://docs.python.org/lib/module-doctest.html
ok, I understand now.
then, for consistency reasons, the ":" could become ":::".
doctest would need to get a tiny addition to be able to 'see' those
":::".
But, say for 'code copy' mode, this selection would be appended to the
clipboard (again manually adding whitespace for clarity):
print 'bob'
print [i for i in xrange(3)]
I understand.
This way you could either make doctest blocks or copy code drafted in
the interactive interpreter. I often get carried away and write complete
useful functions in the interpreter then have to do commands like the
following in vim:
:.,+8s/^....//
to fix ">"s and ellipses, etc., in the copied function. Or if I want to
tweak a function I'm writing in the interpreter, I painfully copy it one
line at a time. This may or may not be the best way to use the
interpreter (to draft actual code) but I find myself doing it all of the
time.
I am wondering that this functionality (copy code) is not included
within IDLE.
It should be possible to add it quite simple.
..
Gabriel Genellina wrote:
At Tuesday 26/9/2006 15:29, Ilias Lazaridis wrote:
>>def f(obj):
print ' ' + repr(obj)
>
>>sys.displayhook = f
I've placed this code within /Lib/sitecustomize.py, but have one
strange result:
....
>>t.sayHello()
Hello world
: None
1st: "Hello world" comes still on the beginning.
2nd: I got this "None"
import sys
def f(obj):
if obj:
print '::: ' + repr(obj)
sys.displayhook = f
The replacement should be a bit more complicated, taking None into
account - see the original PEP for details http://www.python.org/dev/peps/pep-0217/
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Any simple solution for this?
I've looked a little at the code, but get immediately demotivated
seeing 72 files within a flat directroy: http://svn.python.org/view/python/tr...lib/?rev=52013
..
-- http://lazaridis.com
At Wednesday 27/9/2006 09:29, Ilias Lazaridis wrote:
>import sys def f(obj):
if obj:
print '::: ' + repr(obj) sys.displayhook = f
Have you tried that? You have to filter out None, not *any* False value.
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Any simple solution for this?
Displaying things interactively is not the same as executing a print
statement inside the code - I feel right they are not considered the
same thing.
print output goes to sys.stdout, you could replace it.
>I've looked a little at the code, but get immediately demotivated seeing 72 files within a flat directroy:
http://svn.python.org/view/python/tr...lib/?rev=52013
Remember that packages have not existed forever... I've seen worse things :)
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas
Gabriel Genellina wrote:
At Wednesday 27/9/2006 09:29, Ilias Lazaridis wrote:
import sys
def f(obj):
if obj:
print '::: ' + repr(obj)
sys.displayhook = f
Have you tried that? You have to filter out None, not *any* False value.
you are right. 1 == 0 showed an empty response.
this one seems to work:
def f(obj):
if obj is not None:
print '::: ' + repr(obj)
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Any simple solution for this?
Displaying things interactively is not the same as executing a print
statement inside the code - I feel right they are not considered the
same thing.
agree.
print output goes to sys.stdout, you could replace it.
wouldn't this replace all sdtout of every python programm?
i've tried this one:
sys.sdtout = f
without success within IDLE.
I've looked a little at the code, but get immediately demotivated
seeing 72 files within a flat directroy: http://svn.python.org/view/python/tr...lib/?rev=52013
Remember that packages have not existed forever... I've seen worse things :)
ok, me too.
but placing at minimum 2 directories like:
core
gui
could simpify things already very much.
..
-- http://lazaridis.com
Gabriel Genellina wrote:
At Wednesday 27/9/2006 09:29, Ilias Lazaridis wrote:
import sys
def f(obj):
if obj:
print '::: ' + repr(obj)
sys.displayhook = f
Have you tried that? You have to filter out None, not *any* False value.
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Any simple solution for this?
Displaying things interactively is not the same as executing a print
statement inside the code - I feel right they are not considered the
same thing. print output goes to sys.stdout, you could replace it.
this is nicely described here: http://www.voidspace.org.uk/python/w..._21.shtml#e192
do i need the "getattr" and "writeline" methods in MyStdOut?
..
-- http://case.lazaridis.com/ticket/10
Ilias Lazaridis wrote:
IDLE has an output format like this:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
How can I customize it to become like that:
>>object
<type 'object'>
>>type
<type 'type'>
>>object.__class__
<type 'type'>
>>object.__bases__
or that:
>>object
: <type 'object'>
>>type
: <type 'type'>
>>object.__class__
: <type 'type'>
>>object.__bases__
(preferably without modifying code)
I am close to finalizing this task, but have two tiny problems:
import the module from within a site_packages *.pth file, or
include the code into sitecustomize, or
import it withine an IDLE session:
# idlex.py
#---------------------------------------------------------------------------------------
import sys
class ClaimStdOut:
def __init__(self, stream, prefix):
self.stdout = stream #remember original stream
self.prefix = prefix
def write(self, output):
self.stdout.write(self.prefix + output)
#this one is _not_ executed on import:
sys.stdout = ClaimStdOut(sys.stdout, '=== ')
#workaround:
def f(obj):
if obj is not None:
print repr(obj)
# Claiming StdOut here
sys.stdout = ClaimStdOut(sys.stdout, '::: ')
#disable displayhook (which is just used to set stdout)
sys.displayhook = sys.__displayhook__
# this one _is_ executed on import
sys.displayhook = f
#---------------------------------------------------------------------------------------
So, why is this line not executed during import?
sys.stdout = ClaimStdOut(sys.stdout, '=== ')
additionally, the output of IDLE looks like this:
IDLE 1.1.3 ==== No Subprocess ====
>>1==1
True
[the new stdout is active now]
>>1==1
::: True:::
>>>
Possibly IDLE prints the CR/LF in a second call.
How can I compare this operating-system-independent?
if (output == <os.line-end-marker>):
self.stdout.write(output)
else:
self.stdout.write(self.prefix + output)
..
-- http://case.lazaridis.com/ticket/10 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kerry Neilson |
last post by:
For the past couple of months, Idle won't start when I invoke it. I
am at a complete loss for why this is. When this happens, they python
command...
|
by: Bill Davy |
last post by:
To make life easier for my users, I'd like to colour my prompt string (as
handed to raw_input()) a different colour to that produced by print. I'm...
|
by: John Salerno |
last post by:
If I want to write my code in a separate text editor (I like UltraEdit)
but then press a single button to have that code run in the IDLE...
|
by: heidi.hunter |
last post by:
I just downloaded the most recent (2.4.3) Python and IDLE (1.1.3) to
Windows XP Professional. I'm new to the IDLE environment, so hopefully
someone...
|
by: aaragon |
last post by:
Hi everyone. I'm trying to write a class with policy based design
(Alexandrescu's Modern C++ Design). I'm not a programmer but an
engineer so...
|
by: John (Z R) L |
last post by:
Hi all, I am very new to programming, and I chose to study the Python
language before C++. I am currently using the Wikibooks
"Non-Programmer's...
|
by: thecoolone |
last post by:
I am trying to implement the yahoo search api using php.
I prefer to use PHP serialized to get the result of the search
displayed.
Right now i get...
|
by: jimhill10 |
last post by:
I have a perl script that creates an email attachment file from POST data on a web page. This works just fine. I want to customize the email body...
|
by: wongjoekmeu |
last post by:
Dear All,
I have some functions written in C++, which I try to approach from
python using swig. In the C++ functions I use std::cout to print...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |