Sponsored Content
Top Forums Programming Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug? Post 302993112 by wisecracker on Tuesday 7th of March 2017 04:19:36 AM
Old 03-07-2017
After searching the 3.5.x and 3.6.0 documentation and finding absolutely nothing about this someone pointed me to the Python builtin 'help()' function. I never even considered this.
So this is the response:-
Code:
Help on built-in function write:

write(text, /) method of _io.TextIOWrapper instance
    Write string to stream.
    Returns the number of characters written (which is always equal to
    the length of the string).

So it is the 'write' attribute that causes this event and IS NOT an error.
If this number is not stored into a _variable_ it is printed to 'stdout'.
Code:
Last login: Tue Mar  7 08:59:58 on ttys000
AMIGA:amiga~> python3.5
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import sys
>>> TEXT="Some string.\n"
>>> sys.stdout.write(TEXT)
Some string.
13
>>> help(sys.stdout.write)

>>> STRLENGTH=sys.stdout.write(TEXT)
Some string.
>>> print(STRLENGTH)
13
>>> len(TEXT)
13
>>> exit()
AMIGA:amiga~> _

Now solved and my mind is at rest.
This User Gave Thanks to wisecracker For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to write stderr in a subroutine log file?..

perl 5.6.1 in win2000: my program uses a subroutine which will write log file. i will call that sub routine like this &log_message("the file $inputfile opened"); what should i do to write the stderr on the same log file itself.. i tried to pass the stderr to the subroutine like ... (1 Reply)
Discussion started by: sekar sundaram
1 Replies

2. Shell Programming and Scripting

Cisco TCL script write stdout to tftpboot

I want to log the following stdout: router(config)#scripting tcl init tftp://192.168.1.1/remote-ping.tcl ===================================== tclsh proc rping {} { foreach address { 192.168.1.1 192.168.2.1 } { ping $address re 50 si 1500 } ===================================== ... (0 Replies)
Discussion started by: research3
0 Replies

3. Shell Programming and Scripting

how to write a shell script to login to a system which is interactive.

Can anybody help me to write a shell script to login interactive system once u open a connection using telnet it will ask for USERCODE: PASSWORD: DOMAIN: (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

4. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

5. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

6. Programming

read and write stdin/stdout in unix

Hi, i am using the below program to read from the standard input or to write to standard out put. i know that using highlevel functions this can be done better than what i have done here. i just want to know is there any other method by which i find the exact number of characters ( this... (3 Replies)
Discussion started by: MrUser
3 Replies

7. UNIX and Linux Applications

How to write automated interactive shell script?

Hello everyone, I just want to write a shell script for automatic feeding the username and password prompts when running my commands, I tried this one but it did not work. Please help me for any way out. #!/bin/bash #!/usr/bin/expect cd ~/workspace/mimosanetworks_mimosa-nms ls -ltr ... (5 Replies)
Discussion started by: sandy-sm
5 Replies

8. Shell Programming and Scripting

Have each subshell write stderr and stdout to its own logfile

Hello, As stated in the title, I do some hacked parallel processing by running multiple instances of bash scripts, each in their own subshell. The code looks like this, # launch one batch-train script in background for each value in fold group list for FOLD_GROUP in "${FOLD_GROUP_LIST}" do ... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

9. Solaris

SMF in Solaris wont write to stderr/stdout ?

Hi, I got a process (c written) that we usually run this way : EmsChkQu >> /EMS/log/EmsChkQu.log 2>&1 When trying to use it as a service I defined it this way : <?xml version='1.0'?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <service_bundle... (6 Replies)
Discussion started by: zionassedo
6 Replies

10. UNIX for Advanced & Expert Users

Sed: couldn't write 1378 items to stdout: No space left on device

Hi , In file first line start with "",when trying to remove using sed i am getting the below error .Please advise sed -e 's///g' -e 's/$]//g' segment1.txt >>segment_m1 sed: couldn't write 1378 items to stdout: No space left on device Thanks, Mohan (1 Reply)
Discussion started by: mohan705
1 Replies
DROP TEXT SEARCH 
TEMPLATE(7) SQL Commands DROP TEXT SEARCH TEMPLATE(7) NAME
DROP TEXT SEARCH TEMPLATE - remove a text search template SYNOPSIS
DROP TEXT SEARCH TEMPLATE [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP TEXT SEARCH TEMPLATE drops an existing text search template. You must be a superuser to use this command. PARAMETERS
IF EXISTS Do not throw an error if the text search template does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing text search template. CASCADE Automatically drop objects that depend on the text search template. RESTRICT Refuse to drop the text search template if any objects depend on it. This is the default. EXAMPLES
Remove the text search template thesaurus: DROP TEXT SEARCH TEMPLATE thesaurus; This command will not succeed if there are any existing text search dictionaries that use the template. Add CASCADE to drop such dictionar- ies along with the template. COMPATIBILITY
There is no DROP TEXT SEARCH TEMPLATE statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH TEMPLATE [alter_text_search_template(7)], CREATE TEXT SEARCH TEMPLATE [create_text_search_template(7)] SQL - Language Statements 2010-05-14 DROP TEXT SEARCH TEMPLATE(7)
All times are GMT -4. The time now is 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy