Re: Unicode humor

2013-05-11 Thread Steven D'Aprano
On Sat, 11 May 2013 01:16:36 +1000, Chris Angelico wrote:

 On Sat, May 11, 2013 at 1:06 AM, jmfauth wxjmfa...@gmail.com wrote:
 On 8 mai, 15:19, Roy Smith r...@panix.com wrote:
 Apropos to any of the myriad unicode threads that have been going on
 recently:

 http://xkcd.com/1209/

 --


 This reflects a lack of understanding of Unicode.
 
 By the skywriter, or by the two on the ground, or by Randall Munroe?

Obviously by all three. It takes *hours* to execute

'è'*1000.replace('è', 'ã')

using a skywriting plane, so obviously it isn't Unicode compliant.



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


Re: object.enable() anti-pattern

2013-05-11 Thread Steven D'Aprano
On Fri, 10 May 2013 17:59:26 +0100, Nobody wrote:

 On Thu, 09 May 2013 05:23:59 +, Steven D'Aprano wrote:
 
 There is no sensible use-case for creating a file without opening it.
 What would be the point? Any subsequent calls to just about any method
 will fail. Since you have to open the file after creating the file
 object anyway, why make them two different calls?
 
 As a counterpoint, some OSes (e.g. Plan 9) allow you to get a handle
 to a file without opening it. This can then be used for deleting,
 renaming or stat()-type operations without either the risk of race
 conditions (if another process renames files between operations, the
 operations may be performed on different files) or the side-effects of
 actually opening the file (particularly for device files, e.g. opening a
 tape drive may rewind the tape).

Ah, now that's a fantastic counter-example. But I think that says more 
about the primitiveness of the Unix file model than of the idea of 
temporal coupling.


 Python's file model doesn't allow for this, so there isn't really
 anything meaningful that you can do on a file object which isn't open
 (although these actually exist; any file object on which the .close()
 method has been called will be in this state).

Absolutely correct, and I'm amazed it's taken this long for anyone to 
point this out :-)



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


Re: object.enable() anti-pattern

2013-05-11 Thread Steven D'Aprano
On Fri, 10 May 2013 18:20:34 +0100, Robert Kern wrote:

 According to Steven's criteria, neither of these are instances of the
 anti-pattern because there are good reasons they are this way. He is
 reducing the anti-pattern to just those cases where there is no reason
 for doing so. 

But isn't that the case for all anti-patterns?

We agree that GOTO is an anti-pattern. That doesn't mean that there 
aren't valid reasons for using GOTO. Sometimes there are good use-cases 
for GOTO that outweigh the harm. By calling it an anti-pattern, though, 
we shift the onus onto the person wanting to use GOTO: justify why you 
need it, or use something else.

Would you object less if I called it a code smell than an anti-
pattern? If so, I accept your criticism, and call it a code smell: the 
less temporal coupling your API has, the better.


 That is why I asked for in-the-wild instances. 

How about this?

http://legacy.thecodewhisperer.com/post/366626867/improving-clarity-by-removing-temporal-coupling


Another example of temporal coupling is json_decode in PHP: you must 
follow it by a call to json_last_error, otherwise you have no way of 
telling whether the json_decode function succeeded or not.

http://php.net/manual/en/function.json-last-error.php


 I should
 have qualified my sentence to include according to your criteria
 because people seem to be answering my query out of that context.

Now you know how I feel :-)

I started this thread asking for help tracking down a blog post 
describing this code smell, or at least the name of such. Thanks again to 
Wayne Werner, who came through with the name of the anti-pattern, 
temporal coupling, and a blog post describing it, although not the one I 
read all those many moons ago.

I never intended to give the impression that *any* use of a separate 
enable method call was bad. I certainly didn't intend to be bogged 
down into a long discussion about the minutia of file descriptors in 
C, but it was educational :-)



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


Re: Making safe file names

2013-05-11 Thread Andrew Berg
On 2013.05.08 18:37, Dennis Lee Bieber wrote:
   And now you've seen why music players don't show the user the
 physical file name, but maintain a database mapping the internal data
 (name, artist, track#, album, etc.) to whatever mangled name was needed
 to satisfy the file system.
Tags are used mainly for organization but a nice benefit of tags is that they 
are not subject to file system or URL or whatever other
limits. If an audio file has no metadata, most players will show the file name.

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread D'Arcy J.M. Cain
On Thu, 9 May 2013 11:33:45 -0600
Ian Kelly ian.g.ke...@gmail.com wrote:
 about Turing machines and lambda calculus that you've injected into
 the conversation though just reminds me of the Einstein was wrong
 cranks.

But Einstein *was* wrong.  http://www.xkcd.com/1206/

-- 
D'Arcy J.M. Cain da...@druid.net |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 788 2246 (DoD#0082)(eNTP)   |  what's for dinner.
IM: da...@vex.net, VOIP: sip:da...@vex.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-11 Thread Mark Janssen
 In the old days, it was useful to have fine-grained control over the
 file object because you didn't know where it might fail, and the OS
 didn't necessarily give you give good status codes.  So being able to
 step through the entire process was the job of the progammers.

 I don't know what you mean by the old days, but a couple of decades
 ago, there were no such things as file objects.

My apologies.  I used the word object when I shouldn't have.

 I'm beginning to wonder if you and Dihedral are swapping notes.
 Dihedral's been sounding fairly coherent lately.

Dihedral...  That's my dream-self.  Where did you encounter him?  heh

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Mark Janssen
 ...The field needs re-invented and re-centered.[...]

For anyone who want to be involved.  See the wikiwikiweb -- a tool
that every programmer should know and use --  and these pages:
ComputerScienceVersionTwo and ObjectOrientedRefactored.

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


Re: Unicode humor

2013-05-11 Thread Chris Angelico
On Sat, May 11, 2013 at 2:07 AM, rusi rustompm...@gmail.com wrote:
 On May 10, 8:32 pm, Chris Angelico ros...@gmail.com wrote:
 On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder n...@nedbatchelder.com 
 wrote:
  On 5/10/2013 11:06 AM, jmfauth wrote:

  On 8 mai, 15:19, Roy Smith r...@panix.com wrote:

  Apropos to any of the myriad unicode threads that have been going on
  recently:

 http://xkcd.com/1209/

  --

  This reflects a lack of understanding of Unicode.

  jmf

  And this reflects a lack of a sense of humor.  :)

 Isn't that a crime in the UK?

 ChrisA

 The problem with English humour (as against standard humor) is that
 its not unicode compliant

Unicode humour was carefully laid out to incorporate English humour.
In fact, if you use the standard variable-length-joke encoding, it's
possible for a Unicode joke to be decoded as if it were an English
joke, without any actual knowledge of Unicode. Unfortunately, this can
result in non-compliant English humour publishers producing jokes that
come out as gibberish in the rest of the world. Fortunately, we then
get to laugh at them.

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


Re: Making safe file names

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 1:08 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I suspect that the only way to be completely ungoogleable would be to
 name yourself something common, not something obscure. Say, if you called
 yourself Hard Rock Band, and did hard rock. But then, googling for
 Heavy Metal alone brings up the magazine as the fourth hit, so if you
 get famous enough, even that won't work.

Yeah, so why are ubergeneric domain names worth so much? Whatevs.

The best way to be findable in a web search is to have content on your
web site. Real crawlable content. I guarantee you'll be found. Even if
you're some tiny thing tucked away in a corner of teh interwebs, you
can be found.

http://www.google.com/search?q=minstrel+hall

The song is there, but so is an obscure little DD MUD.

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


Re: object.enable() anti-pattern

2013-05-11 Thread Mark Janssen
 Steven, don't be misled.  POSIX is not the model to look to -- it does
 not acknowledge that files are actual objects that reside on a piece
 of hardware.  It is not simply an integer.

Please disregard this (my own) flame bait.
-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
 8 Dihedral writes:

 This is just the handy style for a non-critical loop.
 In a critical loop, the number of  the total operation counts
 does matter in the execution speed.

 Do you use speed often?

Dihedral is a bot. Quite a good one, but a bot.

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Fri, May 10, 2013 at 3:33 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 All this irrelevant nonsense
 about Turing machines and lambda calculus that you've injected into
 the conversation though just reminds me of the Einstein was wrong
 cranks.

http://xkcd.com/1206/

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


Re: Unicode humor

2013-05-11 Thread Mark Lawrence

On 10/05/2013 17:25, Chris Angelico wrote:

On Sat, May 11, 2013 at 2:07 AM, rusi rustompm...@gmail.com wrote:

On May 10, 8:32 pm, Chris Angelico ros...@gmail.com wrote:

On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder n...@nedbatchelder.com wrote:

On 5/10/2013 11:06 AM, jmfauth wrote:



On 8 mai, 15:19, Roy Smith r...@panix.com wrote:



Apropos to any of the myriad unicode threads that have been going on
recently:



http://xkcd.com/1209/



--



This reflects a lack of understanding of Unicode.



jmf



And this reflects a lack of a sense of humor.  :)


Isn't that a crime in the UK?

ChrisA


The problem with English humour (as against standard humor) is that
its not unicode compliant


Unicode humour was carefully laid out to incorporate English humour.
In fact, if you use the standard variable-length-joke encoding, it's
possible for a Unicode joke to be decoded as if it were an English
joke, without any actual knowledge of Unicode. Unfortunately, this can
result in non-compliant English humour publishers producing jokes that
come out as gibberish in the rest of the world. Fortunately, we then
get to laugh at them.

ChrisA



This simply shows bias to the English speaking world, as does Python 
unicode, at least in 3.3+.  I wouldn't mind betting that other languages 
can't cope, e.g. can 3.3+ manage the top secret joke that's so deadly 
even the Germans die laughing?


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


Mark Lawrence

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


Re: Unicode humor

2013-05-11 Thread Chris Angelico
On Sat, May 11, 2013 at 10:40 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 This simply shows bias to the English speaking world, as does Python
 unicode, at least in 3.3+.  I wouldn't mind betting that other languages
 can't cope, e.g. can 3.3+ manage the top secret joke that's so deadly even
 the Germans die laughing?

It most certainly can. However, the space it takes up depends on how
you encode the combining characters; for maximal efficiency of
transmission, you would want to use the fully-composed version,
because like music, if it isn't composed, it's decomposed.

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


Re: object.enable() anti-pattern

2013-05-11 Thread Roy Smith
In article 518df898$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 I never intended to give the impression that *any* use of a separate 
 enable method call was bad. I certainly didn't intend to be bogged 
 down into a long discussion about the minutia of file descriptors in 
 C, but it was educational :-)

Well, you did say you were here for abuse.  I think you got your money's 
worth.  Can I interest you in a course of getting hit on the head 
lessons?

And just to be clear to the studio audience and all of you who are 
watching at home...

For all the effort I put into nit-picking, I do agree with Steven's 
basic premise.  Two-phase construction is usually not the right way to 
be designing classes.  Especially in languages like Python where 
constructors raising exceptions is both inexpensive and universally 
accepted as normal behavior.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-11 Thread André Malo
* Serhiy Storchaka wrote:

 Another example is running a subprocess in Unix-like systems.
 
  fork()
  open/close file descriptors, set limits, etc
  exec*()

For running a subprocess, only fork() is needed. For starting another
executable, only exec() is needed. For running the new executable in a
subprocess fork() and exec() are needed. I think, that's a bad example.
These APIs are actually well-designed.

nd
-- 
Gefunden auf einer Webdesigner-Seite:
 Programmierung in HTML, XML, WML, CGI, FLASH 

# André Malo # http://pub.perlig.de/ #
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-11 Thread Anssi Saari
Chris Angelico ros...@gmail.com writes:

 On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
 jpiit...@ling.helsinki.fi wrote:
 8 Dihedral writes:

 This is just the handy style for a non-critical loop.
 In a critical loop, the number of  the total operation counts
 does matter in the execution speed.

 Do you use speed often?

 Dihedral is a bot. Quite a good one, but a bot.

That's been said often enough. Is the source available and is it in
Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:47 AM, Anssi Saari a...@sci.fi wrote:
 Chris Angelico ros...@gmail.com writes:

 On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
 jpiit...@ling.helsinki.fi wrote:
 8 Dihedral writes:

 This is just the handy style for a non-critical loop.
 In a critical loop, the number of  the total operation counts
 does matter in the execution speed.

 Do you use speed often?

 Dihedral is a bot. Quite a good one, but a bot.

 That's been said often enough. Is the source available and is it in
 Python?

Not to my knowledge. Technically Dihedral is merely _rumoured_ to be a
bot, as we have no actual proof; but we've been conducting a variety
of Turing tests via this list and have yet to see any strong argument
for his being deemed human. Most humans would get defensive, or at
least protest, if treated as bots; Dihedral never has, despite being
referred to in this way a number of times.

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


Re: object.enable() anti-pattern

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:33 AM, André Malo ndpar...@gmail.com wrote:
 * Serhiy Storchaka wrote:

 Another example is running a subprocess in Unix-like systems.

  fork()
  open/close file descriptors, set limits, etc
  exec*()

 For running a subprocess, only fork() is needed. For starting another
 executable, only exec() is needed. For running the new executable in a
 subprocess fork() and exec() are needed. I think, that's a bad example.
 These APIs are actually well-designed.

That said, though, there's certainly plenty of room for one-call APIs
like popen. For the simple case where you want to start a process with
some other executable, wait for it to finish, and then work with its
return value, it makes sense to hide the details of fork/exec/wait -
especially since that simple API can be cross-platform, where fork()
itself is quite hard to implement on Windows.

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


Re: Right way to initialize python embedded in a multi-threaded application

2013-05-11 Thread francis . brosnan
Hi,

Maybe you already fixed the issue, but for the record, I've got the same
problem and finally it turned out that I was calling PyEval_InitThreads twice
and also after fixing that, I also had to move the call to 
PyEval_ReleaseLock();  at the end of the entire initialization (not just after 
PyEval_initThreads).

The key thing there is to follow:

at initialization thread
Py_Initialize ();
PyEval_InitThreads(); 
/* now call here to initialize all python code by loading external files 
   or internal module loading (i.e. Py_InitModule3) */
/* ..and now, once no more Python C/API call is required, release
   the GIL so other threads can come into play */
PyEval_ReleaseLock ();

and now, from other threads, use
/* wait til gil acquired */
state  = PyGILState_Ensure();
/* your code */
/* release GIL */
PyGILState_Release (state);

Hope it helps, Cheers!


 I'm embedding python in a multi-threaded C application.
 
 I've taken care to wrap every call to the Python C API with
 
 
 
 gstate = PyGILState_Ensure();
 
 // call python code
 
 PyGILState_Release(gstate);
 
 
 
 But I'm stumped with what to do in the initialization.
 
 Right after the call to Py_IsInitialized() I've added a call:
 
 
 
 PyEval_InitThreads();
 
 
 
 The docs say that this function leaves the GIL locked when it returns.
 
 I do some more initializations like importing modules and then I call
 
 
 
 PyEval_ReleaseLock();
 
 
 
 This seems to cause a problem since not long after a call to
 
 PyGILState_Release(gstate) that's made in a different thread crashes.
 
 with
 
 
 
 Fatal Python error: This thread state must be current when releasing
 
 
 
 If I don't do the call to PyEval_ReleaseLock() in the main thread
 
 right after initialization, the GIL seems to be released
 
 after the first PyGILState_Ensure() - PyGILState_Release() pair.
 
 
 
 So what am I doing wrong here?
 
 What is the correct way of initializing a multi-threaded application?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-11 Thread Robert Kern

On 2013-05-11 08:51, Steven D'Aprano wrote:

On Fri, 10 May 2013 18:20:34 +0100, Robert Kern wrote:


According to Steven's criteria, neither of these are instances of the
anti-pattern because there are good reasons they are this way. He is
reducing the anti-pattern to just those cases where there is no reason
for doing so.


But isn't that the case for all anti-patterns?

We agree that GOTO is an anti-pattern. That doesn't mean that there
aren't valid reasons for using GOTO. Sometimes there are good use-cases
for GOTO that outweigh the harm. By calling it an anti-pattern, though,
we shift the onus onto the person wanting to use GOTO: justify why you
need it, or use something else.


Yes, that was the point I was making. You seemed to be defining away the 
legitimate instances as not instances of the pattern at all because they were 
legitimate, and that appeared to me to be defeating the purpose of having the 
discussion.


On a related note, I *don't* think it's a good idea to phrase it as justify why 
you need it. I don't think that gives very good guidance to a novice when they 
are given the task of designing something. People can come up with a 
justification for just about anything, especially when they are only justifying 
things to themselves. I think it's more important to just talk about the 
situations where a pattern is useful, and the common situations where people, 
for whatever reason, *think* that a pattern is useful, but isn't. Naming it a 
Pattern or Anti-pattern is really just a measure of how bad the latter half of 
that is compared to the first half, and is less interesting than the discussion 
itself. That's why I had a bug up my ass about what looked like the exclusion of 
the good uses. It's the good examples that give novices an idea of what a good 
justification looks like, so they can tell if the justification they are giving 
themselves measures up.



Would you object less if I called it a code smell than an anti-
pattern? If so, I accept your criticism, and call it a code smell: the
less temporal coupling your API has, the better.


That was not really my objection. I was objecting to the way you appeared to be 
defining the particular pattern in question. But as we appear to agree on the 
important matters, I won't press it further.



That is why I asked for in-the-wild instances.


How about this?

http://legacy.thecodewhisperer.com/post/366626867/improving-clarity-by-removing-temporal-coupling


There's something about Java mixedCase that makes my eyes glaze, so I'll take 
your word for it. :-)



Another example of temporal coupling is json_decode in PHP: you must
follow it by a call to json_last_error, otherwise you have no way of
telling whether the json_decode function succeeded or not.

http://php.net/manual/en/function.json-last-error.php


I suspect that the author might say something about error checking being 
optional. But yeah, terrible API. :-)


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


Python for philosophers

2013-05-11 Thread Citizen Kant
Hi,
this could be seen as an extravagant subject but that is not my original
purpose. I still don't know if I want to become a programmer or not. At
this moment I'm just inspecting the environment. I'm making my way to
Python (and OOP in general) from a philosophical perspective or point of
view and try to set the more global definition of Python's core as an
entity. In order to do that, and following Wittgenstein's indication
about that the true meaning of words doesn't reside on dictionaries but in
the use that we make of them, the starting question I make to myself about
Python is: which is the single and most basic use of Python as the entity
it is? I mean, beside programming, what's the single and most basic result
one can expect from interacting with it directly (interactive mode)? I
roughly came to the idea that Python could be considered as an *economic
mirror for data*, one that mainly *mirrors* the data the programmer types
on its black surface, not exactly as the programmer originally typed it,
but expressed in the most economic way possible. That's to say, for
example, if one types 1+1 Python reflects 2. When data appears
between apostrophes, then the mirror reflects, again, the same but
expressed in the most economic way possible (that's to say without the
apostrophes).

So, would it be legal (true) to define Python's core as an entity that
mirrors whatever data one presents to it (or feed it with) showing back the
most shortened expression of that data?

Don't get me wrong. I can see the big picture and the amazing things that
programmers write on Python, it's just that my question points to the
lowest level of it's existence.

Thanks a lot for your time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Right way to initialize python embedded in a multi-threaded application

2013-05-11 Thread francis . brosnan
Just clarify there's no problem about calling twice to PyEval_InitThreads ()
as indicated by Python's doc.

 Hi,
 
 
 
 Maybe you already fixed the issue, but for the record, I've got the same
 
 problem and finally it turned out that I was calling PyEval_InitThreads twice
 
 and also after fixing that, I also had to move the call to 
 PyEval_ReleaseLock();  at the end of the entire initialization (not just 
 after PyEval_initThreads).
 
 
 
 The key thing there is to follow:
 
 
 
 at initialization thread
 
 Py_Initialize ();
 
 PyEval_InitThreads(); 
 
 /* now call here to initialize all python code by loading external files 
 
or internal module loading (i.e. Py_InitModule3) */
 
 /* ..and now, once no more Python C/API call is required, release
 
the GIL so other threads can come into play */
 
 PyEval_ReleaseLock ();
 
 
 
 and now, from other threads, use
 
 /* wait til gil acquired */
 
 state  = PyGILState_Ensure();
 
 /* your code */
 
 /* release GIL */
 
 PyGILState_Release (state);
 
 
 
 Hope it helps, Cheers!
 
 
 
 
 
  I'm embedding python in a multi-threaded C application.
 
  
 
  I've taken care to wrap every call to the Python C API with
 
  
 
  
 
  
 
  gstate = PyGILState_Ensure();
 
  
 
  // call python code
 
  
 
  PyGILState_Release(gstate);
 
  
 
  
 
  
 
  But I'm stumped with what to do in the initialization.
 
  
 
  Right after the call to Py_IsInitialized() I've added a call:
 
  
 
  
 
  
 
  PyEval_InitThreads();
 
  
 
  
 
  
 
  The docs say that this function leaves the GIL locked when it returns.
 
  
 
  I do some more initializations like importing modules and then I call
 
  
 
  
 
  
 
  PyEval_ReleaseLock();
 
  
 
  
 
  
 
  This seems to cause a problem since not long after a call to
 
  
 
  PyGILState_Release(gstate) that's made in a different thread crashes.
 
  
 
  with
 
  
 
  
 
  
 
  Fatal Python error: This thread state must be current when releasing
 
  
 
  
 
  
 
  If I don't do the call to PyEval_ReleaseLock() in the main thread
 
  
 
  right after initialization, the GIL seems to be released
 
  
 
  after the first PyGILState_Ensure() - PyGILState_Release() pair.
 
  
 
  
 
  
 
  So what am I doing wrong here?
 
  
 
  What is the correct way of initializing a multi-threaded application?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread Mark Janssen
On Sat, May 11, 2013 at 1:03 PM, Citizen Kant citizenk...@gmail.com wrote:
[...] the starting question I make to myself about Python is: which is the 
single
 and most basic use of Python as the entity it is? I mean, beside
 programming, what's the single and most basic result one can expect from
 interacting with it directly (interactive mode)? I roughly came to the
 idea that Python could be considered as an economic mirror for data, one
 that mainly mirrors the data the programmer types on its black surface, not
 exactly as the programmer originally typed it, but expressed in the most
 economic way possible. That's to say, for example, if one types 1+1
 Python reflects 2. When data appears between apostrophes, then the mirror
 reflects, again, the same but expressed in the most economic way possible
 (that's to say without the apostrophes).

Wow.  You must be from another planet.  Find Socrates if you wish to
know these things.  He's from there also.

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


Re: Python for philosophers

2013-05-11 Thread Fábio Santos
On 11 May 2013 21:07, Citizen Kant citizenk...@gmail.com wrote:

 Hi,
 this could be seen as an extravagant subject but that is not my original
purpose. I still don't know if I want to become a programmer or not. At
this moment I'm just inspecting the environment. I'm making my way to
Python (and OOP in general) from a philosophical perspective or point of
view and try to set the more global definition of Python's core as an
entity. In order to do that, and following Wittgenstein's indication
about that the true meaning of words doesn't reside on dictionaries but in
the use that we make of them, the starting question I make to myself about
Python is: which is the single and most basic use of Python as the entity
it is? I mean, beside programming, what's the single and most basic result
one can expect from interacting with it directly (interactive mode)? I
roughly came to the idea that Python could be considered as an economic
mirror for data, one that mainly mirrors the data the programmer types on
its black surface, not exactly as the programmer originally typed it, but
expressed in the most economic way possible. That's to say, for example, if
one types 1+1 Python reflects 2. When data appears between
apostrophes, then the mirror reflects, again, the same but expressed in the
most economic way possible (that's to say without the apostrophes).

 So, would it be legal (true) to define Python's core as an entity that
mirrors whatever data one presents to it (or feed it with) showing back the
most shortened expression of that data?

 Don't get me wrong. I can see the big picture and the amazing things that
programmers write on Python, it's just that my question points to the
lowest level of it's existence.

 Thanks a lot for your time.


I can't tell if you are being sarcastic but I'll reply anyway. Python does
not necessarily shorten data. The Python machine is the house for your
representations of data, your own mirrors.

When you program you are asking python to acknowledge your representations
and to do work on them as you specify. Both of these tasks are expressed in
code. The first is the simplest, where you create your classes. It is
optional since you may use no classes at all and instead use files, text
and numbers, or classes given by someone else. The second is where you give
the orders and lay a script (as in a movie script, or a game script) out.
You can create and command many representations of data in order to make
your program fulfill its purpose. You can also make choices according to
the current state of your data.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread alex23
On 12 May, 06:10, Mark Janssen dreamingforw...@gmail.com wrote:
 Wow.  You must be from another planet.  Find Socrates if you wish to
 know these things.  He's from there also.

Now now, there's no need for a turf war, there's plenty of room on
this list for crazies.

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


Re: in need of some help...

2013-05-11 Thread Jens Thoms Toerring
Alex Norton ayjayn1...@gmail.com wrote:
 On Wednesday, 1 May 2013 13:15:28 UTC+1, Jens Thoms Toerring  wrote:
  Of course, it might be nicer to have a result label some-
  where in the graphical interface which you set to the text
  instead of printing it out to the console. And you also will
  probably add some Quit button to end the game.

 how would i go about adding print outcomes of all options  to a label ?

If you have a QLabel you can set its text to anything you want
using its setText() method.
 Regaeds, Jens

PS: If I may ask you a favor: consider refraining from using Google's
completely broken interface to newsgroups - your post consists
of nearly 200 lines of text containing all I wrote, with an empty
line inserted between each of them, and a single line of text
you wrote. It's rather annoying to have to sieve through that
much of unrelated stuff just to find thar one line that's re-
levant. And this Google groups crap seems to make it nearly
impossible to do it any other way. If you don't believe me see
e.g.

  http://wiki.python.org/moin/GoogleGroupsPython

There are much better alternatives to Google groups,
using a real usenet news server and a program that does
not mess up content of news group postings. They've been
developed with 30 years of experience with newsgroups.

If I'd be conspiracy theorist I would conclude that Google
is up to something bad in trying to make using newsgroups
nearly impossible by their badly broken stuff (and, to add
credibility to such a claim, their complete disregard for
all the criticism they got over the years, actually making
each version of Google groups even worse), but it's rather
likely just another case of pure incompetence (or a why
should we care attitude:-(
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread alex23
On 10 May, 13:07, Chris Angelico ros...@gmail.com wrote:
 Now, whether or not it's worth _debating_ the expressiveness of a
 language... well, that's another point entirely. But for your major
 project, I think you'll do better working in Python than in machine
 code.

I wasn't disagreeing with the concept of linguistic expressiveness, my
ire was over the I'm RIGHT and EVERYONE else is WRONG so STOP WHAT
YOU'RE DOING so I can REBUILD COMPUTER SCIENCE aspect of these posts.
Thought without experience or experiment is about as useful to my work
requirements as bowel gas.

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


Re: object.enable() anti-pattern

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 5:55 AM, Robert Kern robert.k...@gmail.com wrote:
 Another example of temporal coupling is json_decode in PHP: you must
 follow it by a call to json_last_error, otherwise you have no way of
 telling whether the json_decode function succeeded or not.

 http://php.net/manual/en/function.json-last-error.php


 I suspect that the author might say something about error checking being
 optional. But yeah, terrible API. :-)

The problem with that one isn't that error checking is optional, but
that errors are signalled with a perfectly legal return value (FALSE,
if I recall correctly - which is also returned if you json_decode a
boolean false). Better design would either throw an exception on
error, or have a unique sentinel representing the errorness of the
return value.

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Fri, 10 May 2013 14:33:52 +1000, Chris Angelico ros...@gmail.com
 declaimed the following in gmane.comp.python.general:


 I don't answer to them. I also believe in a path of endless
 exponential growth. Challenge: Create more information than can be
 stored in one teaspoon of matter. Go ahead. Try!

 The coordinates of each particle storing the information in that
 teaspoon of matter.

Which is probably more data than any of us will keyboard in a
lifetime. Hence my point.

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


Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
I'm afraid I'm having some trouble with the module.  I've checked it into
my SVN at http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan

I have two versions of your tests in there now - t is minimally changed,
and test-red_black_tree_mod is pretty restructured to facilitate adding
more tests later.  I get the same problem with either version of the tests.

The problem I'm seeing is that the tree, when built from items, isn't
looking quite right.  I inserted a print(tree) into the for loop, and I'm
getting the following, where I expected the tree to grow by one element on
each iteration:

$ python t
6 False None None
6 False 3 None
6 False 3 15
6 False 3 15
6 False 3 11
6 False 3 11
6 False 3 11
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15

Thoughts?

BTW, printing an empty tree seems to say sentinel.  'not sure if that was
intended.

Thanks!



On Thu, May 9, 2013 at 6:52 AM, duncan smith buzzard@invalid.invalidwrote:

 On 09/05/13 02:40, Dan Stromberg wrote:

 OK, I've got one copy of trees.py with md5
 211f80c0fe7fb9cb42feb9645b4b3f**fe.  You seem to be saying I should have
 two though, but I don't know that I do...


 [snip]

 Yes, 211f80c0fe7fb9cb42feb9645b4b3f**fe is the correct checksum for the
 latest version. The previous version had an issue when adding non-distinct
 items (items that compare equal to items already in the tree). Cheers.

 Duncan

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

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Gregory Ewing

Dennis Lee Bieber wrote:

I also believe in a path of endless
exponential growth. Challenge: Create more information than can be
stored in one teaspoon of matter. Go ahead. Try!


If that's your argument, then you don't really believe
in *endless* exponential growth. You only believe in
exponential growth for long enough that I won't be
around to suffer the consequences when it runs out.

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Gregory Ewing

Chris Angelico wrote:

On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:



   The coordinates of each particle storing the information in that
teaspoon of matter.


Which is probably more data than any of us will keyboard in a
lifetime. Hence my point.


My 1TB hard disk *already* contains more information than
I could keyboard in my lifetime.

The fact that it all got there is due to two things: (1)
I didn't have to enter it all myself, and (2) most of it
was auto-generated from other information, using compilers
and other such tools.

Our disk capacities are increasing exponentially, but
so is the rate at which we have the ability to create
information. I wouldn't be surprised if, at some point
before the human race becomes extinct, we build
computers whose operating system requires more than
a teaspoonful of atoms to store. Especially if
Microsoft still exists by then. :-)

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 10:50 AM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Dennis Lee Bieber wrote:

 I also believe in a path of endless
 exponential growth. Challenge: Create more information than can be
 stored in one teaspoon of matter. Go ahead. Try!


 If that's your argument, then you don't really believe
 in *endless* exponential growth. You only believe in
 exponential growth for long enough that I won't be
 around to suffer the consequences when it runs out.

Technically, according to the laws of thermodynamics, there cannot be
any actually endless growth, yes. (Anything beyond that is the realm
of religion, not science.) But in that case, the term endless is
like infinity - a concept only. Like the Infinite Monkey Protocol
Suite description in RFC 2795, there will be many numbers that come up
that are plenty huge but fall pitifully short of infinity (Graham's
Number, for instance, is pretty small in those terms).

So long as storage capacities keep on increasing, we can keep
increasing the world's information at the same rate. So long as the
number of computers connected to the internet increases, we can keep
increasing the internet's information at the same rate. Put both
together - and neither shows any sign of ceasing any time soon - we
can continue with the corresponding growth. How long before that runs
out? A *long* time. We're not talking here of the Year 2000, a
couple of decades after the software was written. We're not talking
about the 2038 issues, roughly half a century after the software was
written. We are talking timeframes that make the Y10K problem look
like a serious lack of foresight.

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


Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 11:02 AM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Chris Angelico wrote:

 On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber
 wlfr...@ix.netcom.com wrote:


The coordinates of each particle storing the information in that
 teaspoon of matter.


 Which is probably more data than any of us will keyboard in a
 lifetime. Hence my point.


 My 1TB hard disk *already* contains more information than
 I could keyboard in my lifetime.

 The fact that it all got there is due to two things: (1)
 I didn't have to enter it all myself, and (2) most of it
 was auto-generated from other information, using compilers
 and other such tools.

I would like to differentiate between information and data, here.
Point 1 is correct, but point 2 is not; auto-generated data is not
more information, and basic data compression can improve that. (Simple
form of compression there: `rm *.o` - you've lost nothing.)

 Our disk capacities are increasing exponentially, but
 so is the rate at which we have the ability to create
 information. I wouldn't be surprised if, at some point
 before the human race becomes extinct, we build
 computers whose operating system requires more than
 a teaspoonful of atoms to store. Especially if
 Microsoft still exists by then. :-)

That's possible. But that would be data bloat, not true information.
It's certainly possible to conceive more data than can be stored.
Microsoft, as you cite, are experts at this :)

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


Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg drsali...@gmail.com wrote:


 I'm afraid I'm having some trouble with the module.  I've checked it into
 my SVN at
 http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan

 I have two versions of your tests in there now - t is minimally changed,
 and test-red_black_tree_mod is pretty restructured to facilitate adding
 more tests later.  I get the same problem with either version of the tests.

 The problem I'm seeing is that the tree, when built from items, isn't
 looking quite right.  I inserted a print(tree) into the for loop, and I'm
 getting the following, where I expected the tree to grow by one element on
 each iteration:

 $ python t
 6 False None None
 6 False 3 None
 6 False 3 15
 6 False 3 15

I figured out that this was printing a single node and some of its
attributes, not an entire tree.  I changed it to print an entire tree using
self.in_order().

I've also changed around the comparisons a bit, to use a __cmp__ method but
still provide __eq__, __neq__ and a new __lt__.

I'm up against a new problem now that it'd be nice if you could look at:
In BinaryTree.find(), it sometimes compares the item being searched for
against None.  In 2.x, this gives strange results, but may be benign in
this code.  In 3.x, this raises an exception.  I've added a comment about
this in the SVN repo I mentioned above.

You can see the traceback yourself with python3 test-red_black_tree_mod .

What should BinaryTree.find() do if it finds a data.node that is None?

Thanks!

PS: Is it about time we moved this discussion off python-list?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread Gregory Ewing

Citizen Kant wrote:
I roughly came to the idea that Python could be 
considered as an *economic mirror for data*, one that mainly *mirrors* 
the data the programmer types on its black surface, not exactly as the 
programmer originally typed it, but expressed in the most economic way 
possible.


At best, this would be true only for a very small
subset of things that you can enter into the
interactive interpreter.

Even confining yourself to arithmetic expressions,
there are problems. Consider:

 12**34
4922235242952026704037113243122008064L

The input is 6 characters long, and the output
is 37 characters long. Is that more economical?

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


Re: Red Black Tree implementation?

2013-05-11 Thread duncan smith

On 12/05/13 00:24, Dan Stromberg wrote:


I'm afraid I'm having some trouble with the module.  I've checked it
into my SVN at
http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan

I have two versions of your tests in there now - t is minimally
changed, and test-red_black_tree_mod is pretty restructured to
facilitate adding more tests later.  I get the same problem with either
version of the tests.

The problem I'm seeing is that the tree, when built from items, isn't
looking quite right.  I inserted a print(tree) into the for loop, and
I'm getting the following, where I expected the tree to grow by one
element on each iteration:

$ python t
6 False None None
6 False 3 None
6 False 3 15
6 False 3 15
6 False 3 11
6 False 3 11
6 False 3 11
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15
11 False 6 15

Thoughts?

BTW, printing an empty tree seems to say sentinel.  'not sure if that
was intended.

Thanks!



The leaf node has parent equal to None. All tree nodes have two 
children. One or both children may be sentinels, and a sentinel is 
signified by having both left and right (children) equal to None. So an 
empty tree is a sentinel node that is also root. So the string 
sentinel is expected (although possibly not the most sensible option).


For non-sentinel nodes the string is generated by,

return '%s %s %s' % (self.data, self.left.data, self.right.data)

for the BinaryTree class, and by

return '%s %s %s %s' % (self.data, self.is_red, self.left.data, 
self.right.data)


for the RedBlackTree class.


So what is being printed above is (in each case) the value contained in 
the root node, followed by its colour (True if red), and the values 
contained in the root node's left and right children.


The root node remains root, although it's value and its children (and 
their values) might change due to tree rotations.


It looks OK to me. The empty tree would print sentinel. After adding 
the value 6 there is one tree node with sentinels as children (values 
equal to None). Adding 3 results in 3 being the value of the root's left 
child. It's right child is still a sentinel. Adding 15 results in that 
value being assigned to the right child. Adding 9 results in no change 
to the values in the root or its children. Adding 11 results in a tree 
rotation and 11 becomes the value in the right child of the root. At a 
later point a tree rotation results in the value of the root node being 
changed.


I haven't implemented a way of representing the structure of the whole 
red black tree. I would probably write some code to generate a dot file 
and use that to generate a png. But you could add something like,


print tree.height, tree.size, list(tree)

and get output like,

0 1 [6]
1 2 [3, 6]
1 3 [3, 6, 15]
2 4 [3, 6, 9, 15]
3 5 [3, 6, 9, 11, 15]
4 6 [3, 6, 9, 11, 12, 15]
4 7 [3, 6, 9, 11, 12, 15, 16]
5 8 [3, 6, 9, 11, 12, 14, 15, 16]
5 9 [3, 6, 9, 11, 12, 14, 15, 16, 17]
5 10 [3, 6, 7, 9, 11, 12, 14, 15, 16, 17]
5 11 [3, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18]
5 12 [3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18]
5 13 [3, 5, 6, 7, 8, 9, 11, 12, 14, 15, 16, 17, 18]
6 14 [3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18]
6 15 [0, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18]
6 16 [0, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18]
6 17 [0, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18]
6 18 [-1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18]
6 19 [-1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]


It doesn't give you the structure, but it does show that it seems to be 
growing reasonably. Cheers.


Duncan


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


Re: Red Black Tree implementation?

2013-05-11 Thread duncan smith

On 12/05/13 02:29, Dan Stromberg wrote:


On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg drsali...@gmail.com
mailto:drsali...@gmail.com wrote:


I'm afraid I'm having some trouble with the module.  I've checked it
into my SVN at
http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan

I have two versions of your tests in there now - t is minimally
changed, and test-red_black_tree_mod is pretty restructured to
facilitate adding more tests later.  I get the same problem with
either version of the tests.

The problem I'm seeing is that the tree, when built from items,
isn't looking quite right.  I inserted a print(tree) into the for
loop, and I'm getting the following, where I expected the tree to
grow by one element on each iteration:

$ python t
6 False None None
6 False 3 None
6 False 3 15
6 False 3 15

I figured out that this was printing a single node and some of its
attributes, not an entire tree.  I changed it to print an entire tree
using self.in_order().


Yes, I've just posted regarding that.



I've also changed around the comparisons a bit, to use a __cmp__ method
but still provide __eq__, __neq__ and a new __lt__.



I have implemented a lot (maybe all?) of the set methods in a subclass. 
I should probably root that out and have a think about what should be in 
the RedBlackTree class and what subclasses might look like.




I'm up against a new problem now that it'd be nice if you could look at:
In BinaryTree.find(), it sometimes compares the item being searched for
against None.  In 2.x, this gives strange results, but may be benign in
this code.  In 3.x, this raises an exception.  I've added a comment
about this in the SVN repo I mentioned above.

You can see the traceback yourself with python3 test-red_black_tree_mod .

What should BinaryTree.find() do if it finds a data.node that is None?



A call to find(data) should find and return either a node containing 
data; or the sentinel node where data should be added. It should not 
get as far as the left or right child of a sentinel node (which would 
equal None). I'll look at this tomorrow. I did have the truth value of a 
node depending on it's data value (None implying False). Then I 
considered the possibility of actually wanting None as a value in the 
tree and changed it, so I could have introduced a bug here.



Thanks!

PS: Is it about time we moved this discussion off python-list?



Maybe. You have my official e-mail address. Cheers.

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


Re: Append to python List

2013-05-11 Thread 88888 Dihedral
Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道:
 On Sun, May 12, 2013 at 1:47 AM, Anssi Saari a...@sci.fi wrote:
 
  Chris Angelico ros...@gmail.com writes:
 
 
 
  On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
 
  jpiit...@ling.helsinki.fi wrote:
 
  8 Dihedral writes:
 
 
 
  This is just the handy style for a non-critical loop.
 
  In a critical loop, the number of  the total operation counts
 
  does matter in the execution speed.
 
 
 
  Do you use speed often?
 
 
 
  Dihedral is a bot. Quite a good one, but a bot.
 
 
 
  That's been said often enough. Is the source available and is it in
 
  Python?
 
 
 
 Not to my knowledge. Technically Dihedral is merely _rumoured_ to be a
 
 bot, as we have no actual proof; but we've been conducting a variety
 
 of Turing tests via this list and have yet to see any strong argument
 
 for his being deemed human. Most humans would get defensive, or at
 
 least protest, if treated as bots; Dihedral never has, despite being
 
 referred to in this way a number of times.
 
 
 
 ChrisA

Don't you get the practices of   POSIX ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 12:29 PM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道:
 Most humans would get defensive, or at
 least protest, if treated as bots; Dihedral never has, despite being
 referred to in this way a number of times.

 ChrisA

 Don't you get the practices of   POSIX ?

I rest my case, m'lud.

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


Re: Python for philosophers

2013-05-11 Thread Ned Batchelder


On 5/11/2013 4:03 PM, Citizen Kant wrote:

Hi,
this could be seen as an extravagant subject but that is not my 
original purpose. I still don't know if I want to become a programmer 
or not. At this moment I'm just inspecting the environment. I'm making 
my way to Python (and OOP in general) from a philosophical perspective 
or point of view and try to set the more global definition of Python's 
core as an entity. In order to do that, and following Wittgenstein's 
indication about that the true meaning of words doesn't reside on 
dictionaries but in the use that we make of them, the starting 
question I make to myself about Python is: which is the single and 
most basic use of Python as the entity it is? I mean, beside 
programming, what's the single and most basic result one can expect 
from interacting with it directly (interactive mode)? I roughly came 
to the idea that Python could be considered as an *economic mirror for 
data*, one that mainly *mirrors* the data the programmer types on its 
black surface, not exactly as the programmer originally typed it, but 
expressed in the most economic way possible. That's to say, for 
example, if one types 1+1 Python reflects 2. When data appears 
between apostrophes, then the mirror reflects, again, the same but 
expressed in the most economic way possible (that's to say without the 
apostrophes).


So, would it be legal (true) to define Python's core as an entity that 
mirrors whatever data one presents to it (or feed it with) showing 
back the most shortened expression of that data?


Don't get me wrong. I can see the big picture and the amazing things 
that programmers write on Python, it's just that my question points to 
the lowest level of it's existence.


Thanks a lot for your time.




Python is straightforward: you write instructions, and it executes 
them.  At its core, that's all it does.  Why does the core have to be 
any different than that?


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


Re: Python for philosophers

2013-05-11 Thread Joel Goldstick
On Sat, May 11, 2013 at 4:03 PM, Citizen Kant citizenk...@gmail.com wrote:

 Hi,
 this could be seen as an extravagant subject but that is not my original
 purpose. I still don't know if I want to become a programmer or not.


My guess is that you don't want to be a programmer.  Otherwise you would
know that you did.


 At this moment I'm just inspecting the environment. I'm making my way to
 Python (and OOP in general) from a philosophical perspective or point of
 view and try to set the more global definition of Python's core as an
 entity. In order to do that, and following Wittgenstein's indication
 about that the true meaning of words doesn't reside on dictionaries but in
 the use that we make of them, the starting question I make to myself about
 Python is: which is the single and most basic use of Python as the entity
 it is? I mean, beside programming, what's the single and most basic result
 one can expect from interacting with it directly (interactive mode)? I
 roughly came to the idea that Python could be considered as an *economic
 mirror for data*, one that mainly *mirrors* the data the programmer types
 on its black surface, not exactly as the programmer originally typed it,
 but expressed in the most economic way possible. That's to say, for
 example, if one types 1+1 Python reflects 2. When data appears
 between apostrophes, then the mirror reflects, again, the same but
 expressed in the most economic way possible (that's to say without the
 apostrophes).

 So, would it be legal (true) to define Python's core as an entity that
 mirrors whatever data one presents to it (or feed it with) showing back the
 most shortened expression of that data?

 Don't get me wrong. I can see the big picture and the amazing things that
 programmers write on Python, it's just that my question points to the
 lowest level of it's existence.

 Thanks a lot for your time.

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




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


Re: Python for philosophers

2013-05-11 Thread rusi
On May 12, 3:16 am, alex23 wuwe...@gmail.com wrote:
 On 12 May, 06:10, Mark Janssen dreamingforw...@gmail.com wrote:

  Wow.  You must be from another planet.  Find Socrates if you wish to
  know these things.  He's from there also.

 Now now, there's no need for a turf war, there's plenty of room on
 this list for crazies.

I'm reminded of this:

Conversation between inmate and attendant in an asylum

Inmate: I am Napoleon
Attendant: Yes of course. But how did you know that?
Inmate: God himself told me s…
[Loud voice from another corner] I told you no such thing!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 2:22 PM, rusi rustompm...@gmail.com wrote:
 On May 12, 3:16 am, alex23 wuwe...@gmail.com wrote:
 On 12 May, 06:10, Mark Janssen dreamingforw...@gmail.com wrote:

  Wow.  You must be from another planet.  Find Socrates if you wish to
  know these things.  He's from there also.

 Now now, there's no need for a turf war, there's plenty of room on
 this list for crazies.

 I'm reminded of this:

 Conversation between inmate and attendant in an asylum

 Inmate: I am Napoleon
 Attendant: Yes of course. But how did you know that?
 Inmate: God himself told me s…
 [Loud voice from another corner] I told you no such thing!

Who's been telling you of private conversations between Steven and me?

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


Re: Python for philosophers

2013-05-11 Thread rusi
On May 12, 9:22 am, rusi rustompm...@gmail.com wrote:
 On May 12, 3:16 am, alex23 wuwe...@gmail.com wrote:

  On 12 May, 06:10, Mark Janssen dreamingforw...@gmail.com wrote:

   Wow.  You must be from another planet.  Find Socrates if you wish to
   know these things.  He's from there also.

  Now now, there's no need for a turf war, there's plenty of room on
  this list for crazies.

 I'm reminded of this:

 Conversation between inmate and attendant in an asylum

 Inmate: I am Napoleon
 Attendant: Yes of course. But how did you know that?
 Inmate: God himself told me s…
 [Loud voice from another corner] I told you no such thing!

I have on occasion expressed that newcomers to this list should be
treated with more gentleness than others.
And since my own joking may be taken amiss, let me hasten to add (to
the OP -- Citizen Kant)

What you are looking for is more in line with what is called
'rewriting systems'
And the shortening you talk of is usually called 'canonical form' or
'normal form'

Python is closer to such than traditional imperative/OO languages like
C/C++/Java, though other languages -- usually called 'functional
language' are generally closer to this ideal.

The most mainstream of these today is probably 'Haskell'
For your purposes however you may want to look at functional languages
that are more explicitly based on rewriting such as 'Pure' (earlier
'Q')

For last http://en.wikipedia.org/wiki/Pure_%28programming_language%29

For rest: Ive tried to put into quotes things that could he helpful
starting points for search engine research
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread Steven D'Aprano
On Sat, 11 May 2013 21:45:12 -0700, rusi wrote:

 I have on occasion expressed that newcomers to this list should be
 treated with more gentleness than others. And since my own joking may be
 taken amiss, let me hasten to add (to the OP -- Citizen Kant)

A noble aim, but I have a feeling that Citizen Kant is version 2.0 of 
8 Dihedral.

Of course, I could be wrong.


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


[issue17908] Unittest runner needs an option to call gc.collect() after each test

2013-05-11 Thread Phil Connell

Changes by Phil Connell pconn...@gmail.com:


--
nosy: +pconnell

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



[issue17930] Search not needed in combinations_with_replacement

2013-05-11 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Thanks Tim :-)

--

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



[issue17920] Documentation: complete ordering should be total ordering

2013-05-11 Thread Raymond Hettinger

Raymond Hettinger added the comment:

It can be closed now.
Thanks for the reminder.

--
resolution:  - fixed
status: open - closed

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



[issue14191] argparse doesn't allow optionals within positionals

2013-05-11 Thread Glenn Linderman

Glenn Linderman added the comment:

OK, I've been running with the new code most the day, and it seems functional 
in my testing.

I only sort of follow your discussion about the custom action class caveat, 
probably because I haven't used custom action classes... I tried once, but 
failed to achieve my goal, as it was more ambitious than they presently 
support. If the [] value is significantly problematical in some manner, could 
positional nargs be set to a sentinal value that would avoid the assignment of 
the [] value? I realize that would require code changes in some other function 
or functions, in addition to the added new functions, so that would make the 
patch a bit more intrusive.

If _fallback helps some folks with understanding errors clearly, I won't object 
to it. I guess it would only be programmers that would be confused, because 
they would be the ones interpreting the errors... and with adequate testing, 
should fix the programming errors before the users get a chance to be confused.

So maybe your next .patch will be ready to ship!

--

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



[issue17952] setup#editors-and-tools

2013-05-11 Thread Tshepang Lekhonkhobe

New submission from Tshepang Lekhonkhobe:

2nd paragraph of http://docs.python.org/devguide/setup#editors-and-tools does 
not look accurate. It implies that there would be some mention of text editor 
in the given link, but I could not find it.

--
components: Devguide
messages: 188900
nosy: ezio.melotti, tshepang
priority: normal
severity: normal
status: open
title: setup#editors-and-tools

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



[issue17952] editors-and-tools section of devguide does not appear to be ccurate

2013-05-11 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
title: setup#editors-and-tools - editors-and-tools section of devguide does 
not appear to be ccurate

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



[issue17953] sys.modules cannot be reassigned

2013-05-11 Thread ProgVal

New submission from ProgVal:

In Python 3.3 (I did not test with 3.4), sys.modules cannot be reassigned 
without breaking the import mechanism; while it works with Python = 3.2.

Here is how to reproduce the bug:

progval@Andromede:/tmp$ mkdir test_imports
progval@Andromede:/tmp$ echo from . import module  test_imports/__init__.py
progval@Andromede:/tmp$ echo print('foo')  test_imports/module.py
progval@Andromede:/tmp$ python3.3
Python 3.3.1 (default, Apr  6 2013, 13:58:40) 
[GCC 4.7.2] on linux
Type help, copyright, credits or license for more information.
 import sys
 sys.modules = dict(sys.modules)
 import test_imports
Traceback (most recent call last):
  File stdin, line 1, in module
  File ./test_imports/__init__.py, line 1, in module
from . import module
SystemError: Parent module 'test_imports' not loaded, cannot perform relative 
import
 
progval@Andromede:/tmp$ python3.2
Python 3.2.3 (default, May  6 2013, 01:46:35) 
[GCC 4.7.2] on linux2
Type help, copyright, credits or license for more information.
 import sys
 sys.modules = dict(sys.modules)
 import test_imports
foo


--
components: Interpreter Core
messages: 188901
nosy: Valentin.Lorentz
priority: normal
severity: normal
status: open
title: sys.modules cannot be reassigned
type: behavior
versions: Python 3.3

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



[issue17940] extra code in argparse.py

2013-05-11 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Removed the duplicated code from argparse.py

--
keywords: +patch
nosy: +Yogesh.Chaudhari
Added file: http://bugs.python.org/file30214/issue17940.patch

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



[issue17940] extra code in argparse.py

2013-05-11 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Remove extra code in argparse.py for 2.7 branch

--
hgrepos: +190
Added file: http://bugs.python.org/file30215/issue17940-27.patch

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



[issue17940] extra code in argparse.py

2013-05-11 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

I have added a patch for default branch as well, because IMO the same issue 
exists in all branches

--

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



[issue15642] Integrate pickle protocol version 4 GSoC work by Stefan Mihaila

2013-05-11 Thread Stefan Mihaila

Changes by Stefan Mihaila mstefa...@gmail.com:


Added file: http://bugs.python.org/file30216/d0c3a8d4947a.diff

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Based on the conversation and the particular inputs to the thread form neologix 
and ezio, I would like to submit this patch. 

It probably needs modification(s) as I am not sure what to do with the 
implementation that is already present in multiprocessing. This patch simply 
calls the os.cpu_count() from multiprocessing now and behaves as it would have 
previously.

The test cases are also added to test_os similar to ones from multiprocessing.

--
components: +2to3 (2.x to 3.x conversion tool)
keywords: +patch
nosy: +Yogesh.Chaudhari
Added file: http://bugs.python.org/file30217/issue17914.patch

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Charles-François Natali

Charles-François Natali added the comment:

 Based on the conversation and the particular inputs to the thread form 
 neologix and ezio, I would like to submit this patch.

 It probably needs modification(s) as I am not sure what to do with the 
 implementation that is already present in multiprocessing. This patch simply 
 calls the os.cpu_count() from multiprocessing now and behaves as it would 
 have previously.

Thanks, but it would be better to reuse Trent's C implementation
instead of multiprocessing's:
http://hg.python.org/sandbox/trent/file/dd1c2fd3aa31/Modules/posixmodule.c#l10213

--

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Ned Batchelder

Ned Batchelder added the comment:

A few small points:

Use `num is None` instead of `num == None`.

Use `isinstance(cpus, int)` rather than `type(cpus) is int`.

And this I think will throw an exception in Python 3: `cpus = 1 or cpus == 
None`, because you can't compare None to 1.

--

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



[issue17945] tkinter/Python 3.3.0: peer_create doesn't instantiate Text

2013-05-11 Thread Gregory HOULDSWORTH

Gregory HOULDSWORTH added the comment:

Noted: I assumed 'works for me' meant user approval of proposed fix,
pending 'official' sanction.
Didn't catch the BNF-like syntax for issue linking, hence the literal
's in my original post.

Thank you for clarifying those.

--

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think the idiom `os.cpu_count() or 1` should be mentioned in the 
documentation an officially recommended. Otherwise people will produce a 
non-portable code which works on their developer's computers but not on exotic 
platforms.

I have added some other comments on Rietveld.

--
nosy: +serhiy.storchaka

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I agree with Charles-François. An approach using C library functions is far 
superior to launching external commands.

--

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



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy:  -serhiy.storchaka

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Charles-François Natali

Charles-François Natali added the comment:

 I think the idiom `os.cpu_count() or 1` should be mentioned in the 
 documentation an officially recommended. Otherwise people will produce a 
 non-portable code which works on their developer's computers but not on 
 exotic platforms.

And I maintain it's an ugly idiom ;-)
Since the user can't do anything except falling back to 1,
os.cpu_count() should always return a positive number (1 by default).
That's AFAICT what all other platforms (Java, Ruby, etc) do, because
it makes sense.

--

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 And I maintain it's an ugly idiom ;-)
 Since the user can't do anything except falling back to 1,
 os.cpu_count() should always return a positive number (1 by default).

The user can also raise an error. For example, if I'm writing a
benchmark to measure per-core scaling performance, I would like to bail
out if I can't calculate the number of cores (rather than report
incorrect results).

--

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



[issue17905] Add check for locale.h

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

There are more places where including locale.h is guarded by HAVE_LANGINFO_H.

Also, there are places where including locale.h isn't guarded by anything (such 
as Python/formatter_unicode.c), so I don't think we need the new configure 
check.

--
nosy: +pitrou

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



[issue17953] sys.modules cannot be reassigned

2013-05-11 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


--
assignee:  - brett.cannon
keywords: +3.3regression
nosy: +brett.cannon

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



[issue17953] sys.modules cannot be reassigned

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I wouldn't call it a bug personally. The modules dictionary is used in all 
kinds of places in the interpreter; you can change the dictionary's contents, 
but not swap it with another one.

It's just a pity that we can't forbid reassignment altogether.

--
nosy: +pitrou

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

PyASCIIObject is allocated on heap and should have a maximal alignment enough 
for every type. If sizeof(PyASCIIObject) % SIZEOF_LONG == 0 then dest is at 
least long-aligned. Currently sizeof(PyASCIIObject) is 22 on m68k and the 
optimization is switched off at compile time. When PyASCIIObject will grow to 
24 bytes the optimization will switched on and perhaps will have some effect. I 
prefer checks for features instead of concrete names.

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 PyASCIIObject is allocated on heap and should have a maximal alignment
 enough for every type. If sizeof(PyASCIIObject) % SIZEOF_LONG == 0
 then dest is at least long-aligned. Currently sizeof(PyASCIIObject) is
 22 on m68k and the optimization is switched off at compile time. When
 PyASCIIObject will grow to 24 bytes the optimization will switched on
 and perhaps will have some effect. I prefer checks for features
 instead of concrete names.

This is a bugfix, please let's keep it simple. Checking for __m68k__
ensures that other architectures aren't affected by mistake.

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread mirabilos

mirabilos added the comment:

Right, keeping it simple helps in preventing accidents, and the code block 
looks full of magic enough as-is.

Maybe add a comment block that says:

/*
 * m68k is a bit different from most architectures in that objects
 * do not use natural alignment - for example, int and long are
 * only aligned at 2-byte boundaries. Tests have shown that skipping
 * the optimised version will even speed up m68k, so we #ifdef
 * for the odd duck out here.
 */

Then we have an in-situ documentation point for why that ifdef is there and why 
m68k is “the odd duck” and this whitelist method is used.

--

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 Since the user can't do anything except falling back to 1,
 os.cpu_count() should always return a positive number (1 by default).

In general I agree with you. Actually the os module should contains two 
functions: cpu_count() which fallbacks to 1 and is_cpu_counting_supported() for 
rare need. But this looks even more ugly and I choose single function even if 
in most cases I need use strange idiom.

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Well, then already too much bikeshedding for such simple fix. Antoine, do you 
want to commit a fix?

--

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



[issue17954] Support creation of extensible enums through metaclass subclassing

2013-05-11 Thread Nick Coghlan

New submission from Nick Coghlan:

Guido chose to follow Java in enforcing the invariant Enum members are 
instances of that Enum for PEP 435 (i.e. assert (all(isinstance(x, SomeEnum) 
for x in SomeEnum)). As a consequence, the Enum metaclass prevents subclassing 
of Enums with defined members.

This is a reasonable design choice, but one that limits the applicability of 
the standard library enum solution for use cases that currently rely on this 
feature of a custom enum implementation (including flufl.enum, the original 
inspiration for this feature).

An alternative reasonable design choice is to allow extension of enumerations 
(similar to flufl.enum) and relax the invariant to Enum members are an 
instance of that Enum or an Enum-derived parent class of that Enum (i.e. 
assert (all(issubclass(type(x), Enum) and type(x) in SomeEnum.mro() for x in 
SomeEnum))

There is no need to support this directly in the standard library, but it would 
be valuable to make it straightforward to support in an Enum variant by 
subclassing the standard metaclass (similar to the customisation mechanisms 
provided to support things like autonumbered enums through a derived 
metaclass). Currently, implementing this behaviour involves overriding a 
private method of the metaclass (EnumMetaclass._get_mixins)

--
messages: 188920
nosy: ncoghlan
priority: low
severity: normal
stage: needs patch
status: open
title: Support creation of extensible enums through metaclass subclassing
type: enhancement
versions: Python 3.4

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



[issue17954] Support creation of extensible enums through metaclass subclassing

2013-05-11 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
dependencies: +Code, test, and doc review for PEP-0435 Enum

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



[issue17947] Code, test, and doc review for PEP-0435 Enum

2013-05-11 Thread Nick Coghlan

Nick Coghlan added the comment:

The accepted PEP states that the frame hack should be removed: To support 
pickling of these enums, the module name can be specified using the module 
keyword-only argument.

Ergo, if you don't specify it, they cannot be pickled. Explicit is better than 
implicit, and this hack should not propagate beyond namedtuple (it should 
actually be deprecated in namedtuple as well).

As far as the second point goes, I had already reviewed the PEP implementation 
before making the comment (that's why I am reasonably sure you can already do 
it just by overriding _get_mixins). I see it as similar to the changes that 
were already made to support autonumbered subtypes.

However, also note that I said we should wait before doing anything about 
providing a supported mechanism for that customisation. I've now created issue 
17954 to cover a possible refactoring and documentation of that part of the 
implementation.

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0f8022ac88ad by Antoine Pitrou in branch '3.3':
Issue #17237: Fix crash in the ASCII decoder on m68k.
http://hg.python.org/cpython/rev/0f8022ac88ad

New changeset 201ae2d02328 by Antoine Pitrou in branch 'default':
Issue #17237: Fix crash in the ASCII decoder on m68k.
http://hg.python.org/cpython/rev/201ae2d02328

--
nosy: +python-dev

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



[issue17952] editors-and-tools section of devguide does not appear to be accurate

2013-05-11 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
title: editors-and-tools section of devguide does not appear to be ccurate - 
editors-and-tools section of devguide does not appear to be accurate

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ok, I hope I got the fix right :) Thanks mirabilos for the comment suggestion, 
I used a modified version.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue17936] O(n**2) behaviour when adding/removing classes

2013-05-11 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

It turned out to be slightly more compilcated.  Two additions make this 
complete:
1) check for the subtype OR the Py_None when removing subclass.  This removes 
any dependency on the order in which weakrefs are cleared.
2) When the type is cleared, manually remove ourselves from all the base 
classes.

It is because of the lack of 2) that the original version was always clearing 
out all stale weakrefs when new subclasses were added.

--
Added file: http://bugs.python.org/file30218/subtype.patch

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread mirabilos

mirabilos added the comment:

Thanks Antoine!

Now, for “finishing up” this… to follow up on Stefan’s comment… is there any 
way I can run the testsuite from an installed Python (from the Debian 
packages)? (I build the packages with disabled testsuite, to get the rest of 
the system running again, since python3.3 was recently made required and we had 
never built it before.)

Otherwise I guess I could run “make test” on one of the earlier trees I used 
for the timing… but that machine is currently building six Linux kernel 
flavours from the src:linux package and thus will not be available for the next 
one and a half week or so…

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Now, for “finishing up” this… to follow up on Stefan’s comment… is
 there any way I can run the testsuite from an installed Python (from
 the Debian packages)?

python -m test (with any options you might like), but we don't
guarantee that all tests pass on an installed Python. But at least you
will be able to spot any hard crashes :-)

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread mirabilos

mirabilos added the comment:

Antoine Pitrou dixit:

python -m test (with any options you might like), but we don't

No, I tried that (as it was the only thing I could find on the
’net as well) on an i386 system and only get:

tglase@tglase:~ $ python2.7 -m test
/usr/bin/python2.7: No module named test.__main__; 'test' is a package and 
cannot be directly executed
1|tglase@tglase:~ $ python3.2 -m test
/usr/bin/python3.2: No module named test.__main__; 'test' is a package and 
cannot be directly executed

Same when adding ‘-h’.

bye,
//mirabilos
-- 
Gast: „Ein Bier, bitte!“
Wirt: „Geht auch alkoholfrei?“
Gast: „Geht auch Spielgeld?“

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 python -m test (with any options you might like), but we don't
 
 No, I tried that (as it was the only thing I could find on the
 ’net as well) on an i386 system and only get:

Ah, that's because the system Python install doesn't include the test
suite. Perhaps you have to install an additional package, python-dev
perhaps?

(note, on 2.7, it's python -m test.regrtest)

--

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



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-11 Thread Brian Curtin

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


--
nosy:  -brian.curtin

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread mirabilos

mirabilos added the comment:

Antoine Pitrou dixit:

(note, on 2.7, it's python -m test.regrtest)

That indeed does things. So I had mistaken them for the same problem.

Ah, that's because the system Python install doesn't include the test
suite. Perhaps you have to install an additional package, python-dev
perhaps?

tglase@tglase:~ $ l /usr/lib/python2.7/test/
__init__.py   pystone.py*  regrtest.py*  test_support.py
__init__.pyc  pystone.pyc  regrtest.pyc  test_support.pyc
tglase@tglase:~ $ l /usr/lib/python3.2/test/
__init__.py  __pycache__/  pystone.py*  regrtest.py*  support.py

Maybe it’s just not packaged… these are all I can find, and
installing python3.2-dev doesn’t fix it.

Oh well, then it’ll just have to wait. Do you have a preferred
place where I can submit the test results, as it’s getting
very off-topic here?

bye,
//mirabilos
-- 
  Using Lynx is like wearing a really good pair of shades: cuts out
   the glare and harmful UV (ultra-vanity), and you feel so-o-o COOL.
 -- Henry Nelson, March 1999

--

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



[issue17237] m68k aligns on 16bit boundaries.

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Oh well, then it’ll just have to wait. Do you have a preferred
 place where I can submit the test results, as it’s getting
 very off-topic here?

Well, if everything works fine, you don't have to submit them!
If you get test failures, you can open issues for the individual test
failures.

--

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



[issue17955] Minor updates to Functional HOWTO

2013-05-11 Thread A.M. Kuchling

New submission from A.M. Kuchling:

I read through the 3.x Functional HOWTO, and it only seems to require a few 
minor updates.  The attached patch:

* adds a forward link to skip the theoretical discussion in the first section.
* remove stray extra comma
* clarify what filterfalse() is the opposite of.
* (more significant) Describe compress(), the combinatoric functions in their 
own section, and accumulate().

--
assignee: docs@python
components: Documentation
files: functional.txt
messages: 188931
nosy: akuchling, docs@python
priority: low
severity: normal
stage: patch review
status: open
title: Minor updates to Functional HOWTO
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file30219/functional.txt

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



[issue17945] tkinter/Python 3.3.0: peer_create doesn't instantiate Text

2013-05-11 Thread Guilherme Polo

Guilherme Polo added the comment:

If someone decides to commit this, please check that the name of the widget
in Tcl is always adequate.

--

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



[issue17947] Code, test, and doc review for PEP-0435 Enum

2013-05-11 Thread Guido van Rossum

Guido van Rossum added the comment:

Sorry everyone, the frame hack needs to stay.  This is not negotiable.

--
nosy: +gvanrossum

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



[issue17914] add os.cpu_count()

2013-05-11 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Appreciate everyone's feedback. I have modified the patch based on further 
messages in the thread.

@Neologix
modified posixmodule according to one in Trent's branch and used that for 
cpu_count(). Kindly suggest improvements/changes if any.

@Ned:
Thanks for the suggestions. I have applied them wherever applicable. However 
regarding 
And this I think will throw an exception in Python 3: `cpus = 1 or cpus == 
None`, because you can't compare None to 1.
It does not throw any exceptions as of now.

--
Added file: http://bugs.python.org/file30220/issue17914-1.patch

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



[issue17956] add ScheduledExecutor

2013-05-11 Thread Charles-François Natali

New submission from Charles-François Natali:

Here's an implementation of a new ScheduledExecutor abstract class, with a 
concrete ScheduledThreadPoolExecutor implementation (see #995907).
The aim is to provide a flexible, efficient and consistent framework for 
delayed and periodic tasks, leveraging on futures. Incidentally, this 
supersedes threading.Timer, which is quite fragile and inefficient.

Here's a patch with test (I didn't write the documentation, I prefer to have 
some feedback first :-), the API is complete.

There's one thing that bothers me with the current implementation: when a 
future is cancelled, like for regular ThreadPoolExecutor, it doesn't get 
removed from the work queue right away, but only when it gets dequeued. For a 
delayed future, this means that one has to wait for the next scheduled 
execution (i.e. worst case now + future.period) for it to be  effectively 
cancelled and removed from the queue, and for the executor to be shutdown. I'm 
considering using a callback (Future.add_done_callback()), that's kind of 
hackish but I don't see any other way.

--
components: Library (Lib)
files: scheduled-1.diff
keywords: needs review, patch
messages: 188935
nosy: neologix, pitrou, r.david.murray
priority: normal
severity: normal
stage: patch review
status: open
title: add ScheduledExecutor
type: enhancement
Added file: http://bugs.python.org/file30221/scheduled-1.diff

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



[issue995907] memory leak with threads and enhancement of the timer class

2013-05-11 Thread Charles-François Natali

Charles-François Natali added the comment:

OK, I just created #17956 for ScheduledExecutor, closing this one.

--
resolution:  - duplicate
stage: test needed - committed/rejected
status: open - closed
superseder:  - add ScheduledExecutor

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



[issue17547] checking whether gcc supports ParseTuple __format__... erroneously returns yes with gcc 4.8

2013-05-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9d50af4c482f by Benjamin Peterson in branch '2.7':
-Wformat is needed by gcc 4.8 (closes #17547)
http://hg.python.org/cpython/rev/9d50af4c482f

New changeset 94a7475d3a5f by Benjamin Peterson in branch '3.3':
-Wformat is needed by gcc 4.8 (closes #17547)
http://hg.python.org/cpython/rev/94a7475d3a5f

New changeset f12e3ce66ae6 by Benjamin Peterson in branch 'default':
merge 3.3 (#17547)
http://hg.python.org/cpython/rev/f12e3ce66ae6

--
nosy: +python-dev
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue17956] add ScheduledExecutor

2013-05-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +bquinlan, gvanrossum

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



[issue17547] checking whether gcc supports ParseTuple __format__... erroneously returns yes with gcc 4.8

2013-05-11 Thread Benjamin Peterson

Benjamin Peterson added the comment:

We really ought to just scrap that configure test.

--

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



[issue17955] Minor updates to Functional HOWTO

2013-05-11 Thread Ezio Melotti

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


--
nosy: +ezio.melotti

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



[issue17937] Collect garbage harder at shutdown

2013-05-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I was asked what this patch did exactly: it simply calls the garbage collector 
one last time after sys.modules has been cleared. I don't know it it makes much 
of a difference, but it may limit the amount of leaking when doing successive 
Py_Initialize/Py_Finalize calls.

--

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



  1   2   >