473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: Intercepting printed strings

En Thu, 18 Sep 2008 19:24:26 -0300, Robert Dailey <rc******@gmail.com>
escribió:
I'm currently using Python 3.0 b3 and I'm curious as to how I can go
about
intercepting things send to print() for some intermediate processing
before
they're actually sent to sys.stdout. Right now I've thought of the
following:

Replace sys.stdout with a class named PrintStream. PrintStream is
defined as
follows:

class PrintStream:
def write( self, message ):
sys.__stdout__.write( '\t{0}'.format( message ) )

Will this work? Basically I want to add a tab character in front of every
message printed. Thanks.
Why don't you try it yourself?
You may replace builtins.print with your own function too. It's not
exactly the same thing, but given your request "intercepting things send
to print() before they're sent to sys.stdout" it may be more adequate.

--
Gabriel Genellina

Sep 19 '08 #1
0 1030

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christian Otteneuer | last post by:
Hello Newsgroup, I have the following problem: I want to write a python script, that writes text into files. The text is being "collected" in a for-loop, the code looks like this: for i in...
6
by: Valery Polyakov | last post by:
I am drawing lines with a semi-transparent color (alpha=100). When these lines intercept, the color becomes more intense. Is there a way to avoid this, so that I would get the same intensity of...
7
by: John | last post by:
Hi, Can anyone point me out how to intercept the keystrokes from a c# application that's not a active window? - intercepting the system wide keystrokes before it hits the target active window? ...
0
by: VMI | last post by:
My Windows datagrid has two columns: one with the data that the user will see (col_X) and the other one (a hidden one: col_sort) that'll be used to sort data. When a user clicks on col_X's column...
1
by: Stu | last post by:
Hi, I am working on a CMS that uses html templates with placeholder strings for the content (eg: %%Content%%). I want to get the web control working on a blank page. Then intercept the page as...
4
by: Curious Coder | last post by:
I have been tasked with a project that I do not think can be accomplished. Our company has an application that runs as an unmanaged ActiveX control on user desktops. It is designed to work with...
5
by: aaa | last post by:
Is there a simple straight forward tool out there for intercepting my SOAP requests so that I can debug the XML that I am sending?
3
by: Kristijan Marin | last post by:
Hi, I need to print a report like document. So in report there are many articles and what I need when I get to the end, is to update page numbers on the second page where the Table of Content...
0
by: Gabriel Genellina | last post by:
En Fri, 19 Sep 2008 10:37:00 -0300, Robert Dailey <rcdailey@gmail.com> escribió: Works for me: p3class PrintStream: .... def write( self, message ): .... sys.__stdout__.write(...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.