Re: [Tutor] code works in windows command but not ubuntu terminal
On 01/26/2014 02:12 AM, Steven D'Aprano wrote: On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: As a foreigner, I noticed that english native speakers use both the series round / square / curly / angle brackets, and individual terms parens (no 'd' ;-) / brackets / braces / chevrons. No major issue, except for 'brackets' which can be either a collective term or specific to []. In the UK and Australia, "brackets" on its own refers to round brackets (parentheses), as they are the most common form. We never use "brackets" on its own to mean [], but only (), and the only time we bother to say "round brackets" is when there is a need to disambiguate them from square ones. I learn english everyday ;-) thank you, Steven! d ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 26/01/2014 01:55, Steven D'Aprano wrote: This is an international forum, and English an international language with many slight differences between variations and dialects. Even in American English alone, there are ambiguous terms. "Coke" could mean a beverage by the Coca-Cola company, a generic or rival cola beverage, a generic carbonated beverage of arbitrary flavour, an illegal drug, or a type of coal. http://strangemaps.wordpress.com/2008/08/18/308-the-pop-vs-soda-map/ Somehow Americans cope with that. They can learn to cope with the many flavours of brackets as well :-) Still my favourite http://english.stackexchange.com/questions/16285/what-is-the-meaning-of-the-expression-we-can-table-this as it caused a row between UK and US commanders during WWII. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Sat, Jan 25, 2014 at 02:39:11PM -0500, bob gailer wrote: > On 1/24/2014 10:28 PM, bob gailer wrote: > > Sorry for misspelling parens. > > My reason for requesting the various names is that it makes > communication clear, explicit and terse. > > When someone says just "brackets" what does he actually mean? It's possible to write ambiguous or unclear sentences about anything, not just brackets. Singling out them out for special treatment makes little sense to me. The nature of the English language is that we can write unclear sentences: "And then she told her that she knew that he said that she knew about that time he and she kissed at a party..." How many people are involved? This is an extreme case, exaggerated for effect, but people do speak like that and given a little bit of context people are usually pretty good at disambiguation. Compared to that, inferring the required type of bracket is usually trivial. If I'm talking to other Australians, I'll generally use "bracket" on its own to mean round () brackets, as that's the normal use here. In an international context, it will be either obvious from context, or generic and apply equally to any sort of bracket. E.g. if I'm talking about a line of code that says print(mylist.index(None) and say "you're missing the closing bracket", is it really so confusing to infer that it's a closing ROUND bracket ) rather than a square bracket ] that is needed? Even a beginner should be able to work that out. But I'm only human, and it is possible that at some point I'll make a mistake and write a confusing sentence where the meaning cannot be inferred, whether that's about brackets or something else doesn't matter. If you, or anyone else, catches me making a *specific* ambiguous statement that is unclear, regardless of whether it is due to the word "bracket" or not, then I welcome people asking me to clarify. This is an international forum, and English an international language with many slight differences between variations and dialects. Even in American English alone, there are ambiguous terms. "Coke" could mean a beverage by the Coca-Cola company, a generic or rival cola beverage, a generic carbonated beverage of arbitrary flavour, an illegal drug, or a type of coal. http://strangemaps.wordpress.com/2008/08/18/308-the-pop-vs-soda-map/ Somehow Americans cope with that. They can learn to cope with the many flavours of brackets as well :-) > For more grins see > http://www.codinghorror.com/blog/2008/06/ascii-pronunciation-rules-for-programmers.html > and http://www.theasciicode.com.ar/ Nice :-) -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: > As a foreigner, I noticed that english native speakers use both the series > round / square / curly / angle brackets, and individual terms parens (no > 'd' ;-) / brackets / braces / chevrons. No major issue, except for > 'brackets' which can be either a collective term or specific to []. In the UK and Australia, "brackets" on its own refers to round brackets (parentheses), as they are the most common form. We never use "brackets" on its own to mean [], but only (), and the only time we bother to say "round brackets" is when there is a need to disambiguate them from square ones. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 25/01/14 19:39, bob gailer wrote: On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? In UK English speaking places 'brackets' by default means what US English speakers call parentheses. Whereas parentheses means any kind of parenthetical expression which includes dashes, quotes and any kind of bracket etc. This was one of the biggest surprises when I first wrote a book for a US publisher. One reviewer went so far as to suggest that my level of "illiteracy" meant the book should be rejected, because if I spelt parentheses as brackets how could I possibly know anything about programming... I actually intended pulling together a list of all the Americanisms that I had to modify in my original text but deadlines got in the way and I never got round to it. But I was amazed at how many language changes were necessary. Language is a funny thing. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? For more grins see http://www.codinghorror.com/blog/2008/06/ascii-pronunciation-rules-for-programmers.html and http://www.theasciicode.com.ar/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 25/01/2014 03:28, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. Not in the UK or Australia, with the former being where English came from. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 01/25/2014 05:14 AM, Steven D'Aprano wrote: On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all brackets. Often the type of bracket doesn't matter, but when it does, adjectives do a perfectly fine job at distinguishing one from the other: round brackets, square brackets, and curly brackets are well-known and in common use all over the Commonwealth, and have been established since the mid 1700s. As a sop to Americans, who I understand are easily confused by ordinary English *wink*, the Unicode consortium describes () as parentheses: py> unicodedata.name("(") 'LEFT PARENTHESIS' but [] and {} are described as brackets: py> unicodedata.name("[") 'LEFT SQUARE BRACKET' py> unicodedata.name("{") 'LEFT CURLY BRACKET' As are angle brackets: py> unicodedata.lookup("LEFT ANGLE BRACKET") '〈' py> unicodedata.lookup("RIGHT ANGLE BRACKET") '〉' As a foreigner, I noticed that english native speakers use both the series round / square / curly / angle brackets, and individual terms parens (no 'd' ;-) / brackets / braces / chevrons. No major issue, except for 'brackets' which can be either a collective term or specific to []. HTML uses ASCII less-than and greater-than signs as angle brackets. Physicists even have a pun about them, with "bra-ket" notation for quantum state: http://en.wikipedia.org/wiki/Bra-ket_notation funny There are a number of other types of brackets with more specialised uses, or common in Asian texts. See http://en.wikipedia.org/wiki/Bracket By the way, the word "bracket" itself is derived from the French and Spanish words for "codpiece". That's not relevant to anything, I just thought I'd mention it. Apparently, according to wiktionary, it may come from an old germanic root through Gaulish: https://en.wiktionary.org/wiki/bracket#Etymology << Etymology From earlier bragget, probably from Middle French braguette, from Old French braguette (“the opening in the fore part of a pair of breeches”), from Old Provençal braga, from Latin brāca (“pants”), from Transalpine Gaulish *brāca (“pants”), perhaps from or related to similar forms in Germanic: compare Old English braccas (“pants”), Old English brōc (“breeches”), from Proto-Indo-European *bʰrāg-, from *bʰreg- (“to break, crack, split, divide”). More at breech, britches. >> d ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Fri, Jan 24, 2014 at 8:38 PM, Steven D'Aprano wrote: > > However, there's more to it than this. For starters, you need to decide > on the exact behaviour. Clearly, "file not found" errors should move on > to try the next prefix in the path list. But what about permission > denied errors? Prior to 3.3, I/O operations raise an IOError, except functions in the os module raise an OSError. Inspect the exception `errno` attribute for the error code. Named error constants are available in the errno module. 3.3 makes IOError an alias for OSError and maps several of the more common error codes to subclasses that have descriptive names. Here are some examples where 3.3 OSError returns a sublcass: >>> for code in [errno.EPERM, errno.ENOENT, ... errno.EACCES, errno.EISDIR]: ... OSError(code, os.strerror(code)) ... PermissionError(1, 'Operation not permitted') FileNotFoundError(2, 'No such file or directory') PermissionError(13, 'Permission denied') IsADirectoryError(21, 'Is a directory') ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: > And please call () parends and [] brackets, and{} braces. Saves a lot of > confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all brackets. Often the type of bracket doesn't matter, but when it does, adjectives do a perfectly fine job at distinguishing one from the other: round brackets, square brackets, and curly brackets are well-known and in common use all over the Commonwealth, and have been established since the mid 1700s. As a sop to Americans, who I understand are easily confused by ordinary English *wink*, the Unicode consortium describes () as parentheses: py> unicodedata.name("(") 'LEFT PARENTHESIS' but [] and {} are described as brackets: py> unicodedata.name("[") 'LEFT SQUARE BRACKET' py> unicodedata.name("{") 'LEFT CURLY BRACKET' As are angle brackets: py> unicodedata.lookup("LEFT ANGLE BRACKET") '〈' py> unicodedata.lookup("RIGHT ANGLE BRACKET") '〉' HTML uses ASCII less-than and greater-than signs as angle brackets. Physicists even have a pun about them, with "bra-ket" notation for quantum state: http://en.wikipedia.org/wiki/Bra-ket_notation There are a number of other types of brackets with more specialised uses, or common in Asian texts. See http://en.wikipedia.org/wiki/Bracket By the way, the word "bracket" itself is derived from the French and Spanish words for "codpiece". That's not relevant to anything, I just thought I'd mention it. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 1/24/2014 4:47 AM, Steven D'Aprano wrote: Hi Tobias, and welcome. On Thu, Jan 23, 2014 at 07:34:18PM -0700, Tobias Quezada wrote: hello community,i am a newbie to python and program in general. the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal. fp=open("prez.dat","r") x=fp.read (print(x) ***i used fp for file pointer.I am using windows 7 and it works Are you sure this is the *exact* same code you use on Windows 7? Because it won't read the file, it will fail with a SyntaxError due to the missing close bracket after the print. This is Python 2.7.3, not 3.x. The error is due to a ( in front of the print statement. And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Fri, Jan 24, 2014 at 04:31:49PM -0500, Keith Winston wrote: > On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano wrote: > > Python does not use a search path for the open() function, only for > > imports. With open(), it uses a simple rule: > > > > - absolute paths will look only in that exact location; > > > > - relative paths are always relative to the current working directory. > > > > Do you know the difference between absolute and relative paths? > > Ah! I was just running into this... I did not know that. So there's no > way to get it to search a path (other than coding some string > concatenation of path names or something, of course) to open a file? Of course there is -- you just have to program it yourself! First, decide whether the filename is absolute or relative. Absolute filenames should not search the path. Then, if it is relative, loop over your "open path list" like this: for prefix in open_path_list: location = os.path.join(prefix, filename) try: f = open(location) except IOError: pass else: break However, there's more to it than this. For starters, you need to decide on the exact behaviour. Clearly, "file not found" errors should move on to try the next prefix in the path list. But what about permission denied errors? -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
> Ah! I was just running into this... I did not know that. So there's no > way to get it to search a path (other than coding some string > concatenation of path names or something, of course) to open a file? Potentially distutils.spawn.find_executable might apply, http://docs.python.org/2/distutils/apiref.html#module-distutils.spawn but this it is not intended for finding data files either. If you really need something like this, you'll probably be writing your own path searching routines for this, as to my knowledge this is not provided by the standard library. (Probably for a good reason: sometimes searching for a data resource without knowing exactly where it should be can be a susceptible vector for attacks. That is, you might consider this a convenience vs. safety thing. Directory search can be _expensive_ in certain contexts as well, such as on a networked file system, for example.) --- In a professional context: there are libraries in place where you say explicitly which resources your file depends on at installation time, and the library manages the placement and finding of those resources at runtime. For an example, see the distutils.package_data option: http://docs.python.org/2/distutils/setupscript.html#installing-package-data ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano wrote: > Python does not use a search path for the open() function, only for > imports. With open(), it uses a simple rule: > > - absolute paths will look only in that exact location; > > - relative paths are always relative to the current working directory. > > Do you know the difference between absolute and relative paths? Ah! I was just running into this... I did not know that. So there's no way to get it to search a path (other than coding some string concatenation of path names or something, of course) to open a file? Well, at least that clears things up for me, I've stumbled over this a few times and didn't understand. Thanks. -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On 24/01/14 02:34, Tobias Quezada wrote: >>>fp=open("prez.dat","r") >>>x=fp.read >>>(print(x) /IOError: [Errno 2] No such file or directory: 'prez.dat'/ Python can't see your file. You can check what python is seeing by importing os and using listdir(): import os os.listdir(',') # . is the current directory If your file is not listed then that's your problem. Or it could be a permissions problem, but I can't recall if that's a different error message, I suspect so. hth -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
hello community,i am a newbie to python and program in general. the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal. >>>fp=open("prez.dat","r")>>>x=fp.read>>>(print(x)***i used fp for file >>>pointer.I am using windows 7 and it works but on ubuntu 12.04 LTS i get this >>>syntax error: Traceback (most recent call last): File "", line 1, in IOError: [Errno 2] No such file or directory: 'prez.dat' Any thoughts?Thanx ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
On Fri, Jan 24, 2014 at 04:22:20AM -0500, Keith Winston wrote: > The file would appear to not be on your search path, that is, in any > directory in which Python is expecting to find it. Python does not use a search path for the open() function, only for imports. With open(), it uses a simple rule: - absolute paths will look only in that exact location; - relative paths are always relative to the current working directory. Do you know the difference between absolute and relative paths? -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
Hi Tobias, and welcome. On Thu, Jan 23, 2014 at 07:34:18PM -0700, Tobias Quezada wrote: > hello community,i am a newbie to python and program in general. > the script below works in python 2.7.3 on windows but not in the python 2.7.3 > ubuntu terminal. > > >>> fp=open("prez.dat","r") > >>> x=fp.read > >>> (print(x) > > ***i used fp for file pointer.I am using windows 7 and it works Are you sure this is the *exact* same code you use on Windows 7? Because it won't read the file, it will fail with a SyntaxError due to the missing close bracket after the print. Fixing that problem reveals another problem: rather than read the file, it will just print something like this: That's because you need round brackets (parentheses) to actually call the read method, otherwise you just get the method itself. Finally we get to the error you have have reported: > but on ubuntu 12.04 LTS i get this syntax error: > Traceback (most recent call last): > File "", line 1, in > IOError: [Errno 2] No such file or directory: 'prez.dat' That's not a syntax error. The problem is not with your code, but with the location of the file. There is no file called "prez.dat" in the current directory. Possibly you have just forgotten to create the file, or you have forgotten that Ubuntu (like all Linux operating systems) are case sensitive and "prez.dat" will not match "Prez.DAT", or the file is in the wrong directory. You may need to use the cd command to go into the directory before starting Python. Does this help solve your problem? Please feel free to ask if you have any further questions. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
Tobias Quezada wrote: > hello community,i am a newbie to python and program in general. > the script below works in python 2.7.3 on windows but not in the python > 2.7.3 ubuntu terminal. > fp=open("prez.dat","r")>>>x=fp.read>>>(print(x)***i used fp for file pointer.I am using windows 7 and it works but on ubuntu 12.04 LTS i get this syntax error: > Traceback (most recent call last): File "", line 1, in > IOError: [Errno 2] No such file or directory: 'prez.dat' That was probably > fp=open("prez.dat","r") > x=fp.read > print(x) > i used fp for file pointer.I am using windows 7 and it works but on ubuntu > 12.04 LTS i get this syntax error: > Traceback (most recent call last): File "", line 1, in > IOError: [Errno 2] No such file or directory: 'prez.dat' > Any thoughts?Thanx Please reread the error message. This is not a SyntaxError. Python is trying to tell you that a file called "prez.dat" doesn't exist in the current working directory. However, once you create the file (or provide the complete path if the file exists but is located in another directory) you will run into the next problem: > x=fp.read This will bind x to the fp.read method. To call the method the parentheses are mandatory: x = fp.read() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
I should have mentioned, the other possibility is that the file does not, in fact, exist, but I assume you put it out there somewhere? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] code works in windows command but not ubuntu terminal
The file would appear to not be on your search path, that is, in any directory in which Python is expecting to find it. Either move it to a directory on your path, or change your path to include it's location. The easiest way to find out what your path is, that I know, is import sys sys.path Good luck! Warning, I'm still a beginner myself, I might be mistaken about something... If you don't understand what I'm talking about, try to be very specific about what you do understand, it'll help people formulate clear responses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] code works in windows command but not ubuntu terminal
hello community,i am a newbie to python and program in general. the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal. >>>fp=open("prez.dat","r")>>>x=fp.read>>>(print(x)***i used fp for file >>>pointer.I am using windows 7 and it works but on ubuntu 12.04 LTS i get this >>>syntax error: Traceback (most recent call last): File "", line 1, in IOError: [Errno 2] No such file or directory: 'prez.dat' Any thoughts?Thanx___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor