XCode Formatting issue for python files -


i have used xcode create several python scripts. appears in editor fine, however, when attempt @ code through terminal, i'm seeing new lines being encoded "^m". problematic, since collaborating through github, , diff features not work when being done.

e.g.: source:

############# # #   test.py # #   author # #############  if __name__ == "__main__":     print "this test" 

when save through editor (pycharmer) , more via console, output expected. when create new file via xcode, past same text, , save, following:

#############^m#^m#   test.py^m#^m#   author^m#^m#############^mif __name__ == "__main__":^m    print "this test" 

out of curiosity, tried creating test .cc file, , same formatting issue did not arise, if want bonus points, explaining inconsistency interesting well.

in latest xcode 6, if create new external-build-system project, set build tool /usr/bin/python or /usr/local/bin/python3, create new file named test.py in project, xcode recognizes type (which can see in file inspector panel of assistant editor) "default — python script", , text settings (which can see in file inspector) as:

text encoding: unicode (utf-8) line endings: default — os x / unix (lf) indent using: spaces widths: tab: 4 indent: 4 wrap lines: checked

and python syntax coloring, tab completions, etc.

if that's not right—in particular, if see line endings "classic mac os (cr)"—you can change current file right there in panel.

that fixes current file. may not fix next file create, try , see.

if not: in xcode 4 , 5, change default settings each language, no longer seems exposed in xcode 6. however, may want try going "text editing" pane of "preferences" dialog, , making sure "default line endings" set "os x / unix (lf)", , maybe "convert existing files on save" checked. if you've got default settings classic mac, c/objc/c++ overriding unix. if, on other hand, somehow have leftover override python earlier version of xcode, i'm not sure how can undo short of wiping of xcode settings , starting clean.

from quick search, this answer has detailed version of of steps involved in configuring python projects handle things run , debug commands , on, may tangentially helpful.