Skip to main content
Filter by
Sorted by
Tagged with
2452 votes
36 answers
3.4m views

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 = ...
Alex Spurling's user avatar
1813 votes
17 answers
1.4m views

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 ...
wim's user avatar
  • 368k
1638 votes
14 answers
1.2m views

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 ...
Walter Nissen's user avatar
1044 votes
23 answers
1.8m views

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 ...
beets's user avatar
  • 11k
851 votes
13 answers
1.5m views

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__....
Ashwin Nanjappa's user avatar
838 votes
13 answers
736k views

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 ...
Eduardo's user avatar
  • 21.2k
703 votes
23 answers
743k views

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, ...
user avatar
575 votes
11 answers
626k views

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 ...
567 votes
37 answers
1.0m views

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 ...
noesgard's user avatar
  • 6,199
537 votes
16 answers
994k views

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 ...
Zabba's user avatar
  • 65.6k
528 votes
16 answers
814k views

Are there situations in which sys.stdout.write() is preferable to print? (Examples: better performance; code that makes more sense)
Johanna Larsson's user avatar
430 votes
32 answers
1.1m views

Whats the best way to print the contents of a DIV?
usertest's user avatar
  • 27.7k
425 votes
30 answers
1.9m views

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's user avatar
413 votes
15 answers
552k views

I'm making a HTML report that is going to be printable, and it has "sections" that should start in a new page. Is there any way to put something in the HTML/CSS that will signal to the browser that ...
Daniel Magliola's user avatar
394 votes
14 answers
1.3m views

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 ...
user1985351's user avatar
  • 4,719
377 votes
22 answers
751k views

I would like to make several statements that give standard output without seeing newlines in between statements. Specifically, suppose I have: for item in range(1,100): print item The result is: ...
Pol's user avatar
  • 25.7k
374 votes
10 answers
509k views

I am using iPython notebook. When I do this: df I get a beautiful table with cells. However, if i do this: df1 df2 it doesn't print the first beautiful table. If I try this: print df1 print df2 ...
Chris's user avatar
  • 13.8k
330 votes
23 answers
473k views

I am trying to print a page. In that page I have given a table a background color. When I view the print preview in chrome its not taking on the background color property... So I tried this property: ...
user avatar
324 votes
18 answers
573k views

I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings? And what are the options ...
doekman's user avatar
  • 19.4k
321 votes
4 answers
781k views

I need simulate an A4 paper in web and allow to print this page as it is show on browser (Chrome, specifically). I set the element size to 21cm x 29.7cm, but when I send to print (or print preview) it ...
David Rodrigues's user avatar
321 votes
13 answers
514k views

I have a project which requires printing an HTML table with many rows. My problem is the way the table is printed over multiple page. It will sometimes cut a row in half, making it unreadable because ...
h3.'s user avatar
  • 11.1k
319 votes
2 answers
261k views

In Java, I can override the toString() method of my class. Then Java's print function prints the string representation of the object defined by its toString(). Is there a Python equivalent to Java's ...
snakile's user avatar
  • 54.9k
309 votes
7 answers
149k views

I'm attempting to customize the print CSS, and finding that it prints links out with the href value as well as the link. This is in Chrome. For this HTML: <a href="http://www.google.com">...
Chris Gratigny's user avatar
304 votes
12 answers
239k views

I'm writing a plug-in for a piece of software that takes a big collection of items and pops them into HTML in a WebView in Cocoa (which uses WebKit as its renderer, so basically you can assume this ...
joeylange's user avatar
  • 3,223
289 votes
18 answers
755k views

E.g: print "hello" What should I do to make the text "hello" bold?
Jia-Luo's user avatar
  • 3,323
288 votes
18 answers
651k views

I want to run a script, which basically shows an output like this: Installing XXX... [DONE] Currently, I print Installing XXX... first and then I print [DONE]. How can I instead print ...
user697108's user avatar
  • 3,651
269 votes
13 answers
596k views

I've got a javascript object which has been JSON parsed using JSON.parse I now want to print the object so I can debug it (something is going wrong with the function). When I do the following... for (...
Skizit's user avatar
  • 45.1k
265 votes
6 answers
127k views

I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server ...
Erik Forbes's user avatar
257 votes
10 answers
489k views

How can I print a pandas dataframe as a nice text-based table, like the following? +------------+---------+-------------+ | column_one | col_two | column_3 | +------------+---------+-------------+ ...
Ofer's user avatar
  • 3,193
254 votes
18 answers
1.8m views

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 ...
Bob Uni's user avatar
  • 2,681
250 votes
9 answers
684k views

Is there a way to print text and variable contents on the same line? For example, wd <- getwd() print("Current working dir: ", wd) I couldn't find anything about the syntax that would allow me to ...
user avatar
248 votes
13 answers
107k views

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 ...
Jim Puls's user avatar
  • 81.4k
244 votes
15 answers
316k views

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 ...
Bart's user avatar
  • 11k
223 votes
19 answers
988k views

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)...
Jett's user avatar
  • 2,559
216 votes
22 answers
318k views

How can I print a binary tree in Java so that the output is like: 4 / \ 2 5 My node: public class Node<A extends Comparable> { Node<A> left, right; A data; public ...
Tian's user avatar
  • 2,473
214 votes
12 answers
295k views

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 { ...
TIMEX's user avatar
  • 275k
210 votes
7 answers
89k views

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 ...
Russ's user avatar
  • 11.4k
210 votes
9 answers
116k views

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 ...
Sam Odio's user avatar
  • 3,105
203 votes
10 answers
300k views

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 ...
Anthony's user avatar
  • 37.2k
198 votes
3 answers
382k views

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 = (&...
Alex 's user avatar
  • 2,287
194 votes
11 answers
412k views

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's user avatar
  • 2,645
178 votes
10 answers
119k views

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's user avatar
  • 51.8k
175 votes
7 answers
417k views

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's user avatar
  • 4,973
171 votes
14 answers
239k views

This question was asked before but the solution is not applicable in my case. I want to make sure certain background images are printed because they are integral to the page. (They are not images ...
DisgruntledGoat's user avatar
165 votes
9 answers
304k views

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 ...
Jay Q.'s user avatar
  • 5,009
162 votes
17 answers
384k views

I am using window.print() for printing page, but I got header and footer contains page title, file path, page number and date. How to remove them? I tried print stylesheet also. #header, #nav, ....
Viralk's user avatar
  • 2,419
161 votes
6 answers
870k views

I want to print some HTML content, when the user clicks on a button. Once the user clicks on that button, the print dialog of the browser will open, but it will not print the webpage. Instead, it will ...
Debiprasad's user avatar
  • 6,243
161 votes
6 answers
460k views

How can I print the filepath and filename values from each row? Array ( [0] => Array ( [fid] => 14 [list] => 1 [data] => Array ( ...
esafwan's user avatar
  • 18.2k
157 votes
9 answers
381k views

I have this python program that adds strings to integers: a = raw_input("Enter a: ") b = raw_input("Enter b: ") print "a + b as strings: " + a + b a = int(a) b = int(b) c ...
plahstic's user avatar
  • 1,621
156 votes
10 answers
169k views

I am running GDB and want to examine one of those unfortunate god objects. It takes many pages (and I have a 24" monitor turned sideways!) to see the whole thing. For ease of use, I'd like GDB to ...
pythonic metaphor's user avatar

1
2 3 4 5
465