Re: The � debate

2014-05-10 Thread Gregory Ewing

Steven D'Aprano wrote:

some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

I'm pretty sure that it isn't common to call the LHS of that assignment a 
variable.


A better way of putting it might be something in the data
model that can be assigned to.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 12:33:28 +1000, Chris Angelico wrote:

 On Sat, May 10, 2014 at 12:19 PM, Rustom Mody rustompm...@gmail.com
 wrote:
 For me, Marko's comment that variables in python are not first-class
 whereas in C they are is for me the most important distinction Ive seen
 (in a long time of seeing these discussions).


 https://en.wikipedia.org/wiki/First-class_citizen
 
 For variables in C to be considered first-class, they must, by most
 definitions, be able to be passed around as parameters and return
 values. Some definitions also require that they be able to be
 constructed at run-time. How do C variables shape up?
 
 1) Passing them as parameters. You can pass a pointer to a variable,
 which is effectively the same as passing a variable to a function. 

No it is not. It is nothing like passing a variable to a function. You 
are passing a pointer, which is itself a value. True, it is a value which 
you, the author, gives meaning as a pointer to a variable, but that need 
not be the case. It might be a pointer to a part of an array, or a 
record, or to some random address in memory, or a dangling pointer. C 
allows you to perform arithmetic on pointers, which means you can 
construct pointers to nothing in particular.

In C, pointers are first-class values, since you can:

- construct pointers at runtime;
- pass them to functions;
- return them from functions;
- assign them to variables;
- stuff them in structs or arrays.

But variables are not. You cannot create new variables, nor treat 
variables themselves as function arguments, or return them from 
functions. The closest you can do is *manually* use a pointer to a 
variable to simulate the same effect, but this is both too much and too 
little:

- too much, because you aren't limited to passing pointers 
  to a variable, you can pass pointers to anything you 
  like, or nothing at all;

- too little, because you are responsible for managing the 
  pointers, instead of having the compiler do so.

In Pascal, like C, you can't create new variables, or return them from 
functions, or embed them in records. But unlike C, you can pass them to 
functions, using a var parameter to use pass-by-reference. Algol is 
similar, except pass-by-name instead. I guess that makes Pascal variables 
second-and-a-half class values. Given:

procedure foo(var inside: integer);
  begin
{...}
  end;

begin
  foo(outside);
end.

the global variable outside is passed to foo where it effectively 
becomes the local variable inside. Notice that we don't manually have 
to concern ourselves with pointers, in fact whether Pascal uses pointers 
to implement this or not is entirely invisible to the coder using the 
feature. It could be using magic fairy dust for all we know. We simply 
write the most direct, natural code we possibly can:

foo(outside);

and the compiler does whatever magic is needed to ensure the variable 
outside, rather than the value of outside, is passed to the procedure foo.

There is nothing like that in C. You can only manually simulate it by 
passing a pointer to a variable, not by passing the variable itself. To 
argue that C pointers are pass by reference is like arguing that C has 
a garbage collector, because you can write one yourself.


 The
 callee can mutate your variable through the pointer. 2) Returning them.
 This is a lot more dodgy, owing to the dangling-pointer issue, but as
 long as you accept that the reference to a variable doesn't ensure its
 continued life, I suppose this might be acceptable. Maybe. But it's
 pushing it. 3) Constructing at run-time. Really REALLY pushing it. You
 can malloc and call that a variable, but it's not a variable any more,
 it's just a patch of memory. In fact, all this proves is that variables
 represent patches of memory, and patches of memory are first-class.

It proves that pointers are first class (well, duh!). The C compiler 
makes very little effort to ensure that pointers actually point to 
anything. Nor can you create patches of memory (I'll like an extra 
couple of terrabytes please), or return them from functions, or insert 
them in arrays.

Rather than *creating* patches of memory, malloc merely allocates it from 
pre-existing memory.


 Not liking the results here. You might just as well define that all
 Python variables must be backed by a dictionary (it's just as true as
 all C variables must be backed by memory) and then define the
 first-class-variable as a combination of a dict and a key.

Python variables aren't first-class either, but in fact we can get a bit 
closer to first-class than either C or Pascal.

Creating new variables is trivial. Since they don't need to be declared, 
you create a new variable just by assigning to it:

try:
spam
except NameError:
spam = 23


There are at least two other ways:

globals()['spam'] = 23
exec('spam = 23')


You can also delete variables:

del spam


Now this really shows first-class-ness. We 

Re: How to implement key of key in python?

2014-05-10 Thread Andrea D'Amore

On 2014-05-10 03:28:29 +, eckhle...@gmail.com said:


While it is fine for a small dataset, I need a more generic way to do so.


I don't get how the dataset size affects the generality of the solution here.


From your first message:



attr = {}
with open('test.txt','rb') as tsvin:
tsvin = csv.reader(tsvin, delimiter='\t')
for row in tsvin:
ID = row[1]


so your is solved by adding a simple
 attr[ID] = {}

after the ID assignment. It seems simple to implement and generic enough to me.


unfortunately none of them illustrates how to store the values and 
access them later.


You access the stored value by using the variable name that holds it, 
but here you should probabily make more clear what your actual issue is.




Moreover, they bring some new terms, e.g. combined, [], etc.


The [] syntax is used in Python for lists.

The term combined hasn't a specific pythonic meaning there and is 
just used as a meaningful variable name as the author is combining, 
i.e. adding, numerical values.



--
Andrea

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


Re: The � debate

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that assignment a
 variable.


 A better way of putting it might be something in the data
 model that can be assigned to.

https://en.wikipedia.org/wiki/Assignment_(computer_science)

Go ahead, start an edit war at that page over its use of variable.
:) Right there it talks about copying values into variables. So if
Python has no variables, then either that article is inappropriate, or
Python has no assignment either.

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


Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-10 Thread wxjmfauth
Le samedi 10 mai 2014 06:22:00 UTC+2, Rustom Mody a écrit :
 On Saturday, May 10, 2014 1:21:04 AM UTC+5:30, scott...@gmail.com wrote:
 
  Hi,
 
  
 
  
 
  
 
   here is a snippet of code that opens a file (fn contains the path\name) 
  and first tried to replace all endash, emdash etc characters with simple 
  dash characters, before doing a search.
 
  
 
But the replaces are not having any effect. Obviously a syntax 
  problemwwhat silly thing am I doing wrong?
 
 
 
 If you are using MS-Word use that, not python.
 
 
 
 Yeah it is possible to script MS with something like this
 
 http://timgolden.me.uk/pywin32-docs/
 
 [no experience myself!]
 
 but its probably not worth the headache for such a simple job.
 
 
 
 The VBA (or whatever is the modern equivalent) will be about as short and 
 simple
 
 as your attempted python and making it work will be far easier.
 
 
 
 I way I used to do it with Windows-98 Word. 
 
 Start a macro
 
 Do a simple single search and replace by hand
 
 Close the macro
 
 Edit the macro (VBA version)
 
 Replace the single search-n-replace with all the many you require

=

That's a wise reommendation.

Anyway, as Python may fail as soon as one uses an
EM DASH or an EM DASH, I think it's not worth the
effort to spend to much time with it.

LibreOffice could be a solution.

jmf


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


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 4:15 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Sat, 10 May 2014 12:33:28 +1000, Chris Angelico wrote:
 1) Passing them as parameters. You can pass a pointer to a variable,
 which is effectively the same as passing a variable to a function.

 No it is not. It is nothing like passing a variable to a function. You
 are passing a pointer, which is itself a value. True, it is a value which
 you, the author, gives meaning as a pointer to a variable, but that need
 not be the case. It might be a pointer to a part of an array, or a
 record, or to some random address in memory, or a dangling pointer. C
 allows you to perform arithmetic on pointers, which means you can
 construct pointers to nothing in particular.

I think at this point it's arguable, in that you can get so close to
passing a variable to a function that it doesn't really matter about
the distinction. But as I explained further down, it really just shows
that patch of memory can be passed around, and that a variable can
be backed by such a patch of memory.

 Rather than *creating* patches of memory, malloc merely allocates it from
 pre-existing memory.

I disagree. On a modern system with memory management, malloc can grab
memory from the system, thus making it available to your process.
Sure, physical memory will normally have to have been installed in the
system, but conceptually you could have a malloc function that
actually freezes the program, asks the user to build a new computer
and turn it on, connects to a new service on that computer, and
allocates memory from there. As far as your program's concerned,
malloc actually does (attempt to) give you more room than you had.

 Python variables aren't first-class either, but in fact we can get a bit
 closer to first-class than either C or Pascal.

 Creating new variables is trivial. Since they don't need to be declared,
 you create a new variable just by assigning to it:

 try:
 spam
 except NameError:
 spam = 23

No no no, this is really creating them at compile time. If you do this
inside a function, the name has to be created as a local name before
the function begins execution.

 There are at least two other ways:

 globals()['spam'] = 23
 exec('spam = 23')

With exec, you can do anything at run time. Does that mean that, in
languages with an exec action, absolutely everything is first-class?
I'm not sure that that counts. Maybe I'm wrong.

Subscript-assigning to globals() is actually creating new
(module-level) variables, though. And if Python allowed you to assign
to locals() inside a function, then I would accept that local function
variables can be created and destroyed at run time, but you can't, so
local variables aren't first-class.

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


Re: The � debate

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 17:10:29 +1000, Chris Angelico wrote:

 On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
 greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that
 assignment a variable.


 A better way of putting it might be something in the data model that
 can be assigned to.
 
 https://en.wikipedia.org/wiki/Assignment_(computer_science)
 
 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

Python assignment doesn't copy values.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The “does Python have variables?” debate

2014-05-10 Thread Larry Hudson

On 05/09/2014 06:11 PM, Steven D'Aprano wrote:

On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote:


On 5/7/14 8:27 PM, Steven D'Aprano wrote:

snip

  Why are new Python coders 'always' confused by this question of
variable (name value) vs. {name: object} model of Python?


Always? I don't think anyone, not even Ben, claims that new Python
coders are always confused about Python's variable semantics. That
would be a straw man, easy to disprove by just finding a single person
who wasn't confused. Perhaps someone who had never learned C and didn't
know C variable semantics?



Well, here is that one person.   ;-)

I'm an entirely self-taught amateur/hobbyist programmer, coming to Python from a C background. 
Very early in my reading of books/tutorials on Python I learned that Python variables are 
different, and how they are different from C variables.  Essentially I said, Okay, they're 
different.  What's next?  There was no confusion at all.  All I had to do was accept that they 
_are_ different.  (BTW, I'm now quite hooked on Python -- and still learning it.)



  The reason I suggest is that the person has a preconceived idea of
what 'variable' means, and they then attempt to apply their conception
of variable on to Python in some way ending in a surprise.


That's the problem as some of us see it.



As I said above, not a problem.  I already accepted the fact that all programming languages are 
different -- often with similarities, but more often quite different, especially in the details. 
 So when programming in C I think in C-style variables, in Python I think in Python-style 
variables.  And uv course, I nefer make mmistakes...  Yeah, right!;-)





  We need a way to speak about Pythons name object model to avoid
this confusion.


And that would be the name binding part.



This is something I absolutely disagree with.  I still think it's only necessary to teach that 
variables in different languages are handled differently.  Insisting on a different name is NOT 
helpful.  And insisting that Python does not have variables is ludicrous!


 -=- Larry -=-

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


Re: Values and objects

2014-05-10 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Sat, May 10, 2014 at 8:34 AM, Marko Rauhamaa ma...@pacujo.net wrote:
 Right, Python's variables aren't like variables in C. Rather,
 Python's variables are like CPU registers. They cannot hold typed or
 structured objects and you can't pass references to them.

 Are you thinking that a Python variable is neither more nor less than
 what CPython implements them as?

I was just being more Catholic than the Pope.

To me, a variable is a variable is a variable.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


dynamic form application

2014-05-10 Thread edd . cowan
hello guys.

i tryng to create a form builder application with a database backend.
like wufoo.com

im stuck,how do i use jquery to create dynamic forms,and how is the database 
designed for the actual forms and the data gathered using those forms i'd like 
to use rdbms preferebly postgres.

regards
eddy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 5:48 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

 Python assignment doesn't copy values.

So either the article is wrong, or Python doesn't have assignment. Which is it?

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


Re: Values and objects

2014-05-10 Thread Jussi Piitulainen
Marko Rauhamaa writes:

 To me, a variable is a variable is a variable.

That works only in Python.

Elsewhere, the sentence would be interpreted either as a variable is
True or as a variable is False depending on whether a distinction
without a difference is deemed helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
 greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that assignment a
 variable.

 [...]
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 [...]

 So if Python has no variables, then either that article is
 inappropriate, or Python has no assignment either.

Many complaints against Python's variables are really comments on
Python's object model.

Steven's example points out a different angle: many complaints against
Python's variables are really comments on Python's assignment statement
(including argument passing).

In Python,

   x   is a variable, a memory slot that can be assigned to,
   a[3]is a list element, a memory slot that can be assigned to,
   d['y']  is a dict entry, a memory slot that can be assigned to,
   o.f is a field, a memory slot that can be assigned to

Now, Python (together with a host of other programming languages) lacks
a way to pass memory slots by reference (although the list/dict+key
comes close). However, the fact that you can't get a reference to a
variable/list element/dict entry/field doesn't mean Python doesn't have
variables/list elements/dict entries/fields.


Marko

PS I have mentioned before that Python 3 *does* allow you to pass a
reference to any LHS by constructing an ad-hoc accessor object:

x, y = 2, 3
class X:
def get(self): return x
def set(self, v): nonlocal x; x = v
class Y:
def get(self): return y
def set(self, v): nonlocal y; y = v
swap(X(), Y())
print(x, y)
= 3, 2

Such ad-hoc accessor classes are required for nonglobal variables only.
Generic accessor classes can be written for global variables, list
elements, dict entries and fields.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to implement key of key in python?

2014-05-10 Thread Peter Otten
eckhle...@gmail.com wrote:

 On Saturday, May 10, 2014 10:30:06 AM UTC+8, MRAB wrote:
 On 2014-05-10 02:22, I wrote:
 
  I'm migrating from Perl to Python and unable to identify the equivalent
  of key of key concept. The following codes run well,
 
  import csv
 
  attr = {}
 
  with open('test.txt','rb') as tsvin:
 
   tsvin = csv.reader(tsvin, delimiter='\t')
 
   for row in tsvin:
 
   ID = row[1]
 
  until:
 
   attr[ID]['adm3'] = row[2]
 
  I then try:
 
   attr[ID].adm3 = row[2]
 
  still doesn't work. Some posts suggest using module dict but some do
  not. I'm a bit confused now. Any suggestions?
 
 Python doesn't have Perl's autovivication feature. If you want the
 
 value to be a dict then you need to create that dict first:
 
 attr[ID] = {}
 
 attr[ID]['adm3'] = row[2]

 You could also have a look at the 'defaultdict' class in the
 
 'collections' module.
 
 I identify the information below:
 s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
 d = defaultdict(list)
 for k, v in s:
   d[k].append(v)
 
 While it is fine for a small dataset, I need a more generic way to do so.
 Indeed the test.txt in my example contains more columns of attributes
 like:
 
 ID address age gender phone-number race education ...
 ABC123 Ohio, USA 18 F 800-123-456 european university
 ACC499 London 33 M 800-111-400 african university
 ...
 
 so later I can retrieve the information in python by:
 
 attr['ABC123'].address (containing 'Ohio, USA')
 attr['ABC123'].race (containing 'european')
 attr['ACC499'].age (containing '33')

Using a csv.DictReader comes close with minimal effort:

# write demo data to make the example self-contained
with open(tmp.csv, w) as f:
f.write(\
ID,address,age,gender,phone-number,race,education
ABC123,Ohio, USA,18,F,800-123-456,european,university
ACC499,London,33,M,800-111-400,african,university
)

import csv
import pprint

with open(tmp.csv) as f:
attr = {row[ID]: row for row in csv.DictReader(f)}

pprint.pprint(attr)

print(attr[ACC499][age])

The dict comprehension

attr = {row[ID]: row for row in csv.DictReader(f)}

is a shortcut for

attr = {}
for row in csv.DictReader(f):
attr[row[ID]] = row

If you insist on attribute access (row.age instead of row[age]) you can 
use a namedtuple. This is a bit more involved:

import csv
import pprint
from collections import namedtuple

with open(tmp.csv) as f:
rows = csv.reader(f)
header = next(rows)

# make sure column names are valid Python identifiers
header = [column.replace(-, _) for column in header]

RowType = namedtuple(RowType, header)
key_index = header.index(ID)
attr = {row[key_index]: RowType(*row) for row in rows}

pprint.pprint(attr)

print(attr[ABC123].race)

 The following links mention something similar,

Too many, so I checked none of them ;)

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


Re: The � debate

2014-05-10 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Sat, May 10, 2014 at 5:48 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

 Python assignment doesn't copy values.

 So either the article is wrong, or Python doesn't have assignment.
 Which is it?

You can understand copying more liberally:

   assignment   -- 0-level copy
   shallow copy -- 1-level copy
   deep copy-- infinite-level copy

Real programs occasionally need 2-level or n-level copies.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-10 Thread Tim Golden

On 10/05/2014 08:11, wxjmfa...@gmail.com wrote:

Anyway, as Python may fail as soon as one uses an
EM DASH or an EM DASH, I think it's not worth the
effort to spend to much time with it.


Nope -- seems all right to me. (Hopefully helping the OP out as well as 
rebutting a rather foolish assertion).


code
#!python3.4
import win32com.client
import unicodedata

word = win32com.client.gencache.EnsureDispatch(Word.Application)
try:
doc1 = word.Documents.Add()
doc1.Range().Text += Hello \u2014 World
doc1.SaveAs(rc:\temp\em_dash.docx)
doc1.Close()

doc2 = win32com.client.GetObject(rc:\temp\em_dash.docx)
for uchar in doc2.Range().Text.strip():
print(unicodedata.name(uchar))

finally:
word.Quit()

/code

TJG
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 17:21:56 +1000, Chris Angelico wrote:

 On Sat, May 10, 2014 at 4:15 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 On Sat, 10 May 2014 12:33:28 +1000, Chris Angelico wrote:
 1) Passing them as parameters. You can pass a pointer to a variable,
 which is effectively the same as passing a variable to a function.

 No it is not. It is nothing like passing a variable to a function. You
 are passing a pointer, which is itself a value. True, it is a value
 which you, the author, gives meaning as a pointer to a variable, but
 that need not be the case. It might be a pointer to a part of an array,
 or a record, or to some random address in memory, or a dangling
 pointer. C allows you to perform arithmetic on pointers, which means
 you can construct pointers to nothing in particular.
 
 I think at this point it's arguable, in that you can get so close to
 passing a variable to a function that it doesn't really matter about
 the distinction. But as I explained further down, it really just shows
 that patch of memory can be passed around, and that a variable can be
 backed by such a patch of memory.

No offence Chris, but I think this demonstrates that learning C causes 
brain damage and prevents clear logical thinking :-P

You're not passing a variable to a function. You're passing a pointer, 
which is itself a first-class value. It could be a pointer to ANYTHING, 
or NOTHING at all -- C doesn't even promise to ensure that it is a valid 
pointer, although more modern languages may. There's certainly no 
guarantee that it's a pointer to a variable. And you cannot create new 
variables -- C only allows variables to be created at compile time.

The question is not, Can I implement some aspects of first-class 
behaviour for variables by hand? The question is, Are variables treated 
as first class values in C?

If you asked, Does Pascal have an exponentiation or power operator?, 
and I answered Sure it does! If you want to calculate x squared, you 
just write x*x, if you want x cubed, write x*x*x, and if you want x to 
the power of twelve, x*x*x*x*x*x*x*x*x*x*x*x you would rightfully slap 
me with a halibut. Being able to manually perform repeated multiplication 
is not the same as having the language support exponentiation. To say 
nothing of fractional exponents. How about x to the power of one third?

Being able to manually pass pointers to variables about is not the same 
as having first class variables. It fails on the very first hurdle, Are 
variables treated the same as other values?

How do I pass an int to a function? func(some_int)

How do I pass a double to a function? func(some_double)

How do I pass a bool to a function? func(some_bool)

How do I pass a variable to a function? ptr = some_variable; func(ptr)

Does that look the same to you? The fact that you can do it at all is not 
sufficient to make it first class. It just makes it a work-around for the 
lack of first class variables in the language.

Personally, I don't imagine that there ever could be a language where 
variables were first class values *exactly* the same as ints, strings, 
floats etc. Otherwise, how could you tell the difference between a 
function which operated on the variable itself, and one which operated on 
the value contained by the value? The best you can do is for variables to 
be second class -- you can do these things to them, but you need 
special syntax or declarations to tell the compiler you're operating on 
the variable rather than the variable's value. E.g. Pascal and Algol have 
syntax for instructing the compiler when to pass a variable as a value, 
and when to pass the value. C gives you nothing.

I would say that C variables are *third class*. There's no compiler 
support for variables-as-values at all, but you can manually fake it a 
bit by using pointers. There is no way to tell whether the pointer 
actually points to a variable, and since arrays aren't first class 
neither are pointer-to-arrays.

Algol and Pascal are *second class*, since the compiler does allow you to 
pass variables as arguments (var parameters in Pascal, I forget what they 
are called in Algol). Likewise, Python let's you create new variables at 
runtime, or delete them, but you can't pass them around. But still, 
you're quite limited in what the language does for you, compared to what 
you have to do yourself:

x = 23
function(x, globals())  # See, I can pass a variable! Not.


 Rather than *creating* patches of memory, malloc merely allocates it
 from pre-existing memory.
 
 I disagree. On a modern system with memory management, malloc can grab
 memory from the system, thus making it available to your process. Sure,
 physical memory will normally have to have been installed in the system,
 but conceptually you could have a malloc function that actually freezes
 the program, asks the user to build a new computer and turn it on,
 connects to a new service on that computer, and allocates memory from
 there. 

Re: The � debate

2014-05-10 Thread Rustom Mody
On Saturday, May 10, 2014 1:18:27 PM UTC+5:30, Steven D'Aprano wrote:
 Python assignment doesn't copy values.

Maybe our values differ wink?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 7:09 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Sat, 10 May 2014 17:21:56 +1000, Chris Angelico wrote:

 No offence Chris, but I think this demonstrates that learning C causes
 brain damage and prevents clear logical thinking :-P

 You're not passing a variable to a function. You're passing a pointer,
 which is itself a first-class value. It could be a pointer to ANYTHING,
 or NOTHING at all -- C doesn't even promise to ensure that it is a valid
 pointer, although more modern languages may. There's certainly no
 guarantee that it's a pointer to a variable. And you cannot create new
 variables -- C only allows variables to be created at compile time.

 The question is not, Can I implement some aspects of first-class
 behaviour for variables by hand? The question is, Are variables treated
 as first class values in C?

Ehh... good point. I admit my brain damage - which, I have to say, has
earned me a good portion of my life's salaries, so it's not useless :)
Okay. So variables are not first-class in C. I still think memory
blocks are pretty much first class, though; you can declare them at
compile time (usually as an array of char or pointers) or at run time
(with malloc or equivalent), and they can be passed to functions,
returned from functions, etc. The only limitation is that a generic
memory block doesn't maintain its size, so you can't distinguish
between a char[10] and a char[1024].

 Being able to manually pass pointers to variables about is not the same
 as having first class variables. It fails on the very first hurdle, Are
 variables treated the same as other values?

 How do I pass an int to a function? func(some_int)

 How do I pass a double to a function? func(some_double)

 How do I pass a bool to a function? func(some_bool)

 How do I pass a variable to a function? ptr = some_variable; func(ptr)

 Does that look the same to you? The fact that you can do it at all is not
 sufficient to make it first class. It just makes it a work-around for the
 lack of first class variables in the language.

You can simply say func(some_variable), but yes, there is that
difference. (This is how out parameters usually look in C. You stick
ampersands in front of things.) And that's still passing memory blocks
around, not variables.

 Rather than *creating* patches of memory, malloc merely allocates it
 from pre-existing memory.

 I disagree. On a modern system with memory management, malloc can grab
 memory from the system, thus making it available to your process. Sure,
 physical memory will normally have to have been installed in the system,
 but conceptually you could have a malloc function that actually freezes
 the program, asks the user to build a new computer and turn it on,
 connects to a new service on that computer, and allocates memory from
 there. As far as your program's concerned, malloc actually does (attempt
 to) give you more room than you had.

 Ha, well I guess you got me there. Perhaps a less over the top example is
 that you're running in a VM, and malloc can request more information from
 the host (which presumably has unlimited memory). Still impractical, but
 theoretically possible.

Yeah. Completely impractical, but so is Post-It Note Python where
everything's done with physical strings and sheets of paper. Thought
experiments don't have to be performant :)

 Nevertheless, blocks of memory are not *first class* because you don't
 handle blocks of memory like other values. To make a new int variable,
 you declare it: int foo. To make a new block of memory, there is no
 declaration block foo. Rather, you call malloc() at runtime. And it
 might fail. int foo can never fail.

As I mentioned above, you can make a new block of memory with char
foo[1234]. And that's where a lot of buffer overruns come from,
because someone thinks 1234 is *heaps* of space... but sometimes you
really can know in advance how long something can be. (Maybe you're
about to ask a file to give you the next 1233 bytes of content.) In
this form, it's as safe as int foo - that is to say, safe unless
your stack overflows, in which case all bets are off anyway.

 Python variables aren't first-class either, but in fact we can get a
 bit closer to first-class than either C or Pascal.

 Creating new variables is trivial. Since they don't need to be
 declared, you create a new variable just by assigning to it:

 try:
 spam
 except NameError:
 spam = 23

 No no no, this is really creating them at compile time.

 It certainly isn't. Here's a slightly different demonstration of the same
 principle, this time inside a function to prove that there's nothing
 special about the global namespace:


 py def demo():
 ... print('spam' in locals())
 ... spam = 23
 ... print('spam' in locals())
 ...
 py demo()
 False
 True

Tell me, what may this function do in a compliant Python?

def demo():
ret = spam
spam = 23
return ret

In CPython, that'll raise 

Re: The � debate

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 11:18:59 +0300, Marko Rauhamaa wrote:

 In Python,
 
x   is a variable, a memory slot that can be assigned to,


If your intention was to prove Ben Finney right, then you've done a 
masterful job of it. Python variables ARE NOT MEMORY SLOTS.

(Not even local variables, since that's an implementation detail which 
the language takes pains to hide from the caller. The abstraction leaks a 
bit, but not much.)



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


xmltodict - TypeError: list indices must be integers, not str

2014-05-10 Thread flebber
I am using xmltodict.

This is how I have accessed and loaded my file.

import xmltodict
document = open(/home/sayth/Scripts/va_benefits/20140508GOSF0.xml, r)
read_doc = document.read()
xml_doc = xmltodict.parse(read_doc)

The start of the file I am trying to get data out of is.

meeting id=35483 barriertrial=0 venue=Gosford date=2014-05-08T00:00:00 
gearchanges=-1 stewardsreport=-1 gearlist=-1 racebook=0 
postracestewards=0 meetingtype=TAB rail=True weather=Fine   
trackcondition=Dead   nomsdeadline=2014-05-02T11:00:00 
weightsdeadline=2014-05-05T16:00:00 acceptdeadline=2014-05-06T09:00:00 
jockeydeadline=2014-05-06T12:00:00
  club abbrevname=Gosford Race Club code=49 associationclass=2 
website=http://; /
  race id=185273 number=1 nomnumber=7 division=0 name=GOSFORD ROTARY 
MAIDEN HANDICAP mediumname=MDN shortname=MDN stage=Acceptances 
distance=1600 minweight=55 raisedweight=0 class=MDNage=~   
   grade=0 weightcondition=HCPtrophy=0 owner=0 trainer=0 
jockey=0 strapper=0 totalprize=22000 first=12250 second=4250 
third=2100 fourth=1000 fifth=525 time=2014-05-08T12:30:00 
bonustype=BX02   nomsfee=0 acceptfee=0 trackcondition=   
timingmethod=   fastesttime=   sectionaltime=   
formavailable=0 racebookprize=Of $22000. First $12250, second $4250, third 
$2100, fourth $1000, fifth $525, sixth $375, seventh $375, eighth $375, ninth 
$375, tenth $375
condition line=1

So thought I had it figured. Can access the elements of meeting and the 
elements of club such as by doing this.

In [5]: xml_doc['meeting']['club']['@abbrevname']
Out[5]: u'Gosford Race Club'

However whenever I try and access race in the same manner I get errors.

In [11]: xml_doc['meeting']['club']['race']['@id']
---
KeyError  Traceback (most recent call last)
ipython-input-11-cce362d7e6fc in module()
 1 xml_doc['meeting']['club']['race']['@id']

KeyError: 'race'

In [12]: xml_doc['meeting']['race']['@id']
---
TypeError Traceback (most recent call last)
ipython-input-12-c304e2b8f9be in module()
 1 xml_doc['meeting']['race']['@id']

TypeError: list indices must be integers, not str

why is accessing race @id any different to the access of club @abbrevname and 
how do I get it for race?

Thanks

Sayth
-- 
https://mail.python.org/mailman/listinfo/python-list


Error while calling round() from future.builtins

2014-05-10 Thread Preethi
Hi,

I am new to python. I am getting an error AttributeError: type object 
'Decimal' has no attribute 'from_float' when I run the following in python 
prompt:

 from future.builtins import int, round
 int(round(5))
Traceback (most recent call last):
  File stdin, line 1, in module
  File 
/usr/lib/python2.6/site-packages/future/builtins/backports/newround.py, line 
32, in newround
d = Decimal.from_float(number).quantize(exponent,
AttributeError: type object 'Decimal' has no attribute 'from_float'

I am running this on Centos 6.5 which has python version 2.6.6
This is the output of 'pip freeze':

Django==1.6.4
Mezzanine==3.1.4
Pillow==2.4.0
South==0.8.4
bleach==1.4
django-appconf==0.6
django-compressor==1.3
filebrowser-safe==0.3.3
future==0.9.0
grappelli-safe==0.3.10
html5lib==0.999
iniparse==0.3.1
oauthlib==0.6.1
psycopg2==2.5.2
pycurl==7.19.0
pygpgme==0.1
pytz==2014.2
requests==2.2.1
requests-oauthlib==0.4.0
six==1.6.1
tzlocal==1.0
urlgrabber==3.9.1
yum-metadata-parser==1.1.2

This is the order in which I installed the above packages. (The box initially 
had python 2.6.6 installed)

yum install gcc python python-setuptools python-devel
yum install libjpeg-turbo-devel
python get-pip.py
pip install -U pip
pip install South django-compressor
pip install mezzanine
yum install postgresql93-server.x86_64
yum install postgresql-devel
sudo pip install psycopg2

What am I missing? Any help is greatly appreciated.

Thanks,
Preethi
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error while calling round() from future.builtins

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 04:39:05 -0700, Preethi wrote:

 Hi,
 
 I am new to python. I am getting an error AttributeError: type object
 'Decimal' has no attribute 'from_float' when I run the following in
 python prompt:
 
 from future.builtins import int, round 

I get an error when I try that:


py from future.builtins import int, round
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named future.builtins


Perhaps you are using the third-party library future? 

https://pypi.python.org/pypi/future

If so, then I believe the library is buggy and you should report it to 
the Centos package maintainer. You might also manually install a more 
recent version of future.

Decimal.from_float was only added in 2.7, it is not available in 2.6.

https://docs.python.org/2/library/decimal.html#decimal.Decimal.from_float




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xmltodict - TypeError: list indices must be integers, not str

2014-05-10 Thread Peter Otten
flebber wrote:

 I am using xmltodict.
 
 This is how I have accessed and loaded my file.
 
 import xmltodict
 document = open(/home/sayth/Scripts/va_benefits/20140508GOSF0.xml, r)
 read_doc = document.read()
 xml_doc = xmltodict.parse(read_doc)
 
 The start of the file I am trying to get data out of is.
 
 meeting id=35483 barriertrial=0 venue=Gosford
 date=2014-05-08T00:00:00 gearchanges=-1 stewardsreport=-1
 gearlist=-1 racebook=0 postracestewards=0 meetingtype=TAB
 rail=True weather=Fine   trackcondition=Dead  
 nomsdeadline=2014-05-02T11:00:00 weightsdeadline=2014-05-05T16:00:00
 acceptdeadline=2014-05-06T09:00:00 jockeydeadline=2014-05-06T12:00:00
   club abbrevname=Gosford Race Club code=49 associationclass=2
   website=http://; /
   race id=185273 number=1 nomnumber=7 division=0 name=GOSFORD
   ROTARY MAIDEN HANDICAP mediumname=MDN shortname=MDN
   stage=Acceptances distance=1600 minweight=55 raisedweight=0
   class=MDNage=~  grade=0 weightcondition=HCP  
trophy=0 owner=0 trainer=0 jockey=0 strapper=0
   totalprize=22000 first=12250 second=4250 third=2100
   fourth=1000 fifth=525 time=2014-05-08T12:30:00 bonustype=BX02
 nomsfee=0 acceptfee=0 trackcondition=   timingmethod= 
fastesttime=   sectionaltime=  
   formavailable=0 racebookprize=Of $22000. First $12250, second $4250,
   third $2100, fourth $1000, fifth $525, sixth $375, seventh $375, eighth
   $375, ninth $375, tenth $375
 condition line=1
 
 So thought I had it figured. Can access the elements of meeting and the
 elements of club such as by doing this.
 
 In [5]: xml_doc['meeting']['club']['@abbrevname']
 Out[5]: u'Gosford Race Club'
 
 However whenever I try and access race in the same manner I get errors.
 
 In [11]: xml_doc['meeting']['club']['race']['@id']
 
---
 KeyError  Traceback (most recent call
 last) ipython-input-11-cce362d7e6fc in module()
  1 xml_doc['meeting']['club']['race']['@id']
 
 KeyError: 'race'
 
 In [12]: xml_doc['meeting']['race']['@id']
 
---
 TypeError Traceback (most recent call
 last) ipython-input-12-c304e2b8f9be in module()
  1 xml_doc['meeting']['race']['@id']
 
 TypeError: list indices must be integers, not str
 
 why is accessing race @id any different to the access of club @abbrevname
 and how do I get it for race?

If I were to guess: there are multiple races per meeting, xmltodict puts 
them into a list under the race key, and you have to pick one:

 doc = xmltodict.parse(\
... meeting
...race id=first race.../race
...race id=second race.../race
... /meeting
... )
 type(doc[meeting][race])
class 'list'
 doc[meeting][race][0][@id]
'first race'
 doc[meeting][race][1][@id]
 
   
'second race'   

   

So 

xml_doc['meeting']['race'][0]['@id']

or

for race in xml_doc[meeting][race]:
   print(race[@id])

might work for you.

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


Fortran (Was: The does Python have variables? debate)

2014-05-10 Thread Roy Smith
In article mailman.9805.1399597367.18130.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On 08 May 2014 16:04:51 GMT, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info declaimed the following:
 
 Personally, I think that trying to be general and talk about many other 
 languages is a failing strategy. Better to be concrete: C, Pascal, 
 Algol, Fortran, VB (I think) are good examples of the value in a box at 
 a fixed location model. Of those, Algol, Pascal and Fortran are either 
 obsolete or legacy, and C is by far the most well-known by people here. 
 (For some reason, few people seem to migrate from VB to Python.) Hence, 
 C-like.
 
 
   Obsolete and Legacy? Fortran still receives regular standards updates
 (currently 2008, with the next revision due in 2015).


Ars Technica article a couple of days ago, about Fortran, and what is 
likely to replace it:

http://tinyurl.com/mr54p96
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error while calling round() from future.builtins

2014-05-10 Thread Jerry Hill
On Sat, May 10, 2014 at 7:39 AM, Preethi preethid...@gmail.com wrote:
 future==0.9.0

It looks like that library is out of date.  The current version looks
to be 0.12.0, and it also looks like this bug was fixed in the 0.12.0
release.  I'd upgrade your version if at all possible.

-- 
Jerry
-- 
https://mail.python.org/mailman/listinfo/python-list


How can this assert() ever trigger?

2014-05-10 Thread Albert van der Horst
I have the following code for calculating the determinant of
a matrix. It works inasfar that it gives the same result as an
octave program on a same matrix.

/ 

def determinant( mat ):
''' Return the determinant of the n by n matrix mat
i row j column
Destroys mat ! '''
#print getting determinat of, mat
n=len(mat)
nom = 1.
if n == 1: return mat[0][0]
lastr = mat.pop()
jx=-1
for j in xrange(n):
   if lastr[j]:
   jx=j
   break
if jx==-1: return 0.
result = lastr[jx]
assert(result0.)
# Make column jx zero by subtracting a multiple of the last row.
for i in xrange(n-1):
pivot = mat[i][jx]
if 0. == pivot: continue
assert(result0.)
nom *= result   # Compenstate for multiplying a row.
for j in xrange(n):
mat[i][j] *= result
for j in xrange(n):
mat[i][j] -= pivot*lastr[j]
# Remove colunm jx
for i in xrange(n-1):
   x= mat[i].pop(jx)
   assert( x==0 )

if (n-1+jx)%20: result = -result
det = determinant( mat )
assert(nom0.)
return result*det/nom

/-

Now on some matrices the assert triggers, meaning that nom is zero.
How can that ever happen? mon start out as 1. and gets multiplied
with a number that is asserted to be not zero.

Any hints appreciated.

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: How can this assert() ever trigger?

2014-05-10 Thread Peter Otten
Albert van der Horst wrote:

 I have the following code for calculating the determinant of
 a matrix. It works inasfar that it gives the same result as an
 octave program on a same matrix.
 
 / 
 
 def determinant( mat ):
 ''' Return the determinant of the n by n matrix mat
 i row j column
 Destroys mat ! '''
 #print getting determinat of, mat
 n=len(mat)
 nom = 1.
 if n == 1: return mat[0][0]
 lastr = mat.pop()
 jx=-1
 for j in xrange(n):
if lastr[j]:
jx=j
break
 if jx==-1: return 0.
 result = lastr[jx]
 assert(result0.)
 # Make column jx zero by subtracting a multiple of the last row.
 for i in xrange(n-1):
 pivot = mat[i][jx]
 if 0. == pivot: continue
 assert(result0.)
 nom *= result   # Compenstate for multiplying a row.
 for j in xrange(n):
 mat[i][j] *= result
 for j in xrange(n):
 mat[i][j] -= pivot*lastr[j]
 # Remove colunm jx
 for i in xrange(n-1):
x= mat[i].pop(jx)
assert( x==0 )
 
 if (n-1+jx)%20: result = -result
 det = determinant( mat )
 assert(nom0.)
 return result*det/nom
 
 /-
 
 Now on some matrices the assert triggers, meaning that nom is zero.
 How can that ever happen? mon start out as 1. and gets multiplied
 with a number that is asserted to be not zero.
 
 Any hints appreciated.

Floating point precision is limited:

 x = 1.0
 for i in itertools.count():
... x *= .1
... assert x
... 
Traceback (most recent call last):
  File stdin, line 3, in module
AssertionError
 i
323


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


Re: How can this assert() ever trigger?

2014-05-10 Thread Ethan Furman

What happens if you run the same matrix through Octave?  By any chance, is nom 
just really, really small?

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: How can this assert() ever trigger?

2014-05-10 Thread Gary Herron

On 05/10/2014 08:24 AM, Albert van der Horst wrote:

I have the following code for calculating the determinant of
a matrix. It works inasfar that it gives the same result as an
octave program on a same matrix.

/ 

def determinant( mat ):
 ''' Return the determinant of the n by n matrix mat
 i row j column
 Destroys mat ! '''
 #print getting determinat of, mat
 n=len(mat)
 nom = 1.
 if n == 1: return mat[0][0]
 lastr = mat.pop()
 jx=-1
 for j in xrange(n):
if lastr[j]:
jx=j
break
 if jx==-1: return 0.
 result = lastr[jx]
 assert(result0.)
 # Make column jx zero by subtracting a multiple of the last row.
 for i in xrange(n-1):
 pivot = mat[i][jx]
 if 0. == pivot: continue
 assert(result0.)
 nom *= result   # Compenstate for multiplying a row.
 for j in xrange(n):
 mat[i][j] *= result
 for j in xrange(n):
 mat[i][j] -= pivot*lastr[j]
 # Remove colunm jx
 for i in xrange(n-1):
x= mat[i].pop(jx)
assert( x==0 )

 if (n-1+jx)%20: result = -result
 det = determinant( mat )
 assert(nom0.)
 return result*det/nom

/-

Now on some matrices the assert triggers, meaning that nom is zero.
How can that ever happen? mon start out as 1. and gets multiplied
with a number that is asserted to be not zero.


Easily due to *underflow* precision trouble.  Your result may never be 
zero, but it can be very small.  Take the product of many of such tiny 
values, and the result can be less then the smallest value representable 
by a float, at which point it becomes zero.


To see this clearly, try this Python code:
 a = 1.0
 while a  0:
...   a = a*1.0e-50
...   print(a)
...
1e-50
1e-100
1e-150
1e-200
1e-250
1e-300
0.0

Gary Herron







Any hints appreciated.

Groetjes Albert


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


Re: How can this assert() ever trigger?

2014-05-10 Thread Alain Ketterlin
alb...@spenarnc.xs4all.nl (Albert van der Horst) writes:

[...]
 Now on some matrices the assert triggers, meaning that nom is zero.
 How can that ever happen? mon start out as 1. and gets multiplied

[several times]

 with a number that is asserted to be not zero.

Finite precision. Try: 1.*1e-162*1e-162. Equals zero.

-- Alain.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can this assert() ever trigger?

2014-05-10 Thread Albert van der Horst
In article 874n0xvd85@dpt-info.u-strasbg.fr,
Alain Ketterlin  al...@dpt-info.u-strasbg.fr wrote:
alb...@spenarnc.xs4all.nl (Albert van der Horst) writes:

[...]
 Now on some matrices the assert triggers, meaning that nom is zero.
 How can that ever happen? mon start out as 1. and gets multiplied

[several times]

 with a number that is asserted to be not zero.

Finite precision. Try: 1.*1e-162*1e-162. Equals zero.

-- Alain.

Thanks you Alan and all others to point this out.
That was indeed the problem. Somehow I expected that floating
underflow would raise an exception, so I had a blind spot there.

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-10 Thread Simon Evans
I am new to Python, but my main interest is to use it to Webscrape. I have 
downloaded Beautiful Soup, and have followed the instruction in the 'Getting 
Started with Beautiful Soup' book, but my Python installations keep returning 
errors, so I can't get started. I have unzipped Beautiful Soup to a folder of 
the same name on my C drive, in accordance with the first two steps of page 12 
of the aforementioned publication, but proceeding to navigate to the program as 
in step three, re: Open up the command line prompt and navigate to the folder 
where you have unzipped the folder as follows:
cd Beautiful Soup
python setup python install 

This returns on my Python 27 :
 cd Beautiful Soup
File stdin,line 1
cd Beautiful Soup
   ^
SyntaxError: invalid syntax


also I get:
 cd Beautiful Soup
SyntaxError: invalid syntax


to my IDLE Python 2.7 version, same goes for the Python 3.4 installations. 
Hope someone can help. 
Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 2:58 AM, Simon Evans musicalhack...@yahoo.co.uk wrote:
 Open up the command line prompt and navigate to the folder where you have 
 unzipped the folder as follows:
 cd Beautiful Soup
 python setup python install 

This would be the operating system command line, not Python's
interactive mode. Since you refer to a C drive, I'm going to assume
Windows; you'll want to open up Command Prompt, or cmd.exe, or
whatever name your version of Windows buries it under. (Microsoft does
not make it particularly easy on you.) Since you have a space in the
name, you'll need quotes:

cd c:\Beautiful Soup

Then proceed as per the instructions.

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


NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread esawiek
Hi All--

Let me state at the start that I am new to Python. I am moving away from 
Fortran and Matlab to Python and I use all different types of numerical and 
statistical recipes in my work. I have been reading about NumPy and SciPy and 
could not find any definitive answers to my questions, below.  I had run into 
many mostly installation problems that I could never get NumPy or SciPy to work 
with Python 3.3 or newer.  I am using Windows7 64 bit OS. 
A few questions:
1.  What are the latest versions of NumPy and SciPy that are compatible 
with Python 3.3 or newer and Windows7 64 bit? 
2.  What is the best source to download and install them on my computer?
3.  Are they all installable on my OS w/o any major problems/addition?
4.  In the long run, would it be better to use UNIX instead of Windows, if 
I were to use Python for all of my research?
Thanks in advance. EK
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 3:07 AM,  esaw...@gmail.com wrote:
 4.  In the long run, would it be better to use UNIX instead of Windows, 
 if I were to use Python for all of my research?

Yes. Absolutely yes. But that's because it's better to run Unix than
Windows regardless of all other considerations. :)

As a general rule, a Linux (I can't speak for other flavours of Unix,
but I expect they'll be mostly the same) system will tend to settle
into better performance the longer it keeps running, as long as it has
sufficient RAM. The things you use will tend to be in cache, but other
than that, nothing much changes as you seek toward infinite uptime.
Windows, on the other hand, tends to accumulate cruft; the longer you
keep the system running, the more RAM gets wasted in various nooks and
crannies. I can't be sure of whether it's the OS itself or an
application, but I do know that my Windows laptop sometimes needs to
be rebooted just because stuff's feeling a bit sluggish, and none of
my Linux boxes are like that.

That said, though, my idea of uptime is measured in months. If you're
the sort of person who arrives at work, turns on the computer, uses it
for a day, and then turns it off and goes home, the difference gets a
lot smaller. (Unless you suspend/hibernate rather than actually
shutting down, in which case the difference gets bigger again.) I
still prefer a Unix system, though, because the worst messes I can get
myself into can usually be cured by SSH'ing in and killing some
process, which on Windows is both harder to do and less effective.

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


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread Никола Вукосављевић
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10.5.2014 19:07, esaw...@gmail.com wrote:
 Hi All--
 
 Let me state at the start that I am new to Python. I am moving away
 from Fortran and Matlab to Python and I use all different types of
 numerical and statistical recipes in my work. I have been reading
 about NumPy and SciPy and could not find any definitive answers to
 my questions, below.  I had run into many mostly installation
 problems that I could never get NumPy or SciPy to work with Python
 3.3 or newer.  I am using Windows7 64 bit OS. A few questions: 1.
 What are the latest versions of NumPy and SciPy that are compatible
 with Python 3.3 or newer and Windows7 64 bit? 2.  What is the best
 source to download and install them on my computer? 3.Are they all
 installable on my OS w/o any major problems/addition? 4.  In the
 long run, would it be better to use UNIX instead of Windows, if I
 were to use Python for all of my research? Thanks in advance. EK
 
For 64-bit Windows, I've had luck with installations from
http://www.lfd.uci.edu/~gohlke/pythonlibs/
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTbl6WAAoJEB1x37R9kdwnVQ4QAMHRLmwKHKAKDiitrSlt/glo
szOMAcjVff4vjNYt5N0x2Rqr1e6vgte9NoGcOgKPJbR1GUYMphQK3pgbkPfxX2Cl
030MI2ir//0WiCYP80rsLJBgAv88vhWx/dKFpG8EeN7LEP6AkJflVsWKeET4ZGfU
p0S/L1n/pePpiNs15QwZ0LVvTu7u86ZSJuxkLQfznL53aJtl5ztPFgNfvgvbW56f
Dap9KruqhbkC1EZD/6ogBQUgDZS51o0Cv3UsXdZJD0W69elnGXLHmCTY4kUwCDSa
psY29aviZHf8RHn5cb/TWobbu5P5PRJx0PVoIRmE8/CDlQKfXny7wPaU6e6PgT0Y
hmnskuN0PBubDm1zfZgiolOa4g5VzVVuB/r/JRpnAw4nxq6tluHbhs/OfFjSEUPu
n3qA4nCTB2wI5cP32sy3Q87SJ33ZQR0Nc8wHOLDmhgyhox7699q/7yu1RLYUCXAS
VLaQ4WEIgH3xJKrmDjktwdDsC+HBlfZuHqUxpHS/rAi54ey8OLWWoBW4t4ZE2PTn
0FPEejNI526WrUS1G/MjoaFAI/usSjnoThERg8gCroAi89JjoE4B53BT4Z5ONhQU
APPfkCIlzW2WQslxXhuoJY2XWM4NMf/dOOfS60qCVZa3EQaX97xo2j96mKkR9bMO
TYrl2RUWjMetm8t8VFNO
=v+OK
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread Stefan Behnel
esaw...@gmail.com, 10.05.2014 19:07:
 Let me state at the start that I am new to Python. I am moving away from 
 Fortran and Matlab to Python and I use all different types of numerical and 
 statistical recipes in my work. I have been reading about NumPy and SciPy and 
 could not find any definitive answers to my questions, below.  I had run into 
 many mostly installation problems that I could never get NumPy or SciPy to 
 work with Python 3.3 or newer.  I am using Windows7 64 bit OS. 
 A few questions:
 1.What are the latest versions of NumPy and SciPy that are compatible 
 with Python 3.3 or newer and Windows7 64 bit? 
 2.What is the best source to download and install them on my computer?
 3.Are they all installable on my OS w/o any major problems/addition?
 4.In the long run, would it be better to use UNIX instead of Windows, if 
 I were to use Python for all of my research?

I concur with Chris that Linux is generally a better choice than Windows,
if only to get a nicely preconfigured system that makes it easy to install
stuff. Especially for research (assuming we're talking about the same
thing). If you say that you're moving away from Fortran on Windows, then
I guess you're aware how clumsy low level software development can be on
that platform and how tricky it is to set up. That could be enough of a
reason to switch platforms (assuming that's really an option for you).

Ok, if you use only the IPython notebook for all your processing needs, you
may not notice the difference in terms of interface all that much, but in
that case, why stick with Windows in the first place? :)

If you decide to use Windows, try Anaconda. It's an all inclusive installer
that comes with pretty much all of your scientific processing tools in one
package:

http://docs.continuum.io/anaconda/

There's a Py3.3 version.

Stefan


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


Re: Fortran (Was: The does Python have variables? debate)

2014-05-10 Thread Terry Reedy

On 5/10/2014 9:42 AM, Roy Smith wrote:

In article mailman.9805.1399597367.18130.python-l...@python.org,
  Dennis Lee Bieber wlfr...@ix.netcom.com wrote:



Obsolete and Legacy? Fortran still receives regular standards updates
(currently 2008, with the next revision due in 2015).


Ars Technica article a couple of days ago, about Fortran, and what is
likely to replace it:


What might *possibly* replace it.


http://tinyurl.com/mr54p96


The article is deficient in that it ignores the 20-year-old combination 
of python with fortran and the facts that the combination gives fortran 
a repl loop and that this combination has already somewhat replaced bare 
fortran.


--
Terry Jan Reedy

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


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-10 Thread Terry Reedy

On 5/10/2014 1:03 PM, Chris Angelico wrote:

On Sun, May 11, 2014 at 2:58 AM, Simon Evans musicalhack...@yahoo.co.uk wrote:

Open up the command line prompt and navigate to the folder where you have 
unzipped the folder as follows:
cd Beautiful Soup
python setup python install 


This would be the operating system command line, not Python's
interactive mode. Since you refer to a C drive, I'm going to assume
Windows; you'll want to open up Command Prompt, or cmd.exe, or
whatever name your version of Windows buries it under. (Microsoft does
not make it particularly easy on you.)


On the All Programs / Start menu, look under Accessories. I have it 
pinned to my Win 7 task bar.


 Since you have a space in the name, you'll need quotes:


cd c:\Beautiful Soup


Not for Win 7, at least

C:\Users\Terrycd \program files

C:\Program Files

--
Terry Jan Reedy

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


Re: Values and objects

2014-05-10 Thread Ethan Furman

On 05/10/2014 02:32 AM, Chris Angelico wrote:


Tell me, what may this function do in a compliant Python?

def demo():
 ret = spam
 spam = 23
 return ret

In CPython, that'll raise UnboundLocalError, because the local
variable 'spam' does already exist, and currently has no value (no
object bound to it).


No, it does not exist -- or, more accurately, it does not exist *yet* but will.  The fact that there is a slot waiting 
for what will be spam is a cpython implementation detail.


And if you don't like that argument (although it is a perfectly sound and 
correct argument), think of the module name space:

ret = spam
spam = 23

will net you a simple NameError, because spam has not yet been created.



 If a compliant Python implementation is allowed
to have this return the value of a global or builtin spam, then I
would agree that you can create variables at run time.


See module example above.  This behavior is not allowed in functions for scope 
and sanity (mostly sanity) reasons.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread MRAB

On 2014-05-10 20:10, Ethan Furman wrote:

On 05/10/2014 02:32 AM, Chris Angelico wrote:


Tell me, what may this function do in a compliant Python?

def demo():
 ret = spam
 spam = 23
 return ret

In CPython, that'll raise UnboundLocalError, because the local
variable 'spam' does already exist, and currently has no value (no
object bound to it).


No, it does not exist -- or, more accurately, it does not exist *yet* but will. 
 The fact that there is a slot waiting
for what will be spam is a cpython implementation detail.

And if you don't like that argument (although it is a perfectly sound and 
correct argument), think of the module name space:

ret = spam
spam = 23

will net you a simple NameError, because spam has not yet been created.



 If a compliant Python implementation is allowed
to have this return the value of a global or builtin spam, then I
would agree that you can create variables at run time.


See module example above.  This behavior is not allowed in functions for scope 
and sanity (mostly sanity) reasons.


UnboundLocalError is like NameError, except that Python knows that the
name is local because somewhere in the function you're binding to that
name and you haven't said that it's global or nonlocal. Having a
different exception for that case makes it clearer to the user what the
problem is.
--
https://mail.python.org/mailman/listinfo/python-list


Question on Debugging a code line

2014-05-10 Thread subhabangalore
Dear Room,

I was trying to go through a code given in 
http://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm[ Forward 
Backward is an algorithm of Machine Learning-I am not talking on that
I am just trying to figure out a query on its Python coding.]

I came across the following codes.

 states = ('Healthy', 'Fever')
 end_state = 'E'
 observations = ('normal', 'cold', 'dizzy')
 start_probability = {'Healthy': 0.6, 'Fever': 0.4}
 transition_probability = {
   'Healthy' : {'Healthy': 0.69, 'Fever': 0.3, 'E': 0.01},
   'Fever' : {'Healthy': 0.4, 'Fever': 0.59, 'E': 0.01},
   }
 emission_probability = {
   'Healthy' : {'normal': 0.5, 'cold': 0.4, 'dizzy': 0.1},
   'Fever' : {'normal': 0.1, 'cold': 0.3, 'dizzy': 0.6},
   }

def fwd_bkw(x, states, a_0, a, e, end_st):
L = len(x)
fwd = []
f_prev = {} #THE PROBLEM 
# forward part of the algorithm
for i, x_i in enumerate(x):
f_curr = {}
for st in states:
if i == 0:
# base case for the forward part
prev_f_sum = a_0[st]
else:
prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) ##
 
f_curr[st] = e[st][x_i] * prev_f_sum
 
fwd.append(f_curr)
f_prev = f_curr
 
p_fwd = sum(f_curr[k]*a[k][end_st] for k in states)

As this value was being called in prev_f_sum = sum(f_prev[k]*a[k][st] for k in 
states marked ## 
I wanted to know what values it is generating.
So, I had made the following experiment, after 
for i, x_i in enumerate(x): 
I had put print f_prev 
but I am not getting how f_prev is getting the values.

Here, 
x=observations,
states= states,
a_0=start_probability,
a= transition_probability,
e=emission_probability,
end_st= end_state

Am I missing any minor aspect?
Code is running fine. 

If any one of the esteemed members may kindly guide me.

Regards,
Subhabrata Banerjee. 



 
   

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


Re: The � debate

2014-05-10 Thread Ethan Furman

On 05/10/2014 02:05 AM, Rustom Mody wrote:

On Saturday, May 10, 2014 1:18:27 PM UTC+5:30, Steven D'Aprano wrote:


Python assignment doesn't copy values.


Maybe our values differ?


Obviously they do.  Yours are irrelevant for Python.  They could be, and probably are, useful when comparing and 
contrasting Python with other languages, or maybe when discussing a particular implementation of Python -- but when 
discussing the *language* of Python, your definition of value doesn't exist.


When learning a foreign human language most folks start at, and some stay at, the think in native language, translate 
on the fly mode.  And it probably works well enough to get by.  But that is not fluency.  Fluency is understanding the 
meaning behind the words, behind the sounds, and eventually being able to *think* in that other language.


If that is not your goal, fine;  please stop muddying other's understanding of 
how Python the language works.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Ethan Furman

On 05/10/2014 12:22 PM, MRAB wrote:


UnboundLocalError is like NameError, except that Python knows that the
name is local because somewhere in the function you're binding to that
name and you haven't said that it's global or nonlocal. Having a
different exception for that case makes it clearer to the user what the
problem is.


Absolutely.  At one point NameError was raised in both cases, which could be 
very confusing to track down.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread esawiek
On Saturday, May 10, 2014 1:07:33 PM UTC-4, esa...@gmail.com wrote:
 Hi All--
 
 
 
 Let me state at the start that I am new to Python. I am moving away from 
 Fortran and Matlab to Python and I use all different types of numerical and 
 statistical recipes in my work. I have been reading about NumPy and SciPy and 
 could not find any definitive answers to my questions, below.  I had run into 
 many mostly installation problems that I could never get NumPy or SciPy to 
 work with Python 3.3 or newer.  I am using Windows7 64 bit OS. 
 
 A few questions:
 
 1.What are the latest versions of NumPy and SciPy that are compatible 
 with Python 3.3 or newer and Windows7 64 bit? 
 
 2.What is the best source to download and install them on my computer?
 
 3.Are they all installable on my OS w/o any major problems/addition?
 
 4.In the long run, would it be better to use UNIX instead of Windows, if 
 I were to use Python for all of my research?
 
 Thanks in advance. EK
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread esawiek
On Saturday, May 10, 2014 1:07:33 PM UTC-4, esa...@gmail.com wrote:
 Hi All--
 
 
 
 Let me state at the start that I am new to Python. I am moving away from 
 Fortran and Matlab to Python and I use all different types of numerical and 
 statistical recipes in my work. I have been reading about NumPy and SciPy and 
 could not find any definitive answers to my questions, below.  I had run into 
 many mostly installation problems that I could never get NumPy or SciPy to 
 work with Python 3.3 or newer.  I am using Windows7 64 bit OS. 
 
 A few questions:
 
 1.What are the latest versions of NumPy and SciPy that are compatible 
 with Python 3.3 or newer and Windows7 64 bit? 
 
 2.What is the best source to download and install them on my computer?
 
 3.Are they all installable on my OS w/o any major problems/addition?
 
 4.In the long run, would it be better to use UNIX instead of Windows, if 
 I were to use Python for all of my research?
 
 Thanks in advance. EK

Thank you all. I checked the website suggested in on of the replies and it 
looks promising. Because I want to use Num, SciPy, and Python on windows just 
to be familiar with them a little more, then I do plan to migrate to UNIX. I 
will let you posted on my progress. Thanks again. EK
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Terry Reedy

On 5/10/2014 3:10 PM, Ethan Furman wrote:

On 05/10/2014 02:32 AM, Chris Angelico wrote:


Tell me, what may this function do in a compliant Python?

def demo():
 ret = spam
 spam = 23
 return ret

In CPython, that'll raise UnboundLocalError,


Note:
 issubclass(UnboundLocalError, NameError)
True

I am not sure if adding the specificity is helpful or not.


because the local
variable 'spam' does already exist, and currently has no value (no
object bound to it).


No, it does not exist -- or, more accurately, it does not exist *yet*
but will.  The fact that there is a slot waiting for what will be spam
is a cpython implementation detail.

And if you don't like that argument (although it is a perfectly sound
and correct argument), think of the module name space:

ret = spam
spam = 23

will net you a simple NameError, because spam has not yet been created.


In other words, those two lines raise a NameError in either case.

--
Terry Jan Reedy

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


Re: NumPy, SciPy, Python 3X Installation/compatibility issues

2014-05-10 Thread Mark H Harris

On 5/10/14 12:07 PM, esaw...@gmail.com wrote:

4.  In the long run, would it be better to use UNIX instead of Windows, if 
I were to use Python for all of my research?



I concur with Chris and Stefan. The *nix model is faster, cleaner, and 
more secure. I prefer gnu/linux, but mac os/x is also quite nice. Simply 
change... or, if you like, just switch.


I moved away from OS/2 and Windows in the late 1990s and have never 
looked back; no reason to use Windows what-so-ever.


You're question (in the long run) is important, to be fair. Because, in 
the short run there will be some learning curve, and there will be some 
conceptual porting as well as code porting to handle; not to mention 
apps. All critical apps from Windows, and most day-to-day apps have free 
libre counter-parts in the unix world, and most everyday apps have gnu 
counter parts and others. Just switch.


Proprietary code and systems will not survive the 21st century, you can 
be sure of that. 'We' can never allow another Microsoft to rule again; 
not google, nor canonical, nor oracle, nor anyone else. 'We' must have 
net neutrality, and software idea patents must die (world-wide).


Go gnu/linux

Go Python

Go away, Microsoft, go away Oracle.


marcus

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


Re: Values and objects

2014-05-10 Thread Terry Reedy

On 5/10/2014 3:22 PM, MRAB wrote:


UnboundLocalError is like NameError,


More specifically,
 isinstance(UnboundLocalError(), NameError)
True

This means that 'except NameError:' clauses written before the 
UnboundLocalError subclass was added still work and do not necessarily 
need to be modified. (I am allowing for the possibility that the body of 
the clause tries to separate the specific error from other NameErrors).


--
Terry Jan Reedy

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


Re: Question on Debugging a code line

2014-05-10 Thread MRAB

On 2014-05-10 20:27, subhabangal...@gmail.com wrote:

Dear Room,

I was trying to go through a code given in 
http://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm[ Forward 
Backward is an algorithm of Machine Learning-I am not talking on that
I am just trying to figure out a query on its Python coding.]

I came across the following codes.


states = ('Healthy', 'Fever')
end_state = 'E'
observations = ('normal', 'cold', 'dizzy')
start_probability = {'Healthy': 0.6, 'Fever': 0.4}
transition_probability = {

'Healthy' : {'Healthy': 0.69, 'Fever': 0.3, 'E': 0.01},
'Fever' : {'Healthy': 0.4, 'Fever': 0.59, 'E': 0.01},
}

emission_probability = {

'Healthy' : {'normal': 0.5, 'cold': 0.4, 'dizzy': 0.1},
'Fever' : {'normal': 0.1, 'cold': 0.3, 'dizzy': 0.6},
}

def fwd_bkw(x, states, a_0, a, e, end_st):
 L = len(x)
 fwd = []
 f_prev = {} #THE PROBLEM
 # forward part of the algorithm
 for i, x_i in enumerate(x):
 f_curr = {}
 for st in states:
 if i == 0:
 # base case for the forward part
 prev_f_sum = a_0[st]
 else:
 prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) ##

 f_curr[st] = e[st][x_i] * prev_f_sum

 fwd.append(f_curr)
 f_prev = f_curr

 p_fwd = sum(f_curr[k]*a[k][end_st] for k in states)

As this value was being called in prev_f_sum = sum(f_prev[k]*a[k][st] for k in 
states marked ##
I wanted to know what values it is generating.
So, I had made the following experiment, after
for i, x_i in enumerate(x):
I had put print f_prev
but I am not getting how f_prev is getting the values.

Here,
x=observations,
states= states,
a_0=start_probability,
a= transition_probability,
e=emission_probability,
end_st= end_state

Am I missing any minor aspect?
Code is running fine.

If any one of the esteemed members may kindly guide me.

The values calculated in the inner loop are being put into the dict 
'f_curr'

and then, when that loop has completed, 'f_prev' is being bound to that
dict.

'f_curr' is bound to a new dict just before the inner loop, ready for
the new values.

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


Re: Values and objects

2014-05-10 Thread Devin Jeanpierre
On Sat, May 10, 2014 at 12:10 PM, Ethan Furman et...@stoneleaf.us wrote:
 On 05/10/2014 02:32 AM, Chris Angelico wrote:


 Tell me, what may this function do in a compliant Python?

 def demo():
  ret = spam
  spam = 23
  return ret

 In CPython, that'll raise UnboundLocalError, because the local
 variable 'spam' does already exist, and currently has no value (no
 object bound to it).


 No, it does not exist -- or, more accurately, it does not exist *yet* but
 will.  The fact that there is a slot waiting for what will be spam is a
 cpython implementation detail.

The name of the exception is UnboundLocalError. And the message says
that we referred to a local variable.

Also see the language reference:

When a name is not found at all, a NameError exception is raised. If
the name refers to a local variable that has not been bound, a
UnboundLocalError exception is raised. UnboundLocalError is a subclass
of NameError.

spam is referring to a local variable that has not been bound. This is
not an implementation detail.

 And if you don't like that argument (although it is a perfectly sound and
 correct argument), think of the module name space:


 ret = spam
 spam = 23

 will net you a simple NameError, because spam has not yet been created.

Because module level variables work differently from local variables.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xmltodict - TypeError: list indices must be integers, not str

2014-05-10 Thread flebber
On Saturday, 10 May 2014 22:10:14 UTC+10, Peter Otten  wrote:
 flebber wrote:
 
 
 
  I am using xmltodict.
 
  
 
  This is how I have accessed and loaded my file.
 
  
 
  import xmltodict
 
  document = open(/home/sayth/Scripts/va_benefits/20140508GOSF0.xml, r)
 
  read_doc = document.read()
 
  xml_doc = xmltodict.parse(read_doc)
 
  
 
  The start of the file I am trying to get data out of is.
 
  
 
  meeting id=35483 barriertrial=0 venue=Gosford
 
  date=2014-05-08T00:00:00 gearchanges=-1 stewardsreport=-1
 
  gearlist=-1 racebook=0 postracestewards=0 meetingtype=TAB
 
  rail=True weather=Fine   trackcondition=Dead  
 
  nomsdeadline=2014-05-02T11:00:00 weightsdeadline=2014-05-05T16:00:00
 
  acceptdeadline=2014-05-06T09:00:00 jockeydeadline=2014-05-06T12:00:00
 
club abbrevname=Gosford Race Club code=49 associationclass=2
 
website=http://; /
 
race id=185273 number=1 nomnumber=7 division=0 name=GOSFORD
 
ROTARY MAIDEN HANDICAP mediumname=MDN shortname=MDN
 
stage=Acceptances distance=1600 minweight=55 raisedweight=0
 
class=MDNage=~  grade=0 weightcondition=HCP  
 
 trophy=0 owner=0 trainer=0 jockey=0 strapper=0
 
totalprize=22000 first=12250 second=4250 third=2100
 
fourth=1000 fifth=525 time=2014-05-08T12:30:00 bonustype=BX02
 
  nomsfee=0 acceptfee=0 trackcondition=   timingmethod= 
 
 fastesttime=   sectionaltime=  
 
formavailable=0 racebookprize=Of $22000. First $12250, second $4250,
 
third $2100, fourth $1000, fifth $525, sixth $375, seventh $375, eighth
 
$375, ninth $375, tenth $375
 
  condition line=1
 
  
 
  So thought I had it figured. Can access the elements of meeting and the
 
  elements of club such as by doing this.
 
  
 
  In [5]: xml_doc['meeting']['club']['@abbrevname']
 
  Out[5]: u'Gosford Race Club'
 
  
 
  However whenever I try and access race in the same manner I get errors.
 
  
 
  In [11]: xml_doc['meeting']['club']['race']['@id']
 
  
 
 ---
 
  KeyError  Traceback (most recent call
 
  last) ipython-input-11-cce362d7e6fc in module()
 
   1 xml_doc['meeting']['club']['race']['@id']
 
  
 
  KeyError: 'race'
 
  
 
  In [12]: xml_doc['meeting']['race']['@id']
 
  
 
 ---
 
  TypeError Traceback (most recent call
 
  last) ipython-input-12-c304e2b8f9be in module()
 
   1 xml_doc['meeting']['race']['@id']
 
  
 
  TypeError: list indices must be integers, not str
 
  
 
  why is accessing race @id any different to the access of club @abbrevname
 
  and how do I get it for race?
 
 
 
 If I were to guess: there are multiple races per meeting, xmltodict puts 
 
 them into a list under the race key, and you have to pick one:
 
 
 
  doc = xmltodict.parse(\
 
 ... meeting
 
 ...race id=first race.../race
 
 ...race id=second race.../race
 
 ... /meeting
 
 ... )
 
  type(doc[meeting][race])
 
 class 'list'
 
  doc[meeting][race][0][@id]
 
 'first race'
 
  doc[meeting][race][1][@id]  


 
 'second race' 
   

 
 
 
 So 
 
 
 
 xml_doc['meeting']['race'][0]['@id']
 
 
 
 or
 
 
 
 for race in xml_doc[meeting][race]:
 
print(race[@id])
 
 
 
 might work for you.

Thanks so much Peter, yes both worked indeed. 

Sayth
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 4:39 AM, Terry Reedy tjre...@udel.edu wrote:
 Since you have a space in the name, you'll need quotes:


 cd c:\Beautiful Soup


 Not for Win 7, at least

 C:\Users\Terrycd \program files

 C:\Program Files

Huh, good to know.

Unfortunately, Windows leaves command-line parsing completely up to
the individual command/application, so some will need quotes, some
won't, and some will actually do very different things if you put an
argument in quotes (look at START and FIND). There is a broad
convention that spaces in file names get protected with quotes, though
(for instance, tab completion will put quotes around them), so it's
not complete chaos.

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


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 5:10 AM, Ethan Furman et...@stoneleaf.us wrote:
 And if you don't like that argument (although it is a perfectly sound and
 correct argument), think of the module name space:


 ret = spam
 spam = 23

 will net you a simple NameError, because spam has not yet been created.

What about this, though:

ret = int
int = 23

That will *not* net you a NameError, because 'int' exists in an outer
scope (builtins). You can create a new module-scope variable and it
will immediately begin to shadow a builtin; you can delete that
variable and it will immediately cease to shadow that builtin. That's
the difference I'm talking about. With function-local variables, they
all have to exist (as other responses confirmed, that *is* a language
guarantee), even though some of them aren't bound to anything yet.

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


Free vs proprietary (was Re: NumPy, SciPy, Python 3X Installation/compatibility issues)

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 6:14 AM, Mark H Harris harrismh...@gmail.com wrote:
 Proprietary code and systems will not survive the 21st century, you can be
 sure of that. 'We' can never allow another Microsoft to rule again; not
 google, nor canonical, nor oracle, nor anyone else. 'We' must have net
 neutrality, and software idea patents must die (world-wide).

 Go gnu/linux

 Go Python

 Go away, Microsoft, go away Oracle.

Actually, I'm not so sure of that. If all free software worked only
with itself, was GPL3'd to prevent non-free software from using it,
etc, the world would be a worse place. Part of what makes free
software so tempting is that it happily interacts with *everything*,
not just other free software. Otherwise, there'd be a massive gulf
between the Apple world, the Microsoft world, and the GNU world, with
minimal interoperability between them.

Instead, what we have is a world in which Python can be used to write
closed-source software, LibreOffice Writer will happily open a
Microsoft Word document, Samba communicates with Windows computers,
libc can be linked to non-free binaries, etc, etc, etc. Yes, that
means the open source community can't wield its weight against
closed-source. I am glad of that. Freedom means letting people choose
to be free, not forcing them to be free. (Don't get me wrong, forcing
someone to be free is better than forcing them to be enslaved. I don't
mind a preinstalled LibreOffice on someone's computer as much as I
would a preinstalled MS Office. But actually letting people choose is
better.)

Proprietary code and systems will continue to exist for as long as
people are willing to buy them. Maybe we'll see a shift away from
non-free desktop software, but cloud and mobile are still very much
the domain of closed source at the moment. There might be a shift
toward free mobile platforms, but I doubt the cloud will change. You
can run anything you like on a server, and people will use it if it's
useful. For one very very obvious example: you and I are both posting
from Gmail. :)

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


Re: Values and objects

2014-05-10 Thread Ethan Furman

On 05/10/2014 04:18 PM, Chris Angelico wrote:

On Sun, May 11, 2014 at 5:10 AM, Ethan Furman et...@stoneleaf.us wrote:

And if you don't like that argument (although it is a perfectly sound and
correct argument), think of the module name space:


ret = spam
spam = 23

will net you a simple NameError, because spam has not yet been created.


What about this, though:

ret = int
int = 23

That will *not* net you a NameError, because 'int' exists in an outer
scope (builtins). You can create a new module-scope variable and it
will immediately begin to shadow a builtin; you can delete that
variable and it will immediately cease to shadow that builtin. That's
the difference I'm talking about. With function-local variables, they
all have to exist (as other responses confirmed, that *is* a language
guarantee), even though some of them aren't bound to anything yet.


Well, with function variables they have to exist *when you use them*. ;)

This seems like more of a scoping issue than a can we create variables in 
Python issue.

I am curious, though, what other python's do with respect to function variables.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 11:28 AM, Ethan Furman et...@stoneleaf.us wrote:
 Well, with function variables they have to exist *when you use them*. ;)

 This seems like more of a scoping issue than a can we create variables in
 Python issue.

 I am curious, though, what other python's do with respect to function
 variables.

Variables exist in scope. Apart from assembly language, where
registers have universal scope, every language I know of has some
concept of scope. (REXX is very different from most, in that
PROCEDURE EXPOSE isn't at all your classic notion of scoping, but
there's still the concept that there can be two variables with the
same name.) When you create one, you create it in a particular scope,
and that's how it must be.

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


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-10 Thread Dave Angel

On 05/10/2014 07:23 PM, Chris Angelico wrote:

 There is a broad
convention that spaces in file names get protected with quotes, though
(for instance, tab completion will put quotes around them), so it's
not complete chaos.



Complete chaos is a pretty good description, especially since MS 
decided to make the default directory paths for many things have 
embedded spaces in them.  And to change the rules from version to 
version of the OS.  And it's not just the cmd line that's inconsistent; 
 some exec function variants liberally parse unquoted names looking for 
some file that happens to match the first few 'words of the string.


I once debugged a customer problem (without actually seeing the 
machine), and told tech support to ask him if he had a file in the root 
directory called program.exe.  I turned out to be right, and the 
customer was sure I must have hacked into his machine.


There was a bug in our code (missing quotes), masked by the liberality 
of the function I mentioned, that wasn't visible till such a file existed.


The customer symptom?  Our code complained that the linker couldn't be 
found.


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


Re: Values and objects

2014-05-10 Thread Steven D'Aprano
On Sun, 11 May 2014 09:18:34 +1000, Chris Angelico wrote:

 On Sun, May 11, 2014 at 5:10 AM, Ethan Furman et...@stoneleaf.us
 wrote:
 And if you don't like that argument (although it is a perfectly sound
 and correct argument), think of the module name space:


 ret = spam
 spam = 23

 will net you a simple NameError, because spam has not yet been created.
 
 What about this, though:
 
 ret = int
 int = 23

 That will *not* net you a NameError, because 'int' exists in an outer
 scope (builtins). You can create a new module-scope variable and it will
 immediately begin to shadow a builtin; you can delete that variable and
 it will immediately cease to shadow that builtin. 

Yes. That's part of documented language behaviour to do with scoping 
search paths. See below.


 That's the difference
 I'm talking about. With function-local variables, they all have to exist
 (as other responses confirmed, that *is* a language guarantee), even
 though some of them aren't bound to anything yet.

Define exist. 

Just because a slot exists waiting for a variable, doesn't mean that the 
variable which would use that slot exists. Like dicts and lists, function 
locals() are over-allocated: CPython pre-allocates slots for locals based 
on compile-time information, even if those locals are never bound to and 
therefore don't exist:

def demo():
if False:
x = 23
print x  # Fails

You're trying to argue that because there is a slot for x, the variable x 
exists. But I think that is the wrong definition of exists. If you have 
a list L = [], would you say that L[4] exists because the array is over-
allocated and already has (at least) four slots waiting to be used, but 
L[100] doesn't because it isn't over-allocated that much? What if the pre-
allocation rules change? What if an implementation decides not to bother 
pre-allocating empty lists?

What if an implementation pre-allocates a random number of array slots? 
Would you be comfortable saying that there is a 25% chance that L[4] 
exists and a 1% chance that L[100] exists?

In both these cases, array slots in a list or dict, and locals, we risk 
mistaking implementation details for language features. I think you 
actually are making this error when it comes to locals.

When talking about the implementation, it is relevant to discuss the 
existence of slots. But when talking about the language, about features 
visible from Python code such as variables (a.k.a. name bindings), local 
slots don't matter. Jython and IronPython don't (so far as I know) use 
them, and locals() happens to be writable. Here's an example from 
IronPython 2.6:

 def test():
... if False: spam = None
... d = locals()
... d['spam'] = 23
... return spam
...
 test()
23


And a similar example from Jython 2.5:

 def test():
... locals()['spam'] = 42
... return spam
... spam = None
...
 test()
42


Neither example works in CPython, you get an UnboundLocalError, but 
whether or not locals() is writable is is *explicitly* documented as an 
implementation detail. How implementations store local variables (in a 
dictionary like globals, slots, in the Cloud) is up to them, so long as 
the implementation follows the scoping rules.

Python determines whether a variable is local or not at compile-time:

(1) If a function contains a binding operation (assignment; import; del) 
on that variable, then the variable is defined as a local unless 
otherwise declared as a global or nonlocal (Python 3 only).

(2) Otherwise it is not a local.

(3) Outside of a function, it is a global whether declared as such or not.

(4) Variables (names) don't exist until they have a value bound to them.

I guess you want to challenge #4, and say that local variables exist as 
soon as the slot that holds them exists. I think that is wrong. And 
besides, even CPython 2 doesn't always use slots for locals: consider 
what happens when you use import * inside a function. And try running 
this function in both 2.7 and 3.3 and see if you can explain the 
difference:

def test():
if False: x = None
exec(x = 1)
return x


But I digress.

Name look-ups for locals look only in the local scope. Name lookups for 
everything else search the chain nonlocals:globals:builtins.

Name bindings (assignments, del, imports) for locals write only to the 
local scope. For globals they write only to the global scope and for 
nonlocals they write to the nearest enclosing nonlocal scope that already 
defines that variable.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 14:03:11 -0700, Devin Jeanpierre wrote:

 On Sat, May 10, 2014 at 12:10 PM, Ethan Furman et...@stoneleaf.us
 wrote:
 On 05/10/2014 02:32 AM, Chris Angelico wrote:


 Tell me, what may this function do in a compliant Python?

 def demo():
  ret = spam
  spam = 23
  return ret

 In CPython, that'll raise UnboundLocalError, because the local
 variable 'spam' does already exist, and currently has no value (no
 object bound to it).


 No, it does not exist -- or, more accurately, it does not exist *yet*
 but will.  The fact that there is a slot waiting for what will be spam
 is a cpython implementation detail.
 
 The name of the exception is UnboundLocalError. And the message says
 that we referred to a local variable.
 
 Also see the language reference:
 
 When a name is not found at all, a NameError exception is raised. If
 the name refers to a local variable that has not been bound, a
 UnboundLocalError exception is raised. UnboundLocalError is a subclass
 of NameError.
 
 spam is referring to a local variable that has not been bound. This is
 not an implementation detail.

Of course not. What is an implementation detail is that there is a slot 
waiting to be filled for it, just like Ethan said. It's the existence of 
pre-allocated slots for locals which is an implementation detail, not 
whether a name is treated as local or not.


 And if you don't like that argument (although it is a perfectly sound
 and correct argument), think of the module name space:


 ret = spam
 spam = 23

 will net you a simple NameError, because spam has not yet been created.
 
 Because module level variables work differently from local variables.

But that is an implementation detail. IronPython and Jython use an 
ordinary dict for local variable namespaces, just like globals. Consider 
this example from Jython:

 spam = 
 def modify(namespace):
... namespace['spam'] = 42
...
 def demo():
... modify(locals())
... spam = spam
... return spam
...
 demo()
42



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 1:17 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 But that is an implementation detail. IronPython and Jython use an
 ordinary dict for local variable namespaces, just like globals. Consider
 this example from Jython:

 spam = 
 def modify(namespace):
 ... namespace['spam'] = 42
 ...
 def demo():
 ... modify(locals())
 ... spam = spam
 ... return spam
 ...
 demo()
 42

All you're proving here is that, in some Pythons, locals() is
writeable. What happens if you remove the spam = spam line? Would
demo() not then return spam from the global scope, because the
variable does not exist at local scope? Every example you've shown is
simply giving a value to something that you've created by the normal
method of having an assignment inside the function.

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


Free vs proprietary (was Re: NumPy, SciPy, Python 3X Installation/compatibility issues)

2014-05-10 Thread Nelson Crosby
I also believe in this more 'BSD-like' view, but from a business point of view. 
No one is going to invest in a business that can't guarantee against piracy, 
and such a business is much less likely to receive profit (see Ardour).

Don't get me wrong - I love free software. It's seriously awesome to she what a 
community can do. But at the same time, some people want to earn a living from 
writing code. That is simply not possible without proprietary software. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Free vs proprietary (was Re: NumPy, SciPy, Python 3X Installation/compatibility issues)

2014-05-10 Thread Rustom Mody
On Sunday, May 11, 2014 9:46:06 AM UTC+5:30, Nelson Crosby wrote:
 I also believe in this more 'BSD-like' view, but from a business point of 
 view. No one is going to invest in a business that can't guarantee against 
 piracy, and such a business is much less likely to receive profit (see 
 Ardour).
 
 
 
 Don't get me wrong - I love free software. It's seriously awesome to she what 
 a community can do. But at the same time, some people want to earn a living 
 from writing code. That is simply not possible without proprietary software.

Whenever this (kind of) debate arises people talk of 'Free' vs 'OpenSource'
which then becomes an rms vs esr debate.
It seems to me that esr gets more press than is his due and the more 
significant ideological difference between rms and Torvalds gets neglected.

rms started working on hurd before Linus was a CS student. 
Its taken him a good 20 years to admit the mistake
http://en.wikipedia.org/wiki/GNU_Hurd#cite_note-fsf-future-of-freedom-12

I believe that he still does not get it - that the mistakes were political more
than technical.

By contrast,
- the Linux kernel targeting hardware for which it was never intended
- perl running equally on DOS and unix, (with all due respect python, ruby etc 
just followed the lead)
- Samba talking to Windows as though it were Windows itself

all show that some amount of guerrilla mindset is necessary 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Steven D'Aprano
On Sun, 11 May 2014 13:30:03 +1000, Chris Angelico wrote:

 On Sun, May 11, 2014 at 1:17 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 But that is an implementation detail. IronPython and Jython use an
 ordinary dict for local variable namespaces, just like globals.
 Consider this example from Jython:

 spam = 
 def modify(namespace):
 ... namespace['spam'] = 42
 ...
 def demo():
 ... modify(locals())
 ... spam = spam
 ... return spam
 ...
 demo()
 42
 
 All you're proving here is that, in some Pythons, locals() is writeable.
 What happens if you remove the spam = spam line? Would demo() not then
 return spam from the global scope, 

Yes, this. See my previous email, and take careful note of Rule #2: in 
the absence of a binding operation, variables are not treated as local.

 because the variable does not exist at local scope? 

No to this. Consider this example:


 spam = 
 def modify(namespace):
... namespace['spam'] = 42
...
 def demo2():
... assert 'spam' not in locals()
... modify(locals())
... assert 'spam' in locals()
... return spam
...
 demo2()



This proves that the spam variable *does* exist in locals, but it is not 
seen because the return spam doesn't check the local scope, so it sees 
the global spam.

Sadly, the version of Jython I have doesn't provide a working dis module, 
but if it did I expect it would show the equivalent of what CPython does: 
the first version uses LOAD_FAST to look up spam, and the second 
version used LOAD_GLOBAL (a misnomer since it doesn't *just* look up 
globals).


 Every example you've shown is simply giving a value to
 something that you've created by the normal method of having an
 assignment inside the function.

Nonsense. Look at the original examples again, more closely. Here they 
are again, this time with comments:

def test():
if False: spam = None  # Dead code, never executed.
d = locals()
d['spam'] = 23  # Not a normal assignment.
return spam

def test():
locals()['spam'] = 42  # Not a normal assignment.
return spam
spam = None  # Dead code.


and from my reply to Devin:

def modify(namespace):
namespace['spam'] = 42

def demo():
modify(locals())  # Not an ordinary assignment.
spam = spam  # Where does the initial value of spam come from?
return spam


The *only* purpose of the dead code in the two test() functions is to 
force the compiler to use LOAD_FAST (or equivalent) rather than 
LOAD_GLOBAL. But they aren't ever executed. At no time do I use normal 
name binding assignment to create local variables. In the demo() 
function, if I expand the line spam = spam out:

temp = spam  # Look up of spam occurs first.
spam = temp  # Binding occurs second.

the difficulty should be even more obvious. Where does the value of spam 
come from before the binding?

The answer is that it comes from writing directly to the namespace (a 
dict). There is no fixed slot for spam waiting for a value, because 
Jython and IronPython don't use fixed slots. There's only a dict.

If we were using globals, it would be be more obvious what was going on, 
and there would be no argument about whether or not a variable exists 
before you give it a value. The answer would be, of course it doesn't 
exist before it has a value. Python declarations (whether implicit or 
explicit) don't create variables, they just instruct the compiler how to 
perform lookups on them.

# Global scope
print spam  # fails, because there is no spam variable yet
spam in globals()  # returns False
globals()['spam'] = 42  # now it exists
spam = spam  # a no-op
print spam


It's only because CPython is special, and locals() is special, that the 
equivalent code is indeterminate inside functions.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Chris Angelico
On Sun, May 11, 2014 at 3:11 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Nonsense. Look at the original examples again, more closely. Here they
 are again, this time with comments:

 def test():
 if False: spam = None  # Dead code, never executed.
 d = locals()
 d['spam'] = 23  # Not a normal assignment.
 return spam

 def test():
 locals()['spam'] = 42  # Not a normal assignment.
 return spam
 spam = None  # Dead code.


 The *only* purpose of the dead code in the two test() functions is to
 force the compiler to use LOAD_FAST (or equivalent) rather than
 LOAD_GLOBAL.

In a C-like language, locals are created by a declaration, and
assigned a value separately. In Python, locals are created by the
presence of assignment within the function, which in simple cases
coincides with giving the value to it; but guarding the assignment
with if False prevents the giving of the value, while still being an
assignment for the sake of creating a local variable. Same if the
assignment happens further down, or even in the same statement (spam
= spam). It's still an assignment, so it has the declarative effect
of telling the compiler this is now local, unless declared
global/nonlocal. It's that declaration that creates the variable, not
changing locals().

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


Re: Values and objects

2014-05-10 Thread Rustom Mody
On Saturday, May 10, 2014 2:39:31 PM UTC+5:30, Steven D'Aprano wrote:
 
 Personally, I don't imagine that there ever could be a language where 
 variables were first class values *exactly* the same as ints, strings, 
 floats etc. Otherwise, how could you tell the difference between a 
 function which operated on the variable itself, and one which operated on 
 the value contained by the value?

Its standard fare in theorem proving languages -
see eg twelf: https://www.cs.cmu.edu/~fp/papers/cade99.pdf
where the distinction is made between variables in the meta-language (ie twelf 
itself)
and variables in the the object theory

What you mean by *exactly* the same mean, I am not sure...

Also I note that I was not meaning first-classness of variables in C in that
literal sense.  Its just I consider them more first-class than say Pascal but 
less than say Lisp.

[The wikipedia link that Chris posted links to an article that makes the claim 
that
firstclassness is not really defined but can be used in a vague/relative way ]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Free vs proprietary (was Re: NumPy, SciPy, Python 3X Installation/compatibility issues)

2014-05-10 Thread Mark H Harris

On 5/10/14 11:16 PM, Nelson Crosby wrote:

I also believe in this more 'BSD-like' view, but from a business
point of view. No one is going to invest in a business that can't
guarantee against piracy, and such a business is much less likely
to receive profit (see Ardour).

Don't get me wrong - I love free software. It's seriously awesome
to see what a community can do. But at the same time, some people want
to earn a living from writing code. That is simply not possible
without proprietary software.



That's just the point...

The twenty-first century is not going to be about making money by moving
bits around a network, nor about making money writing code. It is going
to be about making money|living (whatever that means) by leveraging free 
networking (think libre box) and by leveraging free (as in libre) 
software and libre software engineering.


In other words, no longer are coders going to make a living writing 
proprietary code; rather, coders are going to make a living leveraging 
their skill writing libre software (in the specialized problem domain 
needing their resources --- free agents, have skill, will travel, or 
connect).


So, I go to work for some technical scientific research outfit that just 
got a federal grant for yadda yadda... and I bring in my toolkit|toobox 
(julia, haskell, python, C++ c whatever) and I make a living coding 
within that specialized domain.  I don't market the app ( they don't 
either).  The killer app in the 21st century IS the unix distro 
(gnu/linux), and the toolbox is (mine, or yours).


We are going to stop purchasing software across the board, and we are 
going to share. In the process we are going to make our livings with our 
skills, services, innovations towards specialized problem domains 
through leveraged technical specialty, and by working together to better 
the whole.


This is already occurring.


marcus
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Ethan Furman

[accidentally went off-list; sorry]

On 05/10/2014 02:03 PM, Devin Jeanpierre wrote:


spam is referring to a local variable that has not been bound. This is
not an implementation detail.


The implementation detail is that in cpython there is a spot already reserved for what will be the 'spam' variable, as 
opposed to the module level where no such spots are reserved.



Because module level variables work differently from local variables.


Not by language definition.  There are pythons where modifying function locals works, but the working or not-working is 
not a language guarantee.


--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Values and objects

2014-05-10 Thread Ethan Furman

On 05/10/2014 10:22 PM, Chris Angelico wrote:

It's that declaration that creates the variable, not
changing locals().


A Python variable is a name bound to a value (and values, of course, are objects).  If you don't have both pieces, you 
don't have a Python variable.


--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


[issue6305] islice doesn't accept large stop values

2014-05-10 Thread Alok Singhal

Alok Singhal added the comment:

Uploading another patch which is the same as the last patch but this one 
applies cleanly after the latest islice changes for #21321.

--
Added file: http://bugs.python.org/file35205/islice_large_values-4.patch

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



[issue7776] http.client.HTTPConnection tunneling is broken

2014-05-10 Thread Cybjit

Cybjit added the comment:

On 2014-05-10 00:23, nikratio wrote:
 Is pip maybe doing its own certificate check, and relying on
 HTTPSConnection.host to contain the final hostname rather than the proxy?

I think the culprit might be here 
https://github.com/pypa/pip/blob/1.5.4/pip/_vendor/requests/packages/urllib3/connection.py#L172

--

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



[issue19655] Replace the ASDL parser carried with CPython

2014-05-10 Thread Stefan Behnel

Stefan Behnel added the comment:

The avoid rebuilding part doesn't seem to work for me. Source build currently 
fails as follows:


/bin/mkdir -p Include
python ./Parser/asdl_c.py -h Include ./Parser/Python.asdl
# Substitution happens here, as the completely-expanded BINDIR
# is not available in configure
sed -e s,@EXENAME@,.../INSTALL/py3km/bin/python3.5dm,  
./Misc/python-config.in python-config.py
# Replace makefile compat. variable references with shell script compat. ones;  
- 
sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g'  Misc/python-config.sh 
python-config
# On Darwin, always use the python version of the script, the shell
# version doesn't use the compiler customizations that are provided
# in python (_osx_support.py).
if test `uname -s` = Darwin; then \
cp python-config.py python-config; \
fi
Traceback (most recent call last):
  File ./Parser/asdl_c.py, line 1312, in module
main(args[0], dump_module)
  File ./Parser/asdl_c.py, line 1251, in main
if not asdl.check(mod):
  File .../cpython/Parser/asdl.py, line 183, in check
v = Check()
  File .../cpython/Parser/asdl.py, line 140, in __init__
super().__init__()
TypeError: super() takes at least 1 argument (0 given)


Python installation is 2.7 (originally 2.5 at the system level, but recent 
build changes broke that), no Py3 available.

--
nosy: +scoder

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



[issue21435] Segfault in gc with cyclic trash

2014-05-10 Thread Andrew Svetlov

Andrew Svetlov added the comment:

@Tim nothing to close, aiohttp is separate library based on asyncio.
It just uses constructions like self.attr = None in __del__

--

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



[issue19655] Replace the ASDL parser carried with CPython

2014-05-10 Thread Eli Bendersky

Eli Bendersky added the comment:

Stefan, you need to run `make touch` if you want to avoid rebuilding. See 
#15964 for more details.

[all bots run `make touch` before building now]

--

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



[issue19655] Replace the ASDL parser carried with CPython

2014-05-10 Thread Eli Bendersky

Eli Bendersky added the comment:

This is also described in the Dev Guide: 
https://docs.python.org/devguide/setup.html

--

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



[issue21466] General Index link to del statement is wrong

2014-05-10 Thread Apteris

New submission from Apteris:

In the documentation index, https://docs.python.org/2/genindex-D.html, the link 
to the del statement documentation is not 

https://docs.python.org/2/reference/simple_stmts.html#del

as it presumably should be, but

https://docs.python.org/2/reference/datamodel.html#index-25

Affects all versions, but with a different wrong link in each one, as follows:
Python 2.7: https://docs.python.org/2/reference/datamodel.html#index-25
Python 3.2: https://docs.python.org/3.2/reference/datamodel.html#index-21
Python 3.3: https://docs.python.org/3.3/reference/datamodel.html#index-22
Python 3.4: https://docs.python.org/3.4/reference/datamodel.html#index-22
Python 3.5: https://docs.python.org/3.5/reference/datamodel.html#index-22

The del statement is in each case documented at 
https://docs.python.org/[version number]/reference/simple_stmts.html#del.

--
assignee: docs@python
components: Documentation
messages: 218217
nosy: apteris, docs@python
priority: normal
severity: normal
status: open
title: General Index link to del statement is wrong
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue21466] General Index link to del statement is wrong

2014-05-10 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
versions:  -Python 3.1, Python 3.2, Python 3.3

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



[issue21425] Interactive interpreter doesn't flush stderr prompty

2014-05-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

This can be reproduced as easily under Linux:

$ ./python 21 | cat
Python 3.5.0a0 (default:17689e43839a+39f2a78f4357+, May  9 2014, 00:30:19) 
[GCC 4.8.1] on linux
Type help, copyright, credits or license for more information.
 5
5
 1/0
 nonsense
Traceback (most recent call last):
  File stdin, line 1, in module
ZeroDivisionError: division by zero
 
Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'nonsense' is not defined


--
components: +Interpreter Core -Windows
nosy: +pitrou
stage:  - needs patch
title: Python 3 pipe handling breaks python mode in emacs on Windows - 
Interactive interpreter doesn't flush stderr prompty
versions: +Python 3.5

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



[issue21425] Interactive interpreter doesn't flush stderr prompty

2014-05-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Attached patch fixes it under Linux, and adds tests.
I'd be glad if someone could give it a run under Windows.

--
keywords: +patch
nosy: +ncoghlan, tim.golden, zach.ware
stage: needs patch - patch review
Added file: http://bugs.python.org/file35206/flush_stderr.patch

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Steve Dower

New submission from Steve Dower:

#20406 changed the icon used by IDLE, but forgot to include the new file in the 
Windows installer. As a result, IDLE won't start.

I've attached a patch. 3.4 is unaffected, probably because msi.py changed 
significantly at some point.

(I don't have commit rights, but since I've never actually had a patch accepted 
I know exactly why. I have a few more changes coming that affect/improve 
PCBuild and tools\msi, but I'm happy to keep creating issues and patches if 
that's the right way to make these changes. On the other hand, if someone wants 
to give me commit rights and say just go for it in these dirs (in my new role 
as build manager for 2.7/3.5+) I'm okay with that too.)

--
components: IDLE, Installation, Windows
files: idleico.diff
keywords: patch
messages: 218220
nosy: benjamin.peterson, loewis, steve.dower, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE icon not included in Windows installer
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file35207/idleico.diff

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Martin v . Löwis

Martin v. Löwis added the comment:

I'll declare this release-critical for the moment; I'm sure Benjamin will 
properly process it. As for getting access: send your ssh key to 
hgaccou...@python.org.

--
priority: normal - release blocker

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



[issue21459] DragonFlyBSD support

2014-05-10 Thread Brett Cannon

Brett Cannon added the comment:

It was pointed out to me Dragonfly support is pre-existing, so I prematurely 
rejected this. Sorry about that.

--
resolution: wont fix - 
status: closed - open

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



[issue21468] NNTPLib connections become corrupt after long periods of activity

2014-05-10 Thread James Meneghello

New submission from James Meneghello:

After establishing an NNTP connection for a long-running process (up to hours 
at a time), the connection will eventually die and start producing infinite 
random garbage output, a small part of which is seen below. Any subsequent 
calls to the connection will produce a random stream of exceptions and data, as 
the library flips out. This happens with the connection being constantly used 
over the time period.

The problem occurs approximately 2 hours after the initial connection is 
established, and happens after approximately the same amount of time each run. 
The below connection was initialised at 22:03:27 and broke at 23:55:58.

Workaround is pretty simple: kill the connection and reinitialise it. Calling 
quit() will fail, however, with a series of random exceptions produced, because 
quit() attempts to send a QUIT command to the broken socket.

Tested on Ubuntu 13.10 (which fails) and Windows 8.1, which does not appear to 
have the same problem - I'm unable to replicate it on Win8.1.

--

2014-05-10 23:55:58,937 - ERROR - nntp error: 
ɀ\udcd9?\udc95\udcf6Mo\udcdd0\udcb9\udcb9P0/)\udce4\udcbeBo\udc90q\udcb52\udc97\udcd7\udcf7f\udcacŸ\udcfa

\udceaO2cC\udc92V\udcc1\udcc1ذ\ud,\udcdd\udcf1(\udc82\udcbb\udc906Z4Ft\udceeD\udcb5\udc9d\udcba\udcb5\udca8\udccaEk\udcfa\udcb6\udcc8\udcc1\udcf4yԫ\udce6\udccf\udcd8\udcc9_\udcf9c$\udc8cc֟c_B\udca9\udceefudcecsrCw+4\udc973\udce8\udceem\udc93\udcb4\udca1\udcd4\udc9f\udcb4\udcf1G\udcc1XI\udc9c\udcbc~\udcacK\udcbe\udc98\udcee־]I8\udc9f\udcac\udcc7\udcc6a\udcf58\udcdc-\udc93\udc82\udca6\udc90\udcf0\udcb5\udcf2\udcbeA?\udcf0\udc99:\udcb1\udc9e[\udcf9\udcfa`fvudcad\udcfa\udce7
-f\udcf8\udc81_$٫\udc8bH\udcc1\udced�{\udc90\udca1\udcb2\udc81\udce0I\udc91\udcfeD\udceeE\udcd3\udcf6$\udccfbd\udcec]\udcb0\udc9a\udc8cf6\udcfa\udcbf\udcea\udcb3h:S\udcbc\udc8dG\udca6t\udc85\udcc6(\udcf2\udce0Kb\udcbe\udcb8j\\udc94\udc85B-\udc9dL+le\udcad/.\udc87\udcbbtv\udc89!\udc8f/\udcf9_\udce0
 \udcad\udc98\udcc0\udcc40T\udcc21\udcd3\udcebȳ
\udcbc@\udcf5mG\udcba\udca0\udcc2]۲LUخ\udcc0\udcc*\udce1,H6\udcccja\udcf9h\udc97f\udc95\udc9c\udce3\udc88%\udca7\udc860\udcfb\udc83\udca2\udca1\udccfH\udcd3Uxߴ\udce2\udc86өY\udcad\udcbb\udcd7\udcf7\udca7W㌘\udcf6\udcbf\udce9AI1P\udc8d\udc959^\udcc5\udcc3n\udce5xY\udcfb\udc87\udcfdp\udcb4nT\udca9\udc97\udcfbp\udc8aTkkb\udc90C\udcaa\udc8aq\udcddUm\udcd5sJsS7l\udcdb`\udc88hU\udcf6

--
components: Library (Lib)
messages: 218223
nosy: James.Meneghello
priority: normal
severity: normal
status: open
title: NNTPLib connections become corrupt after long periods of activity
versions: Python 3.2, Python 3.3, Python 3.4

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Tim Golden

Tim Golden added the comment:

Steve -- re changes to PCBuild c.: worth liaising with Zach Ware (and, to a 
lesser extent, me) as he's been working through a number of things in that area 
and I know has other ideas.

Just post a patch and nosy us both (zach.ware / tim.golden)

Obviously, if it's critical: just do it.

--
nosy: +tim.golden, zach.ware

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Steve Dower

Steve Dower added the comment:

Martin - sent. I think I need some bits flipped on my account here too. 
Will/can you take care of that for me?

Tim - thanks. My next task was to figure out who else has an interest in this 
area. I wasn't sure if the 'windows' tag was accurate, but sounds like it is (I 
should probably get on there as well).

--

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



[issue21469] Hazards in robots.txt parser

2014-05-10 Thread Raymond Hettinger

New submission from Raymond Hettinger:

* The can_fetch() method is not checking to see if read() has been called, so 
it returns false positives if read() has not been called.

* When read() is called, it fails to call modified() so that mtime() returns an 
incorrect result.  The user has to manually call modified() to update the 
mtime().

 from urllib.robotparser import RobotFileParser
 rp = RobotFileParser('http://en.wikipedia.org/robots.txt')
 rp.can_fetch('UbiCrawler', 'http://en.wikipedia.org/index.html')
True
 rp.read()
 rp.can_fetch('UbiCrawler', 'http://en.wikipedia.org/index.html')
False
 rp.mtime()
0
 rp.modified()
 rp.mtime()
1399740268.628497

Suggested improvements:

1) Trigger internal calls to modified() every time the parse is modified using 
read() or add_entry().  That would assure that mtime() actually reflects the 
modification time.

2) Raise an exception or return False whenever can_fetch() is called and the 
mtime() is zero (meaning that the parser has not be initialized with any rules).

--
components: Library (Lib)
messages: 218226
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Hazards in robots.txt parser
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5

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



[issue3561] Windows installer should add Python and Scripts directories to the PATH environment variable

2014-05-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a9d34685ec47 by Brian Curtin in branch '2.7':
Backport 4e9f1017355f from #3561.
http://hg.python.org/cpython/rev/a9d34685ec47

--

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



[issue21464] fnmatch module uses regular expression with undefined result to perform matching

2014-05-10 Thread akira

akira added the comment:

I don't see (?x) flag and it is not introduced by `res` regular expression that 
is constructed within translate() function in Lib/fnmatch.py

   import fnmatch
   fnmatch.translate('a b')
  'a\\ b\\Z(?ms)'

--
nosy: +akira

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



[issue21464] fnmatch module uses regular expression with undefined result to perform matching

2014-05-10 Thread Paul Sokolovsky

Paul Sokolovsky added the comment:

I see, so it's my misreading of the re module docs. I kinda thought that x 
in (?x) means any single-character flag of set (?aiLmsux). I was wrong, it 
is the specific literal flag. 

Also, rereading it again, the doc says the letters set the corresponding 
flags: [list of flags], for the entire regular expression. So, my report is 
invalid.

Just to give some context, I hit this when porting fnmatch.py to MicroPython 
(http://micropython.org/), which doesn't use native CPython SRE, but instead 
system PCRE. Well, it would be nice if stdlib maintained kind of compatibility 
with original PCRE semantics, but that's kinda wishful thinking, we'll work it 
around on our side. 

Closing this.

--
resolution:  - works for me
status: open - closed

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



[issue21332] subprocess bufsize=1 docs are misleading

2014-05-10 Thread akira

akira added the comment:

I've asked about thread-safety of tests on python-dev mailing list: 
https://mail.python.org/pipermail/python-dev/2014-May/134523.html

--

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Creating issues with patches, so others can comment, is a good idea even when 
you have commit rights. Adding yourself to
https://docs.python.org/devguide/experts.html#experts
is a good way to test new commit rights.

--

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



[issue19655] Replace the ASDL parser carried with CPython

2014-05-10 Thread Stefan Behnel

Stefan Behnel added the comment:

That fixes it. Thanks!

--

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



[issue21160] incorrect comments in nturl2path.py

2014-05-10 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file35208/d7f128afe9db.diff

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



[issue21160] incorrect comments in nturl2path.py

2014-05-10 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


Removed file: http://bugs.python.org/file35208/d7f128afe9db.diff

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



[issue21165] Optimize str.translate() for replacement with substrings and non-ASCII strings

2014-05-10 Thread Ezio Melotti

Ezio Melotti added the comment:

Aren't there similar benchmarks in the benchmarks repo?
If not, would it be reasonable to add this there?

--
nosy: +ezio.melotti
stage:  - patch review

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



[issue6305] islice doesn't accept large stop values

2014-05-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Alok, have you signed a contributor agreement?

--

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



[issue21467] IDLE icon not included in Windows installer

2014-05-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Steve, I am *really* glad you caught this. We obviously need a new test 
somewhere that would have caught this before the release. How is the installer 
tested now? Is it run and the installed python tested with the test suite? If 
so, a new idle test that runs idlelib/idle.(bat, py, pyw) with subprocess, 
detects startup errors, and cleanly shuts down the subprocces, would cover the 
installer.

3.4 is not directly affected because 3.4 Tools/msi/msi.py does not include the 
patched section
 if dir==Icons:
 lib.glob(*.gif)
+lib.glob(*.ico)
 lib.add_file(idle.icns)
and .gif and .icns are not in the file. Perhaps the change matches a change in 
the build process.

However, new tests should go on all versions.

--
stage:  - test needed

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



[issue20815] ipaddress unit tests PEP8

2014-05-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Marking as low priority.  This patch really isn't worth applying.

If someone wants to starting contributing, there are plenty of useful things to 
do (such as adding docstrings to elementtree).  I don't want to encourage 
non-substantive shallow code churn and eats developer time for no benefit.

From my point of view, the benefit is actually negative because these sort 
of micro-rearrangements clutter the annotate history and because it makes it 
more difficult to apply substantive patches across multiple versions of Python.

--
priority: normal - low

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



[issue21439] Numerous minor issues in Language Reference

2014-05-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I also don't agree with most of the typographic changes and, like Éric find 
some of the grammar changes to be pedantic.

The OP refers to his own changes as editorial infelicities.  This should have 
been a warning sign.

The OP further warns, I have been reading the Language Reference Manual in 
order to teach myself Python 3 which explains why Éric has found  a few 
misunderstandings of Python.

If the OP cares enough to prepare a chapter by chapter patch (as suggested by 
Terry), I would be happy to review them one by one, applying any that are 
actual readability improvements.

--
assignee: zach.ware - rhettinger
nosy: +rhettinger
priority: normal - low
versions:  -Python 3.4

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



  1   2   >