Re: [Tutor] Random Number Question

2010-11-24 Thread Mac Ryan
On Thu, 25 Nov 2010 00:58:23 + Adam Bark wrote: > Ah yes always avoid giving your modules names that appear in the > standard library. It goes wrong, sometimes in unexpected ways. I was wondering... apart from checking each name individually, is there any easy-peasy way to get a list of nam

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Susana Iraiis Delgado Rodriguez wrote: Hello Peter! I added the line you suggested me and found out that I was just searching for the filenames without pointing to a specific directory, so Python took its directory (Python26) as default. After that I need to add a '\'

Re: [Tutor] Random Number Question

2010-11-24 Thread Jeff Goodwin
Thanks Adam and Alan for responding, I'm very much a non-programmer, but my 14 year old son wants to learn, so I have to learn to teach him...slow process lol. Happy Thanksgiving! Jeff On Wed, Nov 24, 2010 at 8:27 PM, Alan Gauld wrote: > > "Jeff Goodwin" wrote > > Ok, I found the problem, I h

Re: [Tutor] Random Number Question

2010-11-24 Thread Alan Gauld
"Jeff Goodwin" wrote Ok, I found the problem, I had saved the file as random.py looks like that was a no-no. Its working now that I changed the name. Yes that's a bad idea. You probably figured out why, but just in case... import random It tries to import itself, which then tries to

Re: [Tutor] Python module structure & directories

2010-11-24 Thread Alan Gauld
"Judy Chen" wrote I am very new to Python, I worked on C/C++ before. I would like to know is it a good practice to put Python development code under ../src/UI/foo.py ../src/businesslogic/bar.py, etc. Thats fine, especially if its a big project. src means source code and python is a type o

[Tutor] Python module structure & directories

2010-11-24 Thread Judy Chen
Hi, I am very new to Python, I worked on C/C++ before. I would like to know is it a good practice to put Python development code under ../src/UI/foo.py ../src/businesslogic/bar.py, etc. or should we eliminate "src' directory since it is not pythonic, or it very C/C++ like. I was told that t

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 22:10, Jeff Goodwin wrote: Ok, I found the problem, I had saved the file as random.py looks like that was a no-no. Its working now that I changed the name. Thanks! Jeff Ah yes always avoid giving your modules names that appear in the standard library. It goes wrong, sometimes in un

Re: [Tutor] Random Number Question

2010-11-24 Thread Jeff Goodwin
Ok, I found the problem, I had saved the file as random.py looks like that was a no-no. Its working now that I changed the name. Thanks! Jeff On Wed, Nov 24, 2010 at 5:06 PM, Jeff Goodwin wrote: > Thanks Adam, that was a typo on my part, in the program the print is > actually indented. Any other

Re: [Tutor] Random Number Question

2010-11-24 Thread Jeff Goodwin
Thanks Adam, that was a typo on my part, in the program the print is actually indented. Any other suggestions? Thanks again! Jeff On Wed, Nov 24, 2010 at 5:00 PM, Adam Bark wrote: > On 24/11/10 21:51, Jeff Goodwin wrote: > > Hello, > > I'm trying to find a way to use the random.randint fu

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 21:51, Jeff Goodwin wrote: Hello, I'm trying to find a way to use the random.randint function to generate a random number, but everytime I run the program it locks up IDLE. Here is what I have so far: import random def main(): x = input("Enter a number: ") y = input("Ente

[Tutor] Random Number Question

2010-11-24 Thread Jeff Goodwin
Hello, I'm trying to find a way to use the random.randint function to generate a random number, but everytime I run the program it locks up IDLE. Here is what I have so far: import random def main(): x = input("Enter a number: ") y = input("Enter a different number: ") z = random

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Susana Iraiis Delgado Rodriguez
Hello Peter! I added the line you suggested me and found out that I was just searching for the filenames without pointing to a specific directory, so Python took its directory (Python26) as default. After that I need to add a '\' to separate the path from the filename because it was reading them a

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Alan Gauld
"Susana Iraiis Delgado Rodriguez" wrote I'm writing a python script to validate if files with extension .prj exist, if they exist it should write 1 or 0 into an excel cell. I've working to do this properly, but I'm not getting the results I need. The script doesn't find all the files, is l

Re: [Tutor] IDEs

2010-11-24 Thread Alan Gauld
"Steven D'Aprano" wrote And we still wound up with over 50 reported bugs during Beta test... But that was much better than the 2000 bugs on an earlier project :-) But testing is hard. Maybe so, but nothing beats running your test suite and seeing everything pass! Yes, I should have adde

Re: [Tutor] Lambda function, was: Simple counter to determine frequencies of words in adocument

2010-11-24 Thread ALAN GAULD
> > Notice that it uses key as a function inside sorted. > > And lambda creates a function so sorted applies > > the lambda to each item in turn to retrieve the sort key. > > OK. I get it. Thanks a lot. This should have been clear if I had been > able to see the code for the sorted() method.

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Peter Otten
Susana Iraiis Delgado Rodriguez wrote: > Hello memebers: > > I'm writing a python script to validate if files with extension .prj > exist, if they exist it should write 1 or 0 into an excel cell. I've > working to do this properly, but I'm not getting the results I need. The > script doesn't find

Re: [Tutor] Fw: Installing Pyserial for Python27 on Win 7

2010-11-24 Thread John Smith
Hi, Walter - Thanks to you, pyserial is installed and imports into Python. Not having double backslashes was the latest problem that you got me through. I am grateful for the support and education you have given me. Cheers, John ___ Tutor maillist

[Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Susana Iraiis Delgado Rodriguez
Hello memebers: I'm writing a python script to validate if files with extension .prj exist, if they exist it should write 1 or 0 into an excel cell. I've working to do this properly, but I'm not getting the results I need. The script doesn't find all the files, is like the files don't exist but th

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Josep M. Fontana
On Wed, Nov 24, 2010 at 3:00 PM, Evert Rol wrote: > Then you haven't read my previous response carefully enough, or I haven't > phrased it properly. The example I gave was: > import mymodule mymodule.X > > where X is defined in a file called mymodule.py > In your case, replace mymodul

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Evert Rol
>> You're not really showing what exactly you type. That's often more clearer >> than describing what you do, although in this case we can get a pretty good >> picture anyway. > > OK, here's what I do: > import test > > I know the shell is importing the file because I can see the followin

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Josep M. Fontana
Thanks Evert and Steve, Both of you are right when you say: > You're not really showing what exactly you type. That's often more clearer > than describing what you do, although in this case we can get a pretty good > picture anyway. OK, here's what I do: >>>import test I know the shell is im

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Steven D'Aprano
Josep M. Fontana wrote: One question for Steve (or for whoever wants to answer): you say you have a terminal with two tabs (neat, I wonder whether I can get tabs as well for my terminal in OS X) and when you need to do debugging you turn to your interactive python terminal and do; import filena

Re: [Tutor] IDEs

2010-11-24 Thread Steven D'Aprano
Alan Gauld wrote: The basic idea in testing is to try to break your code. Try to think of every kind of evil input that could possibly come along and see if your code survives. In amongst all of that you should have a some valid values too, and know what to expect as out put. Testing is more t

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Evert Rol
> > --- > One question for Steve (or for whoever wants to answer): you say you > have a terminal with two tabs (neat, I wonder whether I can get tabs > as well for my terminal in OS X) In Terminal.app, just type command-T and you get a new tab. Switch with the mouse or command-shift-[ & com

[Tutor] Working with interactive Python shell

2010-11-24 Thread Josep M. Fontana
Hi, When a thread gets too long and new subtopics appear it gets pretty hard to keep track of what has been said by whom and what has been answered. Anyway, in one of the threads I started, Steven d'Aprano gave me a very nice response telling me what his preferred working environment was. This pro

Re: [Tutor] IDEs

2010-11-24 Thread Josep M. Fontana
Great. Thanks Eike and Alan. Josep M. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] "if n % 2 == 0" vs. "if not n % 2" compared for speed: aesthetics lose

2010-11-24 Thread Richard D. Moores
On Tue, Nov 23, 2010 at 20:09, R. Alan Monroe wrote: > >> I've always disliked using "if not n % 2"  to test for even/odd ints >> because of its convoluted logic. But I ran some speed tests and found >> it was the way to go over "if n % 2 == 0". > > Did you try bitwise-and with

Re: [Tutor] Help regarding lists, dictionaries and tuples (bob gailer)

2010-11-24 Thread Alan Gauld
"Robert Sjöblom" wrote Why would you want to sum them? You start with 30 points in the pool, then allocate them to the attributes. The sum will still be 30. Because the user should be able to spend 30 points, or remove points from an attribute and get them back in the pool. Like so: attrib