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

2013-04-19 Thread Moez AbdelGawad





 Date: Thu, 18 Apr 2013 15:53:15 -0700
 From: dreamingforw...@gmail.com
 To: types-l...@lists.seas.upenn.edu
 Subject: Re: [TYPES] The type/object distinction and possible synthesis of 
 OOP and imperative programming languages


 
 I am very thankful for the references given by everyone.
 Unfortunately my library does not have the titles and it will be some
 time before I can acquire them.

The official version of my PhD thesis is available at 
https://scholarship.rice.edu/handle/1911/70199
(A version more suitable for electronic browsing and online distribution is 
available at http://sdrv.ms/15qsJ5x )
-Moez
  -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-19 Thread Robert Kern

On 2013-04-19 10:34, Tim Roberts wrote:

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



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

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


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


You understand that this will result in a chunk of text that is not JSON?
Other JSON readers won't be able to read it.


I think he means something like this:

 json.dumps([float('nan')])
'[N/A]'

Not

'[N/A]'

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


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

2013-04-19 Thread Jason Wilkins
I don't quite think I understand what you are saying.  Are you saying that
mathematical models are not a good foundation for computer science because
computers are really made out of electronic gates?

All I need to do is show that my model reduces to some basic physical
implementation (with perhaps some allowances for infinity) and then I can
promptly forget about that messy business and proceed to use my
clean mathematical model.

The reason any model of computation exists is that it is easier to think
about a problem in some terms than in others.  By showing how to transform
one model to another you make it possible to choose exactly how you wish to
solve a problem.

The reason we do not work directly in what are called von Neumann
machines is that they are not convenient for all kinds of problems.
 However we can build a compiler to translate anything to anything else so
we I don't see why anybody would care.


On Thu, Apr 18, 2013 at 5:53 PM, Mark Janssen dreamingforw...@gmail.comwrote:

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

 On Mon, Apr 15, 2013 at 2:53 AM, Moez AbdelGawad moeza...@outlook.com
 wrote:
  I'm not quite sure I understand your question, but I'll give it a shot.
  :-)
 
  I'm in this same camp too :)

 I am very thankful for the references given by everyone.
 Unfortunately my library does not have the titles and it will be some
 time before I can acquire them.  I hope it not too intrusive to offer
 a few points that I've garnered from this conversation until I can
 study the history further.

 The main thing that I notice is that there is a heavy bias in
 academia towards mathematical models.  I understand that Turing
 Machines, for example, were originally abstract computational concepts
 before there was an implementation in hardware, so I have some
 sympathies with that view, yet, should not the Science of Computer
 Science concern itself with how to map these abstract computational
 concepts into actual computational hardware?  Otherwise, why not keep
 the field within mathematics and philosophy (where Logic traditionally
 has been)?   I find it remarkable, for example, that the simple
 continued application of And/Or/Not gates can perform all the
 computation that C.S. concerns itself with and these form the basis
 for computer science in my mind, along with Boolean logic.  (The
 implementation of digital logic into physical hardware is where C.S.
 stops and Engineering begins, I would argue.)

 But still, it seems that there are two ends, two poles, to the whole
 computer science enterprise that haven't been sufficiently *separated*
 so that they can be appreciated:  logic gates vs. logical calculus
 and symbols.   There is very little crossover as I can see.  Perhaps
 the problem is the common use of the Greek root logikos; in the
 former, it pertains to binary arithmetic, where in the latter, it
 retains it's original Greek pertaining to *speech* and symbols,
 logos).  Further, one can notice that in the former, the progression
 has been towards more sophisticated Data Structures (hence the
 evolution towards Object-Orientation), where in the latter (I'm
 guessing, since it's not my area of expertise) the progression has
 been towards function sophistication (where recursion seems to be
 paramount).

 In any case, I look forward to diving into the books and references
 you've all offered so generously so that I can appreciate the field
 and its history better.

 Mark Janssen
 Pacific Lutheran University
 Tacoma, Washington

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


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

2013-04-19 Thread Chris Angelico
On Fri, Apr 19, 2013 at 1:35 PM, rusi rustompm...@gmail.com wrote:
 If I have a loop:

  while i  len(a) and a[i] != x:
i++

 I need to understand that at the end of the loop:
 i = len(a) or a[i] == x
 and not
 i = len(a) and a[i] == x
 nor
 i == len(a) or a[i] == x  # What if I forgot to initialize i?

Or your program has crashed out with an exception.

 i,a,x=-10,test,q
 while i  len(a) and a[i] != x:
i+=1

Traceback (most recent call last):
  File pyshell#69, line 1, in module
while i  len(a) and a[i] != x:
IndexError: string index out of range

Or if that had been in C, it could have bombed with a segfault rather
than a nice tidy exception. Definitely initialize i.

But yeah, the basis of algebra is helpful, even critical, to
understanding most expression evaluators.

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


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

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

 The main thing that I notice is that there is a heavy bias in
 academia towards mathematical models.  I understand that Turing
 Machines, for example, were originally abstract computational concepts
 before there was an implementation in hardware, so I have some
 sympathies with that view, yet, should not the Science of Computer
 Science concern itself with how to map these abstract computational
 concepts into actual computational hardware?

I think there is some misunderstanding here.  Being mathematical in
academic work is a way of making our ideas rigorous and precise, instead of
trying to peddle wooly nonsense.  Providing a mathematical description does
not imply in any way that these ideas are not implementable on machines.  In
fact, very often these mathematical descriptions state precisely how to
implement the concepts (called operational semantics), but using
mathematical notation instead of program code.  The mathematical notation
used here is usually no more than high school set theory, used in a
stylized way.

In contrast, there are deeper mathematical models (called denotational
semantics and axiomatic semantics) which are invented to describe how
programming language features work in a deep, intrinsic way.  This is
similar to, for instance, how Physics invents mathematical models to capture
how the nature around us works.  Physicists don't need to implement
nature.  It has already been implemented for us before we are born.
However, to understand how it works, and how to design systems using
physical materials in a predictable way, we need the mathematical models
that Physics has develeped.

Similarly, the mathematical models of programming languages help us to
obtain a deep understanding of how languages work and how to build systems
in a predictable, reliable way.  It seems too much to expect, at the present
stage of our field, that all programmers should understand the mathematical
models.  But I would definitely expect that programming language designers
who are trying to build new languages should understand the mathematical
models.  Otherwise, they would be like automotive engineers trying to build
cars without knowing any Mechanics.

Cheers,
Uday Reddy

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


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

2013-04-19 Thread Claus Reinke

The main thing that I notice is that there is a heavy bias in
academia towards mathematical models.  I understand that Turing
Machines, for example, were originally abstract computational concepts
before there was an implementation in hardware, so I have some
sympathies with that view, yet, should not the Science of Computer
Science concern itself with how to map these abstract computational
concepts into actual computational hardware?  


I prefer to think of Turing machines as an attempt to model existing
and imagined hardware (at the time, mostly human computers, or
groups of them with comparatively simple tools). See sections 1. 
and 9. in


   Turing, On computable numbers, with an application to the 
   Entscheidungsproblem, 
   http://web.comlab.ox.ac.uk/oucl/research/areas/ieg/e-library/sources/tp2-ie.pdf


Modeling existing systems, in order to be able to reason about them,
is essential for science, as is translating models into experiments, in
order to compare predictions to reality.

Claus

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


Re: How to set my gui?

2013-04-19 Thread Alister
On Thu, 18 Apr 2013 23:24:29 +0200, Tracubik wrote:

 Hi all!
 I'm trying to make a simple program that essentially do this:
 
 1) open a html file (extracted epub file)
 2) search for occurrences like ita-ly
 3) put them on a simple GUI: 1 text field and two buttons: keepy it and
 correct it (i.e. it will become italy)
 
 now this is quite simple but how can i do it properly?
 i suppose i've to first generate the window and than populate it, but
 where i've to put the search for occurences code? I don't think init()
 is the right place..
 
 Thanks MedeoTL
One simple way
Make a method to search for the next occorance  use that as button click 
event.




-- 
Faith:  not *wanting* to know what is true.
-- Friedrich Nietzsche
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to set my gui?

2013-04-19 Thread Roland Koebler
Hi,

 These days, GUI programming is to me just
 programming and calling on certain libraries/modules.
+1

 One thing you may want to consider is using your main thread for the
 UI, and spinning off another thread to do your search. But do that
 ONLY if you know you understand threads, and threading in Python.
 Otherwise you'll make your life unnecessarily hard. :)
For simple tasks, you don't need threads, but can use the glib-functions
timeout_add(), idle_add() etc.

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


RE: subprocess.call

2013-04-19 Thread Ombongi Moraa Fe
Hi Team,

In my python script, I have this:

command=lynx -dump
'phpscript?param1=%sparam2=%sparam3=%sparam4=%sparam5=%s'%(value1,value2,value3,value4)

result=subprocess.call(command,shell=True)
print 'xml message'

However, the response from running the php script is also printed on output
screen. I don't want this output.

How can i ensure that only the last print 'xml response' is returned?

Saludos

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


Re: subprocess.call

2013-04-19 Thread Mau C
Il 19/04/2013 11:56, Ombongi Moraa Fe ha scritto:
 Hi Team,
 
 In my python script, I have this:
 
 command=lynx -dump
 'phpscript?param1=%sparam2=%sparam3=%sparam4=%sparam5=%s'%(value1,value2,value3,value4)

http://docs.python.org/2/library/subprocess.html#module-subprocess

You should set the properly values for stdou and stderr.
Under UNIX, '/dev/null' worked out fine for me, when 'None' didn't.



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


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

2013-04-19 Thread Steven D'Aprano
On Thu, 18 Apr 2013 17:14:13 -0400, Robert Harper wrote:

 In short, there is no such thing as a paradigm.  

Of course there is. A paradigm is a distinct way of thinking, a 
philosophy if you will. To say that there is no such thing as a paradigm 
is to say that all ways of thinking about a topic are the same, and 
that's clearly nonsense.

OOP is a distinct paradigm from procedural programming, even though the 
distinctions are minor when compared to those between imperative and 
functional programming. Java's everything in a class style of 
programming is very distinct from Pascal's functions and records style 
of programming, even though both are examples of imperative programming. 
They lead to different styles of coding, they have different strengths 
and weaknesses, and even taking into account differences of syntax, they 
differ in what you can do simply and naturally without the language 
getting in the way.


 I agree fully.  This
 term is a holdover from the days when people spent time and space trying
 to build taxonomies based on ill-defined superficialities.  See Steve
 Gould's essay What, If Anything, Is A Zebra?.  You'll enjoy learning
 that there is, in fact, no such thing as a zebra---there are, rather,
 three different striped horse-like mammals, two of which are genetically
 related, and one of which is not.

All life on earth is genetically related. Even if the so-called tree of 
life doesn't have a single common ancestor, it has a single set of 
common ancestors.

In the case of the three species of zebra, they are all members of the 
genus Equus, so they are actually *extremely* closely related. The 
argument that zebra is not a genealogical group (which is very 
different from the false statement that there is no such thing as a 
zebra!) is that one of the three species of zebra is in fact more closely 
related to non-zebras than the other two species of zebra.

Something like this tree:

Common ancestor of all Equus
|
+-- Common ancestor of Burchell's Zebras and Grevy's Zebras
|   +-- Burchell's Zebra
|   +-- Grevy's Zebra
|
+-- Common ancestor of horses and Mountain Zebras
+-- Horse
+-- Mountain Zebra

(I've left out asses and donkeys because I'm not sure where they fit in 
relation to the others.)

There's no natural genealogical group that includes all three species of 
zebra that doesn't also include horses. But that doesn't mean that 
there's no reasonable non-genealogical groups! For example, all three 
species of zebra have fewer than 50 chromosome pairs, while all other 
Equus species have more than 50 pairs. Based on physical characteristics 
rather than ancestry, zebras make up a perfectly good group, distinct 
from other members of Equus.

To put it another way, the three species of zebra may not make up a 
natural group when considered by lines of descent, but they do make up a 
natural group when considered by other factors.


 The propensity to be striped, like
 the propensity to have five things (fingers, segments, whatever) is a
 deeply embedded genetic artifact that expresses itself in various ways.

Zebra is not a classification of thing that is striped, but a 
specific subset of such things, and stripes are only one of many 
distinguishing features. Cladistics is an important classification 
scheme, but it is not the only valid such scheme.


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


Re: dynamic forms generation

2013-04-19 Thread andrea crotti
Well I think since we are using django anyway (and bottle on the API side)
I'm not sure why we would use flask forms for this..

Anyway the main question is probably, is it worth to try to define a DSL or
not?
The problem I see is that we have a lot and very complex requirements,
trying to define a DSL that is able to represent everything might be a
massive pain.

I prefer to do something smart with metaclasses and just use Python as the
configuration language itself, using metaclasses and similar nice things to
define the language used..
The only annoying part is the persistance, I don't like too much the idea
to store Python code in the db for example, but maybe it's fine, many
projects configure things with Python anyway..
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Roy Smith
In article 517131cd$0$29977$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 On Thu, 18 Apr 2013 17:14:13 -0400, Robert Harper wrote:
 
  In short, there is no such thing as a paradigm.  
 
 Of course there is. A paradigm is a distinct way of thinking, a 
 philosophy if you will. To say that there is no such thing as a paradigm 
 is to say that all ways of thinking about a topic are the same, and 
 that's clearly nonsense.

This thread has gone off in a strange direction.  When I said:

 One of the nice things about OOP is it means so many different things to 
 different people.  All of whom believe with religious fervor that they 
 know the true answer.

I was indeed talking about the ways people think about programming.  For 
example, OOP in C++ is very much about encapsulation.  People declare 
all data private, and writing setter/getter functions which carefully 
control what access outside entities have to your data.

Often, when you talk to C++ people, they will tell you that 
encapsulation is what OOP is all about.  What they are doing is saying, 
C++ isa OOPL, and C++ has encapsulation, therefore OOPL implies 
encapsulation.  When they look at something like Python, they say, 
That's not object oriented because you don't have private data.

I suppose people who grew up learning Python as their first language 
look at something like C++ and say, That's not OOP because classes 
aren't objects, or something equally silly.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Chris Angelico
On Fri, Apr 19, 2013 at 11:07 PM, Roy Smith r...@panix.com wrote:
 I was indeed talking about the ways people think about programming.  For
 example, OOP in C++ is very much about encapsulation.  People declare
 all data private, and writing setter/getter functions which carefully
 control what access outside entities have to your data.

The funny thing about that notion is that, even in C++, it's
completely optional. I've subclassed someone else's class using a
struct and just left everything public. In fact, I've gotten so used
to the Python way of doing things that now I'm quite happy to run
everything public anyway.

Is OOP truly about X if X is optional?

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


Request

2013-04-19 Thread usman mjoda
Good day, I need help on how to upgradean SAES to AES 128 bits. thank you

-- 
*Usman M. Joda (zhoda), *
*
*
* *
*Master Student of Computer Science  Technology,*
* *
*
*
* *
*Liaoning University Of Technology (LUT),
*
* *
*
*
* *
*+8613840619645*
* *
* usmanjo...@yahoo.com
*
* *
*
Zhinzou- China*
-- 
http://mail.python.org/mailman/listinfo/python-list


Feature Request: `operator.not_in`

2013-04-19 Thread Matthew Gilson
I believe that I read somewhere that this is the place to start 
discussions on feature requests, etc.  Please let me know if this isn't 
the appropriate venue (and what the appropriate venue would be if you know).


This request has 2 related parts, but I think they can be considered 
seperately:


1) It seems to me that the operator module should have a `not_in` or 
`not_contains` function.  It seems asymmetric that there exists a 
`is_not` function which implements `x is not y` but there isn't a 
function to represent `x not in y`.


2) I suspect this one might be a little more controversial, but it seems 
to me that there should be a separate magic method bound to the `not in` 
operator.  Currently, when inspecting the bytecode, it appears to me 
that `not x in y` is translated to `x not in y` (this supports item 1 
slightly).  However, I don't believe this should be the case.  In 
python, `x  y` does not imply `not x = y` because a custom object can 
do whatever it wants with `__ge__` and `__lt__` -- They don't have to 
fit the normal mathematical definitions.  I don't see any reason why 
containment should behave differently.  `x in y` shouldn't necessarily 
imply `not x not in y`.  I'm not sure if `object` could have a default 
`__not_contains__` method (or whatever name seems most appropriate) 
implemented equivalently to:


 def __not_contains__(self,other):
  return not self.__contains__(other)

If not, it could probably be provided by something like 
`functools.total_ordering`.  Anyway, it's food for thought and I'm 
interested to see if anyone else feels the same way that I do.


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


Re: How to set my gui?

2013-04-19 Thread Tracubik

On 19/04/2013 10:42, Alister wrote:

On Thu, 18 Apr 2013 23:24:29 +0200, Tracubik wrote:


Hi all!
I'm trying to make a simple program that essentially do this:

1) open a html file (extracted epub file)
2) search for occurrences like ita-ly
3) put them on a simple GUI: 1 text field and two buttons: keepy it and
correct it (i.e. it will become italy)

now this is quite simple but how can i do it properly?
i suppose i've to first generate the window and than populate it, but
where i've to put the search for occurences code? I don't think init()
is the right place..

Thanks MedeoTL

One simple way
Make a method to search for the next occorance  use that as button click
event.



Mmmmh, this seem good to me. But i also need to add some code in the 
__init__() of the GUI class to get the first occurence and put it in the 
text field.


Thanks for your reply, you was really helpful

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


Re: subprocess.call

2013-04-19 Thread Jens Thoms Toerring
Ombongi Moraa Fe moraa.lovetak...@gmail.com wrote:
 [-- text/plain, encoding 7bit, charset: ISO-8859-1, 19 lines --]

 In my python script, I have this:

 command=lynx -dump
 'phpscript?param1=%sparam2=%sparam3=%sparam4=%sparam5=%s'%(value1,value2,value3,value4)

 result=subprocess.call(command,shell=True)
 print 'xml message'

 However, the response from running the php script is also printed on output
 screen. I don't want this output.

 How can i ensure that only the last print 'xml response' is returned?

You mean is printed out? Use subprocess.Popen() and redirect
stdout to a pipe, similar to this:

 p = subprocess.Popen(command, stdout=subprocess.PIPE)
 r = p.communicate()
 print r[0]   # This is the output (to stdout)

The return value of the Popen objects communicate() method is
a tuple with two elements, first contains what got written to
stdout (if redirected to a pipe, otherwise Nome), the second
what went to stderr (again if redirected to a pipe). If you
also redirect stdin then you can pass what you want to send
to the process spawned via Popen() as an argument to commu-
nicate().

BTW, according to the dicumentation you should split the
command line into its componenents and pass that as a list
to the call() or Popen() subprocess methods, so it would
seem to reasonable to use e.g.

 command = [ 'lynx', '-dump',
 ( 'phpscript?param1={0}param2={1}param3={2}
   param4={3}param5={4}' )
 .format( value1, value2, value3, value4, value5 ) ]


Note that there was one value for creating the string to be
passed to lynx was mising.
   Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-19 Thread Grant Edwards
On 2013-04-18, Wayne Werner wa...@waynewerner.com wrote:
 On Wed, 17 Apr 2013, Miki Tebeka wrote:

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

 Why not use `null` instead? It seems to be semantically more similar...

Why not use 'NaN' instead? It seems to be even more semantically
similar...

-- 
Grant Edwards   grant.b.edwardsYow! I want a VEGETARIAN
  at   BURRITO to go ... with
  gmail.comEXTRA MSG!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: howto remove the thousand separator

2013-04-19 Thread Duncan Booth
pyth0n3r pyth0...@gmail.com wrote:

 I came across a problem that when i deal with int data with ',' as
 thousand separator, such as 12,916, i can not change it into int() or
 float(). How can i remove the comma in int data?
 Any reply will be appreciated!!
 

Parse it using the locale module, just be sure to set the correct locale 
first:

 import locale
 locale.setlocale(locale.LC_ALL, '')
'English_United Kingdom.1252'
 locale.atoi('1,000')
1000
 locale.atof('1,000')
1000.0
 locale.setlocale(locale.LC_ALL, 'French_France')
'French_France.1252'
 locale.atof('1,000')
1.0


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Roy Smith
In article mailman.821.1366378384.3114.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Fri, Apr 19, 2013 at 11:07 PM, Roy Smith r...@panix.com wrote:
  I was indeed talking about the ways people think about programming.  For
  example, OOP in C++ is very much about encapsulation.  People declare
  all data private, and writing setter/getter functions which carefully
  control what access outside entities have to your data.
 
 The funny thing about that notion is that, even in C++, it's
 completely optional.

Well, yeah:

#define private public
#define protected public
#include whatever.h

Not to mention all sorts of horrible things you can do with pointers and 
const_cast, etc.  But that doesn't stop people from thinking that 
somehow they've built some uber-protected cocoon around their data, and 
that this is part and parcel of what OOPL is all about.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Chris Angelico
On Sat, Apr 20, 2013 at 1:31 AM, Roy Smith r...@panix.com wrote:
 #define private public
 #define protected public
 #include whatever.h

And:
#define class struct

But what I mean is that, _in my design_, I make everything public. No
getters/setters, just direct member access. The theory behind getters
and setters is that you can change the implementation without changing
the interface... but I cannot remember a *single time* when I have
made use of that flexibility. Not one. Nor a time when I've wished for
that flexibility, after coding without it. No no, not one!

ChrisA
(He's telling the truth, he is not Mabel.)
-- 
http://mail.python.org/mailman/listinfo/python-list


python : how to Opens folder with specified items selected on Windows

2013-04-19 Thread iMath
I want to Opens folder with specified items selected on Windows ,I looked up 
the The Windows Shell Reference found a function fit for this job 
 
SHOpenFolderAndSelectItems
 
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762232(v=vs.85).aspx
 
but I cannot find an example on how to use it with python 
 
so anyone can give a little example ?
 
I have another extra requirement :if that folder already open ,don??t open it 
again ,just activate it and selected the file-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Roy Smith
In article mailman.824.1366386029.3114.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Sat, Apr 20, 2013 at 1:31 AM, Roy Smith r...@panix.com wrote:
  #define private public
  #define protected public
  #include whatever.h
 
 And:
 #define class struct

I suppose, while we're at it:

# define const 

(I think that works, not sure).

PS: a great C++ interview question is, What's the difference between a 
class and a struct?  Amazing how few self-professed C++ experts have no 
clue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python : how to Opens folder with specified items selected on Windows

2013-04-19 Thread Tim Golden
On 19/04/2013 16:54, iMath wrote:
 I want to Opens folder with specified items selected on Windows ,I
 looked up the The Windows Shell Reference found a function fit for this job
 
 SHOpenFolderAndSelectItems
 
 http://msdn.microsoft.com/en-us/library/windows/desktop/bb762232(v=vs.85).aspx
 
 but I cannot find an example on how to use it with python
 
 so anyone can give a little example ?
 
 I have another extra requirement :if that folder already open ,don’t
 open it again ,just activate it and selected the file 

Have a look over here:

  http://mail.python.org/pipermail/python-win32/2012-September/012533.html

TJG

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


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

2013-04-19 Thread Steven D'Aprano
On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith wrote:

 PS: a great C++ interview question is, What's the difference between a
 class and a struct?  Amazing how few self-professed C++ experts have no
 clue.

I'm not a C++ expert, but I am an inquiring mind, and I want to know the 
answer!


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


New release 0.19 of the Cython compiler

2013-04-19 Thread Stefan Behnel
I'm happy to announce that Cython 0.19 has been released. This is a feature
release of the Cython compiler that adds some major usability improvements
especially for code that needs to run in both Py2 and Py3, as well as
better Python compatibility and optimisations.

http://cython.org/


You can get it from here:

http://cython.org/release/Cython-0.19.tar.gz

http://cython.org/release/Cython-0.19.zip

Release notes:
https://github.com/cython/cython/blob/29bf3493fdc80cb3261a9dfb9f73e3ccd46fec66/CHANGES.rst

Documentation: http://docs.cython.org/


Major new features in this release:
===

* New directives ``c_string_type`` and ``c_string_encoding`` to
  automatically convert between C strings and the different Python
  string types.

* Keyword arguments are supported for cdef functions, including external
  C/C++ library functions.

* New freelist decorator for extension types.

* Fast extension type instantiation using the ``Type.__new__(Type)`` idiom
  has gained support for passing arguments.

* Slicing was optimised for several builtin types and otherwise conforms
  better with Python semantics for user defined types.

* The mapping of dict view/item methods in Python 3 was improved.


What is Cython?
===

Cython is an optimising static compiler for both the Python programming
language and the extended Cython programming language (based on Pyrex). It
makes writing C extensions for Python as easy as Python itself.

The Cython language is a superset of the Python language that additionally
supports calling C functions and declaring C types on variables and class
attributes. This allows the compiler to generate very efficient C code from
Cython code. The C code is generated once and then compiles with all major
C/C++ compilers in CPython 2.4 and later, including Python 3.x.

All of this makes Cython the ideal language for wrapping external C
libraries, embedding CPython into existing applications, and for fast C
modules that speed up the execution of Python code.


See the project home page for further information:

http://cython.org/


Have fun,

Stefan

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


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

2013-04-19 Thread Serhiy Storchaka

18.04.13 19:24, James Jong написав(ла):

The file libtk8.6.so http://libtk8.6.so  has 1.5M and is definitely there.

So why did that compilation fail?


LD_LIBRARY_PATH=/path_to_libtk

However be careful. For now Python doesn't support Tk 8.6 (results of 
some functions changed in 8.6), this is a known bug (issue16809). You 
can build Python with Tk 8.6 and even run, but any real tkinter 
application likely will failed. Use Tk 8.5 instead.



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


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

2013-04-19 Thread Steven D'Aprano
On Fri, 19 Apr 2013 09:07:15 -0400, Roy Smith wrote:

 Often, when you talk to C++ people, they will tell you that
 encapsulation is what OOP is all about.  What they are doing is saying,
 C++ isa OOPL, and C++ has encapsulation, therefore OOPL implies
 encapsulation.  When they look at something like Python, they say,
 That's not object oriented because you don't have private data.
 
 I suppose people who grew up learning Python as their first language
 look at something like C++ and say, That's not OOP because classes
 aren't objects, or something equally silly.

You might say that, but I find in my experience that Python users don't 
tend to fall for the No True Scotsman fallacy anywhere near as often as 
(say) Java or C++ users. I'm not sure what the reason for this is. 
Perhaps it is that the Python community as a whole is more open to other 
languages and paradigms, and less stuffed to the gills with code monkeys 
who only know how to copy and paste code from StackOverflow. The Python 
community frequently tosses around references to other languages, 
compares how Python would do something to other languages, or relates how 
certain features were borrowed from language X (e.g. list comprehensions 
are taken from Haskell; map, filter and reduce are taken from Lisp). But 
when I read forums and blogs about (say) Java, it's nearly always about 
Java in isolation, and one would be forgiven for thinking it was the only 
programming language in existence.

I don't think that there is One True Way to design an OOP language, but I 
do think there are *degrees* of OOP. Java, for instance, I would say is 
only moderately OOP, since classes aren't objects, and it supports 
unboxed native types. I think the first part of that is a weakness, and 
the second is a pragmatic decision that on balance probably is a 
strength. Yes, Python's everything is an object is a cleaner design, 
but Java's unboxed types leads to faster code.

It also depends on what you mean by OOP. If we judge Python by the fact 
that everything is an object, then it is strongly OOP. But if we judge 
Python by its syntax and idioms, it is only weakly OOP, even less than 
Java. 


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


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

2013-04-19 Thread Ned Batchelder

On 4/19/2013 12:16 PM, Steven D'Aprano wrote:

On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith wrote:


PS: a great C++ interview question is, What's the difference between a
class and a struct?  Amazing how few self-professed C++ experts have no
clue.

I'm not a C++ expert, but I am an inquiring mind, and I want to know the
answer!


The only difference between a class and a struct is that classes default 
to private access for their members, and structs default to public.


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


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

2013-04-19 Thread Ian Kelly
On Fri, Apr 19, 2013 at 4:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith wrote:

 PS: a great C++ interview question is, What's the difference between a
 class and a struct?  Amazing how few self-professed C++ experts have no
 clue.

 I'm not a C++ expert, but I am an inquiring mind, and I want to know the
 answer!

C++ class members are private by default; struct members are public by
default.  That's the only difference as I recall.
-- 
http://mail.python.org/mailman/listinfo/python-list


Ubuntu package python3 does not include tkinter

2013-04-19 Thread lcrocker
Am I mistaken in my belief that tkinter is a non-optional part of the
Python language? I installed the python3 package on Ubuntu, and
tkinter is not included--it's an optional package python3-tk that
has to be installed separately. I reported this as a bug as was
summarily slapped down.

Can we apply some pressure to Ubuntu to fix this? Python is a
trademark, is it not? Can Ubuntu legally claim that their Python
package is an implementation of the language if it does not include
the whole language?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Joel Goldstick
On Fri, Apr 19, 2013 at 1:17 PM, lcrocker l...@piclab.com wrote:

 Am I mistaken in my belief that tkinter is a non-optional part of the
 Python language? I installed the python3 package on Ubuntu, and
 tkinter is not included--it's an optional package python3-tk that
 has to be installed separately. I reported this as a bug as was
 summarily slapped down.

 Can we apply some pressure to Ubuntu to fix this? Python is a
 trademark, is it not? Can Ubuntu legally claim that their Python
 package is an implementation of the language if it does not include
 the whole language?
 --
 http://mail.python.org/mailman/listinfo/python-list


From here: http://wiki.python.org/moin/TkInter

Does this help?

Try the correct command for your version at the Python prompt:

 import Tkinter # no underscore, uppercase 'T' for versions prior to V3.0

 import tkinter # no underscore, lowercase 't' for V3.0 and later


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread lcrocker
Thanks, but I'm not having any trouble running tkinter, it works just
fine. I have an issue with the fact that it's optional. It reflects
badly on the language and community if we allow just anyone to call
something Python that doesn't meet some minimum standard of quality.
Java has its compliance tests: if your implementation doesn't pass,
you can't call it Java. I'm asking if there's something similar for
Python, because Ubuntu's Python 3 doesn't pass the test.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Andrew Berg
On 2013.04.19 12:17, lcrocker wrote:
 Am I mistaken in my belief that tkinter is a non-optional part of the
 Python language? I installed the python3 package on Ubuntu, and
 tkinter is not included--it's an optional package python3-tk that
 has to be installed separately. I reported this as a bug as was
 summarily slapped down.
Forcing Tkinter as a dependency would result in a ton of things being installed 
to support it. Why should a web server using Django have X
installed and running because Python /can/ support a GUI in the standard 
library? It's trivial to install Tkinter if you need it, but it
would be a huge mess to try to remove it from an installation that requires it 
- even if you never use Tkinter. Ubuntu is far from alone
here. FreeBSD (and probably the other BSDs) and most Linux distros do something 
similar. There is zero reason to force Tkinter and its
dependencies on all Python users.
-- 
CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread lcrocker
On Apr 19, 10:35 am, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2013.04.19 12:17, lcrocker wrote: Am I mistaken in my belief that tkinter 
 is a non-optional part of the
  Python language? I installed the python3 package on Ubuntu, and
  tkinter is not included--it's an optional package python3-tk that
  has to be installed separately. I reported this as a bug as was
  summarily slapped down.

 Forcing Tkinter as a dependency would result in a ton of things being 
 installed to support it. Why should a web server using Django have X
 installed and running because Python /can/ support a GUI in the standard 
 library? It's trivial to install Tkinter if you need it, but it
 would be a huge mess to try to remove it from an installation that requires 
 it - even if you never use Tkinter. Ubuntu is far from alone
 here. FreeBSD (and probably the other BSDs) and most Linux distros do 
 something similar. There is zero reason to force Tkinter and its
 dependencies on all Python users.
 --
 CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1

I understand that for something like a server distribution, but Ubuntu
is a user-focused desktop distribution. It has a GUI, always. The
purpose of a distro like that is to give users a good experience. If I
install Python on Windows, I get to use Python. On Ubuntu, I don't,
and I think that will confuse some users. I recently recommended
Python to a friend who wants to start learning programming. Hurdles
like this don't help someone like him.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Peter Otten
lcrocker wrote:

 Am I mistaken in my belief that tkinter is a non-optional part of the
 Python language? I installed the python3 package on Ubuntu, and
 tkinter is not included--it's an optional package python3-tk that
 has to be installed separately. I reported this as a bug as was
 summarily slapped down.
 
 Can we apply some pressure to Ubuntu to fix this? Python is a
 trademark, is it not? Can Ubuntu legally claim that their Python
 package is an implementation of the language if it does not include
 the whole language?

Thank you for bringing this criminal offense to our attention. Right now a 
PSU team is readying their black helicopters to get Mr Shuttleworth and his 
accompli

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


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread rusi
On Apr 19, 10:42 pm, lcrocker leedanielcroc...@gmail.com wrote:
 On Apr 19, 10:35 am, Andrew Berg bahamutzero8...@gmail.com wrote:

  On 2013.04.19 12:17, lcrocker wrote: Am I mistaken in my belief that 
  tkinter is a non-optional part of the
   Python language? I installed the python3 package on Ubuntu, and
   tkinter is not included--it's an optional package python3-tk that
   has to be installed separately. I reported this as a bug as was
   summarily slapped down.

  Forcing Tkinter as a dependency would result in a ton of things being 
  installed to support it. Why should a web server using Django have X
  installed and running because Python /can/ support a GUI in the standard 
  library? It's trivial to install Tkinter if you need it, but it
  would be a huge mess to try to remove it from an installation that requires 
  it - even if you never use Tkinter. Ubuntu is far from alone
  here. FreeBSD (and probably the other BSDs) and most Linux distros do 
  something similar. There is zero reason to force Tkinter and its
  dependencies on all Python users.
  --
  CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1

 I understand that for something like a server distribution, but Ubuntu
 is a user-focused desktop distribution. It has a GUI, always. The
 purpose of a distro like that is to give users a good experience. If I
 install Python on Windows, I get to use Python. On Ubuntu, I don't,
 and I think that will confuse some users. I recently recommended
 Python to a friend who wants to start learning programming. Hurdles
 like this don't help someone like him.

Well I guess you could take the example of kde.
kde has a kde-standard and a kde-full.
Likewise one could imagine python-standard being what is currently
called python and python-full pulling in other dependencies like
tkinter.
If there were a number of such it may even make sense, if not it looks
like overkill (to me)
-- 
http://mail.python.org/mailman/listinfo/python-list


unzipping a zipx file

2013-04-19 Thread b_erickson1
I have python 2.6.2 and I trying to get it to unzip a file made with winzip 
pro.  The file extension is zipx.  This is on a windows machine where I have to 
send them all that files necessary to run.  I am packaging this with py2exe.  I 
can open the file with 
zFile = zipfile.ZipFile(fullPathName,'r')
and I can look through all the file in the archive 
for filename in zFile.namelist():
but when I write the file out with this code:
ozFile = open(filename,'w')
ozFile.write(zFile.read(filename))
ozFile.close()
that file still looks encrypted.  No errors are thrown.  The file is just a 
text file not a jpeg or anything else.  I can open the file with 7zip and 
extract the text file out just fine.  


What am I missing?

Thanks 

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


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Andrew Berg
On 2013.04.19 12:42, lcrocker wrote:
 I understand that for something like a server distribution, but Ubuntu
 is a user-focused desktop distribution. It has a GUI, always.
That is incorrect.
http://www.ubuntu.com/server

-- 
CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-19 Thread Chris “Kwpolska” Warrick
On Fri, Apr 19, 2013 at 4:54 PM, Grant Edwards invalid@invalid.invalid wrote:
 On 2013-04-18, Wayne Werner wa...@waynewerner.com wrote:
 On Wed, 17 Apr 2013, Miki Tebeka wrote:

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

 Why not use `null` instead? It seems to be semantically more similar...

 Why not use 'NaN' instead? It seems to be even more semantically
 similar...

Because there is no NaN in JSON?  Unless you mean a string, which
makes no semantical sense and is human-oriented and not
machine-oriented.

--
Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feature Request: `operator.not_in`

2013-04-19 Thread Terry Jan Reedy

On 4/19/2013 10:27 AM, Matthew Gilson wrote:
) It seems to me that the operator module should have a `not_in` or

`not_contains` function.  It seems asymmetric that there exists a
`is_not` function which implements `x is not y` but there isn't a
function to represent `x not in y`.


There is also no operator.in.
There is operator.contains and operator.__contains__.
There is no operator.not_contains because there is no __not_contains__ 
special method. (Your point two, which I disagree with.)



2) I suspect this one might be a little more controversial, but it seems
to me that there should be a separate magic method bound to the `not in`
operator.


The reference manual disagrees.
The operator not in is defined to have the inverse true value of in.


 Currently, when inspecting the bytecode, it appears to me
that `not x in y` is translated to `x not in y` (this supports item 1
slightly).  However, I don't believe this should be the case.  In
python, `x  y` does not imply `not x = y` because a custom object can
do whatever it wants with `__ge__` and `__lt__` -- They don't have to
fit the normal mathematical definitions.


The reason for this is that the rich comparisons do not have to return 
boolean values, and do not for numarray arrays which, I believe, 
implement the operators itemwise.


 I don't see any reason why containment should behave differently.

'Design by analogy' is tricky because analogies often leave out 
important details. __contains__ *is* expected to return true/false.


 object.__contains__(self, item)
Called to implement membership test operators. Should return true 
if item is in self, false otherwise


--
Terry Jan Reedy


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


Re: unzipping a zipx file

2013-04-19 Thread John Gordon
In mailman.834.1366394500.3114.python-l...@python.org b_erickson1 
br...@dashley.net writes:

 ozFile = open(filename,'w')
 ozFile.write(zFile.read(filename))
 ozFile.close()

Perhaps you want to use zFile.extract() instead of zFile.read()?

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

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


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Terry Jan Reedy

On 4/19/2013 1:17 PM, lcrocker wrote:

Am I mistaken in my belief that tkinter is a non-optional part of the
Python language?


Yes. The PSF CPython Windows installer makes installation of 
tcl/tk/tkinter optional. The build files will compile and build Python 
without tkinter and without other modules that depend on other c 
libraries (example, lzma). I believe one can build python 2 without 
unicode, which is much more 'core' than the Tkinter module.



I installed the python3 package on Ubuntu, and
tkinter is not included--it's an optional package python3-tk that
has to be installed separately. I reported this as a bug as was
summarily slapped down.


I hope it was done politely ;-).

Overall, Ubuntu is relatively advanced in moving to new versions. I 
believe I read that they are hoping to make 3.3 the default Python as 
soon as possible.



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


Re: unzipping a zipx file

2013-04-19 Thread John Gordon
In kks2mi$54d$1...@reader1.panix.com John Gordon gor...@panix.com writes:

 In mailman.834.1366394500.3114.python-l...@python.org b_erickson1 
 br...@dashley.net writes:

  ozFile = open(filename,'w')
  ozFile.write(zFile.read(filename))
  ozFile.close()

 Perhaps you want to use zFile.extract() instead of zFile.read()?

No, that's not it.  Your code should work.

You said the output file 'looks encrypted'.  Is the source zip file
encrypted?

Is the source text file something other than plain ASCII?

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

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


Toolbar and PyQT

2013-04-19 Thread lionelgreenstreet
Hi,
i'm new with python, so i need an help about this problem.
I've implemented a toolbar in a QDialog box:

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as 
NavigationToolbar

.

self.toolbar = NavigationToolbar(self.canvas, self)

I've found this code on internet. I have two question:
1. How i can set that toolbar (if possible) with QtDesigner?
2. If i want to modify that toolbar, for example adding a function during axis 
settings, is it possible?
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode issue with Python v3.3

2013-04-19 Thread Νίκος Γκρ33κ
Hello Cameron,

Did you received my yesterday's mail?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feature Request: `operator.not_in`

2013-04-19 Thread Matthew Gilson


On 4/19/13 2:27 PM, Terry Jan Reedy wrote:

On 4/19/2013 10:27 AM, Matthew Gilson wrote:
) It seems to me that the operator module should have a `not_in` or

`not_contains` function.  It seems asymmetric that there exists a
`is_not` function which implements `x is not y` but there isn't a
function to represent `x not in y`.


There is also no operator.in.


True.  I'm not arguing that there should be ...

There is operator.contains and operator.__contains__.


Thankfully :-)


There is no operator.not_contains because there is no __not_contains__ 
special method. (Your point two, which I disagree with.)


But there's also no special method `__is_not__`, but there's a 
corresponding `is_not` in the operator module so I don't really see that 
argument.  It's a matter of functionality that I'm thinking about in the 
first part.


 itertools.starmap(operator.not_in,x,y)

vs.

itertools.starmap(lambda a,b: a not in b,x,y)

Pretty much every other operator in python (that I can think of) has an 
analogous function in the operator module.



2) I suspect this one might be a little more controversial, but it seems
to me that there should be a separate magic method bound to the `not in`
operator.


The reference manual disagrees.
The operator not in is defined to have the inverse true value of in.


I would still leave that as the default behavior.  It's by far the most 
useful and commonly expected.  And I suppose if you *can't* have default 
behavior like that because that is a special case in itself, then that 
makes this second part of the request dead in the water at the outset 
(and I can live with that explanation).



 Currently, when inspecting the bytecode, it appears to me
that `not x in y` is translated to `x not in y` (this supports item 1
slightly).  However, I don't believe this should be the case. In
python, `x  y` does not imply `not x = y` because a custom object can
do whatever it wants with `__ge__` and `__lt__` -- They don't have to
fit the normal mathematical definitions.


The reason for this is that the rich comparisons do not have to return 
boolean values, and do not for numarray arrays which, I believe, 
implement the operators itemwise.


Yes, you're correct about numpy arrays behaving that way.  It can be 
very useful for indexing them.


It would also be fine for a special method `__not_contains__` to be 
expected to return a boolean value as well.  It could still be very 
useful.  Consider a finite square well from quantum mechanics.  I could 
define `in` for my particle in the square well to return `True` if there 
is a 70% chance that it is located in the well (It's a wave-function, so 
it doesn't have a well defined position -- the particle could be anyway, 
but 7 out of 10 measurements will tell me it's in the well).  It might 
be nice if I could define `not in` to be  `True` if there is only a 30% 
chance that it is in the well.  Of course, this leaves us with a 
no-man's land around the 50% mark.  Is it in the well or not?  There's 
no telling.  I'm sure you could argue that this sort of thing *could* be 
done with rich comparisons, but I would consider that a deflection from 
the point at hand.  It seems it should be up to the user to design the 
API most suited for their task.  Or what about a `Fraternity` class.  
Are the new pledges in the fraternity or not?  Maybe they should be 
considered neither in, nor out until pledge season is over.



 I don't see any reason why containment should behave differently.

'Design by analogy' is tricky because analogies often leave out 
important details. __contains__ *is* expected to return true/false.


 object.__contains__(self, item)
Called to implement membership test operators. Should return true 
if item is in self, false otherwise


--
Terry Jan Reedy




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


Re: Encoding NaN in JSON

2013-04-19 Thread Grant Edwards
On 2013-04-19, Chris ???Kwpolska??? Warrick kwpol...@gmail.com wrote:
 On Fri, Apr 19, 2013 at 4:54 PM, Grant Edwards invalid@invalid.invalid 
 wrote:
 On 2013-04-18, Wayne Werner wa...@waynewerner.com wrote:
 On Wed, 17 Apr 2013, Miki Tebeka wrote:

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

 Why not use `null` instead? It seems to be semantically more similar...

 Why not use 'NaN' instead? It seems to be even more semantically
 similar...

 Because there is no NaN in JSON?  Unless you mean a string, which
 makes no semantical sense and is human-oriented and not
 machine-oriented.

The OP asked for a string, and I thought you were proposing the string
'null'.  If one is to use a string, then 'NaN' makes the most sense,
since it can be converted back into a floating point NaN object.

I infer that you were proposing a JSON null value and not the string
'null'?

-- 
Grant Edwards   grant.b.edwardsYow! I'm receiving a coded
  at   message from EUBIE BLAKE!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-19 Thread Miki Tebeka
  You understand that this will result in a chunk of text that is not JSON?
 I think he means something like this:
   json.dumps([float('nan')])
 '[N/A]'
That's exactly what I mean :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unzipping a zipx file

2013-04-19 Thread Dave Angel

On 04/19/2013 01:59 PM, b_erickson1 wrote:

I have python 2.6.2 and I trying to get it to unzip a file made with winzip 
pro.  The file extension is zipx.  This is on a windows machine where I have to 
send them all that files necessary to run.  I am packaging this with py2exe.  I 
can open the file with
zFile = zipfile.ZipFile(fullPathName,'r')
and I can look through all the file in the archive
for filename in zFile.namelist():
but when I write the file out with this code:
 ozFile = open(filename,'w')
 ozFile.write(zFile.read(filename))
 ozFile.close()
that file still looks encrypted.  No errors are thrown.  The file is just a 
text file not a jpeg or anything else.  I can open the file with 7zip and 
extract the text file out just fine.


What am I missing?

Thanks



The second parameter to ZipFile() probably should be 'rb' not 'r'

Likewise, I'd suggest using 'wb' on the output file, though that's not 
your problem here.


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


Re: unzipping a zipx file

2013-04-19 Thread Tim Chase
On 2013-04-19 16:29, Dave Angel wrote:
  zFile = zipfile.ZipFile(fullPathName,'r')
 
 The second parameter to ZipFile() probably should be 'rb' not 'r'

Just for the record, the zipfile.ZipFile.__init__ maps r to open the
file with rb, so that's not the issue.

Your suggestion about opening the file to write in binary mode is a
good one, but I'd just suggest using ZipFile.extract(...) which is
built in and takes care of writing the file for you. :-)

-tkc


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


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

2013-04-19 Thread Roy Smith
I wrote:
  I suppose people who grew up learning Python as their first language
  look at something like C++ and say, That's not OOP because classes
  aren't objects, or something equally silly.
 

In article 517172e7$0$29977$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 You might say that, but I find in my experience that Python users don't 
 tend to fall for the No True Scotsman fallacy anywhere near as often as 
 (say) Java or C++ users.

Now that I think about it, I suspect relatively few people learned 
Python as their first programming language.

Java, for example, is very popular as a teaching language in colleges 
and universities.  There are lots of people who go through a 4-year 
program, do all of their coursework in Java, and come out as one-trick 
ponies.

There aren't many schools who teach Python as a first (and only 
language), but I suppose it's starting to catch on.  5 years from now, 
we may see waves of kids graduating from college knowing nothing but 
Python, with a similarly narrow view of the universe.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Roy Smith
In article mailman.843.1366412626.3114.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith r...@panix.com declaimed
 the following in gmane.comp.python.general:
 
  PS: a great C++ interview question is, What's the difference between a 
  class and a struct?  Amazing how few self-professed C++ experts have no 
  clue.
 
   It's been 15+ years but...
 
   class defaults to private;  struct defaults to public... (very
 simplified G)

You were doing well until you added the very simplified part :-)  That 
is indeed the only difference.

Many people are surprised that you can write member functions for 
structs.  Or that you can subclass (substruct?) them.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-04-19 Thread Steven D'Aprano
On Fri, 19 Apr 2013 19:37:38 -0400, Roy Smith wrote:

 There aren't many schools who teach Python as a first (and only
 language), but I suppose it's starting to catch on.  5 years from now,
 we may see waves of kids graduating from college knowing nothing but
 Python, with a similarly narrow view of the universe.

Send the young whipper-snappers here, we'll soon learn 'em better!



-- 
Steven


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


Re: Ubuntu package python3 does not include tkinter

2013-04-19 Thread Steven D'Aprano
On Fri, 19 Apr 2013 10:17:58 -0700, lcrocker wrote:

 Am I mistaken in my belief that tkinter is a non-optional part of the
 Python language? I installed the python3 package on Ubuntu, and
 tkinter is not included--it's an optional package python3-tk that has
 to be installed separately. I reported this as a bug as was summarily
 slapped down.

Personally, I think that is a silly design by Ubuntu, but tkinter is 
optional and they're free to distribute Python with or without it. That 
becomes a *quality of implementation* issue: some distributions may be 
more complete, easier to install, more up-to-date, etc. than others, but 
they're still Python.

There is Python the language, which is distinct from the CPython 
implementation (to say nothing of other implementations like Jython, 
IronPython, Stackless, PyPy, ...), and then there is the standard 
library. Much of the standard library is optional, although unfortunately 
the documentation doesn't really make that as clear as it should.

Tkinter depends on you have Tk/Tcl installed, which on Linux and Unix 
systems depends on you having X installed. Personally, I think that a 
good packaging system should ensure that once you install Tk/Tcl, tkinter 
should just work. But there may be technical reasons why this is 
impossible.

If you ever build Python from source, you will often get warnings that it 
could not build certain modules. I spent a fruitless couple of hours last 
week trying to install Python 2.7 from scratch with sqlite, before giving 
up. What I got was still Python 2.7. It was just Python 2.7 without 
sqlite (and four or five other modules, which I don't care about and 
don't remember).


 Can we apply some pressure to Ubuntu to fix this? Python is a trademark,
 is it not? Can Ubuntu legally claim that their Python package is an
 implementation of the language if it does not include the whole
 language?

Tkinter is not part of the language. The tkinter module is an interface 
to another language, not part of Python the language itself. There are 
platforms where Tk/Tcl do not exist, platforms which may not even have a 
GUI environment at all. Do you really intend to say that it is forbidden 
to have Python on such platforms?



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


Re: unzipping a zipx file

2013-04-19 Thread Steven D'Aprano
On Fri, 19 Apr 2013 17:59:26 +, b_erickson1 wrote:

 I have python 2.6.2 and I trying to get it to unzip a file made with
 winzip pro.  The file extension is zipx.  This is on a windows machine
 where I have to send them all that files necessary to run.  I am
 packaging this with py2exe.  I can open the file with zFile =
 zipfile.ZipFile(fullPathName,'r') and I can look through all the file in
 the archive for filename in zFile.namelist():
 but when I write the file out with this code:
 ozFile = open(filename,'w')
 ozFile.write(zFile.read(filename))
 ozFile.close()
 that file still looks encrypted.  No errors are thrown.  The file is
 just a text file not a jpeg or anything else.  I can open the file with
 7zip and extract the text file out just fine.
 
 
 What am I missing?


You are missing that zipx is not the same as zip, and Python very likely 
does not support the zipx compression algorithm.

http://kb.winzip.com/kb/entry/7/

My guess is that the zipx header is similar enough to zip that Python can 
retrieve the file names, but it cannot decompress the files. 
Unfortunately, instead of getting a nice error, it is fooled into 
thinking that it decompressed when in fact you just got junk.


I suggest that you start with a simple example: create a plain text file 
with just a few words. Compress this single file to .zipx, then try to 
decompress it using Python. If it still fails, you will have a simple 
example that you could post here and see if others have more success.



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


Re: unzipping a zipx file

2013-04-19 Thread Dave Angel

On 04/19/2013 08:24 PM, Steven D'Aprano wrote:




SNIP


You are missing that zipx is not the same as zip, and Python very likely
does not support the zipx compression algorithm.

http://kb.winzip.com/kb/entry/7/

My guess is that the zipx header is similar enough to zip that Python can
retrieve the file names, but it cannot decompress the files.
Unfortunately, instead of getting a nice error, it is fooled into
thinking that it decompressed when in fact you just got junk.



The zip header includes a 32bit CRC for each file.  Do you know whether 
the zip module checks that CRC ?


I suggest that you start with a simple example: create a plain text file
with just a few words. Compress this single file to .zipx, then try to
decompress it using Python. If it still fails, you will have a simple
example that you could post here and see if others have more success.






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


Re: How to set my gui?

2013-04-19 Thread Chris Angelico
On Sat, Apr 20, 2013 at 9:10 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Fri, 19 Apr 2013 09:24:36 +1000, Chris Angelico ros...@gmail.com
 declaimed the following in gmane.comp.python.general:

 On Fri, Apr 19, 2013 at 8:57 AM, Walter Hurry walterhu...@lavabit.com 
 wrote:
  On Fri, 19 Apr 2013 08:00:11 +1000, Chris Angelico wrote:
 
  But 1 Corinthians 13:11
 
  You are grown up now, I surmise.

 :) Born in 1984, so that'll give you some idea where I was in the 1990s.


 A puppy to be taught by greymuzzles (unfortunately, /this/
 greymuzzle [1958] has reached the point of being an old dog that only
 learns new tricks with extreme difficulty G)

Yep, taught by my Dad, who has often told the story of how he once
held a whole kilobyte of memory in his hands (something like a cubic
meter in size). He introduced me to programming, to fiddling with the
system configs (actually he forbade that, for ages - because he had to
clean up the mess if the system wouldn't boot), and to the joys of
networking. So in a large way he's why I'm a geek... and actually he
started that even earlier, when I was given the name Chris at birth.
That on its own probably is the biggest cause of my geekery, I think!

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


Different cache filename

2013-04-19 Thread Fabian PyDEV
Hi,

when load a module mymodule.py with importlib.machinery.SourceFileLoader a 
bytecode file is created as mymodule.cpython-33.pyc.

If I load a module mymodule.ext.py the same way the same bytecode file is 
created as mymodule.cpython-33.pyc.

Is there any way I could tell python to generate the bycode file as 
mymodule.ext.cpython-33.pyc?

Regards,
Fabian

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


[issue14364] Argparse incorrectly handles '--'

2013-04-19 Thread paul j3

paul j3 added the comment:

The patch that I  recently submitted for http://bugs.python.org/issue13922
appears to solve this issue.  It only removes the '--' that marked the end of 
options.  

With:

parser = argparse.ArgumentParser()
parser.add_argument('-f','--foo')
print(parser.parse_args(['-f--']))
print(parser.parse_args(['--foo=--']))
print(parser.parse_args(['-f', '--']))

I get:

Namespace(foo='--')
Namespace(foo='--')
usage: foodash.py [-h] [-f FOO]
foodash.py: error: argument -f/--foo: expected one argument

--

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



[issue17760] No i18n of IDLE's interface in french

2013-04-19 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 The target is different though (especially the target of Firefox).
 Kate might be used mainly by developers, but it's also used by
 non-developers and it's probably translated also because all the KDE
 programs are.  Mercurial would be a better example against my point.

Or Kdevelop, Eclipse, etc.

--

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



[issue14364] Argparse incorrectly handles '--'

2013-04-19 Thread Michele Orrù

Michele Orrù added the comment:

wow, I was just writing the unittests, thanks paul. 
Shall I continue? I don't see any test case on tip.

--

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



[issue17795] backwards-incompatible change in SysLogHandler with unix domain sockets

2013-04-19 Thread Mike Lundy

New submission from Mike Lundy:

The changed merged from http://bugs.python.org/issue16168 causes a regression 
in SysLogHandler behavior. The socktype of /dev/log is dependent on syslog 
configuration, and the fallback behavior (trying SOCK_DGRAM and then 
SOCK_STREAM if the former failed) was very useful.

A better fix for this would preserve the fallback behavior in cases where the 
caller has not specifically requested a socktype. I've attached a patch with 
one such approach.

--
components: Library (Lib)
files: 0001-Restore-SysLogHandler-fallback-for-AF_UNIX-sockets.patch
keywords: patch
messages: 187347
nosy: Mike.Lundy
priority: normal
severity: normal
status: open
title: backwards-incompatible change in SysLogHandler with unix domain sockets
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
Added file: 
http://bugs.python.org/file29937/0001-Restore-SysLogHandler-fallback-for-AF_UNIX-sockets.patch

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



[issue17796] No mimetype guessed for tar.xz url

2013-04-19 Thread LCID Fire

New submission from LCID Fire:

mimetypes.guess_type( 
http://ftp.gnome.org/pub/GNOME/sources/libxml++/2.36/libxml++-2.36.0.tar.xz;), 
strict=False )

gives

(None, None)

--
components: Library (Lib)
messages: 187348
nosy: lcid-fire
priority: normal
severity: normal
status: open
title: No mimetype guessed for tar.xz url
type: behavior
versions: Python 2.7

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



[issue13922] argparse handling multiple -- in args improperly

2013-04-19 Thread Michele Orrù

Changes by Michele Orrù maker...@gmail.com:


--
nosy: +maker

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



[issue14364] Argparse incorrectly handles '--'

2013-04-19 Thread Michele Orrù

Michele Orrù added the comment:

Yes, http://bugs.python.org/file29845/dbldash.patch seems to fix this.
Attaching the unittests, and noisying on your issue.

--
keywords: +patch
Added file: http://bugs.python.org/file29938/issue14364.test.patch

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



[issue17468] Generator memory leak

2013-04-19 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +benjamin.peterson, ncoghlan

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



[issue5004] socket.getfqdn() doesn't cope properly with purely DNS-based setups

2013-04-19 Thread Stijn Hoop

Stijn Hoop added the comment:

So after a good nights sleep: does it not make sense to use the canonical 
hostname iff the name argument is not present / empty? Otherwise, fall back to 
the documented steps? That way extra API is avoided, and I can't think of a 
case where you would rather have my weird results vs the output of hostname 
-f.

--

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



[issue17778] Fix test discovery for test_multiprocessing.py

2013-04-19 Thread Richard Oudkerk

Changes by Richard Oudkerk shibt...@gmail.com:


--
nosy: +sbt

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



[issue17795] backwards-incompatible change in SysLogHandler with unix domain sockets

2013-04-19 Thread Vinay Sajip

Changes by Vinay Sajip vinay_sa...@yahoo.co.uk:


--
assignee:  - vinay.sajip
nosy: +vinay.sajip

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Mateusz Loskot

New submission from Mateusz Loskot:

In pythonrun.c, there is function initstdio() with the following test:

static int
initstdio(void)
{
...
/* Set sys.stdin */
fd = fileno(stdin);
/* Under some conditions stdin, stdout and stderr may not be connected
 * and fileno() may point to an invalid file descriptor. For example
 * GUI apps don't have valid standard streams by default.
 */
if (fd  0) {
#ifdef MS_WINDOWS
std = Py_None;
Py_INCREF(std);
#else
goto error;
#endif
}
else {
...
}

This function is fails for non-console applications (i.e. MFC) built using 
Visual C++ 11.0 (Visual Studio 2012), becasue **strangely**, fileno(stdin) == 
0, so this test results in false and Python initialisation routines attempt to 
setup streams.

Apparently, fileno(stdin) return value has changed between Visual C++ 10.0 (VS 
2010)
and 11.0. The VC++ 10.0 reports fileno(stdin) == -2.

--
components: IO, Interpreter Core
messages: 187351
nosy: mloskot
priority: normal
severity: normal
status: open
title: Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program
versions: Python 3.2

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

And does it cause an issue later? How?

--
nosy: +amaury.forgeotdarc

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Mateusz Loskot

Mateusz Loskot added the comment:

Yes, it does. In file Modulfileio.c, in function fileio_init, there is this 
code:

if (fd = 0) {
if (check_fd(fd))
goto error;
self-fd = fd;
self-closefd = closefd;
}

The check_fd tests:

if (!_PyVerify_fd(fd) || (fstat(fd, buf)  0  errno == EBADF)) {

The _PyVerify_fd(fd) == 1, but errno is Bad file descriptor.

This eventually leads to Py_InitializeEx failure at:

if (initstdio()  0)
Py_FatalError(
Py_Initialize: can't initialize sys standard streams);

--

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



[issue17468] Generator memory leak

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Generators exit using GeneratorExit, which you could possible catch.

--

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



[issue5004] socket.getfqdn() doesn't cope properly with purely DNS-based setups

2013-04-19 Thread R. David Murray

R. David Murray added the comment:

That is an interesting proposal, yes.  I suppose someone that needs the 
getaddrinfo semantics for something other than the local host can just call it 
directly.

Now, do we add the fact that we are doing this to the current alogarithmic 
documention? :)

--

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Mateusz Loskot

Mateusz Loskot added the comment:

 In file Modulfileio.c,

I messed the path and filename above I meant: In file Modules/_io/fileio.c,

--

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



[issue17796] No mimetype guessed for tar.xz url

2013-04-19 Thread R. David Murray

R. David Murray added the comment:

Adding xz was treated as an enhancement in issue 16316.  Our thinking about 
applying these types of changes as bug fixes has evolved a bit, so I think we 
can consider backporting it.

--
nosy: +r.david.murray

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Maybe check_fd(fd) could be used in initstdio as well.

Can you check whether it's the same for the other files?
What are the values for fileno(stdout) and fileno(stderr)?

--

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



[issue17468] Generator memory leak

2013-04-19 Thread Anssi Kääriäinen

Anssi Kääriäinen added the comment:

True, except GeneratorExit will run at garbage collection time and this will 
result in reference cycle problems. Checking if there is no except 
GeneratorExit clause might be too complicated.

I still think this is worth a brief note in the gc docs. The gc docs talk only 
about __del__ methods, and there isn't one defined for the example generator. 
The generator does have something technically equivalent, but I don't spot any 
actual __del__ methods in the reference loop.

A docs mention will not help much in avoiding this problem, but it will at 
least make the code behaviour equivalent to documentation. A mention in the gc 
docs would have helped me when trying to debug the leak in Django.

--

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



[issue17468] Generator memory leak

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

A documentation patch sounds good to me.

--
assignee:  - docs@python
components: +Documentation
nosy: +docs@python
type: resource usage - behavior

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



[issue17177] Document/deprecate imp

2013-04-19 Thread Brett Cannon

Brett Cannon added the comment:

The deprecation warnings for the explicitly deprecated functions already have 
the instructions on how to port. A note could probably be added to turn on 
deprecation warnings if one needs help with moving code over.

But the deprecation isn't even officially full-on yet. While it's documented as 
such, not all functionality has moved over to importlib, only bits and pieces.

--

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-04-19 Thread Mateusz Loskot

Mateusz Loskot added the comment:

Replacing if the current test in Python 3.2

if (fd  0)
with
if (check_fd(fd)  0)

Seems to be a working solution.

I just noticed, that in current Python/pythonrun.c in the repo, there the fd  
0 tests have been replaced with new function is_valid_fd(). But, its semantic 
is equivalent to fd  0, so it does not check anything really. Perhaps 
is_valid_fd could be redefined as check_fd.

Here are Visual C++ 11.0 (1700) vs 10.0 differences of fileno return value for 
all the standard streams

int fdi, fdo, fde;
fdi = fileno(stdin);
fdo = fileno(stdout);
fde = fileno(stderr);
#if _MSC_VER  1700
assert(fdi == -2);
assert(fdo == -2);
assert(fde == -2);
#else
assert(fdi == 0);
assert(fdo == 1);
assert(fde == 2);
#endif

By the way, I assume such sudden change in fileno(std*) behaviour between 
Visual C++ versions is suspicious, so I also submitted bug report to Visual 
Studio:
https://connect.microsoft.com/VisualStudio/feedback/details/785119/

--

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



[issue17732] distutils.cfg Can Break venv

2013-04-19 Thread Nick Sloan

Nick Sloan added the comment:

Responded to comments with an updated patch. Thanks for all the feedback, and 
sorry for the silly mistakes. Should have read up more thoroughly on the docs 
style guide and the terminology. Hopefully the latest patch is ready to go (or 
at least, nearly so).

--
Added file: http://bugs.python.org/file29939/distutilsvenv.patch

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



[issue17177] Document/deprecate imp

2013-04-19 Thread R. David Murray

R. David Murray added the comment:

Should we back out that module level deprecation notice for the moment, then?

--

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



[issue3778] python uninstaller leave registry entries

2013-04-19 Thread anatoly techtonik

anatoly techtonik added the comment:

What is the reason for not following the good practice? Is it so hard to fix?

--

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



[issue3778] python uninstaller leave registry entries

2013-04-19 Thread Michael Foord

Changes by Michael Foord mich...@voidspace.org.uk:


--
nosy:  -michael.foord

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



[issue3778] python uninstaller leave registry entries

2013-04-19 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy:  -brian.curtin

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



[issue17177] Document/deprecate imp

2013-04-19 Thread Brett Cannon

Brett Cannon added the comment:

Nah, consider it motivation for me to get it done in Python 3.4 else I have to 
back it out before release.

--

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



[issue17468] Generator memory leak

2013-04-19 Thread Nick Coghlan

Nick Coghlan added the comment:

Adding Guido because this appears to be due to a longstanding difference 
between the handling of tp_del and most other slots

Specifically, the reason for the odd behaviour appears to be that generator 
objects define tp_del [1] (which is what the cyclic gc *really* looks for), but 
while defining __del__ in Python will populate tp_del in the type slots, 
defining tp_del directly in a builtin or extension type doesn't create an 
exposed __del__ at the Python level (there's no wrapper function identified in 
the slot definition).

So, at the very least, the fact that builtin and extension types can define 
tp_del without creating a visible __del__ method needs to be documented as a 
CPython implementation detail.

However, I'm not sure we actually have a good *reason* for tp_del failing to 
generate __del__ automatically - it's been that way since Guido implemented it 
[2], but Guido's comment in that commit message about not needing a wrapper 
because types written in C can't define tp_del is clearly no longer accurate.

[1] http://hg.python.org/cpython/file/2.7/Objects/genobject.c#l328
[2] http://hg.python.org/cpython/annotate/71dca7c76fa2/Objects/typeobject.c#3955

--
nosy: +gvanrossum
versions: +Python 3.4

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



[issue17764] Support http.server passing bind address via commend line argument

2013-04-19 Thread Berker Peksag

Berker Peksag added the comment:

I left comments on Rietveld. The patch also needs a documentation update.

--
nosy: +berker.peksag
stage:  - patch review

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



[issue17468] Generator memory leak

2013-04-19 Thread Antoine Pitrou

Antoine Pitrou added the comment:

With the advent of yield-based asynchronous programming, it is going to be 
problematic if a generator caught in a reference cycle can create a memory leak.

--
nosy: +pitrou

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



[issue17796] No mimetype guessed for tar.xz url

2013-04-19 Thread Éric Araujo

Éric Araujo added the comment:

+1

--
nosy: +eric.araujo
stage:  - needs patch

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



[issue17796] No mimetype guessed for tar.xz url

2013-04-19 Thread Éric Araujo

Éric Araujo added the comment:

Let’s keep using that other bug report.

--
resolution:  - duplicate
stage: needs patch - committed/rejected
status: open - closed
superseder:  - Support xz compression in mimetypes module

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



[issue17468] Generator memory leak

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I think the creation of __del__ wrappers for extension types is separate from 
this issue of generator finalization.

--

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



[issue16316] Support xz compression in mimetypes module

2013-04-19 Thread Éric Araujo

Éric Araujo added the comment:

Small changes in registries (mimetypes, html.entities, sometimes webbrowser) 
are acceptable in stable branches.  Can you backport this?

--
stage: committed/rejected - commit review
status: closed - open

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



[issue17468] Generator memory leak

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Yes. Hopefully, the async framework using generators can properly can close() 
on them, though.

--

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



[issue17468] Generator memory leak

2013-04-19 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Yes. Hopefully, the async framework using generators can properly can
 close() on them, though.

With yield from-based generators, you don't need a trampoline anymore,
so the close() call is now left to the application developers (if I'm
not mistaken).

--

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



[issue7951] Should str.format allow negative indexes when used for __getitem__ access?

2013-04-19 Thread Todd Rovito

Changes by Todd Rovito rovit...@gmail.com:


--
nosy: +Todd.Rovito

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



[issue17732] distutils.cfg Can Break venv

2013-04-19 Thread Nick Sloan

Nick Sloan added the comment:

Here is another update. It has come to my attention that I missed some options:

prefix, exec-prefix, home, user and root

These have been added, and the docs and test have been updated to reflect the 
change.

--
Added file: http://bugs.python.org/file29940/distutilsvenv.patch

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



  1   2   >