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  wrote:
>> On 8 mai, 15:19, Roy Smith  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  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  |  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  wrote:
> On May 10, 8:32 pm, Chris Angelico  wrote:
>> On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder  
>> wrote:
>> > On 5/10/2013 11:06 AM, jmfauth wrote:
>>
>> >> On 8 mai, 15:19, Roy Smith  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
 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 D&D 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
 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  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  wrote:

On May 10, 8:32 pm, Chris Angelico  wrote:

On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder  wrote:

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



On 8 mai, 15:19, Roy Smith  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  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  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  writes:

> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
>  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  wrote:
> Chris Angelico  writes:
>
>> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
>>  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  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:

<>
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 ();

<>
/* 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:
> 
> 
> 
> <>
> 
> 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 ();
> 
> 
> 
> <>
> 
> /* 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  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"  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  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  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  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  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
 wrote:
> On Fri, 10 May 2013 14:33:52 +1000, Chris Angelico 
> 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 wrote:

> 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-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
 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
 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
 wrote:
> Chris Angelico wrote:
>>
>> On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber
>>  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  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 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  wrote:
> 
> > Chris Angelico  writes:
> 
> >
> 
> >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
> 
> >>  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
 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  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  wrote:
> On 12 May, 06:10, Mark Janssen  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  wrote:
> On May 12, 3:16 am, alex23  wrote:
>> On 12 May, 06:10, Mark Janssen  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  wrote:
> On May 12, 3:16 am, alex23  wrote:
>
> > On 12 May, 06:10, Mark Janssen  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


Re: Append to python List

2013-05-11 Thread Jussi Piitulainen
Chris Angelico writes:
> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen 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.

Yes, I understood why people say so when it followed up to something I
wrote myself, and what it wrote made no sense in the context. My
response was also generated by a bot: M-x doctor in Emacs, meant to be
funny.

Don't worry, I'm not going to engage it further.
-- 
http://mail.python.org/mailman/listinfo/python-list