Questions tagged [printing]

Printing is a process for reproducing text and images, typically with ink or toner, on paper. For programming questions related to 3D-printing, please, use [3d-printing] tag.

Printing is a process for reproducing text and images. Both ink and toner are commonly used, with the latter being used for laser printers.

It can also refer to printing text to stdout on a terminal, e.g., the printf function in C or the print construct in PHP.

For programming questions related to 3D-printing, general questions can be asked on https://3dprinting.stackexchange.com/.

23212 questions
246
votes
15 answers

How do I keep Python print from adding newlines or spaces?

In python, if I say print 'h' I get the letter h and a newline. If I say print 'h', I get the letter h and no newline. If I say print 'h', print 'm', I get the letter h, a space, and the letter m. How can I prevent Python from printing the…
Bart
  • 10,873
  • 7
  • 29
  • 23
246
votes
18 answers

How can I print variable and string on same line in Python?

I am using python to work out how many children would be born in 5 years if a child was born every 7 seconds. The problem is on my last line. How do I get a variable to work when I'm printing text either side of it? Here is my code: currentPop =…
Bob Uni
  • 2,601
  • 5
  • 17
  • 13
245
votes
13 answers

Suggestions for debugging print stylesheets?

I've recently been working on a print stylesheet for a website, and I realized that I was at a loss for effective ways to tweak it. It's one thing to have a reload cycle for working on the on-screen layout: change code command-tab reload but that…
Jim Puls
  • 79,175
  • 10
  • 73
  • 78
232
votes
10 answers

Pretty Printing a pandas dataframe

How can I print a pandas dataframe as a nice text-based table, like the following? +------------+---------+-------------+ | column_one | col_two | column_3 | +------------+---------+-------------+ | 0 | 0.0001 | ABCD | | …
Ofer
  • 2,883
  • 2
  • 17
  • 16
214
votes
23 answers

How to print binary tree diagram in Java?

How can I print a binary tree in Java so that the output is like: 4 / \ 2 5 My node: public class Node { Node left, right; A data; public Node(A data){ this.data = data; } }
Tian
  • 2,453
  • 5
  • 18
  • 10
210
votes
16 answers

How to print a dictionary line by line in Python?

This is the dictionary cars = {'A':{'speed':70, 'color':2}, 'B':{'speed':60, 'color':3}} Using this for loop for keys,values in cars.items(): print(keys) print(values) It prints the following: B {'color': 3,…
Jett
  • 2,421
  • 5
  • 16
  • 14
209
votes
12 answers

Why doesn't "System.out.println" work in Android?

I want to print something in console, so that I can debug it. But for some reason, nothing prints in my Android application. How do I debug then? public class HelloWebview extends Activity { WebView webview; private static final…
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
202
votes
6 answers

Why is printing to stdout so slow? Can it be sped up?

I've always been amazed/frustrated with how long it takes to simply output to the terminal with a print statement. After some recent painfully slow logging I decided to look into it and was quite surprised to find that almost all the time spent is…
Russ
  • 10,835
  • 12
  • 42
  • 57
197
votes
9 answers

Disabling browser print options (headers, footers, margins) from page?

I have seen this question asked in a couple of different ways on SO and several other websites, but most of them are either too specific or out-of-date. I'm hoping someone can provide a definitive answer here without pandering to speculation. Is…
Anthony
  • 36,459
  • 25
  • 97
  • 163
189
votes
3 answers

Remove and Replace Printed items

I was wondering if it was possible to remove items you have printed in Python - not from the Python GUI, but from the command prompt. e.g. a = 0 for x in range (0,3): a = a + 1 b = ("Loading" + "." * a) print (a) so it…
Alex
  • 2,189
  • 3
  • 15
  • 9
189
votes
11 answers

How can I print the contents of a hash in Perl?

I keep printing my hash as # of buckets / # allocated. How do I print the contents of my hash? Without using a while loop would be most preferable (for example, a one-liner would be best).
Kys
  • 2,597
  • 5
  • 20
  • 16
175
votes
7 answers

In python, why use logging instead of print?

For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that…
Sam Odio
  • 2,717
  • 5
  • 22
  • 25
175
votes
10 answers

Why doesn't print work in a lambda?

Why doesn't this work? lambda: print "x" Is this not a single statement, or is it something else? The documentation seems a little sparse on what is allowed in a lambda...
Anycorn
  • 50,217
  • 42
  • 167
  • 261
171
votes
7 answers

Margin while printing html page

I am using a separate style-sheet for printing. Is it possible to set right and left margins in the style-sheet which set the print margin? (i.e. margin on paper)
kobra
  • 4,853
  • 10
  • 32
  • 33
165
votes
9 answers

How to create a printable Twitter-Bootstrap page

I'm using Twitter-Bootstrap and I need to be able to print the page the way it looks on the browser. I'm able to print other pages made with Twitter-Bootstrap just fine but I can't seem to print my page that uses purely Twitter-Bootstrap. Am I…
Jay Q.
  • 4,979
  • 3
  • 33
  • 36