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  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 "", line 1, in 
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=%s¶m2=%s¶m3=%s¶m4=%s¶m5=%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=%s¶m2=%s¶m3=%s¶m4=%s¶m5=%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  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  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  wrote:
> [-- text/plain, encoding 7bit, charset: ISO-8859-1, 19 lines --]

> In my python script, I have this:

> command="lynx -dump
> 'phpscript?param1=%s¶m2=%s¶m3=%s¶m4=%s¶m5=%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}¶m2={1}¶m3={2}"
   "¶m4={3}¶m5={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  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"  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 ,
 Chris Angelico  wrote:

> On Fri, Apr 19, 2013 at 11:07 PM, Roy Smith  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 

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  wrote:
> #define private public
> #define protected public
> #include 

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 ,
 Chris Angelico  wrote:

> On Sat, Apr 20, 2013 at 1:31 AM, Roy Smith  wrote:
> > #define private public
> > #define protected public
> > #include 
> 
> 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   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
 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  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  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  wrote:
> On Apr 19, 10:35 am, Andrew Berg  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  wrote:
> On 2013-04-18, Wayne Werner  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  | 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  "b_erickson1" 
 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  John Gordon  writes:

> In  "b_erickson1" 
>  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  wrote:
> On Fri, Apr 19, 2013 at 4:54 PM, Grant Edwards  
> wrote:
>> On 2013-04-18, Wayne Werner  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  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 ,
 Dennis Lee Bieber  wrote:

> On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith  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 )

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:







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
 wrote:
> On Fri, 19 Apr 2013 09:24:36 +1000, Chris Angelico 
> declaimed the following in gmane.comp.python.general:
>
>> On Fri, Apr 19, 2013 at 8:57 AM, Walter Hurry  
>> 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 )

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


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

2013-04-19 Thread Mark Janssen
On Thu, Apr 18, 2013 at 11:31 PM, Jason Wilkins
 wrote:
> 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?

No, I'm really trying to point out that models based on Digital Logic
vs. models based on Symbolic Logic are completely different -- they
have different basiis.  They are both types of "Maths", and that you
can interchange them as a demonstration doesn't actually help the
practical issue of keeping the two domains separate -- they have
differing logics.  It's like the domain of Natural numbers vs. the
Complex, or perhaps the Natural and the Real.  Yes you can translate
back and forth, but they are for all practical purposes distinct and
can't be mixed.

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

If that's all you want to do, you can stick with Boolean Logic.

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

Yes, and I'm attempting to provide an argument that the
(historically?) dominant model of symbolic calculus is misinforming
the practical domain of working out differences and arguments within
my own domain of the programming community.

Unfortunately, my inexperience with the literature is actually
betraying the validity of my point.

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

I'm trying to say that *I* care, because I can't seem to find the
common ground that affects 1000's of people in the applied C.S. domain
with the 1000's of people in the theoretical C.S. domain.

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


Free book, "Hacking Secret Ciphers with Python"

2013-04-19 Thread asweigart
I've released my third book, "Hacking Secret Ciphers with Python" for free 
under a Creative Commons license. This book is aimed at people who have no 
experience programming or with cryptography. The book goes through writing 
Python programs that not only implement several ciphers but also can hack these 
ciphers. Each chapter presents a new program and explains how the source code 
works.

You can download the book from http://inventwithpython.com/hacking

100% of the proceeds from the book sales will be donated to the Electronic 
Frontier Foundation, Creative Commons, and The Tor Project.
-- 
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 Mark Janssen
> 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.

I'm sorry.  I am responsible for the misunderstanding.  I used the
word "math" when I really mean symbolic logic (which, historically,
was part of philosophy).  My point is that the field is confusing
because it seems to ignore binary logic in favor of symbolic logic.
Is binary logic not "rigorous and precise" enough?
-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list