Print command

Y

Yong Wang

Hi, All:
For unknow reasons, I often get compiler error in the print
statements. For example: I have following codes:

if len(currentFiberCode) > 0 :
print string.ljust(expandFiberCode(currentFiberCode,buildingRoom),30), \
string.rjust(`currentTotal`,6), \
string.rjust(`currentAvailable`,11), \
string.rjust(`sm_ava`,7), \
string.rjust(`mm_ava`,6), \
string.rjust(`sm_used`,9), \
string.rjust(`mm_used`,9)
else:
print 'data exist in fiber database table'

When I comiped all the codes, I got :
Compiling ./NetDBfiber.py ...
File "./NetDBfiber.py", line 1086
string.rjust(`currentTotal`,6), \
^
SyntaxError: invalid token


How can I fix the problems ?
Thanks a lot.

Yong
 
W

wes weston

Yong said:
Hi, All:
For unknow reasons, I often get compiler error in the print
statements. For example: I have following codes:

if len(currentFiberCode) > 0 :
print string.ljust(expandFiberCode(currentFiberCode,buildingRoom),30), \
string.rjust(`currentTotal`,6), \
string.rjust(`currentAvailable`,11), \
string.rjust(`sm_ava`,7), \
string.rjust(`mm_ava`,6), \
string.rjust(`sm_used`,9), \
string.rjust(`mm_used`,9)
else:
print 'data exist in fiber database table'

When I comiped all the codes, I got :
Compiling ./NetDBfiber.py ...
File "./NetDBfiber.py", line 1086
string.rjust(`currentTotal`,6), \
^
SyntaxError: invalid token


How can I fix the problems ?
Thanks a lot.

Yong

Yong,
Is there a trailing space after the \ ? Looks like it.
wes
 
C

CptPicard

I think that you should try:
string.rjust('currentTotal',6)
instead of:
string.rjust(`currentTotal`,6)

You may also do it this this way:
'currentTotal'.rjust(6)


Yong Wang said:
Hi, All:
For unknow reasons, I often get compiler error in the print
statements. For example: I have following codes:

if len(currentFiberCode) > 0 :
print
string.ljust(expandFiberCode(currentFiberCode,buildingRoom),30), \
 
R

Russell Blau

CptPicard said:
I think that you should try:
string.rjust('currentTotal',6)
instead of:
string.rjust(`currentTotal`,6)

You may also do it this this way:
'currentTotal'.rjust(6)

No, I think he really did want the "backwards" single quotation marks. They
*are* different, you know...
 
C

CptPicard

Russell Blau said:
No, I think he really did want the "backwards" single quotation marks. They
*are* different, you know...

Actually, I don't know the meaning of ``.
On some languages, it means "evaluate": Is it the same meaning in Python ?
 
P

Peter Hansen

Russell Blau said:
> Actually, I don't know the meaning of ``.
> On some languages, it means "evaluate": Is it the same meaning in
> Python?

Why ask when you can do? :
Traceback (most recent call last):
'2'
 
R

Russell Blau

Ummm, actually, that wasn't me you were quoting; it was the OP who replied
to my message pointing out that `x` doesn't mean the same as 'x'.
 
P

Peter Hansen

Russell said:
Ummm, actually, that wasn't me you were quoting; it was the OP who replied
to my message pointing out that `x` doesn't mean the same as 'x'.

Quite right... my apologies for the bad editing. It was
'Cpt Picard' who wrote that, not Russell.

-Peter
 
C

CptPicard

Peter Hansen said:
Quite right... my apologies for the bad editing. It was
'Cpt Picard' who wrote that, not Russell.

Thank you for the explanation on `` and for the fun ;-)

And sorry for asking for things that I could check by myself but the "you
know" at the end of Russel Blau's email sounds like a call for me to say
"no, actually, I don't know".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top