Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

UPDATE: I resolved this issue - it was an issue with a capitalization of a variable earlier on.

I am new to both python and stackOverflow so pardon any etiquette mistakes that i make.

I am trying to figure out correct syntax for python. If i define a variable that is a long string of information - text and numbers and such like so: (its embedded metadata from a file)

coorSys=str(sD.metadata['coordinate system string'])

then i call it to write to a part of a file like so

where.attrs['Coord System Descript']= 'full string %s' % coorSys

where the syntax i need to follow is

where.attrs['Coord System Descript']='text here' 

what is the proper syntax? what i have isn't working. I also tried

where.attrs['Coord System Descript']='full string' & str(coorSys)

I know that coorSys returns the full string as it should... so the variable is right. many thanks in advance for any input. leah

share|improve this question

put on hold as unclear what you're asking by Karl Knechtel, Antti Haapala, larsmans, tobias_k, Jon Clements yesterday

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Are you saying, in the file you are writing, you need to write the literal string where.attrs['Coord System Descript']='x' and x is the value of the coorSys variable? I am not sure what "where the syntax I need to follow" means. –  Burhan Khalid 2 days ago
    
What do you mean by "call it to write to part of a file"? How exactly do you expect the line in question to do that? What is where, and what has it got to do with files? Are you trying to make your Python script create a new file with Python code in it? If so, why? –  Karl Knechtel 2 days ago
    
what i have isn't working is not very explicit ... Please give at least a full example of input and the desired output –  Serge Ballesta 2 days ago
    
THANK YOU ALL for the feedback. I sincerely appreciate it AND i've learned how to post more appropriately in the future (more detail). I figured out the error. It was something earlier in the code that had to do with a capitalization error. I am learning how sensitive python is to spaces and caps. –  user3908816 yesterday

Browse other questions tagged or ask your own question.