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
2386
votes
37 answers

What's the simplest way to print a Java array?

In Java, arrays don't override toString(), so if you try to print one directly, you get the className + '@' + the hex of the hashCode of the array, as defined by Object.toString(): int[] intArray = new int[] {1, 2, 3, 4,…
Alex Spurling
  • 54,094
  • 23
  • 70
  • 76
1733
votes
17 answers

How do I print to stderr in Python?

There are several ways to write to stderr: print >> sys.stderr, "spam" # Python 2 only. sys.stderr.write("spam\n") os.write(2, b"spam\n") from __future__ import print_function print("spam", file=sys.stderr) What are the differences between…
wim
  • 338,267
  • 99
  • 616
  • 750
1573
votes
13 answers

How can I flush the output of the print function?

How do I force Python's print function to flush the buffered output to the screen? See also: Disable output buffering if the goal is to change the buffering behaviour generally. This question is about explicitly flushing output after a specific…
Walter Nissen
  • 16,451
  • 4
  • 26
  • 27
973
votes
22 answers

How do I expand the output display to see more columns of a Pandas DataFrame?

Is there a way to widen the display of output in either interactive or script-execution mode? Specifically, I am using the describe() function on a Pandas DataFrame. When the DataFrame is five columns (labels) wide, I get the descriptive statistics…
beets
  • 10,261
  • 4
  • 18
  • 11
824
votes
17 answers

How to see normal print output created during pytest run?

Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to "exercise" it is with existing pytest tests. But when I run these, I don't seem able to see any standard output (at…
Des
  • 9,195
  • 4
  • 18
  • 21
785
votes
12 answers

How to print instances of a class using print()?

When I try to print an instance of a class, I get an output like this: >>> class Test(): ... def __init__(self): ... self.a = 'foo' ... >>> print(Test()) <__main__.Test object at 0x7fc9a9e36d60> How can I make it so that the print will…
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
766
votes
13 answers

Print a file, skipping the first X lines, in Bash

I have a very long file which I want to print, skipping the first 1,000,000 lines, for example. I looked into the cat man page, but I did not see any option to do this. I am looking for a command to do this or a simple Bash program.
Eduardo
  • 19,928
  • 23
  • 65
  • 73
663
votes
23 answers

How to use HTML to print header and footer on every printed page of a document?

Is it possible to print HTML pages with custom headers and footers on each printed page? I'd like to add the word "UNCLASSIFIED" in Red, Arial, size 16pt to the top and bottom of every printed page, regardless of the content. To clarify, if the…
ben
558
votes
11 answers

How do I hide an element when printing a web page?

I have a link on my webpage to print the webpage. However, the link is also visible in the printout itself. Is there javascript or HTML code which would hide the link button when I click the print link? Example: "Good Evening" Print (click Here To…
sourav
541
votes
33 answers

Print
only?

How do I print the indicated div (without manually disabling all other content on the page)? I want to avoid a new preview dialog, so creating a new window with this content is not useful. The page contains a couple of tables, one of them contains…
noesgard
  • 5,917
  • 3
  • 20
  • 27
515
votes
16 answers

How to make a HTML Page in A4 paper size page(s)?

Is it possible to make a HTML page behave, for example, like a A4-sized page in MS Word? Essentially, I want to be able to show the HTML page in the browser, and outline the content in the dimensions of an A4 size page. For the sake of simplicity,…
Zabba
  • 64,285
  • 47
  • 179
  • 207
508
votes
16 answers

The difference between sys.stdout.write and print?

Are there situations in which sys.stdout.write() is preferable to print? (Examples: better performance; code that makes more sense)
Johanna Larsson
  • 10,531
  • 6
  • 39
  • 50
414
votes
31 answers

Print the contents of a DIV

Whats the best way to print the contents of a DIV?
usertest
  • 27,132
  • 30
  • 72
  • 94
404
votes
30 answers

How can I write to the console in PHP?

Is it possible write a string or log into the console? What I mean Just like in JSP, if we print something like system.out.println("some"), it will be there at the console, not at a page.
Labeeb Panampullan
  • 34,521
  • 28
  • 94
  • 112
383
votes
13 answers

How can I print multiple things (fixed text and/or variable values) on the same line, all at once?

I have some code like: score = 100 name = 'Alice' print('Total score for %s is %s', name, score) I want it to print out Total score for Alice is 100, but instead I get Total score for %s is %s Alice 100. How can I get everything to print in the…
user1985351
  • 4,589
  • 6
  • 22
  • 25
1
2 3
99 100