kayla bishop | 1 Oct 2008 04:47
Picon
Favicon

(no subject)

I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads and tails you flipped but it has to be random. Can you please help
Get more out of the Web. Learn 10 hidden secrets of Windows Live. Learn Now
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Pierre Dagenais | 1 Oct 2008 05:44
Picon
Favicon

Re: python: can't open file 'test.py' : [Errno 2] No such file or directory

W W wrote:
> On Tue, Sep 30, 2008 at 2:58 PM, Pierre Dagenais <pierre.dagenais <at> ncf.ca>wrote:
>
>   
>> The file test.py is in I:\Python25\MyCode,
>> if I enter:
>>
>>  C:\>Python25\MyCode\python25 test.py at the DOS prompt, everything works
>> as I would expect.
>>
>> However when I enter the same command from any other directory I get this
>> error:
>>
>>  C:\>python test.py
>>   python: can't open file 'test.py' : [Errno 2] No such file or directory
>>
>> I've set the environment variable pythonpath as
>>  C:\>set pythonpath = C:\\Python25\\MyCode
>>
>>     
>
> I'm not entirely sure about Windows, but my guess is that your problem is
> that the pythonpath isn't what you need to set. I would venture to guess
> that it's searching for test.py in your current path. If I'm correct in my
> thinking, all it does when you set the python path is tells python to
> execute in that directory, so if your script contains something like f =
> open("myfile.txt", "w") it will put it in that directory.
>
> You may want to try this:
>
> The path is now managed by Windows 2000 / Windows XP and not the
> autoexec.bat or autoexec.nt files. To change the system environment
> variables, follow the below steps.
>
>    1. From the desktop <http://www.computerhope.com/jargon/d/desktop.htm>,
>    right-click My Computer and click properties.
>    2. In the System Properties
> window<http://www.computerhope.com/jargon/w/window.htm>,
>    click on the Advanced tab <http://www.computerhope.com/jargon/t/tab.htm>.
>    3. In the Advanced section, click the Environment Variables
> button<http://www.computerhope.com/jargon/p/pushbutt.htm>
>    .
>    4. Finally, in the Environment Variables window, highlight the path
>    variable in the Systems Variable section and click edit. Add or modify the
>    path lines with the paths you wish the computer to access. Each different
>    directory is separated with a semicolon as shown below.
>
>    C:\Program Files;C:\Winnt;C:\Winnt\System32
>
> from:
> http://www.computerhope.com/issues/ch000549.htm
>
> Try adding the path to your code in that way, and see if it works. HTH,
> Wayne
>
>   
Thank you Wayne,
My path does include C:\python25;C\python25\mycode among other things. 
Is that is what you meant?
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Pierre Dagenais | 1 Oct 2008 06:01
Picon
Favicon

Re: python: can't open file 'test.py' : [Errno 2] No such file or directory

Timothy Grant wrote:
> On Tue, Sep 30, 2008 at 12:58 PM, Pierre Dagenais
> <pierre.dagenais <at> ncf.ca> wrote:
>   
>> The file test.py is in I:\Python25\MyCode,
>> if I enter:
>>
>>  C:\>Python25\MyCode\python25 test.py at the DOS prompt, everything works as
>> I would expect.
>>
>> However when I enter the same command from any other directory I get this
>> error:
>>
>>  C:\>python test.py
>>   python: can't open file 'test.py' : [Errno 2] No such file or directory
>>
>> I've set the environment variable pythonpath as
>>  C:\>set pythonpath = C:\\Python25\\MyCode
>> what am I doing wrong,
>> Thank u for your help,
>> _______________________________________________
>> Tutor maillist  -  Tutor <at> python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>     
>
> You need to give the full path to your test.py file.
>
> PYTHONPATH sets the python library search path.
>
>
>   
> Thank you Tim,
> Definitively C:\python \python25\mycode\test.py does work. If you're right about having to give the
full path, and I suspect you are, Then this means that python knows to search the currennt working
directory for  the file to execute, but nowhere else. It seems a strange behavior. Maybe this is on Mr. Guido
van Rossum todo list.
>   
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Pierre Dagenais | 1 Oct 2008 06:18
Picon
Favicon

Re: (no subject)

kayla bishop wrote:
> I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads
and tails you flipped but it has to be random. Can you please help
> _________________________________________________________________
> Get more out of the Web. Learn 10 hidden secrets of Windows Live.
> http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
>   
> ------------------------------------------------------------------------
> Which part are you having a problem with? Flipping the coin or keeping track of the results, or both? Try to
be little more explicit please.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Chris Babcock | 1 Oct 2008 06:40
Favicon
Gravatar

Question on DOMImplementation Objects

Does the DOMImplementation interface support schemas? 

I'm tweaking an example from a book to process a flat file registration
database:

from xml.dom     import implementation

class RegistrationParser:
  def parseFile(self, fileAsString):

    # Create DocType Declaration
    doctype = implementation.createDocumentType('registrations', '',
                                                'archive.xsd')

    # Create empty DOM Document and get root element
    doc = implementation.createDocument('', 'registrations', doctype)
    elemDoc = doc.documentElement

    . . . 

If I leave archive.xsd out of createDocumentType will it just generate
an XML document without validation?

Chris

--

-- 

Make a difference in the world and support more Diplomacy projects and
services then you can shake a dagger at, please read:

http://members.bluegoosenews.com/diplomacy/blog/2008/09/24/a_special_note_for_diplomacy_players
 - or - 
http://tinyurl.com/3wx6lb 

Blue Goose is willing to give me $250 to support various services and
projects in the Diplomacy hobby. The blog post above will tell you why
they are doing this, what I will do with the money, and what you can do
to help me get it.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Pierre Dagenais | 1 Oct 2008 07:20
Picon
Favicon

Re: (no subject)

kayla bishop wrote:
> I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads
and tails you flipped but it has to be random. Can you please help
> _________________________________________________________________
> Get more out of the Web. Learn 10 hidden secrets of Windows Live.
> http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> http://mail.python.org/mailman/listinfo/tutor
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.173 / Virus Database: 270.7.5/1698 - Release Date: 29/09/2008 7:25 PM
>
>   
Here is how one newbie would do it:

import random

# Initialize variables
head = 0
tail = 0

# Flip the coin a hundred times
for x in range(100):
    choice = random.randint(1,2)

# Is it 'head'?
    if choice == 1 :
        head = head + 1

# If not 'head' then it must be tail
    else :
        tail = tail + 1

print "head = ",head
print "tail = ",tail

   
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Arun Tomar | 1 Oct 2008 07:26
Picon
Gravatar

list to csv

hi!

I've a list

new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']

I am trying to convert this to a csv in 3 columns so that the final
output would look something like this

"n1","m1","p1"
"n2","m2","p2"
"n3","m3","p3"

regds,
arun.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Steve Willoughby | 1 Oct 2008 07:32

Re: list to csv

Arun Tomar wrote:
> hi!
> 
> I've a list
> 
> new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']
> 
> I am trying to convert this to a csv in 3 columns so that the final
> output would look something like this
> 
> "n1","m1","p1"
> "n2","m2","p2"
> "n3","m3","p3"

This can easily be done with the "csv" module in the Python standard 
library.  Just create a csv.writer object, and call the writerow() 
method in it for every three elements in new_array and you're done.

> regds,
> arun.
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Timothy Grant | 1 Oct 2008 07:54
Picon

Re: python: can't open file 'test.py' : [Errno 2] No such file or directory

On Tue, Sep 30, 2008 at 9:01 PM, Pierre Dagenais <pierre.dagenais <at> ncf.ca> wrote:
> Timothy Grant wrote:
>>
>> On Tue, Sep 30, 2008 at 12:58 PM, Pierre Dagenais
>> <pierre.dagenais <at> ncf.ca> wrote:
>>
>>>
>>> The file test.py is in I:\Python25\MyCode,
>>> if I enter:
>>>
>>>  C:\>Python25\MyCode\python25 test.py at the DOS prompt, everything works
>>> as
>>> I would expect.
>>>
>>> However when I enter the same command from any other directory I get this
>>> error:
>>>
>>>  C:\>python test.py
>>>  python: can't open file 'test.py' : [Errno 2] No such file or directory
>>>
>>> I've set the environment variable pythonpath as
>>>  C:\>set pythonpath = C:\\Python25\\MyCode
>>> what am I doing wrong,
>>> Thank u for your help,
>>> _______________________________________________
>>> Tutor maillist  -  Tutor <at> python.org
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>>
>> You need to give the full path to your test.py file.
>>
>> PYTHONPATH sets the python library search path.
>>
>>
>>  Thank you Tim,
>> Definitively C:\python \python25\mycode\test.py does work. If you're right
>> about having to give the full path, and I suspect you are, Then this means
>> that python knows to search the currennt working directory for  the file to
>> execute, but nowhere else. It seems a strange behavior. Maybe this is on Mr.
>> Guido van Rossum todo list.
>>
>

Why is that strange? Would you expect any other program not on the
path to execute without a fully qualified path? Make your python code
executable, and put it somewhere on the path and I'm quite sure it
would run as expected (though it has been over 10 years since I last
had to work on a Windows box so I'm not quite sure how to do that).

--

-- 
Stand Fast,
tjg.  [Timothy Grant]
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Timothy Grant | 1 Oct 2008 08:05
Picon

Re: (no subject)

On Tue, Sep 30, 2008 at 10:20 PM, Pierre Dagenais
<pierre.dagenais <at> ncf.ca> wrote:
> kayla bishop wrote:
>>
>> I can't figure out how to write a program where you flip a coin 100 times
>> and it keeps track of how many heads and tails you flipped but it has to be
>> random. Can you please help
>> _________________________________________________________________
>> Get more out of the Web. Learn 10 hidden secrets of Windows Live.
>>
>> http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
>>  ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor <at> python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>  ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database:
>> 270.7.5/1698 - Release Date: 29/09/2008 7:25 PM
>>
>>
>
> Here is how one newbie would do it:
>
>
> import random
>
> # Initialize variables
> head = 0
> tail = 0
>
> # Flip the coin a hundred times
> for x in range(100):
>   choice = random.randint(1,2)
>  # Is it 'head'?
>   if choice == 1 :
>       head = head + 1
>      # If not 'head' then it must be tail
>   else :
>       tail = tail + 1
>      print "head = ",head
> print "tail = ",tail
>
>
>  _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> http://mail.python.org/mailman/listinfo/tutor
>

Please let us know if Pierre gets an an "A" on that assignment or not Kayla.

--

-- 
Stand Fast,
tjg.  [Timothy Grant]
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane