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  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 
> 
> 
> 
> 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 
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
 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
 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,   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
 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.

"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
 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,   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  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
-- 
http:

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  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=4752820&trk=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  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 cut&paste 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.

http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>http://www.csapi.org/schema/parlayx/sms/send/v2_2/local
">254727DeliveredToNetwork


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('Reply Page')# html reply page
if not 'user' in form:
print('Who are you?')
else:
print('Hello %s!' %
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

Reply Page
Who are you?

*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 wrote:

> [ 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  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 
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 Abel  <><  Du 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  Miki Tebeka 
 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

Re: Parsing soap result

2013-04-17 Thread darnold
On Apr 17, 8:50 am, Ombongi Moraa Fe 
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 = '''\

http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>

http://www.csapi.org/schema/parlayx/sms/send/v2_2/
local">

254727
DeliveredToNetwork




'''
>>> 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 
> 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  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 versio

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  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  wrote:
> Am 17.04.2013 19:55, schrieb darnold:
>
> > On Apr 17, 8:50 am, Ombongi Moraa Fe 
> > 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 
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  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.

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>xmlns:ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local";>254727DeliveredToNetwork



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  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 wrote:
>
>> 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-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  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 

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  wrote:
> On Apr 17, 7:57 am, Bruce McGoveran  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  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  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  wrote:
> On Apr 18, 9:40 am, Mark Janssen  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  wrote:
> On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen  
> 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  wrote:

On Apr 18, 9:40 am, Mark Janssen  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  wrote:

On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen  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  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  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  wrote:
> On Tue, Apr 16, 2013 at 8:55 PM, rusi  wrote:
>> On Apr 17, 7:57 am, Bruce McGoveran  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  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
>  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  wrote:
> On Wed, Apr 17, 2013 at 5:33 PM, Ian Kelly  wrote:
>> On Wed, Apr 17, 2013 at 5:40 PM, Mark Janssen  
>> 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
 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
 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