Re: Python trademark - A request for civility

2013-02-16 Thread Michael Poeltl
hi,

there are also

ruby.co.uk
lua.co.uk

in my opinion someone who is on the ruby-/lua-malinglist too should warn these 
guys

* Steven D'Aprano  [2013-02-16 06:50]:
> Folks,
> 
> It seems that people have been sending threats and abuse to the company
> claiming a trademark on the name "Python". And somebody, somewhere, may
> have launched a DDOS attack on their website.
> 
> The Python Software Foundation has asked the community for restraint and
> civility during this dispute. Abuse and threats just bring the Python
> community into disrepute.

yeah - that's also my opinion!

Michael
> 
> http://pyfound.blogspot.com/2013/02/asking-for-civility-during-our.html
> 
> 
> 
> -- 
> Steven
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

-- 
Michael Poeltl
Computational Materials Physics  voice: +43-1-4277-51409
Univ. Wien, Sensengasse 8/12 fax:   +43-1-4277-9514 (or 9513) 
A-1090 Wien, AUSTRIA   cmp.mpi.univie.ac.at 
---
slackware-13.37 | vim-7.3 | python-3.2.3 | mutt-1.5.21 | elinks-0.12
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python math problem

2013-02-16 Thread Nobody
On Fri, 15 Feb 2013 11:47:33 -0800, Gary Herron wrote:

> Floating point calculations on a computer (ANY computer, and ANY 
> programming language) can *never* be expected to be exact! 

"never" is incorrect. There are many floating-point calculations
which can reasonably be expected be exact[2].

However, multiplying by pi (as in math.radians) isn't such a
calculation[1], so radians(90) isn't exactly equal to pi/2 and so
cos(radians(90)) isn't exactly equal to zero.

[1] It's not so much that the calculation isn't exact, but that the
calculation has to use an inexact approximation to pi to start with.

[2] In particular, any addition, subtraction, multiplication, division,
modulo or square-root calculation for which the correct answer is exactly
representable should actually produce the correct answer, exactly.

Furthermore, any such calculation for which the correct answer isn't
exactly representable should produce the same result as if the correct
answer had been calculated to an infinite number of digits then rounded to
the nearest representable value according to the current rounding mode.

This doesn't apply to transcendental functions (trig, log, exponential),
which are subject to the "table maker's dilemma". Typically, the actual
result will be one of the two closest representable values to the correct
answer, but not necessarily *the* closest.

IOW: floating-point arithmetic is deterministic. It follows rules. Not the
same rules as real arithmetic, but rules nonetheless. Contrary to
common superstition, the least-significant bits are *not* taken from
/dev/random.

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


Re: python math problem

2013-02-16 Thread Chris Angelico
On Sun, Feb 17, 2013 at 12:55 AM, Nobody  wrote:
> Furthermore, any such calculation for which the correct answer isn't
> exactly representable should produce the same result as if the correct
> answer had been calculated to an infinite number of digits then rounded to
> the nearest representable value according to the current rounding mode.

That doesn't change the fact that, according to Murphy's Law of
Floating Point Operations, the error will accumulate in one direction
instead of balancing itself out. So while one operation might well
produce the nearest representable value to what you'd expect from real
arithmetic (and I'm not differentiating "real" from "fake" here, but
rather referring to the notion of "real numbers"), multiple sequential
operations will quite probably draw you further and further away. It's
not something to *fear*, just something to understand and manage. It's
no different from estimating by rounding things off, except that a
computer estimates with a tad more precision than a human (since a
computer does *everything* with a tad more precision).

Gratuitous example of ridiculous rounding that still results in a
plausible ball-park figure: "One pound is one kilogram."
http://what-if.xkcd.com/4/

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


Re: python math problem

2013-02-16 Thread Roy Smith
In article ,
 Nobody  wrote:

> IOW: floating-point arithmetic is deterministic. It follows rules. Not the
> same rules as real arithmetic, but rules nonetheless. Contrary to
> common superstition, the least-significant bits are *not* taken from
> /dev/random.

Unless you're using a Pentium :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First attempt at a Python prog (Chess)

2013-02-16 Thread Oscar Benjamin
On 15 February 2013 15:49, Chris Angelico  wrote:
> On Sat, Feb 16, 2013 at 2:36 AM, Tim Golden  wrote:
>> How true. This last time, my team split into two: one half
>> to handle the display, the other working on the algorithm. We
>> ended up having to draw a really simple diagram on the back of
>> an envelope with the x,y pairs written out and pass it back
>> and forth as *everyone* kept forgetting which went first.
>
> I'm sorry, I don't follow. People forgot that x comes before y, like
> it does in everything algebraic? Or is it that people lost track of
> which axis you called 'x' and which you called 'y'?

When you have a flat array and need to do a[x*N + y] to get an
element, the order is irrelevant. What matters is which of the
coordinates you multiply and what dimension of the array you multiply
it by. There are two equally good ways to do this, row-major and
column-major order:
http://en.wikipedia.org/wiki/Row-major_order

Any time you call into an API that expects a flattened array
representing a multidimensional array you need to check what order the
API expects. Typically a language has a convention such as C
(row-major) or Fortran (column-major). (According to that Wikipedia
page Python uses row-major, but I'm not really sure what that is
referring to).

Numpy allows you to specify the order when creating an array:
>>> import numpy as np
>>> aC = np.array([['a', 'b'], ['c', 'd']], dtype=str, order='C')
>>> aF = np.array([['a', 'b'], ['c', 'd']], dtype=str, order='F')
>>> aC
array([['a', 'b'],
   ['c', 'd']],
  dtype='|S1')
>>> aF
array([['a', 'b'],
   ['c', 'd']],
  dtype='|S1')

The different order in the two arrays above is transparent to Python
code that doesn't directly refer to the underlying memory arrangement:

>>> aC[0, 1]
'b'
>>> aF[0, 1]
'b'
>>> aC.strides
(2, 1)
>>> aF.strides
(1, 2)
>>> str(buffer(aC))
'abcd'
>>> str(buffer(aF))
'acbd'

This is useful when interfacing with linked Fortran and C libraries
(as is the case in scipy).

I find keeping track of what order I'm using when accessing the
elements of an array to be a pointless distraction. I would much
rather use an abstraction over the linear memory (such as a numpy
array) that enables me to forget all about it.


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


Re: Exception running GNU module "op25_grc.py" : AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback'

2013-02-16 Thread matt . doolittle33
>
> I know nothing about this gnuradio thingie, and you didn't supply a 
> 
> website url.  I was wondering if the module is even intended to be run 
> 
> standalone, but I suppose the if __name__ == "__main__"  thing is a clue 
> 
> that it's supposed to.
> 
> 
> 
> I found the mixture of trace lines to confuse the stack trace immensely, 
> 
> since the exception doesn't occur in the last source line quoted. 
> 
> Somebody better than I had best jump in and help.
> 
> 
> 
> 
> If nobody else jumps in, I'd suggest finding a forum that supports 
> 
> gnuradio, and ask there.
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

Thanks Dave, yes, I too am a little surprised as to why nobody cares to supply 
a fix, a workaround, or even a hint as why this is going on.  I put the exact 
same post in the gnu-radio homebrew forum and the moderated closed the thread; 
I am not sure why because he wouldn't answer me but he closed it. Ive posted 
this question in so many places with but no luck so far.  

As a workaround I removed the block "wxgui_fftsink2", as that block is not 
integral to the signal processing.  And that is the goal of "op25_grc.py", to 
decode digital radio signals.  This code block is run in GNU radio companion 
(GRC) along with many others in the signal processing path . GRC is a GUI where 
one can manage the code (ie. use a flow graph instead of coding) needed to 
process radio signals with a personal computer; sort of like the IDEs people 
use to create executables.  One can create there own processing blocks or use 
blocks that others have created.  

Thanks for your cooperation and patience!   I am going to keep working on this 
as time allows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Small program ideas

2013-02-16 Thread Mark R Rivet
On Fri, 15 Feb 2013 22:52:57 -0500, Mitya Sirenef
 wrote:

>On 02/15/2013 10:22 PM, eli m wrote:
>> Any small program ideas? I would prefer to stick to command line ones. 
>> Thanks.
>
>How about these two:
>
>  - simulation of a street crossing with green/red lights allowing cars 
>and pedestrians to pass in one direction then another
>
>  - simulation of an elevator in a building: buttons on each floor to 
>call the elevator, buttons inside to go to a particular floor,
>multiple floors can be selected at the same time, creating a queue 
>of floors to go to.
>
>  -m

I like the elevator sim proposal. We did that exercise in C++ in
college. It makes use of few data structures. I actually was very
impressed at how intense the algorithm for an elevator could be.
Especially if, say, its a skyscraper with many floors and elevator
shafts. Very good exercise! I am new to python myself and just may try
that for the practise.

Here's my suggestion: A python game AI for the text game "Zork"


USMC
Semper Fi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Small program ideas

2013-02-16 Thread Mark R Rivet
On Fri, 15 Feb 2013 19:57:35 -0800 (PST), eli m
 wrote:

>On Friday, February 15, 2013 7:52:57 PM UTC-8, Mitya Sirenef wrote:
>> On 02/15/2013 10:22 PM, eli m wrote:
>> 
>> > Any small program ideas? I would prefer to stick to command line ones. 
>> > Thanks.
>> 
>> 
>> 
>> How about these two:
>> 
>> 
>> 
>>   - simulation of a street crossing with green/red lights allowing cars 
>> 
>> and pedestrians to pass in one direction then another
>> 
>> 
>> 
>>   - simulation of an elevator in a building: buttons on each floor to 
>> 
>> call the elevator, buttons inside to go to a particular floor,
>> 
>> multiple floors can be selected at the same time, creating a queue 
>> 
>> of floors to go to.
>> 
>> 
>> 
>>   -m
>> 
>> 
>> 
>> -- 
>> 
>> Lark's Tongue Guide to Python: http://lightbird.net/larks/
>
>Could i make these text and not visual? That is what i am trying to do.

I would say text would be best. That way you would get the programming
logic down. Graphics would be the next level that could be added.
USMC
Semper Fi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python math problem

2013-02-16 Thread Dave Angel

On 02/16/2013 08:55 AM, Nobody wrote:

On Fri, 15 Feb 2013 11:47:33 -0800, Gary Herron wrote:


Floating point calculations on a computer (ANY computer, and ANY
programming language) can *never* be expected to be exact!


"never" is incorrect. There are many floating-point calculations
which can reasonably be expected be exact[2].

However, multiplying by pi (as in math.radians) isn't such a
calculation[1], so radians(90) isn't exactly equal to pi/2 and so
cos(radians(90)) isn't exactly equal to zero.

[1] It's not so much that the calculation isn't exact, but that the
calculation has to use an inexact approximation to pi to start with.

[2] In particular, any addition, subtraction, multiplication, division,
modulo or square-root calculation for which the correct answer is exactly
representable should actually produce the correct answer, exactly.

Furthermore, any such calculation for which the correct answer isn't
exactly representable should produce the same result as if the correct
answer had been calculated to an infinite number of digits then rounded to
the nearest representable value according to the current rounding mode.

This doesn't apply to transcendental functions (trig, log, exponential),
which are subject to the "table maker's dilemma". Typically, the actual
result will be one of the two closest representable values to the correct
answer, but not necessarily *the* closest.

IOW: floating-point arithmetic is deterministic. It follows rules. Not the
same rules as real arithmetic, but rules nonetheless. Contrary to
common superstition, the least-significant bits are *not* taken from
/dev/random.



Combining two of those rules:   Many years ago I microcoded the decimal 
math package for a machine. Upon checking the value for sin(pi), I was 
considering whether using a different reduction algorithm might get an 
answer closer to zero.  The system used a 13 decimal digit mantissa. 
Imagine my pleasure when I realized that the *second* 13 digits of pi 
were what I was seeing for a result.  (Actually, with a negative sign)


The quantization error of representing pi meant that I was a little 
distance away from 90 degrees, and since the slope of the curve is -1 at 
that point, abs(result) was the first 13 digits of that error.


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


ANN: Python 3 enum package

2013-02-16 Thread Ethan Furman

Greetings!

There was a recent thread on Python-Ideas about adding an enumeration package
to the stdlib.  One idea that seemed to be fairly popular (at least I like it a 
lot ;)
was the use of a metaclass to automatically assign values when a name lookup 
failed.

It was also fairly unpopular and so probably won't make it in (although another 
good one
seems poised to be accepted -- flufl.enum, I believe).

At any rate, I finished putting my prototype together, and it is available on 
github here:

https://bitbucket.org/stoneleaf/enum


And here is some sample code so you can see if you would like to take a closer 
look
(comments and critiques welcome):


8<--
#!/usr/bin/python3

from enum import Enum, BitMaskEnum, UniqueEnum, enum

class Color(Enum):
"basic red/green/blue"
black
red
green
blue

print(Color)
print(Color.green)
print(Color(2))
print(Color('green'))
print(repr(Color.green))

class MoreColor(Color):
"and some cyan/magenta/yellow"
cyan
magenta
yellow

print(MoreColor)
print(MoreColor.red)
print(MoreColor(1))
print(MoreColor('red'))
print(repr(MoreColor.red))

class Errors(Enum):
missing
closed
corrupted
modified

print(Errors)
print(Errors.closed)
print(Errors(1))
print(Errors('closed'))
print(repr(Errors.closed))

print(Color.red in Color)
print(MoreColor.magenta in MoreColor)
print(Color.red in MoreColor)
print(Color.red == MoreColor.red)

print(not (Errors.closed in MoreColor))
print(not (Errors.closed in Color))
print(not (Errors.closed == Color.red))
print(not (Errors.closed == MoreColor.red))

class Status(BitMaskEnum):
has_memo
binary
increment
unicoded

print(Status)
for e in Status:
print(repr(e))
print(Status.binary | Status.increment)
print(Status(5))
print(Status('binary|increment'))
print(repr(Status(5)))

class Position(UniqueEnum):
LEFT
RIGHT
TOP
BOTTOM

print(Position)
print(Position.TOP)
print(Position('top'))
print(Position('TOP'))
print(repr(Position.TOP))

#return class discarded
print(Enum.create('IceCream', 'chocolate vanilla strawberry'))

#class stuffed into globals
Enum.create('IceCream', 'chocolate vanilla strawberry', namespace=globals())
print(IceCream)

# can even subclass this way
import sys
Enum.create(
'MoreIceCream',
'cherry rockyroad coconut',
bases=(IceCream,),
namespace=sys.modules)
from MoreIceCream import * # and import from it
print(cherry)
print()

# and if you don't like the magic, don't use it  :)
class Color(BitMaskEnum):
black  = enum('midnight', '#000', value=0)
red= enum('sunset',   '#001')
green  = enum('emerald',  '#010')
blue   = enum('sky',  '#100')

def __init__(yo, desc, code):
"value is automatically saved"
yo.desc = desc
yo.code = code

def describe(yo, noun):
return "%s %s" % (yo.desc, noun)

print(Color)
print(Color.green)
print(repr(Color.green))
print(Color.green.describe('glow'))

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


python on windows

2013-02-16 Thread babatunde akerele
hello, i'm having problem coding and running python on my pc...i just
started learning python last month in codeacademy.com but i've not
been able to code offline 'cos i don't knw how to go abt installing
the compiler and all that. Any help please?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python on windows

2013-02-16 Thread Michael Herman
http://www.youtube.com/watch?v=dFnuK9dlWdk

On Sat, Feb 16, 2013 at 1:40 PM, babatunde akerele wrote:

> hello, i'm having problem coding and running python on my pc...i just
> started learning python last month in codeacademy.com but i've not
> been able to code offline 'cos i don't knw how to go abt installing
> the compiler and all that. Any help please?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python on windows

2013-02-16 Thread David Robinow
On Sat, Feb 16, 2013 at 4:40 PM, babatunde akerele  wrote:
> hello, i'm having problem coding and running python on my pc...i just
> started learning python last month in codeacademy.com but i've not
> been able to code offline 'cos i don't knw how to go abt installing
> the compiler and all that. Any help please?
Download the Python 3.3 installer from http://www.python.org/download/
and run it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Comparing types

2013-02-16 Thread Jason Friedman
I want to tell whether an object is a regular expression pattern.

Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> s = "hello"
>>> type(s)

>>> isinstance(s, str)
True
>>> my_pattern = re.compile(s)
>>> type(my_pattern)

>>> isinstance(my_pattern, _sre.SRE_Pattern)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name '_sre' is not defined
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: call from pthon to shell

2013-02-16 Thread Jason Friedman
 import os
 os.system("i=3")
> 0
 os.system("echo $i")
>
> 0
>
> why i can not get the value of i?

Each call to os.system starts a new shell.  Think about what would
happen if you opened a terminal and typed:

$ i=3

Then, close that terminal and open a new one.  You would not be surprised that

$ echo $i

returns nothing.

And, as mentioned by Andrew, even absent that problem os.system is not
the way to obtain the data you are looking for.

I realize this is now 5 days after you posted ... what were you
ultimately attempting to accomplish?
-- 
http://mail.python.org/mailman/listinfo/python-list


Calendar module question

2013-02-16 Thread Phil

Thank you for reading this.

My adventures with Python have just begun and during the few weeks I 
have tried many IDEs. The following piece of code fails under all IDEs, 
and the interpreter, except under the Wing IDE.


Why would this code work under the Wing IDE and nowhere else? Could 
there be a different calendar module included with Wing?


import calendar

cal = calendar.prcal(2013)
print cal

Traceback (most recent call last):
  File "calendar.py", line 1, in 
import calendar
  File "/home/phil/calendar.py", line 3, in 
cal = calendar.prcal(2013)
AttributeError: 'module' object has no attribute 'prcal'

--
Regards,
Phil
--
http://mail.python.org/mailman/listinfo/python-list