Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

python - Printing without newline (print 'a',) prints a space, how to remove? -


i have code:

>>> in xrange(20): ...     print 'a', ...  a a a a a a a a a a 

i want output 'a', without ' ' this:

aaaaaaaaaaaaaaaaaaaa 

is possible?

there number of ways of achieving result. if you're wanting solution case, use string multiplication @ant mentions. going work if each of print statements prints same string. note works multiplication of length string (e.g. 'foo' * 20 works).

>>> print 'a' * 20 aaaaaaaaaaaaaaaaaaaa 

if want in general, build string , print once. consume bit of memory string, make single call print. note string concatenation using += linear in size of string you're concatenating fast.

>>> in xrange(20): ...     s += 'a' ...  >>> print s aaaaaaaaaaaaaaaaaaaa 

or can more directly using sys.stdout.write(), print wrapper around. write raw string give it, without formatting. note no newline printed @ end of 20 as.

>>> import sys >>> in xrange(20): ...     sys.stdout.write('a') ...  aaaaaaaaaaaaaaaaaaaa>>>  

python 3 changes print statement print() function, allows set end parameter. can use in >=2.6 importing __future__. i'd avoid in serious 2.x code though, little confusing have never used 3.x. however, should give taste of of goodness 3.x brings.

>>> __future__ import print_function >>> in xrange(20): ...     print('a', end='') ...  aaaaaaaaaaaaaaaaaaaa>>>  

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -