beginner code problem

2006-06-02 Thread RJ
  I'm trying to teach myself Python (probably running into the old dog 
new tricks issue) and I'm trying to start with the very basics to get a 
handle on them.

  I'm trying to write code to get the computer to flip a coin 100 times 
and give me the output of how many times heads and tails. After solving 
a few syntax errors I seem to be stuck in an endless loop and have to 
kill python. A few times I would get it to print 'heads 0 (or 1) times 
and tails 1 (or 0) times' 100 times.

Here's the code I wrote:

import random

flip = random.randrange(2)
heads = 0
tails = 0
count = 0

while count < 100:

if flip == 0:
heads += 1

else:
tails += 1


count += 1



print "The coin landed on heads", heads, 'times ' \
 "and tails", tails, 'times'

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner code problem

2006-06-02 Thread RJ
  Thanks for all the help and examples. As I mentioned, I'm trying to
teach myself and starting with the basics (if, elif, else, while, for,
raw_input, int are about all I know so far and don't know that well
yet) Some of the example posted are still beyond my understanding but
it's good to see other ways of acheiving the result and other things
to look up and read about. 

  I've read a bit about Python but only really started trying
yesterday. Right now I'm still strugling but with practice I hope for
it to come easier and I'll keep learning more syntax.

  I didn't even think about random.randrange being out of the loop but
it makes sence now. Chalk it up to a newbie mistake and a learning
experience.

  I really do appreciate the help and I'm sure this is only the first
of many questions I'll have. It's good to know that there are others
who can help me understand my mistakes.

  Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


New 2.6 and wx install => DLL load failed: The specified procedure could not be found

2009-08-11 Thread RJ
I just installed python-2.6.2.msi from Python.org and 
wxPython2.8-win32-ansi-2.8.10.1-py26.exe and now can't import this 
wx. (I had 2.4, but uninstalled)
This reminds me of a basic question I had before: what are the 
compilers used for the Win32 binaries? Is this a compiler 
compatibility issue? a wx bug?


C:\projects>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx\__init__.py", line 45,

in 
from wx._core import *
  File "C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", 
line 4, in <

module>
import _core_
ImportError: DLL load failed: The specified procedure could not be found.
>>> -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread RJ

At 03:08 PM 8/11/2009, you wrote:

I recommend going to the existing Wiki and looking at what there is
already:

http://wiki.python.org/moin/Documentation
http://wiki.python.org/moin/CategoryDocumentation


I also can't see how to get 
from  http://wiki.python.org/moin/Documentation to 
http://wiki.python.org/moin/CategoryDocumentation, for one...



Sadly, I don't think you'll find much to work with, apart from the
occasional attempt to make an annotated version of the existing
documentation:

http://wiki.python.org/moin/PythonLibraryReference


The library reference above needs a link to Modules (and the link to 
Andrew's pages are now dead - 
http://pydoc.amk.ca/frame.html)


What I've always looked for and Google constantly for, is a main 
language version of the features of http://www.scipy.org/Cookbook and 
http://code.activestate.com/recipes/langs/python/, with module level 
organization. At least users can submit something at Activestate. The 
issue there (and at Scipy) is that I usually want an example 
illustrating some method, and that's not how it's organized (but is 
at those Other language sites), so I still need to search at Scipy, or do

http://www.google.com/search?q=site%3Ascipy.org+foo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-13 Thread RJ
A basic question in this thread is: Who will host the 
doc-wiki/whatever and how will it be linked to?
If not hosted at python.org it can still be linked to from their 
docs, if allowed, possibly with 3rd level domain and re-direct.
I host a number of commercial servers but I don't expect Guido to 
bless them with said links.

If hosted at python.org it will require resources from the existing admins.
If elsewhere then trusted admins and organization.
If not linked to from python.org then it may well expire from lack of 
interest, as other seemingly nice attempts did.


Ray Schumacher



--
http://mail.python.org/mailman/listinfo/python-list


Unicode formatting for Strings

2007-02-05 Thread robson . cozendey . rj
Hi,

I´m trying desperately to tell the interpreter to put an 'á' in my
string, so here is the code snippet:

# -*- coding: utf-8 -*-
filename = u"Ataris Aquáticos #2.txt"
f = open(filename, 'w')

Then I save it with Windows Notepad, in the UTF-8 format. So:

1) I put the "magic comment" at the start of the file
2) I write u"" to specify my unicode string
3) I save it in the UTF-8 format

And even so, I get an error!

  File "Ataris Aqußticos #2.py", line 1
SyntaxError: Non-ASCII character '\xff' in file Ataris Aqußticos #2.py
on line 1
, but no encoding declared; see http://www.python.org/peps/
pep-0263.html for det
ails

I don´t know how to tell Python that it should use UTF-8, it keeps
saying "no encoding declared" !

Robson

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode formatting for Strings

2007-02-05 Thread robson . cozendey . rj
On Feb 5, 7:00 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 2/5/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > [EMAIL PROTECTED] wrote:
> > > Hi,
>
> > > I´m trying desperately to tell the interpreter to put an 'á' in my
> > > string, so here is the code snippet:
>
> > > # -*- coding: utf-8 -*-
> > > filename = u"Ataris Aquáticos #2.txt"
> > > f = open(filename, 'w')
>
> > > Then I save it with Windows Notepad, in the UTF-8 format. So:
>
> > > 1) I put the "magic comment" at the start of the file
> > > 2) I write u"" to specify my unicode string
> > > 3) I save it in the UTF-8 format
>
> > > And even so, I get an error!
>
> > >   File "Ataris Aqußticos #2.py", line 1
> > > SyntaxError: Non-ASCII character '\xff' in file Ataris Aqußticos #2.py
> > > on line 1
>
> > It looks like you are saving the file in Unicode format (not utf-8) and
> > Python is choking on the Byte Order Mark that Notepad puts at the
> > beginning of the document.
>
> Notepad does support saving to UTF-8, and I was able to do this
> without the problem the OP was having. I also saved both with and
> without a BOM (in UTF-8) using SciTe, and Python worked correctly in
> both cases.
>
>
>
> > Try using an editor that will save utf-8 without a BOM, e.g. jedit or
> > TextPad.
>
> > Kent
> > --
> >http://mail.python.org/mailman/listinfo/python-list- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

I saved it in UTF-8 with Notepad. I was thinking here... It can be a
limitation of file.open() method? Have anyone tested that?

-- 
http://mail.python.org/mailman/listinfo/python-list


need help of regular expression genius

2008-05-05 Thread RJ vd Oest
 

--
http://mail.python.org/mailman/listinfo/python-list