Very very simple problem here, can't find out how to do it...
I want to print something without a new line after it, so I can later output
something right after it on the same line.
If I do:
print "stuff here",
print "more"
... it doesn't output a newline, but it does output a space:
stuff here, more
... whereas I want no newline and no space:
stuff here,more
How is this done?
thanks
alex 4 2225
Alex Hunsley wrote: .. whereas I want no newline and no space:
stuff here,more
How is this done?
sys.stdout.writ e('foo')
--
Ciao,
Matteo
Matteo Dell'Amico wrote: Alex Hunsley wrote:
.. whereas I want no newline and no space:
stuff here,more
How is this done?
sys.stdout.writ e('foo')
thankyou!
alex
import sys
sys.stdout.writ e( 'stuff here' )
sys.stdout.writ e( 'more' )
On Thu, Jun 03, 2004 at 02:23:01PM +0100, Alex Hunsley wrote: Very very simple problem here, can't find out how to do it...
I want to print something without a new line after it, so I can later output something right after it on the same line.
If I do:
print "stuff here", print "more"
.. it doesn't output a newline, but it does output a space:
stuff here, more
.. whereas I want no newline and no space:
stuff here,more
How is this done?
thanks alex
Alex Hunsley <la**@tardis.ed .ac.molar.uk> writes: Very very simple problem here, can't find out how to do it...
I want to print something without a new line after it, so I can later output something right after it on the same line.
If I do:
print "stuff here", print "more"
.. it doesn't output a newline, but it does output a space:
stuff here, more
.. whereas I want no newline and no space:
stuff here,more
How is this done?
thanks alex
Just "write" to your file. For stdout (equiv of print), you can use:
def msg(txt):
sys.stdout.writ e(txt)
sys.stdout.flus h() #to see results immediately
Thus:
msg('stuff here,')
msg('more\n')
If you don't care about flushing, try:
out=sys.stdout. write
out('stuff here,')
out('more\n')
-- ha************@ boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Hey there,
I want to print some dots in a single-line while my program loads or does
something. I tried with he following but it didn't work :(.
while 1:
print '.',
Prints line of dots separated by a whitespace (. . . . . . etc). Is there a
way I can get it to display them without that white space (.......etc)?
|
by: Daniel Pryde |
last post by:
Hi there. I hope this isn't a stupid question to ask, but does anyone
know how to print out a string without moving to a new line each time
and simply updating the first line. An example would be, if I wanted to
have a percentage progress counter that was constantly updating. I'm
unsure how to do this without printing to a brand new line. Any help
would be greatly appreciated. Thanks.
Daniel
|
by: Martin Bless |
last post by:
Why can't we have an additional 'print' statement, that behaves
exactly like 'print' but doesn't insert that damn blank between two
arguments?
Could be called 'printn' or 'prin1' or 'prinn' anything similar you
like.
Would make my life so much easier. Often I start with a nice and short
print statement, then there happen to be more arguments and neat
formatting becomes more important and as a result I find myself
|
by: S. Staats |
last post by:
Good day, everbody.
Here is a simple program called test.py:
#!/usr/bin/python
print "No newline, please.",
# End of program
Here is what program does:
prompt> ./test.py
No newline, please.
|
by: Christoph Haas |
last post by:
Evening...
I'm writing a simple interactive program to maintain a database.
The goal was to print "> " at the beginning of the line, wait for
user input and then deal with it. Minimal test program:
import sys; print ">", ; print sys.stdin.readline()
However when I run the program and enter "foobar" it looks like this:
| |
by: Jeff B. |
last post by:
Has anyone come across a decent algorithm for implementing word wrap
features in .net printing? I have a small component that uses basic
printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a
PrintDocument object) to send some formatted text to the printer. However,
if the lines are too long they run off the page rather than wrapping around.
I'm sure I can spend the time and come up with a word wrapping algorithm but...
|
by: DazedAndConfused |
last post by:
I have a 8.5 x 11 landscape document with about 1/4 inch of space on the
left and right where there is no print.
The document displays perfect in print preview, but when I print it, about
1/2 inch on the right is not printed (leaving about 3/4 inch empty margin on
the right side of the page). The left side starts about 1/4 inch in and
prints just like I expect it to.
I tried setting the margins to 0 and OriginAtMargins = True. The print...
|
by: Neo Geshel |
last post by:
Greetings.
BACKGROUND:
My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are
delivered as application/xhtml+xml for all non-MS web clients, and as
text/xml for all MS web clients (Internet Explorer).
My flash content was originally brought in via the “flash satay” method,
but I have since used some server-side magic do deliver one <objecttag
|
by: beertje |
last post by:
This is a very newbie question for my first post, perhaps
appropriately.
I want to print '....' gradually, as a progress indicator. I have a
for-loop that every 10 steps executes:
print '.',
This results in something like 'Loading. . . .', whereas I want
'Loading....'
|
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,...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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...
|
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: 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...
| |