[Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Tobias Quezada
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
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

[Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread Peter Otten
+--+++ | | __iter__ | __next__ | +--+++ | iterable | return an iterator | not available | +--+++ |

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
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:

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Peter Otten
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread maxin...@gmail.com
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Alan Gauld
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

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/24/2014 10:22 AM, Peter Otten wrote: There's an odd outlier that I probably shouldn't tell you about [...] I guess there is a whole class of outliers; not really sure how to classify them. This is the case of defining a wrapper or proxy type, for a underlying data structure which is

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread Peter Otten
spir wrote: On 01/24/2014 10:22 AM, Peter Otten wrote: There's an odd outlier that I probably shouldn't tell you about [...] I guess there is a whole class of outliers; not really sure how to classify them. I think you are focusing on the details too much. In class Angles: def

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano st...@pearwood.info 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

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/24/2014 06:44 PM, Peter Otten wrote: There is no infinite recursion. The for loop is currently implemented as # expect an iterable # handle iterators through an idempotent iter() tmp = iter(xs) # here you must check that tmp actually implements the iterator protocol, # else raise an

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Danny Yoo
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,

[Tutor] How to correct decimal addition.

2014-01-24 Thread Leon S
Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tried and the results of it. def gas_price(price): price == raw_input(What

Re: [Tutor] How to correct decimal addition.

2014-01-24 Thread Norman Khine
maybe this would be of help https://stackoverflow.com/questions/455612/python-limiting-floats-to-two-decimal-points On Fri, Jan 24, 2014 at 5:57 PM, Leon S imthereall...@gmail.com wrote: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that

Re: [Tutor] How to correct decimal addition.

2014-01-24 Thread wesley chun
hi leon, you made a good start and ran into something that i know doesn't seem right to you. however, before we attack the issue, there are some basic problems with the code you need to correct first. below are a few explanations and perhaps workarounds: 1. you're passing in price *and*

Re: [Tutor] How to correct decimal addition.

2014-01-24 Thread Dave Angel
Leon S imthereall...@gmail.com Wrote in message: _ (please post in plain text in this text mailing list. Html messes up formatting and causes some newsreaders grief.) .. Leon said: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
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 st...@pearwood.info 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

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread eryksun
On Fri, Jan 24, 2014 at 8:50 AM, spir denis.s...@gmail.com wrote: xs is an iterator (__next__ is there), then Python uses it directly, thus what is the point of __iter__ there? In any case, python must check whether Python doesn't check whether a type is already an iterator. It's simpler to

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread bob gailer
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.

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
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

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread eryksun
On Fri, Jan 24, 2014 at 8:38 PM, Steven D'Aprano st...@pearwood.info 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

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/25/2014 04:13 AM, eryksun wrote: On Fri, Jan 24, 2014 at 8:50 AM, spir denis.s...@gmail.com wrote: xs is an iterator (__next__ is there), then Python uses it directly, thus what is the point of __iter__ there? In any case, python must check whether Python doesn't check whether a type