Re: code review

2012-07-02 Thread Steven D'Aprano
On Sun, 01 Jul 2012 21:50:29 -0400, Devin Jeanpierre wrote:

> On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano
>  wrote:
>> Technically, < in Python is left-associative: a < b < c first evaluates
>> a, not b or c. But it is left-associative under the rules of comparison
>> operator chaining, not arithmetic operator chaining.
> 
> Left-associativity is when a < b < c is equivalent to (a < b) < c.
> 
> You're talking about evaluation order, which can be different. For
> example, hypothetically, (a < b) < c could evaluate c first, then b,
> then a. However, Python always evaluates operands left-to-right.
> 
> A particular case where this comes into play is the ** operator, which
> is right-associative but still has a left-to-right evaluation order.

Yes, you are right, my mistake.




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


hello everyone! i'm a new member from China

2012-07-02 Thread levi nie
i love python very much.it's powerful,easy and useful.
i got it from Openstack.And i'm a new guy on python.
Can i ask some stupid questions in days? haha...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hello everyone! i'm a new member from China

2012-07-02 Thread Peter Otten
levi nie wrote:

> i love python very much.it's powerful,easy and useful.
> i got it from Openstack.And i'm a new guy on python.

Welcome!

> Can i ask some stupid questions in days? haha...

Sure, but we cannot guarantee that the answer will be stupid, too ;)

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


Re: hello everyone! i'm a new member from China

2012-07-02 Thread Chris Angelico
On Mon, Jul 2, 2012 at 12:48 AM, levi nie  wrote:
> i love python very much.it's powerful,easy and useful.
> i got it from Openstack.And i'm a new guy on python.
> Can i ask some stupid questions in days? haha...

Of course you can. Everyone else does! :) Just remember to give it a
good subject line, state your question clearly, and so on - you'll be
fine.

Welcome!

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


Re: code review

2012-07-02 Thread Steven D'Aprano
On Mon, 02 Jul 2012 12:04:29 +1000, Chris Angelico wrote:

>> Chained comparisons in the Python sense may be rare in computer
>> languages, but it is the standard in mathematics and hardly needs to be
>> explained to anyone over the age of twelve. That is a terrible
>> indictment on the state of programming language design.
> 
> I'd say that proves that Python is a good language for expressing
> mathematics in, then. That's all. 

No. Python is a terrible language for expressing mathematics in. As you 
point out, I can't do things like:

x = y+2
x*3 = y*4+7
print("x = %d, y = %d",x,y)

and sensibly get x = 1, y = -1.


But Python is an excellent language for expressing a series of 
comparisons in, which has applications beyond pure maths or algebra. For 
example:

"c" < first_word < second_word == third_word < "x"

I'm sure I don't have to explain what that means -- that standard chained 
notation for comparisons is obvious and simple. 

In Python, you write it the normal way, as above. But some other 
languages force you into verbosity:

("c" < first_word) and (first_word < second_word) and (second_word == 
third_word) and (third_word < "x")

Worst of all are those languages which allow you to write the expression 
as normal, but evaluate it in a way that you almost never want: the 
maximum number of bugs with the minimum convenience.

This has nothing to do with algebra. It is about picking semantics for 
chained comparisons which is sensible and useful and matches what people 
expect from regular language. 

If you write 2+2 = 2*2 = 4, nearly everyone will agree that, yes, that is 
true. Interpreting it as 1 == 4 is neither sensible nor useful and it is 
certainly not what people expect.


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


Re: code review

2012-07-02 Thread Chris Angelico
On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano
 wrote:
> "c" < first_word < second_word == third_word < "x"
>
> I'm sure I don't have to explain what that means -- that standard chained
> notation for comparisons is obvious and simple.
>
> In Python, you write it the normal way, as above. But some other
> languages force you into verbosity:
>
> ("c" < first_word) and (first_word < second_word) and (second_word ==
> third_word) and (third_word < "x")

Uhh, actually you DO have to explain that, because I interpreted it
quite differently:

(("c" < first_word) and (first_word < second_word)) == (third_word < "x")

And even if you can prove that my interpretation is wrong, it's still
plausible enough that I, as a programmer, would have to dive to the
manual (or test in interactive interpreter) to find out which way the
language evaluates this.

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


Is Django v1.3 documentation the newest version?

2012-07-02 Thread levi nie
Is  Django v1.3 documentation the newest version?
i use the Django book 2.0.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Django v1.3 documentation the newest version?

2012-07-02 Thread Jonathan Harris
Hello

It isn't
Having been frustrated with out of date books, specifically the Apress
published 'Definitive Guide To Django', I've downloaded the Kindle edition
of Django 1.4 documentation
It's a good tutorial

J

On Mon, Jul 2, 2012 at 11:00 AM, levi nie  wrote:

> Is  Django v1.3 documentation the newest version?
> i use the Django book 2.0.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use tkinter in python3.2?

2012-07-02 Thread contro opinion
apt-get install  tk-dev
cd  ./python3.2.3
./cpnfigure
make
make install


ok

root@ocean:/home/tiger/Python-3.2.3# python3.2
Python 3.2.3 (default, Jul  2 2012, 21:23:34)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import  tkinter
>>>


haha,think   Serhiy Storchaka

2012/7/1 Serhiy Storchaka 

> On 01.07.12 07:25, contro opinion wrote:
>
>> i have installed  tk  ,how to use tkinker in python3.2?
>>
>
> You must install tk-dev (or whatever it's called on your system) before
> Python building (don't forget to rerun configure).
>
> --
> http://mail.python.org/**mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eGenix PyRun - One file Python Runtime 1.0.0

2012-07-02 Thread eGenix Team: M.-A. Lemburg

ANNOUNCING

 eGenix PyRun - One file Python Runtime

 Version 1.0.0


  An easy-to-use single file relocatable Python run-time -
available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-PyRun-1.0.0.html


INTRODUCTION

Our new eGenix PyRun combines a Python interpreter with an almost
complete Python standard library into a single easy-to-use
executable, that does not require a system wide installation and
is fully relocatable.

eGenix PyRun's executable only needs 12MB, but still supports
most Python application and scripts - and it can be further
compressed to 3-4MB using gzexe or upx.

Compared to a regular Python installation of typically 100MB on
disk, this makes eGenix PyRun ideal for applications and scripts
that need to be distributed to many target machines, client
installations or customers.

It makes "installing" Python on a Unix based system as simple as
copying a single file.

http://www.egenix.com/products/python/PyRun/


NEWS

This is the first public release of eGenix PyRun. We have been
using the product internally in our mxODBC Connect Server since
2008 with great success and have now extracted it into a
stand-alone open-source product.

We provide both the source archive to build your own eGenix
PyRun, as well as provide pre-compiled binaries for Linux,
FreeBSD and Mac OS X, for the resp. 32- and 64-bit platforms.

Presentation at EuroPython 2012
---

Marc-André, CEO of eGenix, will be giving a presentation about
eGenix PyRun at EuroPython 2012 in Florence, Italy on Wednesday,
July 4th in the Room Tagliatelle.

He will also be available during the conference to answer
questions.


DOWNLOADS

The download archives and instructions for installing the product
can be found at:

http://www.egenix.com/products/python/PyRun/

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about eGenix PyRun, licensing and download
instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


how to solve this tclerror?

2012-07-02 Thread contro opinion
i want to install  a  software,

please see the manul page  2
http://www.openfiling.info/wp-content/upLoads/data/ArelleUsersManual.pdf

when i input the command  to install  Arelle :


tiger@ocean:~$  cd  /home/tiger/Arelle
tiger@ocean:~/Arelle$ python3.2  arelleGUI.pyw
Traceback (most recent call last):
  File "arelleGUI.pyw", line 11, in 
CntlrWinMain.main()
  File "/home/tiger/Arelle/arelle/CntlrWinMain.py", line 1113, in main
cntlrWinMain = CntlrWinMain(application)
  File "/home/tiger/Arelle/arelle/CntlrWinMain.py", line 164, in __init__
windowFrame = Frame(self.parent)
  File "/usr/local/lib/python3.2/tkinter/ttk.py", line 761, in __init__
Widget.__init__(self, master, "ttk::frame", kw)
  File "/usr/local/lib/python3.2/tkinter/ttk.py", line 559, in __init__
_load_tile(master)
  File "/usr/local/lib/python3.2/tkinter/ttk.py", line 47, in _load_tile
master.tk.eval('package require tile') # TclError may be raised here
_tkinter.TclError: can't find package tile

how to solve this problem?

i have installed  python3.2  ,tk-dev ,lxml ,tkinter

tiger@ocean:~/Arelle$ python3.2
Python 3.2.3 (default, Jul  2 2012, 21:23:34)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> import lxml
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to solve this tclerror?

2012-07-02 Thread contro opinion
i solve it myself
1.download  tile-0.8.4.0.tar.gz
2.   ./configure
3.  make
4  make  install

tiger@ocean:~$  cd  /home/tiger/Arelle
tiger@ocean:~/Arelle$ python3.2  arelleGUI.pyw

i get what i want ,haha.

2012/7/2 contro opinion 

> i want to install  a  software,
>
> please see the manul page  2
> http://www.openfiling.info/wp-content/upLoads/data/ArelleUsersManual.pdf
>
> when i input the command  to install  Arelle :
>
>
> tiger@ocean:~$  cd  /home/tiger/Arelle
> tiger@ocean:~/Arelle$ python3.2  arelleGUI.pyw
> Traceback (most recent call last):
>   File "arelleGUI.pyw", line 11, in 
> CntlrWinMain.main()
>   File "/home/tiger/Arelle/arelle/CntlrWinMain.py", line 1113, in main
> cntlrWinMain = CntlrWinMain(application)
>   File "/home/tiger/Arelle/arelle/CntlrWinMain.py", line 164, in __init__
> windowFrame = Frame(self.parent)
>   File "/usr/local/lib/python3.2/tkinter/ttk.py", line 761, in __init__
> Widget.__init__(self, master, "ttk::frame", kw)
>   File "/usr/local/lib/python3.2/tkinter/ttk.py", line 559, in __init__
> _load_tile(master)
>   File "/usr/local/lib/python3.2/tkinter/ttk.py", line 47, in _load_tile
> master.tk.eval('package require tile') # TclError may be raised here
> _tkinter.TclError: can't find package tile
>
> how to solve this problem?
>
> i have installed  python3.2  ,tk-dev ,lxml ,tkinter
>
> tiger@ocean:~/Arelle$ python3.2
> Python 3.2.3 (default, Jul  2 2012, 21:23:34)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import tkinter
> >>> import lxml
> >>>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 02:43 AM, Steven D'Aprano wrote:
> On Sun, 01 Jul 2012 09:35:40 +0200, Thomas Jollans wrote:
>> This is simply wrong. The comparisons are not acting as binary
>> operators.
> 
> Of course they are. Take this chained comparison:

Technically, yes - two-input operations are happening. Syntactically,
no. Read my post.

> 1) What is the operator in this expression? Is it < or == or something 
> else?

I think I've answered this - it's the combination.

> 2) What double-underscore special method does it call? Where is this 
> mysterious, secret, undocumented method implemented?
> 
> 3) Why do the Python docs lie that a < b == c is exactly equivalent to 
> the short-circuit expression (a < b) and (b == c) with b evaluated once?
> 
> 4) And how do you explain that the compiled byte code actually calls the 
> regular two-argument binary operators instead of your imaginary three-
> argument ternary operator?

In this context, I don't care what actually happens. I'm talking about
how the code can be parsed (by the generic reader, not necessarily the
python interpreter).


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


Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 03:28 AM, Steven D'Aprano wrote:
> We *really did have* somebody arguing that chained comparisons are Bad 
> because you can't stick parentheses around bits of it without changing 
> the semantics. That was an actual argument, not a straw-man.

Ahem. It may have been sub-optimally phrased in a way that opened itself
up to attack, but I was arguing that Python comparisons operators are
anomalous because they're not associative.

(and, going back to the root of the argument, this makes them Bad
because "Special cases aren't special enough to break the rules.")


On Sun, 01 Jul 2012 21:50:29 -0400, Devin Jeanpierre wrote:

> On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano
>  wrote:
>> Technically, < in Python is left-associative: a < b < c first evaluates
>> a, not b or c. But it is left-associative under the rules of comparison
>> operator chaining, not arithmetic operator chaining.
>
> Left-associativity is when a < b < c is equivalent to (a < b) < c.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hello everyone! i'm a new member from China

2012-07-02 Thread rdsteph
On Jul 2, 12:50 am, Peter Otten <__pete...@web.de> wrote:
> levi nie wrote:
> > i love python very much.it's powerful,easy and useful.
> > i got it from Openstack.And i'm a new guy on python.
>
> Welcome!
>
> > Can i ask some stupid questions in days? haha...
>
> Sure, but we cannot guarantee that the answer will be stupid, too ;)

Hello and welcome,

What part of China do you live in? I have visited many cities in China
on business and had wonderful experiences.

I think Python is kind of like the Middle Kingdom of programming
languages. :-)

Ron Stephens
Awaretek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2to6 ?

2012-07-02 Thread Thomas Heller

Am 27.06.2012 20:06, schrieb Terry Reedy:

On 6/27/2012 10:36 AM, Thomas Heller wrote:

Is there a tool, similar to 2to3, which converts python2 code
to code using six.py, so that it runs unchanged with python2
*and* python 3?


Others have expressed a similar wish, but I do not know that anyone has
actually revised 2to3 to make a 2to6, or how feasible that would be.



Has nobody heard of, or even tried, modernize?

http://pypi.python.org/pypi/modernize


Thomas



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


Re: code review

2012-07-02 Thread Terry Reedy

On 7/2/2012 1:20 AM, Dennis Lee Bieber wrote:


Obviously, someone coming over from VB or R


or any other single language x


who hasn't read the Python reference is going to


be surprised as something or other. So what. The manuals, including the 
tutorial, are there for a reason. The main points of the language take 
just a few hours to review.


Perhaps my advantage learning Python was that I had written code in over 
10 other languages and dialects and so had few expectations and made few 
assumptions.


--
Terry Jan Reedy



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


WxSlider Mouse Wheel Resolution

2012-07-02 Thread Wanderer
Is there a way to set the mouse wheel resolution for the wxPython
wx.Slider? I would like to use the graphic slider for coarse control
and the mouse wheel for fine control. Right now the mouse wheel makes
the slider jump ten counts and I would like it to be a single count.

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


Re: how to solve this tclerror?

2012-07-02 Thread Terry Reedy

On 7/2/2012 10:14 AM, contro opinion wrote:

i solve it myself
1.download  tile-0.8.4.0.tar.gz


Or install the latest tcl/tk 8.5(.11), which includes tile/tkk and bug 
fixes, instead of the rather old 8.4.?.

--
Terry Jan Reedy



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


Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 3:20 am, Chris Angelico  wrote:
> On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano
>
>  wrote:
> > "c" < first_word < second_word == third_word < "x"
>
> > I'm sure I don't have to explain what that means -- that standard chained
> > notation for comparisons is obvious and simple.
>
> > In Python, you write it the normal way, as above. But some other
> > languages force you into verbosity:
>
> > ("c" < first_word) and (first_word < second_word) and (second_word ==
> > third_word) and (third_word < "x")
>
> Uhh, actually you DO have to explain that, because I interpreted it
> quite differently:
>
> (("c" < first_word) and (first_word < second_word)) == (third_word < "x")

Poor Chris. That's because you've been brainwashed into believing you
must spoon feed your interpreter to get your code working correctly.
Stop applying these naive assumptions to Python code. Python knows
when you reach the end of a statement, no need for redundant
semicolons! Python knows when its reached the end of block and needs
to drop back one level, no need for redundant road signs.  Python
knows Chris; Python KNOWS!

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


Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:57 AM, Rick Johnson
 wrote:
> Poor Chris. That's because you've been brainwashed into believing you
> must spoon feed your interpreter to get your code working correctly.
> Stop applying these naive assumptions to Python code. Python knows
> when you reach the end of a statement, no need for redundant
> semicolons! Python knows when its reached the end of block and needs
> to drop back one level, no need for redundant road signs.  Python
> knows Chris; Python KNOWS!

Why "poor", Ralph?

I am poor in the essence of ignorance's bliss, rich only in the
never-ending thirst for knowledge and more languages. In me there meet
a combination of antithetical elements which are at eternal war with
one another... I hope I make myself clear, lady?

Oops, wrong mailing list. Near enough.

Python is not magic. It's not that it "knows" when I reach the end of
a statement; it simply rules that line ends correspond to statement
ends unless ordered otherwise. It has been told that the reduction of
indentation level is a lexer token. Rick, do you realize that you have
to spoon-feed the interpreter with spaces/tabs when other interpreters
just KNOW to drop back an indentation level when you close a brace?



I simply need to make sure that the interpreter and I have the same
understanding of the code. It will then work correctly. There's
nothing special about one syntax or another, they're all just
communication from my brain to a CPU, and different syntaxes are
suited to different tasks. There's nothing inherently wrong with:

right_length = len(x) > 5, < 20

being a valid way of expressing a double condition. It puts the query
first and the bounds after it, so hey, it's justifiably sane. (No, I'm
not advocating adding this. It's just for argument's sake.) Whatever
you're writing with, you need to have the same rules in your head as
the compiler/interpreter uses; beyond that there's a huge amount of
personal preference (I quite like braces, myself, but many others
don't) and only a relatively small amount of actual logic (use ASCII
mathematical symbols to represent mathematical operations).

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


Re: code review

2012-07-02 Thread Rick Johnson
On Jun 30, 9:06 pm, Steven D'Aprano  wrote:
> On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote:
> > Yes. My sole point, really, is that "normally", one would expect these
> > two expressions to be equivalent:
>
> > a < b < c
> > (a < b) < c
>
> Good grief. Why would you expect that?
>
> You can't just arbitrarily stick parentheses around parts of expressions
> and expect the result to remain unchanged. Order of evaluation matters:
>
> 2**3**4 != (2**3)**4

Yes but as Chris points out in the next message, you can inject the
following parenthesis without changing a thing!:

py> 1 + 3 * 4
13
py> 1 + (3 * 4)
13

Of course i understand the rules of operator precedence, however i
have never liked them AND i continue to believe that such
functionality breeds bugs and is in fact bad language design. I
believe all evaluations should be cumulative:

py> 1 + 3 * 4
should ALWAYS equal 16!

With parenthesis only used for grouping:
py> a + (b*c) + d

Which seems like the most consistent approach to me.

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


Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson
 wrote:
> py> 1 + 3 * 4
> should ALWAYS equal 16!
>
> With parenthesis only used for grouping:
> py> a + (b*c) + d
>
> Which seems like the most consistent approach to me.

Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster
found on page 153 of the 3.5th Edition Monster Manual.

Let's see. By your principle, we should evaluate the ** before the - in:

2**-1

Have fun.

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


Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-02 Thread John Nagle

On 7/1/2012 10:51 AM, dmitrey wrote:

hi all,
are there any information about upcoming availability of parallel
computations in CPython without modules like  multiprocessing? I mean
something like parallel "for" loops, or, at least, something without
forking with copying huge amounts of RAM each time and possibility to
involve unpiclable data (vfork would be ok, but AFAIK it doesn't work
with CPython due to GIL).

AFAIK in PyPy some progress have been done (
http://morepypy.blogspot.com/2012/06/stm-with-threads.html )

Thank you in advance, D.



   It would be "un-Pythonic" to have real concurrency in Python.
You wouldn't be able to patch code running in one thread from
another thread.  Some of the dynamic features of Python
would break.   If you want fine-grained concurrency, you need
controlled isolation between concurrent tasks, so they interact
only at well-defined points.  That's un-Pythonic.

John Nagle

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


Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 11:42 am, Chris Angelico  wrote:
> Rick, do you realize that you have
> to spoon-feed the interpreter with spaces/tabs when other interpreters
> just KNOW to drop back an indentation level when you close a brace?

Yes. And significant white space is my favorite attribute of Python
source code. But the difference here is like night and day. While your
getting bogged down playing "match-the-brackets", i'm writing code and
being productive. I don't need to put any mental effort into pressing
the Enter+Tab keys. On the contrary, you must constantly break your
mental focus to "corral" the braces, and the sad part is, you're still
formatting your code like mine (with tabs and newlines!) however your
simultaneously juggling superfluously archaic syntax! Why Chris? WHY?

> I simply need to make sure that the interpreter and I have the same
> understanding of the code. It will then work correctly. There's
> nothing special about one syntax or another,

I agree in the sense of: "to each his own". However. There are methods
of writing code that are more productive, and methods that are less
productive, and your emotive agenda of defending such nostalgic
pedantry is quite self-defeating.

> they're all just
> communication from my brain to a CPU, and different syntaxes are
> suited to different tasks. There's nothing inherently wrong with:
>
> right_length = len(x) > 5, < 20

Agreed. I wish we had one language. One which had syntactical
directives for scoping, blocks, assignments, etc, etc...

BLOCK_INDENT_MARKER -> \t
BLOCK_DEDENT_MARKER -> \n
STATEMENT_TERMINATOR -> \n
ASSIGNMENT_OPERATOR -> :=
CONDITIONAL_IF_SPELLING -> IF
CONDITIONAL_ELSE_SPELLING -> EL
...

> (I quite like braces, myself, [...] and only a relatively small
> amount of actual logic.

So you have a penchant for confinement and an aversion to logic? Hmm,
interesting!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-02 Thread Stefan Behnel
Dan Stromberg, 01.07.2012 21:28:
> On Sun, Jul 1, 2012 at 11:58 AM, Thomas Jollans wrote:
>> On 07/01/2012 08:44 PM, Dan Stromberg wrote:
>>> IronPython, sadly, lacks a python standard library.
>>
>> Beg pardon?
>>
>> https://github.com/IronLanguages/main/tree/master/External.LCA_RESTRICTED/Languages/IronPython/27/Lib
>
> Perhaps things have changed.

Yes, they have. The original restriction came from Microsoft enforcing a
clean-room implementation for their code, which obviously excluded the
standard library - which is well tested and licence cleared and all that,
but nevertheless non-MS. When they dropped the IronPython project, it
became free to integrate with other software.

Clearly a cultural thing.

Stefan

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


Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 08:22 PM, Rick Johnson wrote:
> Agreed. I wish we had one language. One which had syntactical
> directives for scoping, blocks, assignments, etc, etc...
> 
> BLOCK_INDENT_MARKER -> \t
> BLOCK_DEDENT_MARKER -> \n
> STATEMENT_TERMINATOR -> \n
> ASSIGNMENT_OPERATOR -> :=
> CONDITIONAL_IF_SPELLING -> IF
> CONDITIONAL_ELSE_SPELLING -> EL
> ...

You must be joking.

In C, for example, it is possible to "create your own language" by going

#define IF(cond) if (cond) {
#define ELSE } else {
#define ELIF(cond) } else if (cond) {
#define ENDIF }


and so on. There's a reason nobody does it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Ian Kelly
On Sat, Jun 30, 2012 at 2:50 PM, Thomas Jollans  wrote:
> Which of the two comparisons is done first anyway?
> "In the face of ambiguity, refuse the temptation to guess."

I would consider that a pro, not a con, because the C-like way is much
worse in this regard.  Using operator chaining, is "1 < 2 < 3"
equivalent to:

1 < 2 and 2 < 3  # assuming left-to-right evaluation order for "and"
2 < 3 and 1 < 2

The former seems pretty obvious to me (since it more closely matches
the original syntax) and also turns out to be correct, but more to the
point, most of the time it really doesn't matter which is evaluated
first.  It's only relevant if:

a) your comparison operator has side-effects (bad programmer! bad!); or
b) one of the comparisons is significantly faster than the other --
but since usually both comparisons will be of the same type (e.g. both
comparing two numbers), this is also a corner case.

On the other hand, using the C-like interpretation, is "1 < 2 < 3"
equivalent to:

(1 < 2) < 3
1 < (2 < 3)

I would guess the former is more common, but I really have no basis
for that guess beyond some experience with languages that use this
syntax.  I can see no particular advantages to either interpretation
and can certainly imagine that some languages might choose the latter
instead.  Moreover, the distinction actually matters in this case,
because the first expression is true (at least in Python) while the
second is false.

I will take ambiguity that is mostly unimportant over ambiguity that
is critical to the meaning of the expression any day of the week.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2to6 ?

2012-07-02 Thread Terry Reedy

On 7/2/2012 11:02 AM, Thomas Heller wrote:

Am 27.06.2012 20:06, schrieb Terry Reedy:

On 6/27/2012 10:36 AM, Thomas Heller wrote:

Is there a tool, similar to 2to3, which converts python2 code
to code using six.py, so that it runs unchanged with python2
*and* python 3?


Others have expressed a similar wish, but I do not know that anyone has
actually revised 2to3 to make a 2to6, or how feasible that would be.



Has nobody heard of, or even tried, modernize?

http://pypi.python.org/pypi/modernize


I had not, obviously. I'm glad you found it and hope it works for you.


--
Terry Jan Reedy



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


Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 2:06 pm, Thomas Jollans  wrote:
> On 07/02/2012 08:22 PM, Rick Johnson wrote:
>
> > Agreed. I wish we had one language. One which had syntactical
> > directives for scoping, blocks, assignments, etc, etc...
>
> > BLOCK_INDENT_MARKER -> \t
> > BLOCK_DEDENT_MARKER -> \n
> > STATEMENT_TERMINATOR -> \n
> > ASSIGNMENT_OPERATOR -> :=
> > CONDITIONAL_IF_SPELLING -> IF
> > CONDITIONAL_ELSE_SPELLING -> EL
> > ...
>
> You must be joking.


Well i was slightly serious, but mostly sarcastic.

Whist customizable syntax would be a great benefit to the individual,
it would be a nightmare to the community -- the real solution lies in
assimilation!

I am reminded of a story: A few years back a very nice old woman
offered to give me her typewriter. She said: "i might need to type a
letter one day and it would good to have around". It was a nice
typewriter for 1956, but she had no idea her little "machine" was
reduced to no less than a paper weight thanks to something called the
PC. Her machine had been extinct for decades. Effectually, SHE had
been extinct for decades.

When i hear people like Chris evangelizing about slavish syntax, i am
reminded of the nice old lady. Her intentions where virtuous, however
her logic was flawed. She is still clinging to old technology. Like
the Luddites she refuses to see the importance technological
advancements. And by harboring this nostalgia she is actually
undermining the future evolution of an entire species. Lifespans are
limited for a very important evolutionary reason!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxSlider Mouse Wheel Resolution

2012-07-02 Thread Rick Johnson
On Jul 2, 10:45 am, Wanderer  wrote:
> Is there a way to set the mouse wheel resolution for the wxPython
> wx.Slider? I would like to use the graphic slider for coarse control
> and the mouse wheel for fine control. Right now the mouse wheel makes
> the slider jump ten counts and I would like it to be a single count.
>
> Thanks

I have always found GUI mouse wheel events (and others) to be lacking
in the "user tuned control" category. NOTE: Instead of forcing your
lib users to configure specifics or re-bind events like(course,
medium, fine) simply pre-bind the following events and empower the end
user:

  MouseWheel -> cb(MEDIUM)
  MouseWheel+ControlKey -> cb(FINE)
  MouseWheel+ShiftKey -> cb(COURSE)

What a novel FREAKING idea!

*school-bell-rings*

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


Re: WxSlider Mouse Wheel Resolution

2012-07-02 Thread Rick Johnson
On Jul 2, 3:45 pm, Rick Johnson  wrote:
> [...]
>   MouseWheel -> cb(MEDIUM)
>   MouseWheel+ControlKey -> cb(FINE)
>   MouseWheel+ShiftKey -> cb(COURSE)

Of course some could even argue that three levels of control are not
good enough; for which i wholeheartedly agree!

A REAL pro would provide a configurable method to the user for which a
slider (or numerical range) would pop up to micro-adjust the
increment. However! I think all widgets should expose every
configurable option to the end user. All configure options would be
available by default and the developer can restrict ANY configure
option(s) which would have disastrous side-effects for that particular
GUI.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 5:06 AM, Thomas Jollans  wrote:
> On 07/02/2012 08:22 PM, Rick Johnson wrote:
>> Agreed. I wish we had one language. One which had syntactical
>> directives for scoping, blocks, assignments, etc, etc...
>>
>> BLOCK_INDENT_MARKER -> \t
>> BLOCK_DEDENT_MARKER -> \n
>> STATEMENT_TERMINATOR -> \n
>> ASSIGNMENT_OPERATOR -> :=
>> CONDITIONAL_IF_SPELLING -> IF
>> CONDITIONAL_ELSE_SPELLING -> EL
>> ...
>
> You must be joking.
>
> In C, for example, it is possible to "create your own language" by going
>
> #define IF(cond) if (cond) {
> #define ELSE } else {
> #define ELIF(cond) } else if (cond) {
> #define ENDIF }
>
>
> and so on. There's a reason nobody does it.

I'll go one further. The "create your own language" is just a plain
text file, is in fact is NO LANGUAGE. If it's that flexible, what's
the use of calling it the same language?

Actually there is a lot of use in having that sort of commonality, but
at a different level: source control. Tools like git are
language-agnostic; I can have a repository with Javascript, PHP (ugh),
Pike (that atones), Python, C++, etc source files, a single makefile
that in the darkness binds them, and so on. But they're still all
different languages.

Oh and Rick? Nice troll there with the ellipsis. You fail grammar
forever, but hey, at least you win at trolling.

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


helping with unicode

2012-07-02 Thread self.python
it's a simple source view program.

the codec of the target website is utf-8
so I read it and print the decoded

--
#-*-coding:utf8-*-
import urllib2

rf=urllib2.urlopen(r"http://gall.dcinside.com/list.php?id=programming";)

print rf.read().decode('utf-8')

raw_input()
---

It works fine on python shell

but when I make the file "wrong.py" and run it,
Error rises.


Traceback (most recent call last):
  File "C:wrong.py", line 8, in 
print rf.read().decode('utf-8')
UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 5
5122: illegal multibyte sequence
-

cp949 is the basic codec of sys.stdout and cmd.exe  
but I have no idea why it doesn't works.
printing without decode('utf-8') works fine on IDLE but on cmd, it print broken 
characters(Ascii portion is still fine, problem is only about the Korean)

the question may look silly:(
but I want to know what is the problem or how to print the not broken strings.

thanks for reading.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Steven D'Aprano
On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote:

> On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson
>  wrote:
>> py> 1 + 3 * 4
>> should ALWAYS equal 16!
>>
>> With parenthesis only used for grouping: py> a + (b*c) + d
>>
>> Which seems like the most consistent approach to me.
> 
> Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found
> on page 153 of the 3.5th Edition Monster Manual.

GvR is fond of quoting Ralph Waldo Emerson:

"A foolish consistency is the hobgoblin of little minds."

Perhaps the world would be better off if mathematicians threw out the 
existing precedence rules and replaced them with a strict left-to-right 
precedence. (Personally, I doubt it.)

But until they do, consistency with mathematics is far more important 
than the foolish consistency of left-to-right precedence.


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


Re: ANN: eGenix PyRun - One file Python Runtime 1.0.0

2012-07-02 Thread Simon Cropper

On 02/07/12 23:52, eGenix Team: M.-A. Lemburg wrote:


ANNOUNCING

  eGenix PyRun - One file Python Runtime

  Version 1.0.0


   An easy-to-use single file relocatable Python run-time -
 available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-PyRun-1.0.0.html


INTRODUCTION

Our new eGenix PyRun combines a Python interpreter with an almost
complete Python standard library into a single easy-to-use
executable, that does not require a system wide installation and
is fully relocatable.

eGenix PyRun's executable only needs 12MB, but still supports
most Python application and scripts - and it can be further
compressed to 3-4MB using gzexe or upx.

Compared to a regular Python installation of typically 100MB on
disk, this makes eGenix PyRun ideal for applications and scripts
that need to be distributed to many target machines, client
installations or customers.

It makes "installing" Python on a Unix based system as simple as
copying a single file.

 http://www.egenix.com/products/python/PyRun/


NEWS

This is the first public release of eGenix PyRun. We have been
using the product internally in our mxODBC Connect Server since
2008 with great success and have now extracted it into a
stand-alone open-source product.

We provide both the source archive to build your own eGenix
PyRun, as well as provide pre-compiled binaries for Linux,
FreeBSD and Mac OS X, for the resp. 32- and 64-bit platforms.

Presentation at EuroPython 2012
---

Marc-André, CEO of eGenix, will be giving a presentation about
eGenix PyRun at EuroPython 2012 in Florence, Italy on Wednesday,
July 4th in the Room Tagliatelle.

He will also be available during the conference to answer
questions.


DOWNLOADS

The download archives and instructions for installing the product
can be found at:

 http://www.egenix.com/products/python/PyRun/

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

 http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about eGenix PyRun, licensing and download
instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,



Hello,

Are you able to indicate what size the installation would be WITH ALL 
the mentioned dependencies on various typical systems (MS Windows 32/64, 
Ubuntu, etc)?


Saying something is only 12-13 MB in size is one thing but noting that 
you need 283MB+* of other packages means that in order to get this 
package to work on another machine you would need to install more than a 
12-13MB executable, particularly on a Windows machine.



OpenSSL on Windows 20MB -- http://slproweb.com/products

zlib binary on Windows 0.012MB-- /Win32OpenSSL.html -- 
http://gnuwin32.sourceforge.net/packages/zlib.htm


SQLite binary for Windows 262.59 MB -- http://www.sqlite.org/download.html/

BZip tarball 0.75 MB -- http://www.bzip.org/downloads.html

Also, do you have a page that indicates what standard libraries have 
been included? How can someone tell whether they would need to 
distribute or include any additional modules to get a script to work?


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting


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


Re: helping with unicode

2012-07-02 Thread Andrew Berg
On 7/2/2012 7:49 PM, self.python wrote:
> 
> Traceback (most recent call last):
>   File "C:wrong.py", line 8, in 
> print rf.read().decode('utf-8')
> UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 
> 5
> 5122: illegal multibyte sequence
> -
> 
> cp949 is the basic codec of sys.stdout and cmd.exe  
> but I have no idea why it doesn't works.
> printing without decode('utf-8') works fine on IDLE but on cmd, it print 
> broken characters(Ascii portion is still fine, problem is only about the 
> Korean)
Your terminal can't display those characters. You could try using other
code pages with chcp (a CLI utility that is part of Windows). IDLE is a
GUI, so it does not have to work with code pages.

Python 3.3 supports cp65001 (which is the equivalent of UTF-8 for
Windows terminals), but unfortunately, previous versions do not.
-- 
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: helping with unicode

2012-07-02 Thread MRAB

On 03/07/2012 01:49, self.python wrote:

it's a simple source view program.

the codec of the target website is utf-8
so I read it and print the decoded

--
#-*-coding:utf8-*-
import urllib2

rf=urllib2.urlopen(r"http://gall.dcinside.com/list.php?id=programming";)

print rf.read().decode('utf-8')

raw_input()
---

It works fine on python shell

but when I make the file "wrong.py" and run it,
Error rises.


Traceback (most recent call last):
   File "C:wrong.py", line 8, in 
 print rf.read().decode('utf-8')
UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 5
5122: illegal multibyte sequence
-

cp949 is the basic codec of sys.stdout and cmd.exe
but I have no idea why it doesn't works.
printing without decode('utf-8') works fine on IDLE but on cmd, it print broken 
characters(Ascii portion is still fine, problem is only about the Korean)

the question may look silly:(
but I want to know what is the problem or how to print the not broken strings.

thanks for reading.


The encoding of your console is 'cp949', so when you try to print the
Unicode string, Python tries to encode it as 'cp949'.

Unfortunately, the character (actually, when talking about Unicode the
correct term is 'codepoint') u'\u1368' cannot be encoded into 'cp949'
because that codepoint does not exist in that encoding, in the same way
that ASCII doesn't have Korean characters.

So what is that codepoint?

>>> import unicodedata
>>> unicodedata.name(u'\u1368')
'ETHIOPIC PARAGRAPH SEPARATOR'

Apparently 'cp949', which is for the Korean language, doesn't support
Ethiopic codepoints. Somehow that doesn't surprise me! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano
 wrote:
> On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote:
>> Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found
>> on page 153 of the 3.5th Edition Monster Manual.
>
> GvR is fond of quoting Ralph Waldo Emerson:
>
> "A foolish consistency is the hobgoblin of little minds."

Yeah, that's what I was referring to. Dungeons and Dragons has specs
for a hobgoblin warrior :)

> Perhaps the world would be better off if mathematicians threw out the
> existing precedence rules and replaced them with a strict left-to-right
> precedence. (Personally, I doubt it.)
>
> But until they do, consistency with mathematics is far more important
> than the foolish consistency of left-to-right precedence.

And if they ever do, it'll break consistency with past centuries of
mathematical writing. Imagine (taking this to another realm) that it's
decided that since Wolfram is now called Tungsten, it should have the
chemical symbol 'T' instead of 'W'. This is far more consistent,
right? And Iron should be I, not Fe. We'll move Iodine to Io (and
Europium to Europa and Gallium to Ganymede?), and tritium (the isotope
of hydrogen) can become H3. It'd make today's chemistry notes look as
archaic and unreadable as those using alchemical symbols, only the
actual symbols are the same, making it ambiguous. Nope. Better to
stick with what's standardized.

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


Re: helping with unicode

2012-07-02 Thread Terry Reedy

On 7/2/2012 8:49 PM, self.python wrote:

it's a simple source view program.

the codec of the target website is utf-8
so I read it and print the decoded


which re-encodes before printing


--
#-*-coding:utf8-*-
import urllib2

rf=urllib2.urlopen(r"http://gall.dcinside.com/list.php?id=programming";)

print rf.read().decode('utf-8')

raw_input()
---

It works fine on python shell


Do you mean the Windows Command Prompt shell?


but when I make the file "wrong.py" and run it,
Error rises.


Traceback (most recent call last):
   File "C:wrong.py", line 8, in 
 print rf.read().decode('utf-8')
UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 5
5122: illegal multibyte sequence
-

cp949 is the basic codec of sys.stdout and cmd.exe
but I have no idea why it doesn't works.


cp949 is a Euro-Korean multibyte encoding whose mapping is given at
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT
u1368 is not in the mapping. There is no reason the utf-8 site would 
restrict itself to the cp949 subset.


Perhap it prints in the interpreter because 2.x uses errors = 'replace' 
rather than 'strict' (as in 3.x).


Try print rf.read().decode('utf-8').encode('cp949', errors = 'replace')
Non-cp949 chars will print as '?'.


printing without decode('utf-8') works fine on IDLE


because IDLE encodes to utf-8, and x.decode('utf-8').encode('utf-8') == x


but on cmd, it print broken characters


Printing utf-8 encoded bytes as if cp949 encoded bytes is pretty hilariour


the question may look silly:(

 but I want to know what is the problem



 or how to print the not broken strings.


thanks for reading.




--
Terry Jan Reedy



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


Re: helping with unicode

2012-07-02 Thread Terry Reedy

On 7/2/2012 8:49 PM, self.python wrote:

it's a simple source view program.

the codec of the target website is utf-8
so I read it and print the decoded


which re-encodes before printing


--
#-*-coding:utf8-*-
import urllib2

rf=urllib2.urlopen(r"http://gall.dcinside.com/list.php?id=programming";)

print rf.read().decode('utf-8')

raw_input()
---

It works fine on python shell


Do you mean the Windows Command Prompt shell?


but when I make the file "wrong.py" and run it,
Error rises.


Traceback (most recent call last):
   File "C:wrong.py", line 8, in 
 print rf.read().decode('utf-8')
UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position 5
5122: illegal multibyte sequence
-

cp949 is the basic codec of sys.stdout and cmd.exe
but I have no idea why it doesn't works.


cp949 is a Euro-Korean multibyte encoding whose mapping is given at
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT
u1368 is not in the mapping. There is no reason the utf-8 site would 
restrict itself to the cp949 subset.


Perhap it prints in the interpreter because 2.x uses errors = 'replace' 
rather than 'strict' (as in 3.x).


Try print rf.read().decode('utf-8').encode('cp949', errors = 'replace')
Non-cp949 chars will print as '?'.


printing without decode('utf-8') works fine on IDLE


because IDLE encodes to utf-8, and x.decode('utf-8').encode('utf-8') == x


but on cmd, it print broken characters


Printing utf-8 encoded bytes as if cp949 encoded bytes is pretty hilariour


the question may look silly:(

 but I want to know what is the problem



 or how to print the not broken strings.


thanks for reading.




--
Terry Jan Reedy



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


Re: code review

2012-07-02 Thread John O'Hagan
On Tue, 3 Jul 2012 11:22:55 +1000
Chris Angelico  wrote:

> On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano
>  wrote:
> 
> > Perhaps the world would be better off if mathematicians threw out the
> > existing precedence rules and replaced them with a strict left-to-right
> > precedence. (Personally, I doubt it.)
> >
> > But until they do, consistency with mathematics is far more important
> > than the foolish consistency of left-to-right precedence.
> 
> And if they ever do, it'll break consistency with past centuries of
> mathematical writing. Imagine (taking this to another realm) that it's
> decided that since Wolfram is now called Tungsten, it should have the
> chemical symbol 'T' instead of 'W'. This is far more consistent,
> right? And Iron should be I, not Fe. We'll move Iodine to Io (and
> Europium to Europa and Gallium to Ganymede?), and tritium (the isotope
> of hydrogen) can become H3. It'd make today's chemistry notes look as
> archaic and unreadable as those using alchemical symbols, only the
> actual symbols are the same, making it ambiguous. Nope. Better to
> stick with what's standardized.
> 

I agree to some extent, but as a counter-example, when I was a child there
a subject called "Weights and Measures" which is now redundant because of the
Metric system. I don't miss hogsheads and fathoms at all. 

Music is another field which could do with a "metrification": I get tired of
explaining to beginners why there's no B#, except when it's C. Check out
http://musicnotation.org

If legacy systems get too far out of sync with current practice, they become
an unnecessary layer of complexity and a hurdle to understanding, and at some
point you have to take the plunge, old books be damned.

--

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


New member from India

2012-07-02 Thread anuj kumar
Hello Everyone,

Warm greetings to all of you...

I have to learn Python.So i recently join the python mailing list .Can you
please send me some sample programs from where i can start.

Thanks,
Anuj
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter and Chess problems

2012-07-02 Thread Lalitha Prasad K
Dear All

Recently I have been playing with Tkinter. I wrote two scripts to solve
well known chess problems: eight queens and knight's tour. Both are
available here: https://github.com/LalithaPrasad/PythonScripts
All are welcome to download and improve them if required. Hope to rewrite
them using the other GUI libraries for comparison purposes. But I think,
though Tkinter is considered primitive, It is extremely easy to use.

Cheers
Lalitha Prasad
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN]: asyncoro: Framework for asynchronous, concurrent, distributed programming

2012-07-02 Thread Giridhar Pemmasani
Hi,

I would like to announce asyncoro (http://asyncoro.sourceforge.net),
a Python framework for developing concurrent, distributed programs with
asynchronous completions and coroutines. asyncoro features include

  * Asynchronous (non-blocking) sockets
  * Efficient polling mechanisms epoll, kqueue, /dev/poll
    (and poll and select if necessary), and Windows I/O Completion Ports (IOCP)
    for high performance and scalability
  * SSL for security
  * Timers, including non-blocking sleep
  * Locking primitives similar to Python threading module
  * Thread pools with asynchronous task completions (for executing
    time consuming synchronous tasks)
  * Asynchronous database cursor operations (using asynchronous thread pool)
  * Communicating coroutines with messages
  * Remote execution of coroutines
  * Coroutines monitoring other coroutines (to get exit status notifications)
  * Hot-swapping and restarting of coroutine functions

Programs developed with asyncoro have same logic and structure as
programs with threads, except for a few syntactic changes. With
asyncoro's message communication, coroutines can exchange messages
one-to-one or through (broadcasting) channels. Coroutines exchanging
messages can be local (within single asyncoro instance) or distributed
(in many asyncoro instances across network).

Cheers,
Giri
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New member from India

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:36 PM, anuj kumar  wrote:
> Hello Everyone,
>
> Warm greetings to all of you...
>
> I have to learn Python.So i recently join the python mailing list .Can you
> please send me some sample programs from where i can start.

Welcome! Start here...

http://docs.python.org/py3k/tutorial/

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


Re: code review

2012-07-02 Thread Steven D'Aprano
On Tue, 03 Jul 2012 12:25:59 +1000, John O'Hagan wrote:

> On Tue, 3 Jul 2012 11:22:55 +1000
> Chris Angelico  wrote:
> 
>> On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano
>>  wrote:
>> 
>> > Perhaps the world would be better off if mathematicians threw out the
>> > existing precedence rules and replaced them with a strict
>> > left-to-right precedence. (Personally, I doubt it.)
>> >
>> > But until they do, consistency with mathematics is far more important
>> > than the foolish consistency of left-to-right precedence.
>> 
>> And if they ever do, it'll break consistency with past centuries of
>> mathematical writing. Imagine (taking this to another realm) that it's
>> decided that since Wolfram is now called Tungsten, it should have the
>> chemical symbol 'T' instead of 'W'. This is far more consistent, right?
>> And Iron should be I, not Fe. We'll move Iodine to Io (and Europium to
>> Europa and Gallium to Ganymede?), and tritium (the isotope of hydrogen)
>> can become H3. It'd make today's chemistry notes look as archaic and
>> unreadable as those using alchemical symbols, only the actual symbols
>> are the same, making it ambiguous. Nope. Better to stick with what's
>> standardized.
>> 
>> 
> I agree to some extent, but as a counter-example, when I was a child
> there a subject called "Weights and Measures" which is now redundant
> because of the Metric system. I don't miss hogsheads and fathoms at all.

Don't mistake tradition for consistency. There's little consistency in 
the legacy weights and measures used before the metric system. The 
introduction of the Imperial system in 1824 at least got rid of *some* of 
the more wacky measures, and standardised the rest, but there was still 
damn little consistency: e.g. a finger was 7/8 of an inch, and an ell was 
45 inches, meaning an ell is 39 and 3/8th fingers.

One of my favourites is the league, which in the Middle Ages was actually 
defined as the distance that a man, or a horse, could walk in an hour.



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


Dictless classes

2012-07-02 Thread Steven D'Aprano
You can create instances without a __dict__ by setting __slots__:

py> class Dictless:
... __slots__ = ['a', 'b', 'c']
... 
py> Dictless().__dict__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Dictless' object has no attribute '__dict__'


But the class itself still has a __dict__:

py> Dictless.__dict__
dict_proxy({'a': , 'c': , 'b': , 
'__module__': '__main__', '__slots__': ['a', 'b', 'c'], '__doc__': None})


I wonder whether there is some metaclass magic one can do to create a 
class without a __dict__?


I don't have a use-case for this. But I have some code which assumes that 
every class will have a __dict__, and I wonder whether that is a safe 
assumption.



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


How can i do python form post request?

2012-07-02 Thread gmspro

form.html:

 
 


p.py:
#!/usr/bin/python

#what to write here...

Both files are put in /var/www/ , now from http://localhost/form.html, if i 
click the submit button would i execute the p.py  and how can i get the value 
of textbox?

Any answer will be highly appreciated.
Thanks in advanced.

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


Re: code review

2012-07-02 Thread rusi
On Jul 3, 7:25 am, John O'Hagan  wrote:
>
> I agree to some extent, but as a counter-example, when I was a child there
> a subject called "Weights and Measures" which is now redundant because of the
> Metric system. I don't miss hogsheads and fathoms at all.
>
> Music is another field which could do with a "metrification": I get tired of
> explaining to beginners why there's no B#, except when it's C. Check 
> outhttp://musicnotation.org

You assume that equal temperament is the only way to have music.
Apart from the fact that there are non-tempered musics all over the
world, even Bach Mozart and Beethoven did not write for/to equal
temperament. In a pure/untempered C-scale A-flat is almost half a
semitone sharper than G-sharp -- 8/5 vs 25/16.

Similar for standardized languages: Python's indentation is nice --
except when you have to embed it into say, html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-07-02 Thread Ben Finney
rusi  writes:

> Similar for standardized languages: Python's indentation is nice --
> except when you have to embed it into say, html

If you can't write a ‘pre’ element for pre-formatted text, you don't
have HTML http://www.w3.org/TR/html401/struct/text.html#h-9.3.4>.

-- 
 \ “Pinky, are you pondering what I'm pondering?” “Uh, I think so, |
  `\ Brain, but we'll never get a monkey to use dental floss.” |
_o__)   —_Pinky and The Brain_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictless classes

2012-07-02 Thread alex23
On Jul 3, 3:03 pm, Steven D'Aprano  wrote:
> I don't have a use-case for this. But I have some code which assumes that
> every class will have a __dict__, and I wonder whether that is a safe
> assumption.

Remember the recent thread on using a different implementation for
.__dict__?
https://groups.google.com/group/python-ideas/browse_frm/thread/f15ef3c7b702a1fa

Given it was impossible to have it *not* create a conventional dict
via metaclasses, I would assume that there will always be a .__dict__.
-- 
http://mail.python.org/mailman/listinfo/python-list