There are objects whose repr() is not the same
as what gets printed out when you apply the
print statement to them. Usually these are
complex objects like exceptions.
Example: import smtplib
server=smtplib. SMTP("smtp.your isp.com")
try:
server.sendmail ("xx*@in88valid domain.com",
"xx*@abc.com"," message")
except smtplib.SMTPRec ipientsRefused, senderrs:
exc_obj=senderr s
repr(exc_obj)
'<smtplib.SMTPR ecipientsRefuse d instance at 0x00EA7C60>'
print exc_obj
{'xx*@abc.com': (550, 'Verification failed for <xx*@in88validd omain.com>\nunr outeable mail domain "in88validdomai n.com"\nSender
verify failed')}
Question:
Is there a way to somehow put the output of 'print exc_obj' into
a string? 2 1429
In <3a************ *@individual.ne t>, Jon Perez wrote: Question:
Is there a way to somehow put the output of 'print exc_obj' into a string?
There are ways to do even that, but maybe ``str(exc_obj)` ` is enough for
your needs!?
Ciao,
Marc 'BlackJack' Rintsch
Thanks, man! That was one fast reply...
Marc 'BlackJack' Rintsch wrote: In <3a************ *@individual.ne t>, Jon Perez wrote:
Question:
Is there a way to somehow put the output of 'print exc_obj' into a string?
There are ways to do even that, but maybe ``str(exc_obj)` ` is enough for your needs!?
Ciao, Marc 'BlackJack' Rintsch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe Flynt |
last post by:
I'm try to display the output of ipconfig.exe to the web browser
using:
Apache/2.0.48 (Win32) mod_python/3.1.2b Python/2.3.2
but when I view http://server/cgi-bin/test.py i get the following
format of output:
['\r\n', 'Windows IP Configuration\r\n', '\r\n',
etc.
How do I get it to display the same output as if I had executed the
|
by: Marcin Ciura |
last post by:
Here is a pre-PEP about print that I wrote recently.
Please let me know what is the community's opinion on it.
Cheers,
Marcin
PEP: XXX
Title: Print Without Intervening Space
Version: $Revision: 0.0 $
|
by: Jason |
last post by:
Hello,
I have a class, transCore, that does certain work, and by default, prints
its progress to the stand output.
Later, I will to write a GUI class that encapsulate the transCore class. I
would like to redirect/intercept the output of transCore class to this GUI
class. I wrote a sample program that demonstrate how I did it, but I am not
sure if it's any good. Can anyone critic my code? If there's any
non-standard conforming code or...
|
by: Little |
last post by:
Could someone start me on putting in a table into this code, and some
HTML tags. I would to make the table below the map and have a header at
the top. Thanks for the help.
""" Publisher example """
def query(req, building=""):
# NOTE: best way to understand this is to see the output,
# that is, to "view source" on the generated web page
# read common header for any google mapping
|
by: Johannes Barop |
last post by:
Hi,
I want to format the output of a 'std::ostream', but i dont know how to
do it .
Example:
int main()
{
my_out << "Hi.\nI'am a" << " Computer.";
my_out << "Nice.";
| |
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 can tell me what I'm missing here! Below is the code, which I'm
editing within IDLE, and attempting to test with the Run commands.
I was expecting to see at least see the prints to stdout from the if
__name__ ... statement and main() function, but when I use F5 Run
module I don't see any...
|
by: fdu.xiaojf |
last post by:
Hi,
I'm writing a program which imports an external module writing in C and
calls a function provided by the module to do my job. But the method
produces
a lot of output to the stdout, and this consumes most of the running time.
My question is, is there a way to depress the output produced by the
function and hence make my program run faster? It's too complicated for me
to modify the source code and recompile the external module.
|
by: Pradnyesh Sawant |
last post by:
Hello,
I need the cpu usage of a linux box, for which i capture the output of
"top" using "popen". However, i am facing problems during string
handling. The code snippet is:-
top = os.popen("top -n 1")
rd = top.read().split("\n")
splt = rd.split()
# cpu = splt # why ain't this working ???
cpu = splt
|
by: jebbyleezer |
last post by:
Hello, I have source code that builds correctly, however, after the program terminates the output file produced is empty.
Here is my source code:
import java.io.*;
import java.util.Scanner;
public class project
{
public static void main( String args )
{
|
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...
|
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...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |