Re: Missing decimals in the code - some suggestions?

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 12:20:18 -0600, Ian Kelly wrote:

 This isn't a Python question.  If you take a look at the csv file that
 you download from Yahoo, you will see that it only contains 2 digits of
 precision.  There's no way to make Python print out 4 digits of
 precision when it is only provided with 2.

Pish posh! It's easy to add extra precision.


py value = 2.57
py import random
py n = random.randrange(0, 100)
py value += %2d % n
py print value
2.5791


On average, your numbers will only be off by five parts in a thousand. If 
the values represent dollars, that's half a cent. Who care about half a 
cent?



Adding-spurious-precision-for-fun-and-profit-ly y'rs,


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


Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 15:38:29 -0700, Mark Janssen wrote:

 On Mon, Apr 15, 2013 at 3:32 PM, Chris Angelico ros...@gmail.com
 wrote:
 On Tue, Apr 16, 2013 at 8:12 AM, Rotwang sg...@hotmail.co.uk wrote:
 Traceback (most recent call last):
   File pyshell#2, line 1, in module
 class C(type(lambda: None)):
 TypeError: type 'function' is not an acceptable base type


 and I don't think that FunctionType would be considered an internal
 detail, would it? Not that I'd cite the fact that not all types can
 be inherited from as evidence that types and classes are not synonyms,
 mind.

 Actually, I'm not sure how you'd go about inheriting from a function.
 Why not just create a bare class, then assign its __call__ to be the
 function you're inheriting from?
 
 I think his point remains valid, from a theoretical pov.  Python prides
 itself on the idea of first-class functions and such, but unlike the
 world of lambda calculus, this selling point is a bit invalid.


Python functions are first-class functions, which is short-hand for 
saying functions which are also capable of being treated as values, 
which means they can be created at run-time, returned from functions, 
passed around as arguments, and assigned to variables.

Python's function type is not a first-class object-type, because it 
cannot be subclassed in at least three of the main implementations. But 
this has nothing to do with whether or not functions are first-class 
functions, which is an unrelated meaning. One can conceive of a language 
where FunctionType is a first-class type capable of being subclasses, but 
functions are *not* first-class values capable of being passed around as 
arguments.



 Because for Python (and any C-based language), 

Python-the-language is not C-based, or at least, very little of Python is 
C-based. It's main influences are, according to GvR, Lisp and ABC, with 
Pascal, Haskell and of course C also having some influence. Syntax-wise, 
it is much more of an Algol-inspired language than a C-inspired language.



 it is roots squarely in the
 Turing machine and its real-word implementation.

Python is certainly not inspired by Turing machines. Since a Turing 
machine is a simple device with an infinitely long paper tape which can 
have marks added and deleted from it, very few real programming languages 
are based on Turing machines.

It is, however, Turing-complete. Just like every programming language 
worthy of the name, whether it has syntax like Python, C, Lisp, Forth, 
INTERCAL, Oook, Applescript, Inform-7, Java, PHP, or x86 assembler.


   (Note this contrasts starkly with Java(script), which doesn't seem
 to be based on anything -- can anyone clarify where Java actually comes
 from?)

C.



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


Re: Unicode issue with Python v3.3

2013-04-17 Thread nagia . retsina
Τη Κυριακή, 14 Απριλίου 2013 12:28:32 μ.μ. UTC+3, ο χρήστης Cameron Simpson 
έγραψε:
 On 13Apr2013 23:00, nagia.rets...@gmail.com nagia.rets...@gmail.com wrote:
 
 | root@nikos [/home/nikos/public_html/foo-py]# pwd
 
 | /home/nikos/public_html/foo-py
 
 | root@nikos [/home/nikos/public_html/foo-py]# cat foo.py 
 
 | #!/bin/sh
 
 | exec 2/home/nikos/cgi.err.out
 
 | echo $0 $* 2
 
 | id 2
 
 | env | sort 2
 
 | set -x
 
 | exec /full/path/to/foo-py ${1+$@}
 
 | 
 
 | root@nikos [/home/nikos/public_html/foo-py]# python3 foo.py 
 
 |   File foo.py, line 2
 
 | exec 2/home/nikos/cgi.err.out
 
 |  ^
 
 | SyntaxError: invalid syntax
 
 
 
 That is because foo.py isn't a python script anymore, it is a shell script.
 
 Its purpose is to divert stderr to a file and to recite various
 
 things about the environment to that file in addition to any error
 
 messages.
 
 
 
 Just run it directly:
 
 
 
   ./foo.py
 
 
 
 The #! line should cause it to be run by the shell.
 
 
 
 I also recommend you try to do all this as your normal user account.
 
 Root is for administration, such as stopping/starting apache and
 
 so on. Not test running scripts from the command line; consider:
 
 if the script has bugs, as root it can do an awful lot of damage.
 
 
 
 | root@nikos [/home/nikos/public_html/foo-py]# 
 
 | As far as thr tail -f of the error_log:
 
 | root@nikos [/home/nikos/public_html]# touch /var/log/httpd/error_log
 
 
 
 That won't do you much good; apache has not opened it, and so it
 
 will not be writing to it. It was writing to a file of that name,
 
 but you removed that file. Apache probably still has its hooks in the old
 
 file (which now has no name).
 
 
 
 Restarting apache should open (or create if missing) this file for you.
 
 
 
 | root@nikos [/home/nikos/public_html]# tail -f /var/log/httpd/error_log
 
 | and its empty even when at the exact same time i run 'python3
 
 | metrites.py' from another interactive prompt when it supposed to
 
 | give live feed of the error messages.
 
 
 
 No, _apache_ writes to that file. So only when you visit the web
 
 page will stuff appear there.
 
 
 
 If you just run things from the command line, error messages will appear on 
 your terminal. Or, after this line of the wrapper script:
 
 
 
   exec 2/home/nikos/cgi.err.out
 
 
 
 the error messages will appear in cgi.err.out.
 
 
 
 | Cameron would it be too much to ask to provide you with root
 
 | access to my VPS server so you can have a look there too?
 
 | i can pay you if you like if you wait a few days to gather some money.
 
 
 
 I really do not recommend that:
 
 
 
   - it is nuts to blithely allow a stranger root access to your system
 
   - you won't learn anything about CGI scripts
 
 
 
 What you need for further debugging of your python issues is access
 
 to the error messages from the CGI script. That is the purpose of
 
 the wrapper script.
 
 
 
 Get the wrapper running on the command line and then test it via the browser.
 
 
 
 Cheers,
 
 -- 
 
 Cameron Simpson c...@zip.com.au
 
 
 
 Lord grant me the serenity to accept the things I can not change,
 
  the courage to change the things that I can,
 
 and the wisdom to hide the bodies of those people I had to kill
 
  because they pissed me off.
 
 - Jeffrey Papen jpa...@asucla.ucla.edu
cameron,

can you help please or tell me what else i need to try?
Hello
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Chris Angelico
On Wed, Apr 17, 2013 at 4:40 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Tue, 16 Apr 2013 15:38:29 -0700, Mark Janssen wrote:
   (Note this contrasts starkly with Java(script), which doesn't seem
 to be based on anything -- can anyone clarify where Java actually comes
 from?)

 C.

offee.

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


Re: Missing decimals in the code - some suggestions?

2013-04-17 Thread Ian Kelly
On Wed, Apr 17, 2013 at 12:23 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Tue, 16 Apr 2013 12:20:18 -0600, Ian Kelly wrote:

 This isn't a Python question.  If you take a look at the csv file that
 you download from Yahoo, you will see that it only contains 2 digits of
 precision.  There's no way to make Python print out 4 digits of
 precision when it is only provided with 2.

 Pish posh! It's easy to add extra precision.

It's easy to add extra /digits/.  Adding extra precision is much harder. ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode issue with Python v3.3

2013-04-17 Thread Chris Angelico
On Wed, Apr 17, 2013 at 4:56 PM,  nagia.rets...@gmail.com wrote:
 can you help please or tell me what else i need to try?

You need to try trimming quoted text in replies, not double-spacing,
and paying for help.

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


Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Chris Rebert
On Tue, Apr 16, 2013 at 11:40 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Tue, 16 Apr 2013 15:38:29 -0700, Mark Janssen wrote:
snip
(Note this contrasts starkly with Java(script), which doesn't seem
  to be based on anything -- can anyone clarify where Java actually comes
  from?)

 C.

Influenced by: Ada 83, C++, C#, Eiffel, Generic Java, Mesa, Modula-3,
Oberon, Objective-C, UCSD Pascal, Smalltalk
Categories: C programming language family | [...]
– http://en.wikipedia.org/wiki/Java_(programming_language)

Sincerely,
Chris
--
Read Wikipedia's infoboxes! People work hard on them!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Ian Kelly
On Tue, Apr 16, 2013 at 8:57 PM, Bruce McGoveran
bruce.mcgove...@gmail.com wrote:
 These are terms that appear in section 5 (Expressions) of the Python online 
 documentation.  I'm having some trouble understanding what, precisely, these 
 terms mean.  I'd appreciate the forum's thoughts on these questions:

 1.  Section 5.2.1 indicates that an identifier occurring as an atom is a 
 name.  However, Section 2.3 indicates that identifiers are names.  My 
 question:  can an identifier be anything other than a name?

Yes.  For example:

from a import b

Here a is an identifier but not a name, as it does not carry
object-binding semantics.

 2.  Section 5.3 defines primaries as the most tightly bound operations of 
 Python.  What does this mean?

Tightly bound here refers to operator precedence.  For example, we
say that the multiplication operator binds more tightly [to the
surrounding operands] than the arithmetic operator, because the
multiplication takes precedence.  This section defines that the most
tightly bound operations in Python are attribute references,
subscriptions, slices and calls; these always take precedence over
other neighboring operations.

 In particular, if an atom is a primary, what operation is the atom performing 
 that leads to the label most tightly bound?

An atom doesn't perform an operation.  The grammar defines that a
primary can be just an atom, so that anywhere in the grammar that
expects a primary, a simple atom with no primary operation performed
on it can equally be used.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eGenix mx Base Distribution 3.2.6 (mxDateTime, mxTextTools, etc.)

2013-04-17 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

   eGenix.com mx Base Distribution

 mxDateTime, mxTextTools, mxProxy, mxURL, mxUID,
  mxBeeBase, mxStack, mxQueue, mxTools

Version 3.2.6


Open Source Python extensions providing
 important and useful services
for Python programmers.

This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.6-GA.html



ABOUT

The eGenix.com mx Base Distribution for Python is a collection of
professional quality software tools which enhance Python's usability
in many important areas such as fast text searching, date/time
processing and high speed data types.

The tools have a proven record of being portable across many Unix and
Windows platforms. You can write applications which use the tools on
Windows and then run them on Unix platforms without change due to the
consistent platform independent interfaces.

Contents of the distribution:

 * mxDateTime - Easy to use Date/Time Library for Python
 * mxTextTools - Fast Text Parsing and Processing Tools for Python
 * mxProxy - Object Access Control for Python
 * mxBeeBase - On-disk B+Tree Based Database Kit for Python
 * mxURL - Flexible URL Data-Type for Python
 * mxUID - Fast Universal Identifiers for Python
 * mxStack - Fast and Memory-Efficient Stack Type for Python
 * mxQueue - Fast and Memory-Efficient Queue Type for Python
 * mxTools - Fast Everyday Helpers for Python

The package also include a number of helpful smaller modules in the
mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing
or mx.Misc.CommandLine to quickly write command line applications in
Python.

All available packages have proven their stability and usefulness in
many mission critical applications and various commercial settings all
around the world.

For more information, please see the distribution page:

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



NEWS

The 3.2.6 release of the eGenix mx Base Distribution is the latest
release of our open-source Python extensions. It includes these fixes
and enhancements:

Fixes
-

 * mxURL: Added a work-around to resolve a segfault when exiting the
   Python 2.7.4 interpreter. This is a Python bug which was introduced
   in Python 2.7.4 and will get fixed again in Python 2.7.5 - see
   http://bugs.python.org/issue17703.

Documentation Enhancements
--

 * mxURL: Added sections on URL join operations and interaction with
   strings to mxURL documentation.

 * mxDateTime: Added notice to documentation that .gmtoffset() can
   give wrong results during DST switching time.

Compatibility Enhancements
--

 * Filled the tp_methods slot of all extension types to improve Python
   2.7 compatibility.

Distribution Enhancements
-

 * Added download URL registered with PyPI is now a static page and
   includes an MD5 hash tag to allow verification of the page.

 * All distribution files are GPG signed with our release key. We also
   provide MD5 and SHA1 hash values for all files to easily verify the
   downloads.

eGenix mx Base Distribution 3.2.0 was release on 2012-08-28. Please
see the eGenix mx Base Distribution 3.2.0 announcement for new
features in the 3.2 major release:

https://cms.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html

For a full list of changes, please refer to the eGenix mx Base
Distribution change log and the change logs of the various included
Python packages.

http://www.egenix.com/products/python/mxBase/changelog.html



UPGRADING

We encourage all users to upgrade to this latest eGenix mx Base
Distribution release.

If you are upgrading from eGenix mx Base 3.1.x, please see the eGenix
mx Base Distribution 3.2.0 release notes for details on what has
changed since the 3.1 major release.

http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html

For a full list of changes, please refer to the eGenix mx Base Distribution
change log at

http://www.egenix.com/products/python/mxBase/changelog.html

and the change logs of the various included Python packages.



LICENSE

The eGenix mx Base package is distributed under the eGenix.com Public
License 1.1.0 which is an Open Source license similar to the Python
license. You can use the packages in both commercial and non-commercial
settings without fee or charge.

The package comes with full source code



DOWNLOADS

Re: Unicode issue with Python v3.3

2013-04-17 Thread Chris Angelico
On Wed, Apr 17, 2013 at 4:56 PM,  nagia.rets...@gmail.com wrote:
 can you help please or tell me what else i need to try?

You need to try trimming quoted text in replies, not double-spacing,
and paying for help.

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


Re: Understanding Boolean Expressions

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 15:19:25 -0700, Bruce McGoveran wrote:

 Hello.  I am new to this group.  I've done a search for the topic about
 which I'm posting, and while I have found some threads that are
 relevant, I haven't found anything exactly on point that I can
 understand.  So, I'm taking the liberty of asking about something that
 may be obvious to many readers of this group.
 
 The relevant Python documentation reference is: 
 http://docs.python.org/2/reference/expressions.html#boolean-operations.
 
 I'm trying to make sense of the rules of or_test, and_test, and not_test
 that appear in this section.  While I understand the substance of the
 text in this section, it is the grammar definitions themselves that
 confuse me.  For example, I am not clear how an or_test can be an
 and_test.

In this case, you could have saved us some time by copying and pasting 
the relevant three lines:

or_test  ::=  and_test | or_test or and_test
and_test ::=  not_test | and_test and not_test
not_test ::=  comparison | not not_test


I agree that this is not entirely the most obvious wording, but it makes 
a sort of sense if you follow it through carefully. Unfortunately, to 
really understand the grammar, you have to follow through the entire 
thing. But translated into English, the above three rules might read like 
this:

An expression which we call an or_test can be either:

1) an and_test; or

2) another or_test, followed by the literal string or, followed by an 
and_test.

An expression which we call an and_test can be either:

3) a not_test; or

4) another and_test, followed by the literal string and, followed by 
another not_test.

An expression which we call a not_test can be either:

5) a comparison; or

6) the literal string not, followed by another not_test.

An expression which we call a comparison can be:

... a bunch more different alternatives, going through bitwise 
comparisons, then arithmetic operators, then other expressions, and so 
on, until finally you reach the simplest expressions possible, names and 
constant literals.

So in a sense, an or_test does not JUST mean it's a test with an or 
in it. The thing called an or_test is an and_test *or* a test with an 
or in it; an and_test is a not_test *or* a test with an and in it; a 
not_test is a comparison *or* a test with a not in it; a comparison 
is ... and so forth, until you run out of expressions and end up with a 
simple atom like a name or a constant.

So paradoxically, that means that x or y counts as an and_test 
(obviously!) but also as an or_test, since every and_test also counts as 
an or_test. Here's some crappy ASCII art of a Venn diagram with a couple 
of examples shown: (best viewed in a fixed-width font):


+-+
|  or_tests   |
|  x or y   |
|+--+ |
||  and_tests   | |
||x and y | |
||+-+   | |
|||  not_tests  |   | |
||| |   | |
||| not x |   | |
||+-+   | |
|+--+ |
+-+


Inside the not_test box, not shown, are other boxes relating to other 
expressions, and ending deep down with boxes labelled names and 
literals. (Or so I expect, since I haven't followed the maze of twisty 
grammar rules, all alike, to the very end.)


Of course, in practice we wouldn't normally call an expression such as 
x and y as an or_test, even though strictly speaking the grammar says 
it is. We would call it by the smallest box it is contained within, 
namely and_test.

An analogy: normally, we would refer to Python's creator Guido van Rossum 
as a man, not a mammal, but since all men are mammals, it wouldn't be 
wrong to call him such. But not all mammals are men, and not all or_tests 
are and_tests. x or y is an or_test, obviously, but not an and_test.

Does this help explain it?


 Perhaps an example will help put my confusion into more concrete terms. 
 Suppose I write the expression if x or y in my code.  I presume this is
 an example of an or_test.  Beyond that, though, I'm not sure whether
 this maps to an and_test (the first option on the right-hand side of the
 rule) or to the or_test or and_test option (the second on the
 right-hand side of the rule).

x or y maps to the second option. The x matches and_test, which then 
matches not_test, which then matches comparison, which ... blah blah 
blah ... which finally matches a plain name. The or matches the literal 
string or in the grammar rule. Then the y matches and_test, which ... 
finally matches a plain name.

Of course, this is NOT necessarily what Python does every time it parses 
a piece of code! It's just a description of the grammar.



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


Re: Understanding Boolean Expressions

2013-04-17 Thread Jussi Piitulainen
Steven D'Aprano writes:

 So paradoxically, that means that x or y counts as an and_test
 (obviously!) but also as an or_test, since every and_test also
 counts as an or_test. Here's some crappy ASCII art of a Venn diagram

I think you mean to say that x and y counts as an and_test and also
as an or_test.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The node.js Community is Quietly Changing the Face of Open Source

2013-04-17 Thread Antoine Pitrou
rusi rustompmody at gmail.com writes:
 
 Just what I said: ecosystem matters.  We may or may not argue about
 more than language, but it surely matters. Some examples:
 
 1. In the link that Roderick originally posted there is a long comment
 that adds perl to the languages the author discussed. As a language
 perl is… um well… its perl.  Yet when perl wins its because CPAN
 wins.
 
 2. Haskell as a language is very well designed. However its package
 system -- cabal+hackage -- is completely broken.

I think you are deluded. Haskell may very well designed from a language
theoretist's
point of view, but I suspect most average programmers would find it a hell
to code in.

Regards

Antoine.



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


RGB combine

2013-04-17 Thread m . shemuni
Hi everyone.

I have 3 grayscaled picture. These are Red, Green and Blue filtered.
I want to colorize it.
I'm a GNU/Linux user and I did it with imagemagick using this code:

convert r.png g.png b.png -set colorspace RGB -combine -set colorspace sRGB 
rgb.gif

But I want to colorize it with using color matrix. For example I want it to 
looks more red or blue. I remember something from fits liberator. I was able to 
change density of colors.
How can I do it with python?
Sorry for bad English.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Uday S Reddy
Mark Janssen writes:

  Having said that, theorists do want to unify concepts wherever possible
  and wherever they make sense.  Imperative programming types, which I
  will call storage types, are semantically the same as classes.
 
 I like that word storage type, it makes it much clearer what one is
 referring to.

Indeed.  However, this is not the only notion of type in imperative
programming languages.  For example, a function type in C or its descendants
is not there to describe storage, but to describe the interface of an
abstraction.  I will use Reynolds's term phrase types to refer to such
types.  Reynolds's main point in The Essence of Algol was to say that
phrase types are much more general, and a language can be built around them
in a streamlined way.  Perhaps Streamlining Algol would have been a more
descriptive title for his paper.  Nobody should be designing an imperative
programming language without having read The Essence of Algol, but they
do.

Whether storage types (and their generalization, class types) should be
there in a type system at all is an open question.  I can think of arguments
both ways.  In Java, classes are types.  So are interfaces (i.e., phrase
types).  I think Java does a pretty good job of combining the two
in a harmonious way.

If you have trouble getting hold of The Essence of Algol, please write to
me privately and I can send you a scanned copy.  The Handout 5B in my
Principles of Programming Languages lecture notes is a quick summary of
the Reynolds's type system.

  http://www.cs.bham.ac.uk/~udr/popl/index.html

 I feel like I'm having to come up to speed of the academic
 community, but wonder how and why this large chasm happened between
 the applied community and the theoretical.   In my mind, despite the
 ideals of academia, students graduate and they inevitably come to work
 on Turing machines of some kind (Intel hardware, for example,
 currently dominates).  If this is not in some way part of some
 ideal, why did the business community adopt and deploy these most
 successfully?  Or is it, in some *a priori* way, not possible to apply
 the abstract notions in academia into the real-world?

The chasms are too many, not only between theoretical and applied
communities, but within each of them.  My feeling is that this is
inevitable.  Our field progresses too fast for people to sit back, take
stock of what we have and reconcile the multiple points of view.

There is nothing wrong with Turing machines.  But the question in
programming language design is how to integrate the Turing machine concepts
with all the other abstractions we need (functions/procedures, modules,
abstract data types etc.), i.e., how to fit the Turing machine concepts into
the big picture.  That is not an easy question to resolve, and there isn't
a single way of doing it.  So you see multiple approaches being used in the
practical programming languages, some cleaner than the others.

The abstract notions of academia do make it into the real world, but rather
more slowly than one would hope.  Taking Java for example, the initial
versions of Java treated interfaces in a half-hearted way, ignored
generics/polymorphism, and ignored higher-order functions.  But all of them
are slowly making their way into Java, with pressure not only from the
academic community but also through competition from other practical
languages like Python, C# and Scala.  If this kind of progress continues,
that is the best we can hope for in a fast-paced field like ours.

Cheers,
Uday Reddy

-- 
Prof. Uday ReddyTel: +44 121 414 2740 
Professor of Computer Science   Fax: +44 121 414 4281
School of Computer Science  
University of BirminghamEmail: u.s.re...@cs.bham.ac.uk  
Edgbaston   
Birmingham B15 2TT  Web: http://www.cs.bham.ac.uk/~udr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The node.js Community is Quietly Changing the Face of Open Source

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 12:02:01 -0400, Rodrick Brown wrote:

 I came across this article which sums up some of the issues I have with
 modern programming languages. I've never really looked at Javascript for
 anything serious or Node itself but I found this article really
 informational.

 The “Batteries included” philosophy of Python was definitely the right
 approach during the mid 90’s and one of the reasons that I loved Python
 so much; this was a time before modern package management, and before it
 was easy to find and install community-created libraries.  Nowadays
 though I think it’s counter-productive.  Developers in the community
 rarely want to bother trying to compete with the standard library, so
 people are less likely to try to write libraries that improve upon it.

What of corporate users on locked-down boxes where installing software is 
either a firing offence, or simply cannot be done at all? Or they have to 
fill out long and tiresome forms requesting permission. Or students using 
shared machines, where even if you install something, it will be gone the 
next time you come in?

What of people who don't want the hassle of trolling through 7 different 
maths libraries looking for the best one to use, or who might not trust 
random packages found on the Internet by authors you know nothing about.

Or those who don't want to spend their time reading licences? With the 
Python standard library, you know you can use anything in that library 
without worrying about the licence. With third party libraries, you have 
to decide whether or not you are legally allowed to distribute that 
library, and if not, how do you install it for your customers?

There are all sorts of reasons why people might not want to *hunt and 
install* their own packages, starting with laziness and ending with I 
like my job very much thank you, and I'd rather not get the sack. I 
think it shows astonishing privilege of the author to just assume that 
because he finds it easy to install third-party software, everybody must.

 http://caines.ca/blog/programming/the-node-js-community-is-quietly-
changing-the-face-of-open-source/


Just three sentences after telling us how the right URL library to use 
for Python is the third-party requests module, the author tells us that 
developers rarely want to bother trying to compete with the standard 
library, so people are less likely to try to write libraries that improve 
upon it.

Like requests, huh?

He then compares node.js packages with Twitter:

Just like the 140 character limit on twitter makes people “blog” more, 
the node.js community has a culture of publishing tiny modules that makes 
people more comfortable with publishing smaller packages, and so it 
happens vastly more often.

Yeah, because the vast bulk of 140-character tweets are something to 
aspire to. 

What matters is not how often people publish tiny packages that nobody 
uses. That's not a good measure of the health of a developer's culture. 
How many of those tiny packages are published, only to then languish in 
obscurity, lost and forgotten? How many are ever used by anyone other 
than their author?

ActiveState includes almost 4000 Python recipes:

http://code.activestate.com/recipes/langs/python/new/

and I would say that the great bulk of them are rubbish, or so 
specialised as to be of interest to very few people, or both. Or 
suffering from NIH syndrome. I see about 100 different recipes for 
implementing enums:

http://code.activestate.com/search/recipes/#q=enums

I don't think that 100 different recipes for enums is a good measure of 
Python's health, and I don't think that hundreds of little tiny packages 
are a good measure of the health of node.js either.

If you look at the node.js site, the first thing that jumps out at me is 
that the culture encourages churning out packages rather than encouraging 
quality packages. The front page offers author recognition for being 
prolific, but not for writing good code. Good (or at least *popular*, 
which is not the same thing) packages get their name on the front page, 
but *authors* get their name on the front page by writing loads of 
packages regardless of quality.

The current most prolific author is Sindre Sorhus, and if you look at his 
list of packages, you will see a certain amount of replication. This is 
what happens when you reward people for quantity:


# generator-jasmine  Yeoman generator for Jasmine
# generator-webapp Default Yeoman generator for scaffolding out a front-
end web app
# generator-testacular Yeoman generator for Testacular
# generator-chromeapp Yeoman generator for Chrome App
# generator-angular Yeoman generator for AngularJS
# generator-mocha Yeoman generator for Mocha
# generator-bbb Yeoman generator for Backbone Boilerplate
# generator-backbone Yeoman generator for Backbone.js


https://npmjs.org/~sindresorhus


I wonder, how much copy-and-pasting between packages does he do?



-- 
Steven
-- 

Re: Understanding Boolean Expressions

2013-04-17 Thread Steven D'Aprano
On Wed, 17 Apr 2013 11:47:49 +0300, Jussi Piitulainen wrote:

 Steven D'Aprano writes:
 
 So paradoxically, that means that x or y counts as an and_test
 (obviously!) but also as an or_test, since every and_test also counts
 as an or_test. Here's some crappy ASCII art of a Venn diagram
 
 I think you mean to say that x and y counts as an and_test and also as
 an or_test.

You may very well be right, but I'll be damned if I go back and read 
through my post trying to work out what I intended to say instead of what 
I actually said! 


:-)


And-or-or-and-or-or-or-and-and-or-ly y'rs,



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


Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Uday S Reddy
Mark Janssen writes:

 From:  en.wikipedia.org: Programming_paradigm:
 
 A programming paradigm is a fundamental style of computer
 programming. There are four main paradigms: object-oriented,
 imperative, functional and declarative. Their foundations are distinct
 models of computation: Turing machine for object-oriented and
 imperative programming, lambda calculus for functional programming,
 and first order logic for logic programming.
 
 While I understand the interest in purely theoretical models, I wonder
 two things:  1)  Are these distinct models of computation valid?  And,
 2) If so, shouldn't a theory of types announce what model of
 computation they are working from?

These distinctions are not fully valid.  

- Functional programming, logic programming and imperative programming are
three different *computational mechanisms*.

- Object-orientation and abstract data types are two different ways of
building higher-level *abstractions*.

The authors of this paragraph did not understand that computational
mechanisms and higher-level abstractions are separate, orthogonal dimensions
in programming language design.  All six combinations, obtained by picking a
computational mechanism from the first bullet and an abstraction mechanism
from the second bullet, are possible.  It is a mistake to put
object-orientation in the first bullet.  Their idea of paradigm is vague
and ill-defined.

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


Re: Understanding Boolean Expressions

2013-04-17 Thread Jussi Piitulainen
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:

 On Wed, 17 Apr 2013 11:47:49 +0300, Jussi Piitulainen wrote:
 
  Steven D'Aprano writes:
  
  So paradoxically, that means that x or y counts as an and_test
  (obviously!) but also as an or_test, since every and_test also counts
  as an or_test. Here's some crappy ASCII art of a Venn diagram
  
  I think you mean to say that x and y counts as an and_test and also as
  an or_test.
 
 You may very well be right, but I'll be damned if I go back and read 
 through my post trying to work out what I intended to say instead of what 
 I actually said! 
 
 :-)

The quote above is sufficient context for one who knows that x or y
is not an and_test. I'm hoping that pointing this little thing out
will help some potentially confused reader of your otherwise excellent
explanation see more quickly that this is really just a harmless typo.
(Unless it's me who's confused :)

The quote appeared just before your ASCII art.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread Serhiy Storchaka

17.04.13 07:57, Larry Hudson написав(ла):

So using a list comprehension you can do it in two lines:

def get_rule(num):
 bs = bin(num)[2:]
 return [0] * (8 - len(bs)) + [int(i) for i in bs]


You can do it in one line!

def get_rule(num):
 return list(map(int, '{:08b}'.format(num)))


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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread aaB
Hello,

Thanks for all your replies, things are getting clearer.


- copy/paste vs retyping:
Several people have remarked that I had retyped instead of copy/pasting.
This is exactly what happened, the fact is I haven't figured out yet how to
enable copy/pasting from urxvt to vim.
I'll try to get this done before posting output from an interactive session.


- iterating a list:
If I understand what you've told me,

bitpattern = [1, 0, 0, 1, 1, 0, 1]
for bit in bitpattern: 
  print bit

and 

bitpattern = [1, 0, 0, 1, 1, 0, 1]
for i in range(len(bitpattern)): 
  print bitpattern[i]

are equivalent, the former being more python and the latter being something
like C written using python syntax.


- the complement thing:
I haven't yet tried to reproduce this, but I will, and I will post back if I see
this happening again, this time with a real log of python's interactive console,
or a complete script which people can use.


- list comprehension:
I wasn't at all aware of this, thanks a lot for pointing it out.
I had an other function that generated a list of cells for the CA, each cell
being randomly alive or dead.
I have rewritten it using list comprehension,

def populate(n):
  random.seed()
  return [random.randint(0,1) for i in range(n)]

which works the same as my previous, C-like, version but feels much better.

I might come back to you all but you've already given me a good push forward, so
I guess I'll be trying to use it as much as I can before asking for an other.
-- 
http://mail.python.org/mailman/listinfo/python-list


IV ECCOMAS Thematic Conference VipIMAGE 2013: SUBMISSION DEADLINE EXTENDED

2013-04-17 Thread tava...@fe.up.pt
Dear Colleague,

We are pleased to inform you that the submission of abstracts for the 
International Conference VipIMAGE 2013 - IV ECCOMAS THEMATIC CONFERENCE ON 
COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING (www.fe.up.pt/~vipimage) to 
be held October 14-16, 2013, in Melia Madeira Mare Hotel, Madeira Island, 
Funchal, Portugal, is going very well.
Attending several requests, the organizing committee has extended the 
submission period to May 6th.
Once again, we would like to invite you to participate and share your expertise 
in VipIMAGE 2013.


Possible Topics (not limited to)

• Signal and Image Processing 
• Computational Vision 
• Medical Imaging 
• Physics of Medical Imaging 
• Tracking and Analysis of Movement 
• Simulation and Modeling
• Image Acquisition 
• Industrial Applications 
• Shape Reconstruction 
• Objects Segmentation, Matching, Simulation 
• Data Interpolation, Registration, Acquisition and Compression 
• 3D Vision 
• Virtual Reality 
• Visual Inspection 
• Software Development for Image Processing and Analysis 
• Computer Aided Diagnosis, Surgery, Therapy, and Treatment 
• Computational Bioimaging and Visualization 
• Telemedicine Systems and their Applications

Invited Lecturers

• Daniel Rueckert - Imperial College London, UK
• Dimitris N. Metaxas - Rutgers University, USA
• Durval C. Costa - Champalimaud Foundation, Portugal
• James S Duncan - Yale School of Medicine, USA
• Milan Sonka - The University of Iowa, USA
• Richard Bowden - University of Surrey, UK

Thematic Sessions

Proposals to organize Thematic Session under the auspicious of VipIMAGE 2013 
are welcome.
The proposals should be submitted by email to the conference co-chairs 
(tava...@fe.up.pt, rna...@fe.up.pt).

Confirmed Thematic Sessions

• Imaging of Biological Flows: trends and challenges
• Trabecular Bone Characterization: New trends and challenges
• Computational Vision and Image Processing applied to Dental Medicine

Publications

• Proceedings: The proceedings book will be published by the Taylor  Francis 
Group (www.balkema.nl/instructions.asp) and indexed by Thomson Reuters 
Conference Proceedings Citation Index, IET Inspect and Elsevier Scopus.
• Springer Book: A book with 20 invited works from the ones presented in the 
conference will be published by Springer under the book series “Lecture Notes 
in Computational Vision and Biomechanics” (www.springer.com/series/8910).
• Journal Publication: A dedicated special issue of the Taylor  Francis 
International Journal “Computer Methods in Biomechanics and Biomedical 
Engineering: Imaging  Visualization” (www.tandfonline.com/tciv) will be 
published with extended versions of the best works presented in the conference.

Important dates

• Deadline for (2-4 pages) Abstracts: May 6, 2013 (POSTPONED)
• Authors Notification: June 10, 2013 (POSTPONED)
• Deadline to upload Lectures and Papers: July 1, 2013


We are looking forward to see you in Funchal next October.

Kind regards,

João Manuel R. S. Tavares
Renato Natal Jorge
(conference co-chairs)

PS. For further details, please, have a look in the conference website at: 
www.fe.up.pt/~vipimage, or in the conference Facebook page at: 
www.facebook.com/pages/Vipimage/237980719665456, or join the LinkedIn 
conference group at: http://www.linkedin.com/groups?gid=4752820trk=hb_side_g
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Dave Angel

On 04/16/2013 10:57 PM, Bruce McGoveran wrote:

These are terms that appear in section 5 (Expressions) of the Python online 
documentation.  I'm having some trouble understanding what, precisely, these 
terms mean.  I'd appreciate the forum's thoughts on these questions:


3.  Section 5.3.1 offers this definition of an attributeref:
 attributeref ::= primary . identifier

Now, I was at first a little concerned to see the non-terminal primary on the 
right hand side of the definition, since primary is defined to include 
attributeref in section 5.3 (so this struck me as circular).  Am I correct in 
thinking attributeref is defined this way to allow for situations in which the 
primary, whether an atom, attributeref (example:  an object on which a method 
is called that returns another object), subscription, slicing, or call, returns 
an object with property identifier?



It is circular.  Nothing wrong with that.  It means that not only can 
you use

a.b

but also
a.b.c

and
a.b.c.d.e.f.g

without any explicit limit.  if a non-circular definition were to be 
attempted, you might need a few dozen rules, just to cover what someone 
*might* happen to use in an expression.  Of course normally, one doesn't 
go much beyond a.b.c in a single expression.



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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread Lele Gaifax
aaB mecagonoisic...@gmail.com writes:

 - copy/paste vs retyping:
 Several people have remarked that I had retyped instead of copy/pasting.
 This is exactly what happened, the fact is I haven't figured out yet how to
 enable copy/pasting from urxvt to vim.

I used to use rxvt, but since a while I switched to roxterm for exactly
that annoying problem: I may be wrong, but urxvt uses only the ancient
X cutpaste way of selecting a region with the mouse and then using the
middle mouse button to paste it back.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 19:57:25 -0700, Bruce McGoveran wrote:

 These are terms that appear in section 5 (Expressions) of the Python
 online documentation.  I'm having some trouble understanding what,
 precisely, these terms mean.  I'd appreciate the forum's thoughts on
 these questions:
 
 1.  Section 5.2.1 indicates that an identifier occurring as an atom is a
 name.  However, Section 2.3 indicates that identifiers are names.  My
 question:  can an identifier be anything other than a name?

Yes and no.

According to the Python grammar as documented, no, identifiers are just 
another name for, er, name.

But according to common practice, yes, we call many things identifiers:

x  # a bare name, or identifier according to the grammar

x.attr  # name with an attribute, or attributeref

x[key]  # name with a subscript, or subscription

x[5]  # name with an indexed subscript, or slicing

x[start:stop:step]  # name with a slice subscript



 2.  Section 5.3 defines primaries as the most tightly bound operations
 of Python.  What does this mean?

It means that primaries are evaluated at the highest priority. For 
example, given:

x.a+b

that is evaluated as:

(x.a) + b

rather than:

x . (a+b)


In particular, if you have a variable:

name = Fred

then x.name will look for an attribute name, *not* x.Fred.


 In particular, if an atom is a
 primary, what operation is the atom performing that leads to the label
 most tightly bound?  To put it a different way, I think of atoms as
 things (i.e. identifiers).

Correct.


 The documentation makes me think atoms
 actually do something, as opposed to being things (I think I have in my
 mind the difference between a noun and a verb as I write this).

The only thing they do is be evaluated.




 3.  Section 5.3.1 offers this definition of an attributeref:
 attributeref ::= primary . identifier
 
 Now, I was at first a little concerned to see the non-terminal primary
 on the right hand side of the definition, since primary is defined to
 include attributeref in section 5.3 (so this struck me as circular).  Am
 I correct in thinking attributeref is defined this way to allow for
 situations in which the primary, whether an atom, attributeref (example:
  an object on which a method is called that returns another object),
 subscription, slicing, or call, returns an object with property
 identifier?

Yes. It means you can write things like this:

module.Class.method()[0](arg).attr.name[2]['spam'].aardvark()

and have it evaluated from left to right.



With respect, I think you may be confusing yourself unnecessarily with an 
excessive concern for the formal grammar of Python. You may find it makes 
a lot more sense in practice than it makes in theory. I strongly 
recommend you open up an interactive interpreter and just play around 
with the syntax and see what happens.




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


Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Antoon Pardon
Op 16-04-13 18:49, Terry Jan Reedy schreef:
 On 4/16/2013 5:07 AM, Antoon Pardon wrote:
 Op 16-04-13 05:17, Terry Jan Reedy schreef:

 I will keep the above in mind if I write or review a patch. here are 4
 non-subclassable builtin classes. Two are already documented. Bool in
 one, forget which other. I believe it was recently decided to leave
 the other two as is given the absence of any practical use case.

 Why should there be a practical use case here?

 As a practical matter, the change is non-trivial. Someone has to be
 motivated to write the patch to enable subclassing, write tests, and
 consider the effect on internal C uses of slice and stdlib Python used
 of slice (type() versus isinstance).
I see. It seems I have underestimated the work involved.

 I once had an idea of a slice-like class that I would have liked to
 experiment with.

 Did the idea actually require that instances *be* a slice rather than
 *wrap* a slice? 

As far as I remember I wanted my slice object usable to slice lists
with. But python doesn't allow duck typing when you use your object to
index a list. No matter how much your object resembles a slice, when
you actualy try to use it to get a slice of a list, python throw a
TypeError with the message object cannot be interpreted as an index.
This in combination with slice not being subclassable effectively killed
the idea.

As I already said I don't know if the idea would have turned up
something usefull. The following years I never had the feeling how great
it would have been should I have been able to pursue this idea. I just
thought it was a pity I was so thoroughly stopped at the time.

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


Parsing soap result

2013-04-17 Thread Ombongi Moraa Fe
My

client.service.gere(ri)

method call logs the below soap response in my log file.

?xml version=1.0 encoding=utf-8 ?soapenv:Envelope xmlns:soapenv=
http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsi=
http://www.w3.org/2001/XMLSchema-instance;soapenv:Bodyns1:gere
xmlns:ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local
ns1:resultaddress254727/addressdeliveryStatusDeliveredToNetwork/deliveryStatus/ns1:result/ns1:gere/soapenv:Body/soapenv:Envelope


If I assign the client.service.gere(ri) to a variable, i get the output on
my screen:

result=client.service.gere(ri)

output:
[(DeliveryInformation){
   address = 254727
   deliveryStatus = DeliveredToNetwork
 }]

string functions replace() and strip don't work.

how do I use xml.etree.ElementTree to print the parameters address and
deliveryStatus? Or is there a better python method?

Thanks in advance.

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Tornado with cgi form

2013-04-17 Thread Renato Barbosa Pim Pereira
*I installed tornado and he is functional, but when I execute the following
script:*

import tornado.ioloop
import tornado.web
import cgi

class MainHandler(tornado.web.
RequestHandler):

form = cgi.FieldStorage() # parse form data
print('Content-type: text/html\n')# hdr plus blank line
print('titleReply Page/title')# html reply page
if not 'user' in form:
print('h1Who are you?/h1')
else:
print('h1Hello i%s/i!/h1' %
cgi.escape(form['user'].value))

application = tornado.web.Application([
(r/, MainHandler),
])

if __name__ == __main__:
application.listen()
tornado.ioloop.IOLoop.instance().start()

*In the terminal have these outputs:*

python test.py
Content-type: text/html

titleReply Page/title
h1Who are you?/h1

*When I call the browser on localhost:, the message is this:*

405: Method Not Allowed
*
**Please, can someone have a idea about why the error occurs? and what I
need to do to fix this?*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Rishiyur Nikhil
If you have trouble getting hold of The Essence of Algol, ...

There seems to be a downloadable copy at:

www.cs.cmu.edu/~crary/819-f09/Reynolds81.ps

It's in PostScript, which is easily convertible to PDF if you wish.

Nikhil


On Wed, Apr 17, 2013 at 5:30 AM, Uday S Reddy u.s.re...@cs.bham.ac.ukwrote:

 [ The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list]

 Mark Janssen writes:

  From:  en.wikipedia.org: Programming_paradigm:
 
  A programming paradigm is a fundamental style of computer
  programming. There are four main paradigms: object-oriented,
  imperative, functional and declarative. Their foundations are distinct
  models of computation: Turing machine for object-oriented and
  imperative programming, lambda calculus for functional programming,
  and first order logic for logic programming.
 
  While I understand the interest in purely theoretical models, I wonder
  two things:  1)  Are these distinct models of computation valid?  And,
  2) If so, shouldn't a theory of types announce what model of
  computation they are working from?

 These distinctions are not fully valid.

 - Functional programming, logic programming and imperative programming are
 three different *computational mechanisms*.

 - Object-orientation and abstract data types are two different ways of
 building higher-level *abstractions*.

 The authors of this paragraph did not understand that computational
 mechanisms and higher-level abstractions are separate, orthogonal
 dimensions
 in programming language design.  All six combinations, obtained by picking
 a
 computational mechanism from the first bullet and an abstraction mechanism
 from the second bullet, are possible.  It is a mistake to put
 object-orientation in the first bullet.  Their idea of paradigm is vague
 and ill-defined.

 Cheers,
 Uday Reddy

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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread darnold
On Apr 17, 5:25 am, aaB mecagonoisic...@gmail.com wrote:

 - the complement thing:
 I haven't yet tried to reproduce this, but I will, and I will post back if I 
 see
 this happening again, this time with a real log of python's interactive 
 console,
 or a complete script which people can use.


That was happening when you incorrectly used bit as an index back into
bitpattern.
When you do that, the behavior actually changes depending on the value
of bitpattern:

a bitpattern that starts with [1, 0, ...] will yield its complement:

 bitpattern = [1, 0, 0, 1, 1, 0, 1]
 for bit in bitpattern:
print 'bitpattern[%s] : %s' % (bit, bitpattern[bit])


bitpattern[1] : 0
bitpattern[0] : 1
bitpattern[0] : 1
bitpattern[1] : 0
bitpattern[1] : 0
bitpattern[0] : 1
bitpattern[1] : 0


while a bitpattern that starts with [0, 1, ...] will yield the
expected results:

 bitpattern = [0, 1, 0, 1, 1, 0, 1]
 for bit in bitpattern:
print 'bitpattern[%s] : %s' % (bit, bitpattern[bit])


bitpattern[0] : 0
bitpattern[1] : 1
bitpattern[0] : 0
bitpattern[1] : 1
bitpattern[1] : 1
bitpattern[0] : 0
bitpattern[1] : 1


HTH,
Don



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


Re: Encoding NaN in JSON

2013-04-17 Thread Miki Tebeka
 I'm trying to find a way to have json emit float('NaN') as 'N/A'.
 No.  There is no way to represent NaN in JSON.  It's simply not part of the
 specification.
I know that. I'm trying to emit the *string* 'N/A' for every NaN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tornado with cgi form

2013-04-17 Thread Lele Gaifax
Renato Barbosa Pim Pereira renato.barbosa.pim.pere...@gmail.com
writes:

 *I installed tornado and he is functional, but when I execute the following
 script:*

I think this is the wrong place to ask such a question, more appropriate
would be http://groups.google.com/group/python-tornado

Anyway, you defined a MainHandler class *without* any method, and you
should instead implement at least a get or post method, as the
Hello, world example on http://www.tornadoweb.org suggests.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Andreas Abel

On 17.04.2013 11:30, Uday S Reddy wrote:

Mark Janssen writes:


From:  en.wikipedia.org: Programming_paradigm:

A programming paradigm is a fundamental style of computer
programming. There are four main paradigms: object-oriented,
imperative, functional and declarative. Their foundations are distinct
models of computation: Turing machine for object-oriented and
imperative programming, lambda calculus for functional programming,
and first order logic for logic programming.


I removed the second sentence relating paradigms to computation models
and put it on the talk page instead.  It does not make sense to connect 
imperative programming to Turing machines like functional programming to 
lambda calculus.  A better match would be random access machines, but 
the whole idea of a connection between a programming paradigm and a 
computation model is misleading.



While I understand the interest in purely theoretical models, I wonder
two things:  1)  Are these distinct models of computation valid?  And,
2) If so, shouldn't a theory of types announce what model of
computation they are working from?


These distinctions are not fully valid.

- Functional programming, logic programming and imperative programming are
three different *computational mechanisms*.

- Object-orientation and abstract data types are two different ways of
building higher-level *abstractions*.

The authors of this paragraph did not understand that computational
mechanisms and higher-level abstractions are separate, orthogonal dimensions
in programming language design.  All six combinations, obtained by picking a
computational mechanism from the first bullet and an abstraction mechanism
from the second bullet, are possible.  It is a mistake to put
object-orientation in the first bullet.  Their idea of paradigm is vague
and ill-defined.

Cheers,
Uday Reddy




--
Andreas AbelDu bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.a...@ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-17 Thread John Gordon
In c37a3b9c-6fe8-48aa-b703-9b4f922c3...@googlegroups.com Miki Tebeka 
miki.teb...@gmail.com writes:

  I'm trying to find a way to have json emit float('NaN') as 'N/A'.
  No.  There is no way to represent NaN in JSON.  It's simply not part of the
  specification.
 I know that. I'm trying to emit the *string* 'N/A' for every NaN.

import math

x = possibly_NaN()

if math.isnan(x):
x = 'N/A'

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread 88888 Dihedral
Serhiy Storchaka於 2013年4月17日星期三UTC+8下午5時35分07秒寫道:
 17.04.13 07:57, Larry Hudson написав(ла):
 
  So using a list comprehension you can do it in two lines:
 
 
 
  def get_rule(num):
 
   bs = bin(num)[2:]
 
   return [0] * (8 - len(bs)) + [int(i) for i in bs]
 
 
 
 You can do it in one line!
 
 
 
 def get_rule(num):
 
   return list(map(int, '{:08b}'.format(num)))

Well, a new object is returned and can be used. 
Then who is going to clean up the object when required?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The node.js Community is Quietly Changing the Face of Open Source

2013-04-17 Thread Stefan Behnel
Steven D'Aprano, 17.04.2013 11:16:
 If you look at the node.js site, the first thing that jumps out at me is 
 that the culture encourages churning out packages rather than encouraging 
 quality packages. The front page offers author recognition for being 
 prolific, but not for writing good code. Good (or at least *popular*, 
 which is not the same thing) packages get their name on the front page, 
 but *authors* get their name on the front page by writing loads of 
 packages regardless of quality.
 
 The current most prolific author is Sindre Sorhus, and if you look at his 
 list of packages, you will see a certain amount of replication. This is 
 what happens when you reward people for quantity:
 
 
 # generator-jasmine  Yeoman generator for Jasmine
 # generator-webapp Default Yeoman generator for scaffolding out a front-
 end web app
 # generator-testacular Yeoman generator for Testacular
 # generator-chromeapp Yeoman generator for Chrome App
 # generator-angular Yeoman generator for AngularJS
 # generator-mocha Yeoman generator for Mocha
 # generator-bbb Yeoman generator for Backbone Boilerplate
 # generator-backbone Yeoman generator for Backbone.js
 
 
 https://npmjs.org/~sindresorhus
 
 I wonder, how much copy-and-pasting between packages does he do?

It's possible that the answer is none, and that you actually need to
install all of his packages in order to make use of one.

Stefan


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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Bruce McGoveran
Thank you all for your thoughtful replies.  I appreciate your collective 
insight.  I didn't mean to cast the concept of recursion in a negative light - 
I'm actually comfortable with the concept, at least to some extent, and I 
appreciate the need for its use in this documentation.  I also appreciate the 
need to play with expressions at the command line, to gain a feel for how 
expressions are evaluated.  My interest in the language's formal description 
arises merely out of a desire to understand as precisely as possible what 
happens when I hit enter at the command line, or when I run a module.  
Your answers to my initial questions in this thread and the ones I posed in 
another thread (Understanding Boolean Expressions) have lead me to some 
follow-up questions.  Suppose I'm working at the command line, and I bind x to 
the value 1 and y to the value 0.  Suppose I next type x and y and hit enter.  
Python returns 0 (zero).  I'm glad I checked this before sending in this post 
because I thought it would return a value of False based on the presence of the 
and operand.  My question:  what did the interpreter have to do to evaluate the 
expression x and y and return a value of zero?
I know the lexical analyzer has to parse the stream of characters into tokens.  
I presume this parsing generates the toxens x, y, and, and a NEWLINE.  Beyond 
that, things get a little fuzzy, and it occurs to me that this fuzziness is the 
result of my looking at the expression x and y knowing full well what each 
token means and what I want done with them, whereas the interpreter won't know 
these things until it can parse the character stream and sort the tokens into 
some recognizable (and syntactically correct) order.
As I look at it, the expression x and y has two atoms, namely x and y.  x and y 
are also primaries, and they represent the most tightly bound parts of this 
expression (meaning they bind more tightly to their underlying objects than to 
the and operator).   Incidentally, how does Python figure out that the x and y 
in this expression refer to the x and y I previously bound to integer values?  
I know there's a symbol table in each execution frame.  How does Python know to 
go to that table and check for x and y?
The and token represents an operator, a boolean operator to be specific.  As I 
look at the grammar for and_test in section 5.10 of the documentation, it would 
appear that the and_test resolves via not_test's definition to two comparisons, 
which in turn resolve to or_expr, and then via a series of binary bitwise 
definitions to shift_expr, then to a_expr, then to m_expr, then to u_expr, to 
power, and then primary, and then to atom, which lands us finally at 
non-terminal identifiers (i.e. x and y themselves).  
Questions:  In working through these steps, what I have actually demonstrated?  
Is this how Python deconstructs an and statement with two operands?  Do I take 
from the fact that the progression from and_test to identifier involved 
reference to bitwise operators that the boolean testing of x and y involves a 
bitwise comparison of x and y?  I have to admit these questions are a little 
confusing; this may reflect the fact I am not exactly sure what it is I am 
trying to ask.  In general terms, I am trying to understand how Python evalutes 
the expression x and y in this context.
For my sanity's sake (and, perhaps, for yours) I will stop there.  I send 
thanks in advance for any thoughts you have on my questions.



On Tuesday, April 16, 2013 10:57:25 PM UTC-4, Bruce McGoveran wrote:
 These are terms that appear in section 5 (Expressions) of the Python online 
 documentation.  I'm having some trouble understanding what, precisely, these 
 terms mean.  I'd appreciate the forum's thoughts on these questions:
 
 
 
 1.  Section 5.2.1 indicates that an identifier occurring as an atom is a 
 name.  However, Section 2.3 indicates that identifiers are names.  My 
 question:  can an identifier be anything other than a name?
 
 
 
 2.  Section 5.3 defines primaries as the most tightly bound operations of 
 Python.  What does this mean?  In particular, if an atom is a primary, what 
 operation is the atom performing that leads to the label most tightly 
 bound?  To put it a different way, I think of atoms as things (i.e. 
 identifiers).  The documentation makes me think atoms actually do something, 
 as opposed to being things (I think I have in my mind the difference between 
 a noun and a verb as I write this).  Perhaps the doing in this case (or 
 binding, if you like) is linking (binding) the identifier to the underlying 
 object?  I think it might help if I had a better working notion of what a 
 primary is.
 
 
 
 3.  Section 5.3.1 offers this definition of an attributeref:
 
 attributeref ::= primary . identifier
 
 
 
 Now, I was at first a little concerned to see the non-terminal primary on the 
 right hand side of the definition, since primary is defined to include 
 attributeref 

Re: Parsing soap result

2013-04-17 Thread darnold
On Apr 17, 8:50 am, Ombongi Moraa Fe moraa.lovetak...@gmail.com
wrote:

 how do I use xml.etree.ElementTree to print the parameters address and
 deliveryStatus? Or is there a better python method?



I'm sure there are prettier ways to do this, but you can use XPath
syntax to find all of your ns1:result nodes and loop through them:

 import xml.etree.ElementTree as ET
 myXML = '''\
?xml version=1.0 encoding=utf-8 ?
soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/
envelope/ xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
soapenv:Body
ns1:gere xmlns:ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/
local
ns1:result
address254727/address
deliveryStatusDeliveredToNetwork/deliveryStatus
/ns1:result
/ns1:gere
/soapenv:Body
/soapenv:Envelope
'''
 myNamespaces=dict(ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local,soapenv=http://schemas.xmlsoap.org/soap/envelope/;)
 root = ET.fromstring(myXML)
 for result in root.findall('.//ns1:result',namespaces=myNamespaces):
address = result.find('address').text
deliveryStatus = result.find('deliveryStatus').text
print address: %s, deliveryStatus: %s % (address,deliveryStatus)


address: 254727, deliveryStatus: DeliveredToNetwork


HTH,
Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing soap result

2013-04-17 Thread Christian Heimes
Am 17.04.2013 19:55, schrieb darnold:
 On Apr 17, 8:50 am, Ombongi Moraa Fe moraa.lovetak...@gmail.com
 wrote:
 
 how do I use xml.etree.ElementTree to print the parameters address and
 deliveryStatus? Or is there a better python method?

 
 
 I'm sure there are prettier ways to do this, but you can use XPath
 syntax to find all of your ns1:result nodes and loop through them:

You want all {http://www.csapi.org/schema/parlayx/sms/send/v2_2/
local}result tags. The prefix isn't fixed.

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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread Ned Batchelder


On 4/17/2013 12:10 PM, 8 Dihedral wrote:

Serhiy Storchaka於 2013年4月17日星期三UTC+8下午5時35分07秒寫道:

17.04.13 07:57, Larry Hudson написав(ла):


So using a list comprehension you can do it in two lines:
def get_rule(num):
  bs = bin(num)[2:]
  return [0] * (8 - len(bs)) + [int(i) for i in bs]



You can do it in one line!



def get_rule(num):

   return list(map(int, '{:08b}'.format(num)))

Well, a new object is returned and can be used.
Then who is going to clean up the object when required?


This is a key thing to understand about Python: memory is managed 
automatically, no one has to clean up the object.  Once there are no 
names referring to the object, it will be cleaned up automatically.


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


Re: a couple of things I don't understand wrt lists

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 4:36 AM, Ned Batchelder n...@nedbatchelder.com wrote:

 On 4/17/2013 12:10 PM, 8 Dihedral wrote:
 Well, a new object is returned and can be used.
 Then who is going to clean up the object when required?


 This is a key thing to understand about Python: memory is managed
 automatically, no one has to clean up the object.  Once there are no names
 referring to the object, it will be cleaned up automatically.

Dihedral is a bot. An amusing one, at times, but not someone you need
overly concern yourself with. :)

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Steven D'Aprano
Wow, that's some impressive wall of text! Splitting your comments up into a
few paragraphs would make it much easier to read :-)

My comments below...


On Wed, 17 Apr 2013 10:15:02 -0700, Bruce McGoveran wrote:

 Thank you all for your thoughtful replies.  I appreciate your collective
 insight.  I didn't mean to cast the concept of recursion in a negative
 light - I'm actually comfortable with the concept, at least to some
 extent, and I appreciate the need for its use in this documentation.  I
 also appreciate the need to play with expressions at the command line,
 to gain a feel for how expressions are evaluated.  My interest in the
 language's formal description arises merely out of a desire to
 understand as precisely as possible what happens when I hit enter at the
 command line, or when I run a module. 

You won't gain that from the *grammar* of the language. Grammar is only part
of the story, and in some ways, the least important part. If I tell you
that the grammar of English includes:

ADJECTIVE NOUN

that alone is not going to help you understand the differences between
a wise man and a wise guy, or peanut oil and baby oil.

I'm not saying that syntax and grammar is unimportant, but it is independent
of the *semantics* of the program, and really its the semantics (the
meaning) of code that is important. One can easily imagine four languages
where the identical operation was written as:

name.attribute
name-attribute
name(attribute)
attribute of name

Contrariwise, just because two languages have ostensibly the same syntax for
something, doesn't mean they are doing the same thing. E.g. there are
subtle differences between attribute lookup name.attribute in Java and
Python.


 Your answers to my initial
 questions in this thread and the ones I posed in another thread
 (Understanding Boolean Expressions) have lead me to some follow-up
 questions.  Suppose I'm working at the command line, and I bind x to the
 value 1 and y to the value 0.  Suppose I next type x and y and hit
 enter.  Python returns 0 (zero).  I'm glad I checked this before sending
 in this post because I thought it would return a value of False based on
 the presence of the and operand.

The command line is actually irrelevant here. With one or two minor
exceptions, Python will do the same thing whether you are working
interactively or not. The main differences are that at the interactive
prompt, Python will automatically print the result of any expression which
is not otherwise bound to a value, and also bind it to the variable
name _. (A single underscore.) Other interactive command prompts may do
more, or less.


 My question:  what did the interpreter
 have to do to evaluate the expression x and y and return a value of
 zero? I know the lexical analyzer has to parse the stream of characters
 into tokens.  I presume this parsing generates the toxens x, y, and, and
 a NEWLINE.  

Well, yes, but you're being awfully reductionist here. I'm the first to be
in favour of curiosity for curiosity's sake, but I'm not sure that getting
bogged down at such a low level this early in your Python learning
experience is a good idea. *shrug* No skin off my nose though.

The answer is going to depend on the implementation. There are at least four
major implementations of Python these days, and another dozen or two
obsolete, experimental or minor implementations. (Oh, and let me apologise
in advance to anyone whose implementation I haven't listed as major.)

CPython is the implementation you are probably using; Jython runs on top of
the Java virtual machine, IronPython runs on top of the Dot Net virtual
machine, and PyPy runs on the deepest, darkest voodoo known to Mankind. But
essentially, any implementation will have to perform all or most of these
steps:

* Parse the source code into tokens. CPython generates an AST, Abstract
Syntax Tree. What that means in practice, I have no idea. This is
relatively new: some versions back, the syntax was essentially identical,
but there was no AST involved.

* From the tokens, or the AST, generate byte code. Or machine code, if your
compiler is clever enough.

* Execute the byte code in some virtual machine, or the machine code
directly on your CPU, as the case may be.


You can view the byte code using the dis module, e.g.:


py import dis
py code = compile('x = 1; y = 0; print x and y', '', 'exec')
py dis.dis(code)
  1   0 LOAD_CONST   0 (1)
  3 STORE_NAME   0 (x)
  6 LOAD_CONST   1 (0)
  9 STORE_NAME   1 (y)
 12 LOAD_NAME0 (x)
 15 JUMP_IF_FALSE_OR_POP21
 18 LOAD_NAME1 (y)
   21 PRINT_ITEM
 22 PRINT_NEWLINE
 23 LOAD_CONST   2 (None)
 26 RETURN_VALUE


If you run this under another implementation of Python, such as WPython, or
even a different version of CPython, you may get completely 

Re: a couple of things I don't understand wrt lists

2013-04-17 Thread Steven D'Aprano
Ned Batchelder wrote:

 On 4/17/2013 12:10 PM, 8 Dihedral wrote:

 Well, a new object is returned and can be used.
 Then who is going to clean up the object when required?
 
 This is a key thing to understand about Python: memory is managed
 automatically, no one has to clean up the object.  Once there are no
 names referring to the object, it will be cleaned up automatically.

The key to understand about 8 Dihedral is that it is a bot.

:-)

But seriously, it's a bot.


-- 
Steven

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


Re: Encoding NaN in JSON

2013-04-17 Thread Johann Hibschman
Miki Tebeka miki.teb...@gmail.com writes:

 I'm trying to find a way to have json emit float('NaN') as 'N/A'.
 No.  There is no way to represent NaN in JSON.  It's simply not part of the
 specification.
 I know that. I'm trying to emit the *string* 'N/A' for every NaN.

Easiest way is probably to transform your object before you try to write
it, e.g.

  def transform(x):
  if isinstance(x, dict):
  return dict((k, transform(v)) for k, v in x.items())
  elif isinstance(x, list) or isinstance(x, tuple):
  return [transform(v) for v in x]
  elif isinstance(x, float) and x != x:
  return 'N/A'
  else:
  return x

Then just use

  json.dumps(transform(x))

rather than just

  json.dumps(x)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing soap result

2013-04-17 Thread darnold
On Apr 17, 1:05 pm, Christian Heimes christ...@python.org wrote:
 Am 17.04.2013 19:55, schrieb darnold:

  On Apr 17, 8:50 am, Ombongi Moraa Fe moraa.lovetak...@gmail.com
  wrote:

  how do I use xml.etree.ElementTree to print the parameters address and
  deliveryStatus? Or is there a better python method?

  I'm sure there are prettier ways to do this, but you can use XPath
  syntax to find all of your ns1:result nodes and loop through them:

 You want all {http://www.csapi.org/schema/parlayx/sms/send/v2_2/
 local}result tags. The prefix isn't fixed.

I'm sorry, but I'm not understanding the difference.
By specifying:

 myNamespaces=dict(ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local;)

Isn't this:

 for result in root.findall('.//ns1:result',namespaces=myNamespaces):

equivalent to:

 for result in 
 root.findall('.//{http://www.csapi.org/schema/parlayx/sms/send/v2_2/local}result'):

?

Or am I misunderstanding? Is there a namespace-agnostic way of doing
this?
Admittedly, I haven't used ElementTree or XPath much prior to toying
with them to (attempt to) answer the OP's question.

Thanks for your patience,
Don
-- 
http://mail.python.org/mailman/listinfo/python-list


anyone know pandas ? Don't understand error: NotImplementedError...

2013-04-17 Thread someone

Hi,

Here's my script (from 
http://brenda.moon.net.au/category/data-visualisation/:



#!/usr/bin/python

import pandas
import datetime
import numpy

datesList = [datetime.date(2011,12,1), \
 datetime.date(2011,12,2), \
 datetime.date(2011,12,3), \
 datetime.date(2011,12,10)]

countsList = numpy.random.randn(len(datesList))
startData = datetime.datetime(2011,12,3)
endData = datetime.datetime(2011,12,8)

def convertListPairToTimeSeries(dList, cList):
# my dateList had date objects, so convert back to datetime objects
dListDT = [datetime.datetime.combine(x, datetime.time()) for x in 
dList]

# found that NaN didn't work if the cList contained int data
cListL = [float(x) for x in cList]
#  create the index from the datestimes list
indx = pandas.Index(dListDT)
#  create the timeseries
ts = pandas.Series(cListL, index=indx)
# fill in missing days
ts = ts.asfreq(pandas.datetools.DateOffset())
return ts

print \nOriginal datesList list:\n, datesList
tSeries = convertListPairToTimeSeries(datesList, countsList)
print \nPandas timeseries:\n, tSeries

# use slicing to change length of data
tSeriesSlice = tSeries.ix[startData:endData]
print \nPandas timeseries sliced between, startData.date(), \
  and, endData.date(), :\n, tSeriesSlice

# use truncate instead of slicing to change length of data
tSeriesTruncate = tSeries.truncate(before=startData, after=endData)
print \nPandas timeseries truncated between, startData.date(), \
  and, endData.date(), :\n, tSeriesTruncate

# my data had lots of gaps that were actually 0 values, not missing data
# So I used this to fix the NaN outside the known outage
startOutage = datetime.datetime(2011,12,7)
endOutage = datetime.datetime(2011,12,8)
tsFilled = tSeries.fillna(0)
# set the known outage values back to NAN
tsFilled.ix[startOutage:endOutage] = numpy.NAN
print \nPandas timeseries NaN reset to 0 outside known outage between, \
  startOutage.date(), and, endOutage.date(), :\n, tsFilled

print \nPandas series.tail(1) and series.head(1) are handy for  +\
  checking ends of list:\n, tsFilled.head(1), tsFilled.tail(1)
print

tsFilled.plot(); # ==  NotImplementedError...!!!



If I run it, I get:

...
...
..
2011-12-090.00
2011-12-101.431665
Freq: 1 DateOffset

Pandas series.tail(1) and series.head(1) are handy for checking ends of 
list:

2011-12-01   -0.969533
Freq: 1 DateOffset 2011-12-101.431665
Freq: 1 DateOffset

Traceback (most recent call last):
  File ./pandas_example.py, line 57, in module
tsFilled.plot();
  File /usr/lib/pymodules/python2.7/pandas/tools/plotting.py, line 
985, in plot_series

plot_obj.generate()
  File /usr/lib/pymodules/python2.7/pandas/tools/plotting.py, line 
376, in generate

self._make_plot()
  File /usr/lib/pymodules/python2.7/pandas/tools/plotting.py, line 
623, in _make_plot

if self.use_index and self._use_dynamic_x():
  File /usr/lib/pymodules/python2.7/pandas/tools/plotting.py, line 
619, in _use_dynamic_x

return (freq is not None) and self._is_dynamic_freq(freq)
  File /usr/lib/pymodules/python2.7/pandas/tools/plotting.py, line 
602, in _is_dynamic_freq

freq = freq.rule_code
  File /usr/lib/pymodules/python2.7/pandas/tseries/offsets.py, line 
214, in rule_code

raise NotImplementedError
NotImplementedError


Can anyone tell why this error appears and how to fix it?
--
http://mail.python.org/mailman/listinfo/python-list


PyCamp Registration Open for Columbus, Toronto, and Oshkosh

2013-04-17 Thread Chris Calloway
Registration is open for three upcoming PyCamps produced by the Triangle 
Python Users Group:


- A five-day PyOhio PyCamp hosted by the Ohio State University Open 
Source Club, July 22-26, 2013 the week prior to the PyOhio regional 
Python conference weekend. PyCamp is a training program and sponsor of 
PyOhio:


http://trizpug.org/boot-camp/pyohio13/

- A five-day Toronto PyCamp hosted by the University of Toronto 
Department of Physics, August 12-16, 2013 the week after the PyCon 
Canada national Python conference weekend. PyCamp is a Diversity Sponsor 
of PyCon CA:


http://trizpug.org/boot-camp/torpy13/

- A three-day Wisconsin Mini-PyCamp hosted at the University of 
Wisconsin Oshkosh, June 2-4, 2013 as part of the Plone Symposium Midwest 
training days:


http://trizpug.org/boot-camp/wiscpy13/

PyCamp is the original, ultra-low-cost Python Boot Camp created by a 
user group for user groups. For beginners, PyCamp makes you productive 
so you can get your work done quickly. PyCamp emphasizes the features 
which make Python a simpler and more efficient language. Following along 
with example Python PushUps speeds your learning process. Become a 
self-sufficient Python developer at PyCamp. PyCamps are conducted in 
state of the art high technology classrooms on university campuses.


Registration will open soon also for two additional Triangle Python User 
Group boot camp events. An additional announcement will follow when 
registration opens for these events, but mark your calendars now:


- A five-day Seattle PyCamp hosted by the University of Washington 
Department of Computer Science and Engineering and UW Marketing, 
September 9-13, 2013. PyCamp is a sponsor of the Seattle Plone Users Group.


- A five-day special Python Web Programming boot camp hosted by the 
University of North Carolina Department of Marine Sciences, August 5-9, 
2013.


--
Sincerely,

Chris Calloway http://nccoos.org/Members/cbc
office: 3313 Venable Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-17 Thread Miki Tebeka
  I'm trying to find a way to have json emit float('NaN') as 'N/A'.
 Easiest way is probably to transform your object before you try to write
Yeah, that's what I ended up doing. Wondered if there's a better way ...

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


Re: Encoding NaN in JSON

2013-04-17 Thread Dave Angel

On 04/17/2013 03:05 PM, Johann Hibschman wrote:

Miki Tebeka miki.teb...@gmail.com writes:


I'm trying to find a way to have json emit float('NaN') as 'N/A'.

No.  There is no way to represent NaN in JSON.  It's simply not part of the
specification.

I know that. I'm trying to emit the *string* 'N/A' for every NaN.


Easiest way is probably to transform your object before you try to write
it, e.g.

   def transform(x):
   if isinstance(x, dict):
   return dict((k, transform(v)) for k, v in x.items())
   elif isinstance(x, list) or isinstance(x, tuple):
   return [transform(v) for v in x]
   elif isinstance(x, float) and x != x:
   return 'N/A'
   else:
   return x



Note that for a self-referencing object, this function might run 
forever, or until it runs out of stack.  The programmer is likely to 
know about the possibility, but just in case ...



Then just use

   json.dumps(transform(x))

rather than just

   json.dumps(x)




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


Re: Parsing soap result

2013-04-17 Thread Burak Arslan

On 04/17/13 16:50, Ombongi Moraa Fe wrote:

My

client.service.gere(ri)

method call logs the below soap response in my log file.

?xml version=1.0 encoding=utf-8 ?soapenv:Envelope 
xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; 
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;soapenv:Bodyns1:gere 
xmlns:ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local;ns1:resultaddress254727/addressdeliveryStatusDeliveredToNetwork/deliveryStatus/ns1:result/ns1:gere/soapenv:Body/soapenv:Envelope



If I assign the client.service.gere(ri) to a variable, i get the 
output on my screen:


result=client.service.gere(ri)

output:
[(DeliveryInformation){
   address = 254727
   deliveryStatus = DeliveredToNetwork
 }]

string functions replace() and strip don't work.

how do I use xml.etree.ElementTree to print the parameters address and 
deliveryStatus? Or is there a better python method?


hi,

try:

result[0].deliveryStatus

or

result[0].DeliveryInformation.deliveryStatus


and let us know.

best,
burak

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


Re: Preparing sqlite, dl and tkinter for Python installation (no admin rights)

2013-04-17 Thread James Jong
I managed to compile sqlite with:

CPPFLAGS='-I/path_to_sqlite-3.7.16.2/include -I/path_to_tk8.6.0/include'

DFLAGS='-L/path_to_sqlite-3.7.16.2/lib -L/path_to_tk8.6.0/lib/'
./configure --prefix=/path_to_python-2.7.4 --enable-shared

However, _tkinter is still failing. I don't know what else to try. Any
thoughts?

Thanks,

James



On Tue, Apr 16, 2013 at 1:28 PM, James Jong ribonucle...@gmail.com wrote:

 Thank you Terry, I am working with:
  cat /proc/version
 Linux version 2.6.18-274.el5xen (brewbuil...@norob.fnal.gov) (gcc version
 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Thu Jul 21

  cat /etc/redhat-release
 Scientific Linux SL release 5.1 (Boron)

 I did not find distribution-specific tar balls for tck/tk, sqlite or dl on
 the Scientific  Linux website, but maybe I am not looking in the right
 place. Do you know how I can find which tarballs I need?

 James








 On Tue, Apr 16, 2013 at 12:55 PM, Terry Jan Reedy tjre...@udel.eduwrote:

 On 4/16/2013 10:30 AM, rosoloum wrote:

 I do not have admin rights on my machine


 The answer to your question may depend on the OS (linux), distribution
 (many), and version.


  What about `_tkinter` and  `dl`? How can I have them ready for the Python
 installer?


 Building _tkinter (a Python C-coded module) requires tcl/tk and header
 files. Some distros have a separate python sdk kit with the headers not
 included with tcl/tk.


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



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


Re: Encoding NaN in JSON

2013-04-17 Thread Roland Koebler
Hi,

  Easiest way is probably to transform your object before you try to write
 Yeah, that's what I ended up doing. Wondered if there's a better way ...
yes, there is: subclass+extend the JSON-encoder, see pydoc json.

e.g.:
class JsonNanEncoder(json.JSONEncoder):
def default(self, obj):
if some-check-if-obj-is-NaN:
return 'NaN'
return json.JSONEncoder.default(self, obj)

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


Re: Unicode issue with Python v3.3

2013-04-17 Thread Cameron Simpson
On 14Apr2013 04:22, nagia.rets...@gmail.com nagia.rets...@gmail.com wrote:
|  | Cameron would it be too much to ask to provide you with root
|  | access to my VPS server so you can have a look there too?
|  | i can pay you if you like if you wait a few days to gather some money.
|  
|  I really do not recommend that:
|- it is nuts to blithely allow a stranger root access to your system
|- you won't learn anything about CGI scripts
[...]
| I insist that you will make the most of this if you access the VPS yourself.
| it runs CentOS 6.4
| Please accept, i trust you.

Very well.

Let's take this off list to personal email (note that the reply-to
on this message is just myself, not the list/group).

We can return here after sorting CGI issues, should there be any further python
specific issues.

Reply to this message. I will email you my ssh public key. Please make me an
_ordinary_ user account called cameron and send me the ssh details of your 
VPS.
-- 
Cameron Simpson c...@zip.com.au

TeX: When you pronounce it correctly to your computer, the terminal may
 become slightly moist. - D. E. Knuth.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Mark Janssen
On Tue, Apr 16, 2013 at 8:55 PM, rusi rustompm...@gmail.com wrote:
 On Apr 17, 7:57 am, Bruce McGoveran bruce.mcgove...@gmail.com wrote:
 3.  Section 5.3.1 offers this definition of an attributeref:
 attributeref ::= primary . identifier


 One general comment I will make is regarding your distress at what you
 call 'circular'
 Circular just means recursive and recursion is the bedrock for
 language-design.

Rercursion the bedrock of language-design.  I don't think so.  From
what I know, a well-defined language ends at its symbols.  It makes no
use of infinities.

 You cannot hope to define an infinite object such as the python
 language (there are an infinite number of python programs) with a
 finite specification

You've committed two grave sins in C.S.:  Conflating a programming
language (an infinite object such as python language) with a program
written in that language (there are an infinite number of python
programs).   These two are entirely separate (at least anything
implemented on a real computer).  Further, you've made a silly
description of python an infinite object such as the python
language.  A programming language that is well defined has complete,
finite, specification.  The fact that there are an endless number of
programs that can be made from such is irrelevant to the language
itself.

 -- a useful language definition must start and
 end and preferably fit in one's pocket!

Likewise, a language specification must end in its symbols.

 The trick is to find ways of making an inifinite object finitely
 generated.

There is no trick involved.

 So much of language design is a generalization of Peano's
 method of defining (designing?) natural numbers:
 a. 0 is a natural number
 b. If x is a natural number then the successor of x (informally x+1)
 is a natural number

Well now you're getting to the root of the confusion and what I'm
arguing within the C.S. community:  there must be clear distinction
between lambda calculii and programming languages rooted in actual
hardware implementations.  While, traditionally, the field has not
made much of a distinction, in practice the computational architecture
is different.  One of these has a connection to reality and the other
not as much ;^).

In any case, talking about the mathematical realm *as a realm of
Platonic thought* is irrelevant to the discussion of program spaces
where *things actually get done*.

This is what this list (python) has not figured out yet, because they
look up to the theoretical C.S. field and it hasn't yet been
published.

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread alex23
On Apr 18, 9:40 am, Mark Janssen dreamingforw...@gmail.com wrote:
 This is what this list (python) has not figured out yet, because they
 look up to the theoretical C.S. field and it hasn't yet been
 published.

No one here idolises the theoretical C.S. field. They *use* Python
to *get things done*, not to engage in pointless masturbation.

Please keep your computer pseudo-science nonsense to your own threads,
don't use it to derail others.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Ian Kelly
On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 Rercursion the bedrock of language-design.  I don't think so.  From
 what I know, a well-defined language ends at its symbols.  It makes no
 use of infinities.

From what I know, you can't have a Turing-complete language without
some form of recursion.  So yeah, it's pretty damn important in
language design.

 You cannot hope to define an infinite object such as the python
 language (there are an infinite number of python programs) with a
 finite specification

 You've committed two grave sins in C.S.:

You've just committed the grave sin of being needlessly hyperbolic.

 Conflating a programming
 language (an infinite object such as python language) with a program
 written in that language (there are an infinite number of python
 programs).   These two are entirely separate (at least anything
 implemented on a real computer).

Mathematically, a language (e.g. a programming language) is a set of
well-formed strings (i.e. programs) constructed from the symbols of an
alphabet (i.e. tokens).  For most languages, this set is infinite;
saying the Python language is infinite is equivalent to saying
there are an infinite number of Python programs.

 Further, you've made a silly
 description of python an infinite object such as the python
 language.  A programming language that is well defined has complete,
 finite, specification.  The fact that there are an endless number of
 programs that can be made from such is irrelevant to the language
 itself.

A finite, non-recursive grammar can only hope to accept a finite
number of strings.  To have an infinite language, the defining grammar
must then be either infinite (not practical) or recursive.

 Well now you're getting to the root of the confusion and what I'm
 arguing within the C.S. community:  there must be clear distinction
 between lambda calculii and programming languages rooted in actual
 hardware implementations.  While, traditionally, the field has not
 made much of a distinction, in practice the computational architecture
 is different.  One of these has a connection to reality and the other
 not as much ;^).

 In any case, talking about the mathematical realm *as a realm of
 Platonic thought* is irrelevant to the discussion of program spaces
 where *things actually get done*.

Of course it's relevant.  Without theory we would not have big-Oh
notation or efficient data structures or regular expressions or
context-free grammars; languages like Python would be harder to
invent.  I'm sure one could come up with a myriad other examples, but
that's enough for me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Mark Janssen
On Wed, Apr 17, 2013 at 5:29 PM, alex23 wuwe...@gmail.com wrote:
 On Apr 18, 9:40 am, Mark Janssen dreamingforw...@gmail.com wrote:
 This is what this list (python) has not figured out yet, because they
 look up to the theoretical C.S. field and it hasn't yet been
 published.

 No one here idolises the theoretical C.S. field. They *use* Python
 to *get things done*, not to engage in pointless masturbation.

Woah!  no one you say  Interesting...

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Mark Janssen
On Wed, Apr 17, 2013 at 5:33 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen dreamingforw...@gmail.com 
 wrote:
 Rercursion the bedrock of language-design.  I don't think so.  From
 what I know, a well-defined language ends at its symbols.  It makes no
 use of infinities.

 From what I know, you can't have a Turing-complete language without
 some form of recursion.  So yeah, it's pretty damn important in
 language design.

A Turing-complete language generally has items that are defined in
terms of other, simpler items, but this is not called recursion in any
C.S. paper I know.
In C.S. of my world, recursion is a specific term that is related to
functional calculii.  This type of recursion is sometimes often found
in imperative/iterative languages, but is rooted in the fomer.

 Conflating a programming
 language (an infinite object such as python language) with a program
 written in that language (there are an infinite number of python
 programs).   These two are entirely separate (at least anything
 implemented on a real computer).

 Mathematically, a language (e.g. a programming language) is a set of
 well-formed strings (i.e. programs) constructed from the symbols of an
 alphabet (i.e. tokens).

Mathematically, perhaps, but from C.S. theory, a language is a
fully-specified set of expressions and tokens which are considered
valid -- it's grammar.

 For most languages, this set is infinite;

This set is always finite, as you can see on the specification for
Python's language.

 saying the Python language is infinite is equivalent to saying
 there are an infinite number of Python programs.

I don't think Guido would agree that the Python language is
infinite, but then perhaps he doesn't care either.

 A finite, non-recursive grammar can only hope to accept a finite
 number of strings.

Is the language we're speaking in now one with a finite, non-recursive grammar?

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Mark Lawrence

On 18/04/2013 01:41, Mark Janssen wrote:

On Wed, Apr 17, 2013 at 5:29 PM, alex23 wuwe...@gmail.com wrote:

On Apr 18, 9:40 am, Mark Janssen dreamingforw...@gmail.com wrote:

This is what this list (python) has not figured out yet, because they
look up to the theoretical C.S. field and it hasn't yet been
published.


No one here idolises the theoretical C.S. field. They *use* Python
to *get things done*, not to engage in pointless masturbation.


Woah!  no one you say  Interesting...

Mark



IMHO very few cos we all know that practically beats purity.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Mark Lawrence

On 18/04/2013 02:04, Mark Janssen wrote:

On Wed, Apr 17, 2013 at 5:33 PM, Ian Kelly ian.g.ke...@gmail.com wrote:

On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen dreamingforw...@gmail.com wrote:

Rercursion the bedrock of language-design.  I don't think so.  From
what I know, a well-defined language ends at its symbols.  It makes no
use of infinities.


 From what I know, you can't have a Turing-complete language without
some form of recursion.  So yeah, it's pretty damn important in
language design.


A Turing-complete language generally has items that are defined in
terms of other, simpler items, but this is not called recursion in any
C.S. paper I know.
In C.S. of my world, recursion is a specific term that is related to
functional calculii.  This type of recursion is sometimes often found
in imperative/iterative languages, but is rooted in the fomer.


Conflating a programming
language (an infinite object such as python language) with a program
written in that language (there are an infinite number of python
programs).   These two are entirely separate (at least anything
implemented on a real computer).


Mathematically, a language (e.g. a programming language) is a set of
well-formed strings (i.e. programs) constructed from the symbols of an
alphabet (i.e. tokens).


Mathematically, perhaps, but from C.S. theory, a language is a
fully-specified set of expressions and tokens which are considered
valid -- it's grammar.


For most languages, this set is infinite;


This set is always finite, as you can see on the specification for
Python's language.


saying the Python language is infinite is equivalent to saying
there are an infinite number of Python programs.


I don't think Guido would agree that the Python language is
infinite, but then perhaps he doesn't care either.


A finite, non-recursive grammar can only hope to accept a finite
number of strings.


Is the language we're speaking in now one with a finite, non-recursive grammar?



Thanks for reminding me that I must add food for the trolls to the 
bottom of my shopping list.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Encoding NaN in JSON

2013-04-17 Thread Miki Tebeka
[Roland]
 yes, there is: subclass+extend the JSON-encoder, see pydoc json.
Please read the original post before answering. What you suggested does not 
work since NaN is of float type.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-17 Thread Roland Koebler
Hi,

  yes, there is: subclass+extend the JSON-encoder, see pydoc json.
 Please read the original post before answering. What you suggested does not 
 work since NaN is of float type.
ok, right, default does not work this way.
But I would still suggest to extend the JSON-encoder, since that is
quite simple (see sourcecode of JSON module); as a quickhack, you
could even monkey patch json.encoder.floatstr with a wrapper which
returns N/A for NaN. (I've tested it: It works.)

But: If you only need NaN and inf, and are ok with 'NaN' instead of 'N/A',
you can simply use the json module. See pydoc json:

If allow_nan is True, then NaN, Infinity, and -Infinity will be
encoded as such.  This behavior is not JSON specification compliant,
but is consistent with most JavaScript based encoders and decoders.
Otherwise, it will be a ValueError to encode such floats.

 import json
 json.dumps(float('NaN'))
'NaN'
 json.dumps(float('inf'))
'Infinity'


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


Re: Encoding NaN in JSON

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 11:01 AM, Miki Tebeka miki.teb...@gmail.com wrote:
 [Roland]
 yes, there is: subclass+extend the JSON-encoder, see pydoc json.
 Please read the original post before answering. What you suggested does not 
 work since NaN is of float type.

You may be able to override a bit more of the code, though. Check out
Lib/json/encoder.py for the implementation, and have a look at the
floatstr() internal function; unfortunately you can't simply subclass
and override that, but perhaps overriding iterencode (which is where
floatstr is defined) would do the job.

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


Re: Encoding NaN in JSON

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 11:39 AM, Roland Koebler r.koeb...@yahoo.de wrote:
 as a quickhack, you
 could even monkey patch json.encoder.floatstr with a wrapper which
 returns N/A for NaN. (I've tested it: It works.)

Wait... you can do that? It's internal to iterencode, at least in
Python 3.3 and 2.7 that I'm looking at here. Can you share your code
please? I'd like to try that! When I first looked at the docstring, I
was thinking Ah, can I override the bit that emits NaN to return
\N/A\ instead?, but the code made me think that's not possible.

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 9:40 AM, Mark Janssen dreamingforw...@gmail.com wrote:
 On Tue, Apr 16, 2013 at 8:55 PM, rusi rustompm...@gmail.com wrote:
 On Apr 17, 7:57 am, Bruce McGoveran bruce.mcgove...@gmail.com wrote:
 3.  Section 5.3.1 offers this definition of an attributeref:
 attributeref ::= primary . identifier


 One general comment I will make is regarding your distress at what you
 call 'circular'
 Circular just means recursive and recursion is the bedrock for
 language-design.

 Rercursion the bedrock of language-design.  I don't think so.  From
 what I know, a well-defined language ends at its symbols.  It makes no
 use of infinities.

There's a difference between infinite and recursive, though. I was
defining a function (it converted from JSON to an internal format) and
wanted to explain that not all of JSON would reliably round-trip (ie
be able to be translated to the internal format and then back again).
To describe what _would_ round-trip correctly, I used this simple yet
technically illegal description:

typedef valid string|array(valid)|object(string:valid)

In other words, a string is valid, and a list/array of valid elements
is valid, and a dictionary/mapping/object with string keys and valid
elements is valid. It's a recursive definition, but it can't go
infinite (self-references aren't valid - though this isn't stated by
the typedef); however, it can go arbitrarily deep.

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


Re: Preparing sqlite, dl and tkinter for Python installation (no admin rights)

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 8:39 AM, James Jong ribonucle...@gmail.com wrote:
 I managed to compile sqlite with:

 CPPFLAGS='-I/path_to_sqlite-3.7.16.2/include -I/path_to_tk8.6.0/include'

 DFLAGS='-L/path_to_sqlite-3.7.16.2/lib -L/path_to_tk8.6.0/lib/'

 ./configure --prefix=/path_to_python-2.7.4 --enable-shared

 However, _tkinter is still failing. I don't know what else to try. Any
 thoughts?

Can you build Python on a different system (to which you have admin
rights), then deploy the binary to the one where you don't? Then you
could do a much more standard compilation process. As long as the two
systems are broadly similar, it should work.

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Steven D'Aprano
On Wed, 17 Apr 2013 18:33:09 -0600, Ian Kelly wrote:

 On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen
 dreamingforw...@gmail.com wrote:
 Rercursion the bedrock of language-design.  I don't think so.  From
 what I know, a well-defined language ends at its symbols.  It makes no
 use of infinities.
 
 From what I know, you can't have a Turing-complete language without
 some form of recursion.  So yeah, it's pretty damn important in language
 design.

Incorrect. Early Fortran, which was definitely Turing complete, was 
incapable of using recursion. But that doesn't matter, since any 
recursive algorithm can be re-written as iteration. So long as a language 
can iterate an indefinite number of times, it may be Turing complete.

(Languages which can only iterate a fixed number of times cannot be 
Turing complete.)

Hell, Turing machines themselves are not recursive. Since they don't have 
a concept of functions, they don't have a concept of functions that call 
themselves. A Turing machine only has a couple of trivial operations:

* read a cell
* write a cell
* advance the tape
* change direction

and so it's grammar is correspondingly trivial. Actually, talking about 
the grammar of a Turing machine is probably wrong. In practice, Turing 
machines are specified as a finite (and usually small) table of states 
and cells. See here for examples: 

http://en.wikipedia.org/wiki/Turing_machine_examples

So it isn't even correct to say that recursion is necessary for a 
language's *grammar*. However, for any real-world practical language 
(there's a reason that no practical language is based on Turing machines) 
recursive grammars are extraordinarily useful.


 A finite, non-recursive grammar can only hope to accept a finite number
 of strings.  To have an infinite language, the defining grammar must
 then be either infinite (not practical) or recursive.

I don't believe that is true, so long as the grammar has a concept of 
zero or more of some syntactic element. For example, suppose your 
grammar has a concept of integers, defined recursively as either a digit, 
or a digit followed by an integer:

INTEGER ::= DIGIT | DIGIT INTEGER

This can be defined more naturally as a digit followed by zero or more 
digits:

INTEGER ::= DIGIT (DIGIT)*



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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Ian Kelly
On Wed, Apr 17, 2013 at 7:04 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 On Wed, Apr 17, 2013 at 5:33 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen dreamingforw...@gmail.com 
 wrote:
 Rercursion the bedrock of language-design.  I don't think so.  From
 what I know, a well-defined language ends at its symbols.  It makes no
 use of infinities.

 From what I know, you can't have a Turing-complete language without
 some form of recursion.  So yeah, it's pretty damn important in
 language design.

 A Turing-complete language generally has items that are defined in
 terms of other, simpler items, but this is not called recursion in any
 C.S. paper I know.
 In C.S. of my world, recursion is a specific term that is related to
 functional calculii.  This type of recursion is sometimes often found
 in imperative/iterative languages, but is rooted in the fomer.

You are thinking of recursive procedures.  Recursion is the more
general concept of self-repetition.  In a programming language, it can
be implemented by recursive procedures, or it can equivalently be
implemented by looping constructs.

Incidentally, in computability theory (also known as recursion
theory), recursive is basically a synonym for computable, which
relates back to my point that recursion is necessary for
Turing-completeness; a Turing-complete language is one that can
compute any computable (i.e. recursive) function.

 Conflating a programming
 language (an infinite object such as python language) with a program
 written in that language (there are an infinite number of python
 programs).   These two are entirely separate (at least anything
 implemented on a real computer).

 Mathematically, a language (e.g. a programming language) is a set of
 well-formed strings (i.e. programs) constructed from the symbols of an
 alphabet (i.e. tokens).

 Mathematically, perhaps, but from C.S. theory, a language is a
 fully-specified set of expressions and tokens which are considered
 valid -- it's grammar.

Sorry, but as computer science *is* math, the computer science
definition is the same as the mathematical one.  See for example this
CS paper which formally defines language as I described:

http://www.cs.ucr.edu/~jiang/cs215/tao-new.pdf

 For most languages, this set is infinite;

 This set is always finite, as you can see on the specification for
 Python's language.

No, the set of valid Python programs is not finite.

 saying the Python language is infinite is equivalent to saying
 there are an infinite number of Python programs.

 I don't think Guido would agree that the Python language is
 infinite, but then perhaps he doesn't care either.

 A finite, non-recursive grammar can only hope to accept a finite
 number of strings.

 Is the language we're speaking in now one with a finite, non-recursive 
 grammar?

No, English is also recursive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread Ian Kelly
On Wed, Apr 17, 2013 at 8:14 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Incorrect. Early Fortran, which was definitely Turing complete, was
 incapable of using recursion. But that doesn't matter, since any
 recursive algorithm can be re-written as iteration. So long as a language
 can iterate an indefinite number of times, it may be Turing complete.

You're also confusing recursion with recursive programming.  See
the response I just gave to Mark.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode issue with Python v3.3

2013-04-17 Thread Νίκος Γκρ33κ
Τη Πέμπτη, 18 Απριλίου 2013 2:00:48 π.μ. UTC+3, ο χρήστης Cameron Simpson 
έγραψε:

 Reply to this message. I will email you my ssh public key. Please make me an 
 _ordinary_ user account called cameron and send me the ssh details of your
 VPS.

Thank you very much Cameron, i appreciate all your help and i'am willing to 
open you a free lifetime premium account at my webhosting as a token of 
appreciation.

I have just mail you the login credentials.
-- 
http://mail.python.org/mailman/listinfo/python-list


Novice Issue

2013-04-17 Thread Bradley Wright
Good Day all, currently writing a script that ask the user for three things;
1.Name
2.Number
3.Description
I've gotten it to do this hurah!

print Type \q\ or \quit\ to quit
while raw_input != quit or q:

print 
name = str(raw_input(Name: ))
number = str(raw_input(Number: ))
description = str(raw_input(Description: ))

but here a few things, can anyone help me on figuring out how to at the users 
whim print out all of the names, numbers and descriptions. this is sort of an 
information logger.

additionally, minor issue with getting script to stop when q or quit is typed

any help would be greatly appreciated
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Novice Issue

2013-04-17 Thread Chris Angelico
On Thu, Apr 18, 2013 at 2:06 PM, Bradley Wright
bradley.wright@gmail.com wrote:
 Good Day all, currently writing a script that ask the user for three things;
 1.Name
 2.Number
 3.Description
 I've gotten it to do this hurah!

 print Type \q\ or \quit\ to quit
 while raw_input != quit or q:

You'll want to actually _call_ that function: raw_input()


 print 
 name = str(raw_input(Name: ))
 number = str(raw_input(Number: ))
 description = str(raw_input(Description: ))

raw_input already returns a string, so the str() is redundant here.

 but here a few things, can anyone help me on figuring out how to at the users 
 whim print out all of the names, numbers and descriptions. this is sort of an 
 information logger.

 additionally, minor issue with getting script to stop when q or quit is typed

 any help would be greatly appreciated

Once you have all the values, you just need to figure out what you're
trying to do with them. Do you need to retain them till the end of the
loop? If so, consider a list or dictionary. Or do you need to work
with them right there inside the loop? What are you needing to
accomplish?

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


Re: Atoms, Identifiers, and Primaries

2013-04-17 Thread 88888 Dihedral
Ian於 2013年4月17日星期三UTC+8下午3時21分00秒寫道:
 On Tue, Apr 16, 2013 at 8:57 PM, Bruce McGoveran
 
  wrote:
 
  These are terms that appear in section 5 (Expressions) of the Python online 
  documentation.  I'm having some trouble understanding what, precisely, 
  these terms mean.  I'd appreciate the forum's thoughts on these questions:
 
 
 
  1.  Section 5.2.1 indicates that an identifier occurring as an atom is a 
  name.  However, Section 2.3 indicates that identifiers are names.  My 
  question:  can an identifier be anything other than a name?
 
 
 
 Yes.  For example:
 
 
 
 from a import b
 
 
 
 Here a is an identifier but not a name, as it does not carry
 
 object-binding semantics.
 
 
 
  2.  Section 5.3 defines primaries as the most tightly bound operations of 
  Python.  What does this mean?
 
 
 
 Tightly bound here refers to operator precedence.  For example, we
 
 say that the multiplication operator binds more tightly [to the
 
 surrounding operands] than the arithmetic operator, because the
 
 multiplication takes precedence.  This section defines that the most
 
 tightly bound operations in Python are attribute references,
 
 subscriptions, slices and calls; these always take precedence over
 
 other neighboring operations.
 
 
 
  In particular, if an atom is a primary, what operation is the atom 
  performing that leads to the label most tightly bound?
 
 
 
 An atom doesn't perform an operation.  The grammar defines that a
 
 primary can be just an atom, so that anywhere in the grammar that
 
 expects a primary, a simple atom with no primary operation performed
 
 on it can equally be used.

An atom can not be divided into further details.
An atom can be created and cloned or just referenced 
in some relations.

An object is composed of atoms linked in someway.

Of course, one can box those atoms of an object 
to make the object immutable at least in some situations
to be named and used.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue16878] argparse: positional args with nargs='*' defaults to []

2013-04-17 Thread paul j3

paul j3 added the comment:

In this example:

 p.add_argument('--foo', nargs='*', default=None)
 p.parse_args([])
Namespace(foo=None)
 p.parse_args(['--foo'])
Namespace(foo=[])

'p.parse_args([])' just assigns the default to 'foo' in the Namespace.

p.parse_args(['--foo']) invokes 'take_action(dest='foo',[]).  That is, it 
'assigns' an empty array to 'foo'.   The same thing would happen if 'foo' was a 
positional.  

'take_action' then passes these arguments to '_get_values'.  That is where the 
differences between '?' and '*' arise.

The key pieces of code in '_get_values' when arg_strings==[] are:

# optional argument produces a default when not present
if not arg_strings and action.nargs == OPTIONAL:
value = action.default
# and evaluate 'value' if is a string

# when nargs='*' on a positional, if there were no command-line
# args, use the default if it is anything other than None
elif (not arg_strings and action.nargs == ZERO_OR_MORE ...):
if action.default is not None:
value = action.default
else:
value = arg_strings # i.e. []

In other words, if nargs='?', the attribute gets its default value.  But for 
'*', this is true only if the default is not None.

So in:

parse([], nargs='?')# get the default value: None
parse([], nargs='*')# default is None, get arg_strings []
parse([], nargs='*', default=None)  # same case
parse([], nargs='*', default=False) # default is not None, get default
parse([], nargs='*', default=0) # same case

I tried changing the _get_values() so '*' got the default (like '?' does), and 
got 54 failures when running test_argparse.py.

--
nosy: +paul.j3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17532] IDLE: Always include Options menu on MacOSX

2013-04-17 Thread Guilherme Simões

Guilherme Simões added the comment:

I actually removed something I shouldn't have in the first patch so I'm 
attaching a new one.

--
Added file: http://bugs.python.org/file29899/17532MenuOptions-1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17532
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16694] Add pure Python operator module

2013-04-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

length_hint() looks ok as well.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17758] test_site fails when the user does not have a home directory

2013-04-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

As a sidenote, I find it a bit scary that test_site even *tries* to create 
USER_SITE. The test suite shouldn't touch anything outside of test-specific 
temp files.

--
nosy: +christian.heimes, pitrou
type: enhancement - behavior
versions: +Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17758
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17758] test_site fails when the user does not have a home directory

2013-04-17 Thread Christian Heimes

Christian Heimes added the comment:

Don't be scared ... :)

I'll think about a solution.

--
assignee:  - christian.heimes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17758
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17772] test_gdb doesn't detect a gdb built with python3.3 (or higher)

2013-04-17 Thread Matthias Klose

New submission from Matthias Klose:

test_gdb skipped -- gdb not built with embedded python support

$ gdb --version
GNU gdb (GDB) 7.5.91.20130408
$ ldd /usr/bin/gdb|grep python
libpython3.3m.so.1.0 = /usr/lib/libpython3.3m.so.1.0

--
messages: 187151
nosy: dmalcolm, doko
priority: normal
severity: normal
stage: needs patch
status: open
title: test_gdb doesn't detect a gdb built with python3.3 (or higher)
versions: Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17772
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17773] test_pydoc fails with the installed testsuite (2.7)

2013-04-17 Thread Matthias Klose

New submission from Matthias Klose:

these are failures not seen with 3.x, running with -S doesn't help.

test_pydoc
test test_pydoc failed -- multiple errors occurred; run in verbose mode for 
details
1 test failed:
test_pydoc
Re-running failed tests in verbose mode
Re-running test 'test_pydoc' in verbose mode
test_html_doc (test.test_pydoc.PyDocDocTest) ... 
--- expected
+++ got
@@ -19 +19 @@
-dtfont face=helvetica, ariala href=test.pydoc_mod.html#BB/a
+dtfont face=helvetica, arialB
@@ -22 +22 @@
-dtfont face=helvetica, ariala href=test.pydoc_mod.html#AA/a
+dtfont face=helvetica, arialA
@@ -56,12 +55,0 @@
-tr bgcolor=#eeaa77
-td colspan=3 valign=bottomnbsp;br
-font color=#ff face=helvetica, 
arialbigstrongFunctions/strong/big/font/td/tr
-
-trtd 
bgcolor=#eeaa77ttnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/tt/tdtdnbsp;/td
-td width=100%dldta 
name=-doc_funcstrongdoc_func/strong/a()/dtddttThisnbsp;functionnbsp;solvesnbsp;allnbsp;ofnbsp;thenbsp;world'snbsp;problems:br
-hungerbr
-lacknbsp;ofnbsp;Pythonbr
-war/tt/dd/dl
- dldta name=-nodoc_funcstrongnodoc_func/strong/a()/dt/dl
-/td/tr/tablep
-table width=100% cellspacing=0 cellpadding=2 border=0 summary=section

FAIL
test_input_strip (test.test_pydoc.PyDocDocTest) ... ok
test_issue8225 (test.test_pydoc.PyDocDocTest) ... ok
test_non_str_name (test.test_pydoc.PyDocDocTest) ... ok
test_not_here (test.test_pydoc.PyDocDocTest) ... ok
test_stripid (test.test_pydoc.PyDocDocTest) ... ok
test_text_doc (test.test_pydoc.PyDocDocTest) ... 
--- expected
+++ got
@@ -34,9 +33,0 @@
-FUNCTIONS
-doc_func()
-This function solves all of the world's problems:
-hunger
-lack of Python
-war
-
-nodoc_func()
-

FAIL
test_apropos_with_bad_package (test.test_pydoc.PydocImportTest) ... FAIL
test_apropos_with_unreadable_dir (test.test_pydoc.PydocImportTest) ... FAIL
test_badimport (test.test_pydoc.PydocImportTest) ... ok
test_class (test.test_pydoc.TestDescriptions) ... ok
test_classic_class (test.test_pydoc.TestDescriptions) ... ok
test_module (test.test_pydoc.TestDescriptions) ... ok
test_namedtuple_public_underscore (test.test_pydoc.TestDescriptions) ... ERROR
test_builtin (test.test_pydoc.TestHelper) ... ok
test_keywords (test.test_pydoc.TestHelper) ... test test_pydoc failed -- 
multiple errors occurred
ok

==
ERROR: test_namedtuple_public_underscore (test.test_pydoc.TestDescriptions)
--
Traceback (most recent call last):
  File /usr/lib/python2.7/test/test_pydoc.py, line 383, in 
test_namedtuple_public_underscore
help(NT)
NameError: global name 'help' is not defined

==
FAIL: test_html_doc (test.test_pydoc.PyDocDocTest)
--
Traceback (most recent call last):
  File /usr/lib/python2.7/test/test_pydoc.py, line 248, in test_html_doc
self.fail(outputs are not equal, see diff above)
AssertionError: outputs are not equal, see diff above

==
FAIL: test_text_doc (test.test_pydoc.PyDocDocTest)
--
Traceback (most recent call last):
  File /usr/lib/python2.7/test/test_pydoc.py, line 259, in test_text_doc
self.fail(outputs are not equal, see diff above)
AssertionError: outputs are not equal, see diff above

==
FAIL: test_apropos_with_bad_package (test.test_pydoc.PydocImportTest)
--
Traceback (most recent call last):
  File /usr/lib/python2.7/test/test_pydoc.py, line 341, in 
test_apropos_with_bad_package
result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
  File /usr/lib/python2.7/test/test_pydoc.py, line 196, in run_pydoc
rc, out, err = assert_python_ok('-B', pydoc.__file__, *args, **env)
  File /usr/lib/python2.7/test/script_helper.py, line 55, in assert_python_ok
return _assert_python(True, *args, **env_vars)
  File /usr/lib/python2.7/test/script_helper.py, line 47, in _assert_python
stderr follows:\n%s % (rc, err.decode('ascii', 'ignore')))
AssertionError: Process return code is -11, stderr follows:


==
FAIL: test_apropos_with_unreadable_dir (test.test_pydoc.PydocImportTest)
--
Traceback (most recent call last):
  File /usr/lib/python2.7/test/test_pydoc.py, line 351, in 
test_apropos_with_unreadable_dir
result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
  File /usr/lib/python2.7/test/test_pydoc.py, line 196, in run_pydoc
rc, out, err = assert_python_ok('-B', pydoc.__file__, *args, **env)
  File /usr/lib/python2.7/test/script_helper.py, 

[issue17750] allow the testsuite to run in the installed location

2013-04-17 Thread Matthias Klose

Changes by Matthias Klose d...@debian.org:


--
dependencies: +test_pydoc fails with the installed testsuite (2.7)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17750
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17353] Plistlib outputs empty data tags when deeply nested

2013-04-17 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The tests look good, thanks for writing them.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17353
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 65623d7dc76e by Giampaolo Rodola' in branch '3.3':
Fix issue #17707: multiprocessing.Queue's get() method does not block for short 
timeouts.
http://hg.python.org/cpython/rev/65623d7dc76e

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17707
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 87882c96d138 by Giampaolo Rodola' in branch 'default':
Fix issue #17707: multiprocessing.Queue's get() method does not block for short 
timeouts.
http://hg.python.org/cpython/rev/87882c96d138

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17707
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
keywords: +3.2regression, 3.3regression
resolution:  - fixed
status: open - closed
versions:  -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17707
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Tim Golden

Tim Golden added the comment:

Attached is a qd script to produce the list of extension - mimetype maps for 
a version of the mimetypes module.

--
Added file: http://bugs.python.org/file29900/mt.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Tim Golden

Tim Golden added the comment:

Three outputs produced by mt.py: tip as-is; tip without registry; tip
with new approach to registry. The results for 2.7 are near-enough
identical. Likewise the results for an elevated prompt.

--
Added file: http://bugs.python.org/file29901/mt-tip.txt
Added file: http://bugs.python.org/file29902/mt-tip-newregistry.txt
Added file: http://bugs.python.org/file29903/mt-tip-noregistry.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___.jpg = image/jpg
.mid = audio/midi
.midi = audio/midi
.pct = image/pict
.pic = image/pict
.pict = image/pict
.rtf = application/rtf
.xul = text/xul
.3g2 = video/3gpp2
.3gp = video/3gpp
.AMR = audio/AMR
.a = application/octet-stream
.aac = audio/x-aac
.ac3 = audio/x-ac3
.acrobatsecuritysettings = application/vnd.adobe.acrobat-security-settings
.adts = audio/vnd.dlna.adts
.ai = application/postscript
.aif = audio/x-aiff
.aifc = audio/x-aiff
.aiff = audio/x-aiff
.amc = application/x-mpeg
.application = application/x-ms-application
.asx = video/x-ms-asf-plugin
.au = audio/basic
.avi = video/x-msvideo
.bat = text/plain
.bcpio = application/x-bcpio
.bin = application/octet-stream
.bmp = image/bmp
.c = text/plain
.c2r = text/vnd-ms.click2record+xml
.caf = audio/x-caf
.cat = vnd.ms-pki.seccat
.cdf = application/x-netcdf
.cer = x-x509-ca-cert
.contact = text/x-ms-contact
.cpio = application/x-cpio
.crl = pkix-crl
.csh = application/x-csh
.css = text/css
.dir = application/x-director
.dll = application/octet-stream
.doc = application/msword
.dot = application/msword
.dvi = application/x-dvi
.dwfx = model/vnd.dwfx+xps
.easmx = model/vnd.easmx+xps
.edrwx = model/vnd.edrwx+xps
.eml = message/rfc822
.eprtx = model/vnd.eprtx+xps
.eps = application/postscript
.etx = text/x-setext
.exe = application/octet-stream
.fdf = application/vnd.fdf
.fif = application/fractals
.flc = video/flc
.gif = image/gif
.gsm = audio/x-gsm
.gtar = application/x-gtar
.gz = application/x-gzip
.h = text/plain
.hdf = application/x-hdf
.hqx = application/mac-binhex40
.hta = application/hta
.htc = text/x-component
.htm = text/html
.html = text/html
.ico = image/x-icon
.ics = text/calendar
.ief = image/ief
.iqy = text/x-ms-iqy
.jnlp = application/x-java-jnlp-file
.jp2 = image/x-jpeg2000-image
.jpe = image/jpeg
.jpeg = image/jpeg
.jpg = image/pjpeg
.js = application/javascript
.jtx = application/x-jtx+xps
.ksh = text/plain
.latex = application/x-latex
.m1v = video/mpeg
.m3u = audio/x-mpegurl
.m3u8 = application/vnd.apple.mpegurl
.m4a = audio/x-m4a
.m4b = audio/x-m4b
.m4p = audio/x-m4p
.m4v = video/x-m4v
.man = application/x-troff-man
.mdi = image/vnd.ms-modi
.me = application/x-troff-me
.mht = message/rfc822
.mhtml = message/rfc822
.mid = midi/mid
.mif = application/x-mif
.mov = video/quicktime
.movie = video/x-sgi-movie
.mp2 = audio/mpeg
.mp3 = audio/x-mpg
.mp4 = video/mp4
.mpa = video/mpeg
.mpe = video/mpeg
.mpeg = video/x-mpeg2a
.mpf = application/vnd.ms-mediapackage
.mpg = video/mpeg
.ms = application/x-troff-ms
.nc = application/x-netcdf
.nix = application/x-mix-transfer
.nws = message/rfc822
.o = application/octet-stream
.obj = application/octet-stream
.oda = application/oda
.odc = text/x-ms-odc
.osdx = application/opensearchdescription+xml
.p10 = pkcs10
.p12 = x-pkcs12
.p7b = x-pkcs7-certificates
.p7c = application/pkcs7-mime
.p7m = pkcs7-mime
.p7r = x-pkcs7-certreqresp
.p7s = pkcs7-signature
.pbm = image/x-portable-bitmap
.pdf = application/pdf
.pdfxml = application/vnd.adobe.pdfxml
.pdx = application/vnd.adobe.pdx
.pfx = application/x-pkcs12
.pgm = image/x-portable-graymap
.pict = image/x-pict
.pko = vnd.ms-pki.pko
.pl = text/plain
.pls = audio/x-scpls
.png = image/x-png
.pnm = image/x-portable-anymap
.pntg = image/x-macpaint
.pot = application/vnd.ms-powerpoint
.ppa = application/vnd.ms-powerpoint
.ppm = image/x-portable-pixmap
.pps = application/vnd.ms-powerpoint
.ppt = application/x-mspowerpoint
.ps = application/postscript
.pwz = application/vnd.ms-powerpoint
.py = text/x-python
.pyc = application/x-python-code
.pyo = application/x-python-code
.qcp = audio/vnd.qcelp
.qt = video/quicktime
.qtif = image/x-quicktime
.qtl = application/x-quicktimeplayer
.ra = audio/x-pn-realaudio
.ram = application/x-pn-realaudio
.ras = image/x-cmu-raster
.rdf = application/xml
.rels = application/vnd.ms-package.relationships+xml
.rgb = image/x-rgb
.roff = application/x-troff
.rqy = text/x-ms-rqy
.rtsp = application/x-rtsp
.rtx = text/richtext
.sdp = application/x-sdp
.sdv = video/sd-video
.sgi = image/x-sgi
.sgm = text/x-sgml
.sgml = text/x-sgml
.sh = application/x-sh
.shar = application/x-shar
.sit = application/x-stuffit
.slupkg-ms = application/x-ms-license
.snd = audio/basic
.so = application/octet-stream
.spl = application/futuresplash
.src = application/x-wais-source
.sst = vnd.ms-pki.certstore
.stl = vnd.ms-pki.stl
.sv4cpio = application/x-sv4cpio
.sv4crc = application/x-sv4crc
.svg 

[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Tim Golden

Tim Golden added the comment:

There seems to be a consensus that the current behaviour is undesirable,
indeed broken for any meaningful use. 

The critical argument against the current Registry approach is that it
returns unexpected (or outright incorrect) mimetypes for very standard
extensions.

The arguments against reading the Registry at all are:

* That it requires some extra level of privilege to read the appropriate
keys.

* That there is a startup cost to reading the Registry

* That it can be and is updated by arbitrary programs (typically during
installation) and therefore its values cannot be relied upon.


We have 3.5 proposals on the table:

1) Don't read the registry at all, ie revert issue4969 (this is what Ben
Hoyt is advocating) [noregistry]

2) Read the registry *before* reading the standard types (this is not
strongly advocated by anyone).

3) Read the registry but in a different way, mapping from extension to
mimetype rather than vice versa. (This is Dave Chambers' patch from
issue15207). [newregistry]

3a) Lookup as per (3) but only on demand. This eliminates any startup cost.

I've produced three output files from a simple dump of the mimetypes database. 
For the purposes of taking this  forward, we're really comparing the noregistry 
and the newregistry variants.

One key issue is what to do when the same key occurs in both sets but with a 
different value. (Examples include .avi - video/x-msvideo vs video/avi; and 
.zip - application/zip vs application/x-zip-compressed).

And the other key issue is whether the overheads (security, speed) of using the 
registry outweigh its usefulness in any case.

Could I ask those who would remove the registry use altogether to comment on 
the newregistry output (generating your own if it helps) to see whether it 
changes your views at all.

Either approach -- no-registry or new-registry -- feasible and the code churn 
is about equal. I'm unsure about compatibility issues: it's hard to see anyone 
relying on the incorrect mimetypes; but it's certainly possible to see someone 
relying on the additional (correct) mimetypes.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

I think it's important to stick to established standards for
MIME types and to make sure that Python returns the same values
on all platforms using the default settings.

Apache comes with a mime.types file which includes both the
official IANA types and many common, but unregistered types:

http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup

This can be used as reference (much like we use the X.org locale
database as reference for the locale module).

If an application wants to use the Windows registry settings instead,
that's fine, but it should not be the default if there's a difference
in output compared to the hard-coded list in mimetypes.

Note that this would probably require a redesign of the
internals of the mimetypes module. It currently provides only a
small subset as default mapping and then reads the full set from
one of the mime.types files it can find on the system.
Such a redesign would only be possible for Python 3.4, not
Python 2.7.

--
nosy: +lemburg

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17774] unable to disable -r in run_tests.py

2013-04-17 Thread Matthias Klose

New submission from Matthias Klose:

it is not possible to disable -r in run_tests.py. Other options like -u or -j 
can be overwritten, but not removing -r.

--
components: Tests
messages: 187160
nosy: doko
priority: normal
severity: normal
stage: needs patch
status: open
title: unable to disable -r in run_tests.py
type: behavior
versions: Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17774
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17724] urllib -- add_handler method refactoring for clarity

2013-04-17 Thread Max Mautner

Changes by Max Mautner max.maut...@gmail.com:


--
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17724
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17775] Error with Hello, World in 3.3.1

2013-04-17 Thread David Walker

New submission from David Walker:

I'm brand new to Python (and programming in general) and I'm reading Python 
for Dummies while trying to learn this.  I downloaded 3.3.1 and when I entered 
the command

 print Hello, World!

it would give the following error:

SyntaxError: invalid syntax
  File stdin, line 1
 print Hello, World!

Yet when I do the same thing in v 2.7.4 it works fine.  Is there something I'm 
doing wrong?  Thanks in advance

--
components: Windows
messages: 187161
nosy: walkah21
priority: normal
severity: normal
status: open
title: Error with Hello, World in 3.3.1
type: compile error
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17775
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

After a more careful look of the b85encode code I say that it's implementation 
is not optimal. For the sake of simplicity the entire volume of data is copied 
several times. This can affect the processing of a large volume of data. On 
other hand, this dumb copying can be faster then more smart processing in 
a85encode. Only benchmarks will show the truth.

Using a trick with struct.unpack() has very unpleasant side effect. It might be 
a few speed up encoding, but creates the Struct object with the size is many 
times larger than the size of the processed data. Worse, this object is cached 
and continues to consume memory. Since the size of the data most likely will be 
unique, almost every call of b85encode creates a new object. This will lead to 
memory leaks.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17775] Error with Hello, World in 3.3.1

2013-04-17 Thread Ramchandra Apte

Ramchandra Apte added the comment:

Python 3 and Python 2 have different syntax (same code won't work with both 
versions).
You would have to run print(Hello, World)
Please close this bug as invalid.

--
nosy: +Ramchandra Apte
type: compile error - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17775
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17775] Error with Hello, World in 3.3.1

2013-04-17 Thread David Walker

Changes by David Walker walka...@gmail.com:


--
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17775
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17768] _decimal: allow NUL fill character

2013-04-17 Thread Ramchandra Apte

Ramchandra Apte added the comment:

Yes.

--
nosy: +Ramchandra Apte

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17768
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17776] IDLE Internationalization

2013-04-17 Thread Damien Marié

New submission from Damien Marié:

Following the issue 17760

Internationalization should be implemented.
I propose to implement it as an optionnal settings first. And with the gettext 
library.

I'm not experienced with the idlelib module but here is a first patch, don't 
hesitate to comment it. It just add i18n to the menu for now.

--
components: IDLE
files: patch.diff
keywords: patch
messages: 187165
nosy: Damien.Marié
priority: normal
severity: normal
status: open
title: IDLE Internationalization
type: enhancement
Added file: http://bugs.python.org/file29904/patch.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17776
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9849] Argparse needs better error handling for nargs

2013-04-17 Thread Mark Lawrence

Mark Lawrence added the comment:

The first error raised is TypeError: 'str' object cannot be interpreted as an 
integer, followed by ValueError: length of metavar tuple does not match 
nargs.  Therefore the code has already been changed to reflect the title of 
this issue.  If other code changes are needed I believe that should be done in 
a new or another already existing issue.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9849
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Dave Chambers

Dave Chambers added the comment:

Enough with the bikeshedding... it's been 10 months... fix the bug.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings

2013-04-17 Thread Brian Curtin

Brian Curtin added the comment:

Just an FYI, but if it takes 10 more months to get it right, we'll do that.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15207
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >