473,790 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "intercepti ng things send
to print() before they're sent to sys.stdout" it may be more adequate.

--
Gabriel Genellina

Sep 19 '08 #1
0 1052

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

Similar topics

4
1759
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 range(len(myList)): id = myList print "some text" container.writeToFile(id, printed)
6
1802
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 color? Thanks a lot.
7
4092
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? Thanks! John
0
1707
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 header, I'm intercepting the header click and "telling" it to sort the dataview using col_sort. But for some reason, the "return" is not being executed. When I press the mouse key, it'll sort correctly (by col_sort), but as soon as I release the...
1
1155
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 it is being rendered to the browser and place the template around the output. How do I intercept and change the html as it is being rendered to teh browser?
4
3959
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 our phone system. When a phone call comes in, users can click a button on the ActiveX control and begin recording. My task is to fire off this recording, behind the scenes, without user interaction, using the existing instance of the ActiveX...
5
16265
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
2370
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 is .... or even update strings like Page 1 or 10 ... Page 2 of 10 etc .... When starting the report I don't know the total number of pages nor the page number on which each and every article starts ....
0
164
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( '\t{0}'.format( message ) ) ....
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.