Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   \ in idle? (http://www.programmingforums.org/showthread.php?t=12851)

thondal Mar 20th, 2007 10:14 AM

\ in idle?
 
trying to write some python on my macbook, but when in idle I cannot make the \. Why? Everywhere else it works. Just not in idle, I can make every other characters even the /, but just not \. Can somebody help me please? Using macbook intel with OS 10.4.9 if that helps you in helping me.


-thondal-

kurt Mar 20th, 2007 10:26 AM

i'm a n00b programmer, but i'll try to answer anyway.

Are you trying to print out \ ?

Probably need an escape sequence to print it out, e.g:
\\
\"

Sane Mar 20th, 2007 12:46 PM

Yes, Python, like almost all other languages, reserves the "\" character for identifying escape sequences. If you want to output a newline you print "\n", a tab is "\t", an alert is "\a", etc, etc...

You can get a complete list on all of the different escape sequences.

To output a slash, you can write, as kurt mentioned:
:

print "This is one slash: \\ ... \nThis is two slashes: \\\\"

Escape sequences can also be used to output an apostraphe without closing your print statement:
:

print "Look! An apostraphe: \" ... And yet this is still printed out!"
print 'Another apostraphe: \' ... More text'


thondal Mar 22nd, 2007 9:11 AM

no.... i meant just the \.. at all in idle.. i canīt write it at all.. is this a common problem in idle..

I know enough python to know how to print it out.. problem is, i canīt write it at all when iīm in idle.. i can when i write it in word, and other places, like here.. i know it is the alt+command 7, but it wonīt show when I try to write it...

-thondal-

DaWei Mar 22nd, 2007 9:16 AM

Hmmm. Are you saying there's not a key for it on your particular keyboard, and that a sequence that normally generates it is not being interpreted properly by Idle?

thondal Mar 22nd, 2007 9:23 AM

well.. on my norwegian keyboard there is only one way to get it, and that is to do command+shift 7... but where is that button on the ameriac/us/english layout? because if there is a button for it there, then i could just change over to that kind of layout and write code.. got a picture of one? :D

-thondal-

thondal Mar 22nd, 2007 9:42 AM

Okay, so i just changed my keyboard layout to the us layout, and now i can use the \... hurray....

DaWei Mar 22nd, 2007 10:02 AM

Great. Incidentally, on a typical US keyboard the '\' is right below the backspace key. I'm mildly surprised that there isn't a dedicated key for it, given its common usage as a path delimiter, as well as (for programming-type users) an escape character.

Arevos Mar 22nd, 2007 10:45 AM

Quote:

Originally Posted by DaWei (Post 125587)
I'm mildly surprised that there isn't a dedicated key for it, given its common usage as a path delimiter, as well as (for programming-type users) an escape character.

I believe OS X uses the forward slash character as the standard path delimiter, so perhaps a Norwegian Macbook keyboard doesn't bother with having an easy-to-find backslash, as presumably it's rarely used.

thondal Mar 23rd, 2007 7:26 PM

well, i found it rather difficult to program in python(idle) when i have to use us layout, because i have no idea where the " are, and all the other stuff, it kinda gets upside down. So, think I have to find a norwegian forum for this one. Sorry to bother you guys, and Dawei, thanks for the quick reply.

-thondal-


All times are GMT -5. The time now is 11:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC