[Tutor] Getting started with Python

2008-05-16 Thread ppaarrkk
I can't. import file.py is all very well if the interpreter knows where file.py is. I want to do this : import /directory1/directory2/file.py Is this not possible ? -- View this message in context: http://www.nabble.com/Getting-started-with-Python-tp17273337p17273337.html Sent from

Re: [Tutor] Getting started with Python

2008-05-16 Thread Moishy Gluck
On Fri, May 16, 2008 at 11:20 AM, Moishy Gluck [EMAIL PROTECTED] wrote: You need to place a __init__.py file in a directory you want to reference in an import statement. I don't believe the content of the file is important but you can place code in the file that will affect how files are

Re: [Tutor] Getting started with Python

2008-05-16 Thread jay
Have you tried this ? import sys sys.path.append('/directory1/directory2') import file.py j On Fri, May 16, 2008 at 10:20 AM, Moishy Gluck [EMAIL PROTECTED] wrote: On Fri, May 16, 2008 at 11:20 AM, Moishy Gluck [EMAIL PROTECTED] wrote: You need to place a __init__.py file in a directory

Re: [Tutor] Open a directory in the default file manager

2008-05-16 Thread Thomas Pani
Tim Michelsen wrote: Hello, is there any function/module that allows me to open a directory in the default file manager of a operating system? On Windows you can use os.startfile(). On pure Unices there's no such thing as filetype associations However, if you use a desktop environment, you

Re: [Tutor] Getting started with Python

2008-05-16 Thread jay
Your right, typo :-) On Fri, May 16, 2008 at 10:57 AM, Hansen, Mike [EMAIL PROTECTED] wrote: Isn't it import file not import file.py or has that changed in recent versions? Mike -- *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *jay

[Tutor] quickly pulling marbles out of urns

2008-05-16 Thread Joel Miller
I'm looking for a faster way to do the following problem: I have an urn with many different colors of marbles in it. I pull one out and note the color. I do not replace it. For the programming of this, I actually know how many are yellow, green, etc. So the way the code works right now is:

[Tutor] Dictionaries or Numpy?

2008-05-16 Thread Adam Clarridge
Hi, I'm writing an AI for a board game called Blokus, and I believe that the quality of the program is going to greatly depend on the efficiency of the algorithm I use to generate legal moves and rate them. I know sort of how I'm going to do this legal move generation, and I know it is going to

Re: [Tutor] Dictionaries or Numpy?

2008-05-16 Thread John Fouhy
On 17/05/2008, Adam Clarridge [EMAIL PROTECTED] wrote: I'm fairly new to Python, and I am not sure whether it would be faster for me to use a Dictionary data type to represent the board (advantages: indices can be strings or tuples, and the dictionary can store different types of data as

[Tutor] datetime syntax error for May 8th and 9th 2008??

2008-05-16 Thread Che M
Am I missing something? Why does May 7th and other dates work but I'm getting invalid token for May 8th and 9th? (I have not tested many other dates of the year in this way) This is from a freshly begun IDLE session: IDLE 1.2 import datetime datetime.datetime(2008,05,07)

Re: [Tutor] quickly pulling marbles out of urns

2008-05-16 Thread Kent Johnson
On Fri, May 16, 2008 at 5:43 PM, Joel Miller [EMAIL PROTECTED] wrote: I'm looking for a faster way to do the following problem: I have an urn with many different colors of marbles in it. I pull one out and note the color. I do not replace it. You probably know, this is called sampling

Re: [Tutor] datetime syntax error for May 8th and 9th 2008??

2008-05-16 Thread Che M
From: [EMAIL PROTECTED] To: tutor@python.org Subject: datetime syntax error for May 8th and 9th 2008?? Date: Sat, 17 May 2008 00:09:03 -0400 Am I missing something? Why does May 7th and other dates work but I'm getting invalid token for May 8th and 9th? (I have not tested many other

Re: [Tutor] datetime syntax error for May 8th and 9th 2008??

2008-05-16 Thread John Fouhy
On 17/05/2008, Che M [EMAIL PROTECTED] wrote: datetime.datetime(2008, 05, 08) SyntaxError: invalid token It's simpler than that... Try this: x = 08 File stdin, line 1 x = 08 ^ SyntaxError: invalid token x = 010 x 8 Basically, python interprets integer literals starting with

Re: [Tutor] quickly pulling marbles out of urns

2008-05-16 Thread John Fouhy
On 17/05/2008, Joel Miller [EMAIL PROTECTED] wrote: I have an urn with many different colors of marbles in it. I pull one out and note the color. I do not replace it. Kent's suggest seems simplest: represent the marbles as a list of integers, where marbles[i] is the integer corresponding to