I got Ytterbijum's code to see what you meant by the new line at the end, and there's a reason that I didn't notice it, because it doesn't exist!
The output from this code:
import sys
w=sys.stdout.write
w('1')
for i in range(1001):
if i%7!=0 and any([i%n==0 for n in range(2,i)]):w(' %d'%i)
and this code:
d='1'
for i in range(1001):
if i%7!=0 and any([i%n==0 for n in range(2,i)]):d=d+' '+str(i)
print d
Is exactly the same. the MD5 is 72014911BE26119697EDB0D393EA9D60.
On screen, both output this:
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.2.2
>>> ================================ RESTART ================================
>>>
1 4 6 8 9 10 12 ....... 995 996 998 999 1000
>>>
The only way to rid yourself of the line at the end is to make sure that the program doesn't finish.
On a semi related note, this is my feeble attempt at making the shortest compiled code:
segment.data
x dw 1 ;reserves 16 bits mem for x
g db "1 $" ;g = '1 $'
y dw 2 ;y = 2 (16 bits)
segment.text
org 100h ;starts program
mov cx, [y] ;CX = y
mov bx, [x] ;BX = x
mov dx, g ;DX = g
mov ah, 9 ;ah needs to be 9 for stdout
int 21h ;dos service interupt(stdout)
whilex ;while x<1000: (label only)
inc bx ;x+=1
mov cx, 2 ;y=2
whiley ;while y<x: (label)
inc cx ;y+=1
cmp bx, cx ;while y<x: compare x, y
jnc whiley ;goto whiley if cf=0
cmp bx, 1000 ;while x<1000> 1000
mov ah,4CH ;ends program
int 21h
It's not finished. This program outputs "1 ". Each line represents one opcode except for pseudo codes.