can't assign to literal

M

maehhheeyy

this is stopping my program from running properly. is there something
wrong in my code when that happens?
 
M

Matimus

this is stopping my program from running properly. is there something
wrong in my code when that happens?

yes

Post your code, or at least the full error message if you want more
details.

Matt
 
M

maehhheeyy

yes

Post your code, or at least the full error message if you want more
details.

Matt

for 1 in oids, vals head_oids:
SyntaxError: can't assign to literal
 
S

Steven Clark

for 1 in oids, vals head_oids:
SyntaxError: can't assign to literal
--

1 is a literal, you can't assign it to something. Are you trying to
use it as a variable name?
 
M

MRAB

1 is a literal, you can't assign it to something. Are you trying to
use it as a variable name?

Slightly OT, but is there an editor that can display digits in a
different colour to letters?
 
C

Chris

Slightly OT, but is there an editor that can display digits in a
different colour to letters?

SciTE and Notepad++ which are just 2 of the editors installed on my PC
currently.
 
L

Lie

Slightly OT, but is there an editor that can display digits in a
different colour to letters?

Most programmer oriented editors could, some even have full syntax
coloring, they would color keywords (like def, class, etc), literals
(1, 'hello', etc), and commonly used built-in function (int, ord,
iter, etc). It really helped if you have to read/write lots of codes
 
T

TheSaint

SciTE and Notepad++
Pype, spe, just to point it out. Jedit, but rather a bloatware.
I'd like to know which is the litest multi platform and indipendent.
Pype is very good when compiled in exe, but not doing in Linux in that way.
 
L

Lie

this is stopping my program from running properly. is there something
wrong in my code when that happens?

That simply means you did something like this:
'hello' = 'another'
123 = 'kilo'
[12, 'asd] = 123

Sometimes it's not that obvious (although they're obvious for a more
experienced programmers):
for 123 in xrange(10):
pass

I think you've realized what you've done. And there is a pretty
obvious signal that hints that you didn't know the basic syntax of
python (or at least the basic syntax of the for-loop).
 
E

Ethan Furman

MRAB said:
Slightly OT, but is there an editor that can display digits in a
different colour to letters?

I like Vim (Vi Improved) -- multi-platform, multi-lingual (both spoken
and programmatic), and you can change the existing syntax/color/indent
files or make your own.

http://www.vim.org/
 
E

Ethan Furman

TheSaint said:
What about justifying text ?

Do you mean indenting, or wrapping? Vim has excellent indenting
support, and Python files already included that support proper
indenting, syntax coloring, etc.

I don't use the line-wrapping feature myself, so I have no experience
with it.
 
T

TheSaint

Do you mean indenting, or wrapping?
I mean fill the line by increasing spaces between words in order to get a
paragraph aligned both side, left and right on the page.
So if the width is 78 chars it wouldn't have jig saw end to the right side,
unless applying some word hyphenation.
This feature would be nice for writing here and some plain documentation
plain text. Beside that it might doing for Python scripts as well.
 
C

Chris

I mean fill the line by increasing spaces between words in order to get a
paragraph aligned both side, left and right on the page.
So if the width is 78 chars it wouldn't have jig saw end to the right side,
unless applying some word hyphenation.
This feature would be nice for writing here and some plain documentation
plain text. Beside that it might doing for Python scripts as well.

You should strip all extraneous white space from code though.
 
E

Ethan Furman

TheSaint said:
I mean fill the line by increasing spaces between words in order to get a
paragraph aligned both side, left and right on the page.
So if the width is 78 chars it wouldn't have jig saw end to the right side,
unless applying some word hyphenation.
This feature would be nice for writing here and some plain documentation
plain text. Beside that it might doing for Python scripts as well.

I don't think justification is built in. It does offer it's own script
language, though, so you could write your own function to do that, and
then only apply it to the doc strings, etc.
 
T

TheSaint

Word spaced line justification is only feasible if one is using a
fixed width font and have a line length defined in "characters/line".

===8<======8<======8<======8<======8<======8<======8<======8<======8<======8<

line= 'fixed width font and have a line length defined in "characters/line".'

lenLine= 78; newLine= ''; Words= line.split(' ')
lnWords= len(Words); norm_spc= lnWords-1; xtr_spc = lenLine -len(line)
lenChr= len(line)-norm_spc
numspc= (norm_spc+ xtr_spc)/ norm_spc
lstword= len(Words[norm_spc])
for spc in range(lnWords):
if len(newLine)+lstword + numspc > lenLine : break
newLine += Words[spc]+(' '* numspc)
if xtr_spc:
newLine += ' '; xtr_spc -= 1
print newLine+ ' '+ Words[spc]

===8<======8<======8<======8<======8<======8<======8<======8<======8<======8<

In my mind it took me just few seconds :), but to get it working I spent
nearly *one* hour. I admit that my skill lacks of knowledge ])
 
T

TheSaint

-=-=-=-=-=-=- (make sure you have a fixed width client)
Very good indeed :) Specially to do with block reformatting.
I just post my script to demonstrate my thoughts in what I meant as
justifying. Specially considering that I meant character justification
regardless of its width. Monospace chars will show pretty alignment.

BTW, I'm beginner and my coding takes much try-and-test. ;)
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top