Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Terry Reedy

On 8/20/2014 11:36 AM, Everything You Need To Know wrote:

Neat little exercise, surprisingly cool results!
less than 3 minutes!

https://www.youtube.com/watch?v=PlDjl5JK0eU&feature=youtu.be


Dear EYNToK (Adam Nowak?, the name on the video?): I am both a long-term 
participant in this group and currently one of the behind-the-scenes 
moderators. Here are the mistakes you made.


0. You posted from Google Groups.
0a. GG is the source of at least half the spam targeted at python-list, 
including the stuff that gets caught and discarded by me or another 
moderator.  Google gives the appearance of being indifferent to being 
spam source #1. Or maybe they see it as a mark of success somehow.
0b. By default, GG does not follow normal and reasonable protocols. 
Google is obviously indifferent to that. At one time in the past, Google 
would have been cut off from usenet groups for GG's behavior. Now Google 
is too big and powerful and hence arrogant.
0c. Some posters, when requested, change the defaults as requested and 
instructed. Some do not, thereby asking to be ignored.


1. A pseudonym, but not just a pseudonym, but one that could be 
interpreted as intentionally obnoxious and 'in our faces', such as used 
by trolls.  I realize that as a newcomer, you don't know the history, 
but it affects people who have been around awhile.


2. Slightly deceptive subject line, to your detriment. The video is 
about simulating indefinite precision long division with python. This is 
a quite legitimate beginner exercise. The 1/998001 example is just an 
illustration of the value of being able to get more than 18 decimal digits.


3. The form of your post! It screams 'I am spam!' Judgment in 3 seconds!

In sum, if this post had been presented to me by the spam filter for 
action, and I had acted without viewing the video, especially late at 
night when tired, I might have deleted it.


Having watched the video, I now know that would have been a mistake. As 
Steven said, properly formatted occasional announcements of free 
python-related resources are on-topic. (If we got multiple such 
announcements every day, we might change the rules.) I agree with the 
rest of his excellent post.


--
Terry Jan Reedy

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Everything You Need To Know
On Thursday, 21 August 2014 16:55:44 UTC+9:30, Terry Reedy  wrote:
> On 8/20/2014 11:36 AM, Everything You Need To Know wrote:
> 
> > Neat little exercise, surprisingly cool results!
> 
> > less than 3 minutes!
> 
> >
> 
> > https://www.youtube.com/watch?v=PlDjl5JK0eU&feature=youtu.be
> 
> 
> 
> Dear EYNToK (Adam Nowak?, the name on the video?): I am both a long-term 
> 
> participant in this group and currently one of the behind-the-scenes 
> 
> moderators. Here are the mistakes you made.
> 
> 
> 
> 0. You posted from Google Groups.
> 
> 0a. GG is the source of at least half the spam targeted at python-list, 
> 
> including the stuff that gets caught and discarded by me or another 
> 
> moderator.  Google gives the appearance of being indifferent to being 
> 
> spam source #1. Or maybe they see it as a mark of success somehow.
> 
> 0b. By default, GG does not follow normal and reasonable protocols. 
> 
> Google is obviously indifferent to that. At one time in the past, Google 
> 
> would have been cut off from usenet groups for GG's behavior. Now Google 
> 
> is too big and powerful and hence arrogant.
> 
> 0c. Some posters, when requested, change the defaults as requested and 
> 
> instructed. Some do not, thereby asking to be ignored.
> 
> 
> 
> 1. A pseudonym, but not just a pseudonym, but one that could be 
> 
> interpreted as intentionally obnoxious and 'in our faces', such as used 
> 
> by trolls.  I realize that as a newcomer, you don't know the history, 
> 
> but it affects people who have been around awhile.
> 
> 
> 
> 2. Slightly deceptive subject line, to your detriment. The video is 
> 
> about simulating indefinite precision long division with python. This is 
> 
> a quite legitimate beginner exercise. The 1/998001 example is just an 
> 
> illustration of the value of being able to get more than 18 decimal digits.
> 
> 
> 
> 3. The form of your post! It screams 'I am spam!' Judgment in 3 seconds!
> 
> 
> 
> In sum, if this post had been presented to me by the spam filter for 
> 
> action, and I had acted without viewing the video, especially late at 
> 
> night when tired, I might have deleted it.
> 
> 
> 
> Having watched the video, I now know that would have been a mistake. As 
> 
> Steven said, properly formatted occasional announcements of free 
> 
> python-related resources are on-topic. (If we got multiple such 
> 
> announcements every day, we might change the rules.) I agree with the 
> 
> rest of his excellent post.
> 
> 
> 
> -- 
> 
> Terry Jan Reedy

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


proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper
Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic (in 
a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the language
this is what yours truly thinks: don't we all know that ":" means the next 
token must be an indent (mostly)? and doesn't the "(" and its alikes, [ and } 
begin an space-insensitive lexing context? so all we need is having an 
"space-sensitivity-stack" and the corresponding "(" counting stack and this way 
we could match opening and closing "()" and pop the space-sensitivity-stack 
whenever the "(" counting stack gets a 0 at the top:

def doFunc(func): return func()
doFunc(def(): 
   print( "anon" )
   return "gvr") #this ")" will try to decrease the "(" -matching stak's top, 
but this is a zero(there is no "(" to be matchd in the current context) so this 
will pop the "(" stack and also the space sensitivity stack till a non-zero 
value gets in top of "("-matching stac


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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 21/08/2014 03:07, Everything You Need To Know wrote:

You'd make more friends here if you weren't suffering from google groups 
disease, which seems to be spreading like wildfire at the moment.  To 
cure this terrible affliction please access this list via 
https://mail.python.org/mailman/listinfo/python-list or read and action 
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us 
seeing double line spacing and single line paragraphs, thanks.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 21/08/2014 07:09, Everything You Need To Know wrote:


I am just finishing this thread, as I said it will take a little time, I am 
trying to collaborate with more than one person.



You are certainly very trying.  I see no evidence of collaboration.  I 
also see no evidence of the vitriol you keep mentioning.


You have three options.

1) Carry on the way you are and get plonked.
2) Change and be accepted.

Take your pick.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread Chris Angelico
Ah, here we go again! It's multi-line lambda season. Comes around as
regularly as duck-typing season, rabbit seasoning, baseball season,
and other Looney Tunes references. :)

On Thu, Aug 21, 2014 at 5:55 PM,   wrote:
> doFunc(def():
>print( "anon" )
>return "gvr")

What I'm seeing here is that "def():" introduces a suite which becomes
a function definition that's part of the current expression. That's
reasonable, but I don't like the close parens on the same line; even
if this syntax is allowed, I'd frown on it in style guides,
recommending the close parens go on the next line:

doFunc(def():
print( "anon" )
return "gvr"
)

But either way, the question you need to answer is: How is this better
than the regular syntax for named functions?

def tmp():
print( "anon" )
return "gvr"
doFunc(tmp)

The one use-case that I can think of is large expressions like dict
displays, but I'd like to see a serious example that actually needs
this. Here's a toy example:

tag_handler = {
"span": lambda content: content,
"div": lambda content: "\n"+content+"\n",
"p": lambda content: "\n"+content+"\n",
"br": lambda content: "\n",
}

If you wanted to expand one of those to have statements in it, you'd
have to take it out-of-line and break the flow. But this is totally
contrived and not real-world; before this sort of feature gets into
the language, there really needs to be a concrete use-case. Since
there's nothing that actually cannot be done with an out-of-line
function, the criterion has to be "doing this out-of-line is extremely
ugly or error-prone", which is a fairly high bar to reach. You'll need
something where anyone will immediately say "Oh, that way is horribly
hard to read, but the new way makes it beautifully clean!".

Python is much more statement-oriented than some languages. In Pike, I
can have a function that's syntactically a single gigantic expression,
because it (occasionally!!) makes sense to do it that way; Python
doesn't really give that option. So while Pike has good justification
for an anonymous function syntax with full statement support, Python
doesn't really call for it as much. That's why Python's survived this
long with its lambda functions being so severely restricted :)

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 21/08/2014 07:52, Everything You Need To Know wrote:



I have answered all these questions already! stop wasting time



I entirely agree, stop wasting time.  Hardly surprising you didn't get 
on at uni as that involves engaging with people.  You can't take the 
mildest criticism and refuse to change, with the dread google groups 
conspicious throughout your posts.  Much more of this and I'll be 
reaching for the plonk key.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Chris “Kwpolska” Warrick
On Thu, Aug 21, 2014 at 3:22 AM, Everything You Need To Know
 wrote:
> I do understand where you are coming from 'Chris "Kwpolska" Warrick', though, 
> your own self serving link to your own website and unproductive post is 
> closer to spam than my own, I offer something practical and positive to the 
> community, even if the wrong community to post.

You are speaking of the link in the signature.  Signatures are not
considered “content”.  You weren’t forced to read the signature, you
could’ve stopped at the dash-dash-space line; hell: modern e-mail
clients would helpfully hide this, or change its color, or in a
different way state “signature — no need to care”.

Unlike you, I haven’t just posted “read this amazing blog post!  only
500 words!  it does not explain things thoroughly!” in a way that many
spam filters would (or should) catch.  In fact, I never posted a thing
to promote my blog to this list in my life.  Besides, this is a
discussion list — announcements would fit the announcement list better
(comp.lang.python.announce on usenet/python-announce as ML).

On Thu, Aug 21, 2014 at 1:08 AM, Steven D'Aprano
 wrote:
> If you think it is spam (or at least borderline), perhaps you should not
> quote the url and provide links to the content?

Oh, sorry.  I forgot to edit and just had the message reproduced verbatim.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 21/08/2014 08:40, Everything You Need To Know wrote:

On Thursday, 21 August 2014 16:55:44 UTC+9:30, Terry Reedy  wrote:

On 8/20/2014 11:36 AM, Everything You Need To Know wrote:


Neat little exercise, surprisingly cool results!



less than 3 minutes!







https://www.youtube.com/watch?v=PlDjl5JK0eU&feature=youtu.be




Dear EYNToK (Adam Nowak?, the name on the video?): I am both a long-term

participant in this group and currently one of the behind-the-scenes

moderators. Here are the mistakes you made.



0. You posted from Google Groups.

0a. GG is the source of at least half the spam targeted at python-list,

including the stuff that gets caught and discarded by me or another

moderator.  Google gives the appearance of being indifferent to being

spam source #1. Or maybe they see it as a mark of success somehow.

0b. By default, GG does not follow normal and reasonable protocols.

Google is obviously indifferent to that. At one time in the past, Google

would have been cut off from usenet groups for GG's behavior. Now Google

is too big and powerful and hence arrogant.

0c. Some posters, when requested, change the defaults as requested and

instructed. Some do not, thereby asking to be ignored.



1. A pseudonym, but not just a pseudonym, but one that could be

interpreted as intentionally obnoxious and 'in our faces', such as used

by trolls.  I realize that as a newcomer, you don't know the history,

but it affects people who have been around awhile.



2. Slightly deceptive subject line, to your detriment. The video is

about simulating indefinite precision long division with python. This is

a quite legitimate beginner exercise. The 1/998001 example is just an

illustration of the value of being able to get more than 18 decimal digits.



3. The form of your post! It screams 'I am spam!' Judgment in 3 seconds!



In sum, if this post had been presented to me by the spam filter for

action, and I had acted without viewing the video, especially late at

night when tired, I might have deleted it.



Having watched the video, I now know that would have been a mistake. As

Steven said, properly formatted occasional announcements of free

python-related resources are on-topic. (If we got multiple such

announcements every day, we might change the rules.) I agree with the

rest of his excellent post.



--

Terry Jan Reedy


Well said



Glad to see that you took it on board.  Except that you're still using 
google groups.  I'm not interested in trying to read posts when they're 
in the appalling formatting above.  Please take steps to rectify the 
situation or go away, your choice.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper

> reasonable, but I don't like the close parens on the same line; even
> 
> if this syntax is allowed, I'd frown on it in style guides,
> 

thanks, bu what exactly do you find unlikeable in this syntax? the ")" is no 
new syntax, but simply a match for a previous "("; and you can put it anywhere 
because the "(" contents are space-insensitive:
  
this would be a syntax error:
a = def():
   print("gvr")

this too:
a = def():
  print("anon")

but not this:
a = (def():
   print("no")
)

neither this:
a = (def():
   print("d"))

nor this:
a = (def():
print( "no" )


)

yours truly would be glad to know your thoughts on this
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread Chris Angelico
On Thu, Aug 21, 2014 at 6:59 PM,   wrote:
> thanks, bu what exactly do you find unlikeable in this syntax? the ")" is no 
> new syntax, but simply a match for a previous "("; and you can put it 
> anywhere because the "(" contents are space-insensitive:
>
> this would be a syntax error:
> a = def():
>print("gvr")
>
> this too:
> a = def():
>   print("anon")
>
> but not this:
> a = (def():
>print("no")
> )
>
> neither this:
> a = (def():
>print("d"))
>
> nor this:
> a = (def():
> print( "no" )
>
>
> )
>
> yours truly would be glad to know your thoughts on this

I think it's less readable if the close parens goes on the previous
line. However, that's a question of style, more than syntax. I just
think it'd look better with a clear unindent at the end of a block of
statements which all stand alone.

But that was a small side point. What matters is: How is this new
syntax better than out-of-line function definition?

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


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper
reasonable, but I don't like the close parens on the same line; even 
> 
> if this syntax is allowed, I'd frown on it in style guides, 
> 

thanks, bu what exactly do you find unlikeable in this syntax? the ")" is no 
new syntax, but simply a match for a previous "("; and you can put it anywhere 
because the "(" contents are space-insensitive: 
  
this would be a syntax error: 
a = def(): 
   print("gvr") 

this too: 
a = def(): 
  print("anon") 

but not this: 
a = (def(): 
   print("no") 
) 

neither this: 
a = (def(): 
   print("d")) 

nor this: 
a = (def(): 
print( "no" ) 


) 

we're all grown-ups, aren't we? if we wanted to mess the syntax up then "(" 
alone would have let us do obscene things like:

if (a
==
 b): gvr()

or

a =(1, 2
  5



)

and we also could fiddle with an instance's (or class's) intendedly private 
members (no pun) but 

did we ever do?

yours truly would be glad to know your thoughts on this
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper
it is simply a matter of convenience:


def a(): 
  print( "gvr" )
func(a);

or

func( def():
   print("gvr")
)

it would be great if others could further share their opinions 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread Marko Rauhamaa
[email protected]:

> it is simply a matter of convenience:
>
> def a(): 
>   print( "gvr" )
> func(a);
>
> or
>
> func( def():
>print("gvr")
> )
>
> it would be great if others could further share their opinions 

In practice, your proposal would not make life easier for Python
programmers.


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


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper

> tag_handler = {
> 
> "span": lambda content: content,
> 
> "div": lambda content: "\n"+content+"\n",
> 
> "p": lambda content: "\n"+content+"\n",
> 
> "br": lambda content: "\n",
> 
> }
> 
> 
> 
> If you wanted to expand one of those to have statements in it, you'd
> 
> have to take it out-of-line and break the flow. 

what 'bout, well , this?
tag_handler = { 
"span": 
lambda content: content, 
"div": 
lambda content: 
"\n"+content+"\n", 
"p": 
  lambda content: "\n"+content+"\n", 
"br": 
 lambda content: "\n", 
} 

yours truly is trying to convey the actual fact that python could already be 
untidy; what has kept the language tidy so far is partly because moral 
developers 
(the syntax being another half)

yours truly will hence think the proposition won't be directly untidifying the 
syntax -- much in the sense that not-caring-for-ws-in-"{" won't.

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


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread icefapper
On Thursday, August 21, 2014 2:27:08 AM UTC-7, Marko Rauhamaa wrote:

> In practice, your proposal would not make life easier for Python
> 
> programmers.
> 
> 
> 
> 
> 
> Marko

neither did the lambda, yours truly supposes?

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


ANN: PyDDF Sprint 2014

2014-08-21 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 sprint in Düsseldorf, Germany]

ANKÜNDIGUNG

 PyDDF Sprint 2014

   27/28.09.2014

 Python Meeting Düsseldorf
http://pyddf.de/sprint2014/


INFORMATION

Das Python Meeting Düsseldorf (PyDDF) veranstaltet zusammen mit dem
ZIM der Heinrich-Heine-Universität Düsseldorf ein Python Sprint
Wochenende im September.

Der Sprint findet am Wochenende 27/28.09.2014 im Seminarraum
25.41.00.45 (Gebäude 25.41, Erdgeschoss, Raum 45) des ZIM der
HHU Düsseldorf stattfinden:

http://www.zim.hhu.de/das-zim/lageplan-und-anreiseskizze.html

Folgende Themengebiete haben wir als Anregung angedacht:

 * Openpyxl

   Openpyxl ist eine Python Bibliothek, mit der man Excel 2010
   XLSX/XLSM Dateien lesen und schreiben kann
   (https://pythonhosted.org/openpyxl/).

   Charlie ist Co-Maintainer des Pakets und würde gerne an
   folgenden Themen arbeiten:

 - ElementTree Implementation des lxml.etree.xmlfile Moduls
   (context manager)
 - Co-Routines für die Serialisierung
 - Python Code-Object-Generierung anhand des Schemas

 * HTTP Audio Streaming für Mopidy

   Mopidy ist ein MPD Musikserver, der viele Internet-Streaming-Dienste
   abonnieren kann, diese jedoch nur über lokale Audiogeräte ausgibt
   (http://docs.mopidy.com/en/latest/).

   Es wäre schön, wenn man auch Internetradios anschließen
   könnte, wie z.B. die Squeezebox. Es gibt dazu schon ein Ticket,
   auf dem man vermutlich aufbauen könnte:

- https://github.com/mopidy/mopidy/issues/56

   Ziel wäre es, eine Mopidy Extension zu schreiben, die dieses
   Feature umsetzt.

Natürlich kann jeder Teilnehmer weitere Themen vorschlagen, z.B.

 * Kivy
 * Raspberry Pi
 * FritzConnection
 * OpenCV
 * u.a.

Alles weitere und die Anmeldung findet Ihr auf der Sprint Seite:

http://pyddf.de/sprint2014/

Teilnehmer sollten sich zudem auf der PyDDF Liste anmelden, da wir
uns dort koordinieren:

https://www.egenix.com/mailman/listinfo/pyddf

Wir haben nur begrenzten Platz im Seminarraum, daher wäre es gut,
wenn wir die ungefähre Anzahl Teilnehmer schon in Vorfeld einplanen
könnten. Platz ist für max. 30 Teilnehmer.


ÜBER UNS

Das Python Meeting Düsseldorf (PyDDF) ist eine regelmäßige Veranstaltung
in Düsseldorf, die sich an Python Begeisterte aus der Region wendet:

 * http://pyddf.de/

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

 * http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/

Mit freundlichen Grüßen,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 21 2014)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2014-09-19: PyCon UK 2014, Coventry, UK ...29 days to go

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread Terry Reedy

On 8/21/2014 5:14 AM, [email protected] wrote:

it is simply a matter of convenience:


def a():
   print( "gvr" )
func(a);

or

func( def():
print("gvr")
)

it would be great if others could further share their opinions


I have, multiple time in previous threads. A bad idea. Unnecessary. 
Nearly useless.


--
Terry Jan Reedy

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


Python vs C++

2014-08-21 Thread David Palao
Hello,
I consider myself a python programmer, although C++ was one of the
first languages I learned (not really deeply and long time ago).

Now I decided to retake C++, to broaden my view of the business.
However, as I progress in learning C++, I cannot take out of my head
one question

 Why to use C++ instead of python?

It is not ranting against C++. I was/am looking for small-medium
projects to exercise my C++ skills. But I'm interested in a "genuine"
C++ project: some task where C++ is really THE language (and where
python is actually a bad ab initio choice).
The usual argument in favour of C++ (when comparing to python) is
performance. But I'm convinced that, in general, the right approach is
"python-profiling-(extension/numpy/Cython/...)". At least for a python
programmer. I might be wrong, though.

This is, perhaps, a bit off-topic, but I really want to know the
thoughts of experienced python programmers on it.

Thanks in advance,

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Everything You Need To Know
On Thursday, 21 August 2014 01:06:37 UTC+9:30, Everything You Need To Know  
wrote:

These exercises were all linked together to make a 'python' board game, Thought 
it was really neat myself. This is something that would not interest this Forum 
I am to presume?

Thank you

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


Re: Python vs C++

2014-08-21 Thread Burak Arslan

On 08/21/14 15:54, David Palao wrote:
> But I'm interested in a "genuine"
> C++ project: some task where C++ is really THE language (and where
> python is actually a bad ab initio choice)

For my day job, I chose Qt on C++ for a classic desktop app that needs
to be deployed on Windows (among other platforms) with an installation
package that is as small as possible.

All I need to do deployment-wise is to create an NSIS script putting a
couple of DLL's and my executable in a folder in %ProgramFiles% and a
shortcutin start menu. The full package is 5 megs and the update archive
is pushing half a megabyte.

I was also back to C++ after a number of years of exclusive web dev with
Python and Javascript. C++11 is just *sweet*, I'd never imagined I'd
enjoy doing non-computer-sciencey work with C++.

good luck,
burak

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


Re: Python vs C++

2014-08-21 Thread Chris Angelico
On Thu, Aug 21, 2014 at 10:54 PM, David Palao  wrote:
> Why to use C++ instead of python?
>
> This is, perhaps, a bit off-topic, but I really want to know the
> thoughts of experienced python programmers on it.

No, it's a fair question. Why are we all here?

The fact is, there's not a huge amount of reason left. If you're
linking against a C++ API, you may find it easiest to do the whole
program in C++, rather than use something like Cython (which, as far
as I'm aware, is C-only) or write a two-part project. And obviously if
you have an existing C++ codebase, then porting it has costs, and
maintaining it is probably better. But for the most part, I would
strongly recommend starting a project in a high level language like
Python unless there's a really compelling reason to do otherwise. C++
has, of late, been growing a number of features that belong in higher
level languages; but if you want those sorts of features, why not just
grab Python or Pike or something and save yourself the trouble?

One possible advantage is compactness. Once you've compiled a C++
program, you don't have to distribute as much stuff with it as an
entire Python interpreter. Also, true compilation obscures your source
code a lot better than any attempt at a mangled Python would, so if
you're trying to demonstrate to upper management that your code isn't
being given away, that might be an advantage. (But frankly, even that
isn't all that useful. The only way to truly stop people from using
your code is to not give it to them in any form, which these days
generally means putting it on a server and providing web browser
access. And that works just fine for Python code.)

There are reasons for using C, of course. I'm not sure whether your
question is about C++ specifically, or also about C. But in my
opinion, C is for writing high level languages in, and applications
should be written in something else. It's like stack-based programming
- sure, it's efficient and all, but it's not something you want to
spend all day debugging. (If you look at CPython bytecode disassembly,
you'll see that the interpreter's actually stack-based; but we don't
have to worry about keeping the stack straight, we just write nice
clean Python code.) Interfacing with C-level libraries can be done
with an absolute minimum of low-level code (probably with Cython), and
the main application logic can still be in Python.

Let's suppose you're starting a greenfield project, and either Python
or C++ would have been the perfect language, but you chose wrongly.
What are the consequences? If you chose C++, you have a much heavier
development and maintenance cost, and Python would have been good
enough, so you get no significant benefit - basically, you miss out on
the ease of coding that Python offers you. If you chose Python, what
you now have is a proof-of-concept that you can use to prove the
correctness of any rewrites (just get a good test suite going and then
use the same tests for both engines), at a relatively low development
cost. Considering that the cost of erring on Python's side is lower
AND the likelihood of Python being correct is higher, I would say that
you can safely bet on Python for a new project, and leave C++ until
you have some really good reason for taking it up :)

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


Re: Python vs C++

2014-08-21 Thread Neil D. Cerutti

On 8/21/2014 8:54 AM, David Palao wrote:

Hello,
I consider myself a python programmer, although C++ was one of the
first languages I learned (not really deeply and long time ago).


Hey, that sounds just like me.


Now I decided to retake C++, to broaden my view of the business.
However, as I progress in learning C++, I cannot take out of my head
one question


I have gone back and attempted to use C++ again a couple of times, but 
 it turns out to not be worthwhile in my current position.



  Why to use C++ instead of python?

It is not ranting against C++. I was/am looking for small-medium
projects to exercise my C++ skills. But I'm interested in a "genuine"
C++ project: some task where C++ is really THE language (and where
python is actually a bad ab initio choice).
The usual argument in favour of C++ (when comparing to python) is
performance. But I'm convinced that, in general, the right approach is
"python-profiling-(extension/numpy/Cython/...)". At least for a python
programmer. I might be wrong, though.


Python, for me, is the ultimate translator and aggregator of data. I use 
it constantly to get data from one place, combine it with some other 
data over there, fiddle with it, and spit it out in some usable manner.


I could certainly use C++ for my projects. I think the standard 
containers, iterators, and algorithms provided in the STL are beautiful. 
Simple things can be relatively simple in C++, when I use the right 
parts of it. But in that case C++ doesn't provide me many 
benefits--virtually zero. Python's immutable strings and hash-based 
mapping type can even be faster than C++ in some cases. But I simply 
don't need efficiency. My longest running program takes less than 3 
seconds to complete, and that's plenty fast for my purpose. The archaic 
separate compilation/linking model and the complication of static type 
declarations seem a pain in the ass that I don't benefit very much from.


The one program I needed that was just horribly slow in Python involved 
trying to match up names in a fuzzy manner between two systems, to help 
me find students who couldn't be bothered to get their own social 
security number correct. This took nearly 20 minutes to run. But, 
ummm.., it turned out I was doing the wrong thing. Even students who 
can't remember their SSN mostly got their phone number or email address 
correct, it turns out.


There's a tall stack of stuff *not* written in Python that I depend on, 
though: Python itself, sqlite3, gvim, Windows 7, etc. At this point I 
feel hopelessly unqualified to write any of that stuff, but if I had to, 
I'd need to resuscitate my C++, or at least my C, as a starting point. 
There's a growing number of projects hoping to bridge an apparent gap 
between Python and C. C++ can be regarded as an early effort--so early 
that there was no Python to measure against. Maybe it would've turned 
out better if there had been. ;)


Python developers are filling part of the gap with libraries, e.g., 
numpy and scipy. I could take advantage of numpy by installing Pandas; 
I'll learn Pandas long before I resort to C++.


--
Neil Cerutti

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


Distinguishing attribute name from varible name to make codes clear and definite

2014-08-21 Thread luofeiyu

I feel that self.x and x will be confused in the following codes.

class MyDescriptor(object):
 def __init__(self, x):
 self.x = x
 def __get__(self, instance, owner):
 print('get from descriptor')
 return self.x
 def __set__(self, instance, value):
 print('set from descriptor')
 self.x = value
 def __delete__(self, instance):
 print('del from descriptor, the val is', self.x)

exam=MyDescriptor("hallo")


when class MyDescriptor  initiate , the `hallo` was passed into x in 
__init__(self, x);
Literally  self.x maybe understood to be self.hallo ,assign a attribute 
named 'hallo' to instance exam.

It is a better way to replace self.x to self.y .

class MyDescriptor(object):
 def __init__(self, x):
 self.y = x
 def __get__(self, instance, owner):
 print('get from descriptor')
 return self.y
 def __set__(self, instance, value):
 print('set from descriptor')
 self.y = value
 def __delete__(self, instance):
 print('del from descriptor, the val is', self.y)
exam=MyDescriptor("hallo")


There is a attribute y  in instance exam , the `hallo` was passed into x 
in __init__(self, x).No any relation between x and y ,`hallo` and y.

My view is correct or not ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread Rustom Mody
On Thursday, August 21, 2014 6:24:18 PM UTC+5:30, David Palao wrote:
> Hello,
> I consider myself a python programmer, although C++ was one of the
> first languages I learned (not really deeply and long time ago).

> Now I decided to retake C++, to broaden my view of the business.
> However, as I progress in learning C++, I cannot take out of my head
> one question

>  Why to use C++ instead of python?

> It is not ranting against C++. I was/am looking for small-medium
> projects to exercise my C++ skills. But I'm interested in a "genuine"
> C++ project: some task where C++ is really THE language (and where
> python is actually a bad ab initio choice).
> The usual argument in favour of C++ (when comparing to python) is
> performance. But I'm convinced that, in general, the right approach is
> "python-profiling-(extension/numpy/Cython/...)". At least for a python
> programmer. I might be wrong, though.

> This is, perhaps, a bit off-topic, but I really want to know the
> thoughts of experienced python programmers on it.

Not C++ but (mostly) C:
http://damienkatz.net/2013/01/the_unreasonable_effectiveness_of_c.html

And someone opposed to that view:
http://dieswaytoofast.blogspot.in/2013/01/why-i-grown-to-loathe-c.html

I said something about it here:
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Distinguishing attribute name from varible name to make codes clear and definite

2014-08-21 Thread Denis McMahon
On Thu, 21 Aug 2014 22:13:32 +0800, luofeiyu wrote:

> I feel that self.x and x will be confused in the following codes.

Then don't call them self.x and x, call them self.internal_x and param_x, 
or any other pair of different names.

You are the one who chooses what names to use in your code.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread Grant Edwards
On 2014-08-21, David Palao  wrote:

>  Why to use C++ instead of python?

 1) C++ is the only language available for your platform, and for some
reason you are unable to build Python from source.

 2) You need money, and the only person willing to pay you says use
C++ and won't listen to reason.

 3) You're a masochist.

That's all I can think of...

-- 
Grant Edwards   grant.b.edwardsYow! I want a WESSON OIL
  at   lease!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread David Palao
Thank you for the interesting answers.

Just a clarification. Actually for the scope of this question, I
consider C and C++ quite different. At least when they are "properly"
used (eg, you could use C++ as a better C, but this is not C++ in its
full glory).
In my opinion, if all that you want is performance, coding critical
parts in C or Frotran should be enough. Or even Cython. As far as the
fraction of code that turns out to be critical is relatively small.
But C++ is a monster compared to C. And I realize it requires a huge
amount of time and practice to master it. The question is whether is
it worth as a generic approach or not (*). I tend to think that it
isn't that useful.

Best,

David


(*) as some of you already mentioned, you could need C++ for joining a
specific project, for instance. But that would not imply anything
about how well suited is C++ for that particular project.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread Michael Torrie
On 08/21/2014 07:39 AM, Burak Arslan wrote:
> For my day job, I chose Qt on C++ for a classic desktop app that needs
> to be deployed on Windows (among other platforms) with an installation
> package that is as small as possible.
> 
> All I need to do deployment-wise is to create an NSIS script putting a
> couple of DLL's and my executable in a folder in %ProgramFiles% and a
> shortcutin start menu. The full package is 5 megs and the update archive
> is pushing half a megabyte.
> 
> I was also back to C++ after a number of years of exclusive web dev with
> Python and Javascript. C++11 is just *sweet*, I'd never imagined I'd
> enjoy doing non-computer-sciencey work with C++.

Definitely second the idea of using Qt and C++ to build something.  Qt
is natively C++, so it's most at home there.  Qt works fine in other
languages, like Python, but it's not a perfect fit there because Qt is
based on the C++ object model.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Steven D'Aprano
Ben Finney wrote:

> Everything You Need To Know  writes:
> 
>> I guess I have to agree and was mistaken, though vitriol I found
>> unnecessary and unproductive!
> 
> You've behaved obnoxiously, as has been pointed out. 

People can point out anything they like, it does not mean it is necessarily
so. Adam ("Everything You Need To Know") has perhaps posted unwisely and
clumsily, but obnoxiously?

Obnoxious (noun): 
very offensive; hateful; odious; reprehensible.

What did Adam do that was *obnoxious*? Here are some of the accusations
thrown at him:

- his "fancy" video is too simple for the "skilled Python programmers" at
this forum and is "barely original";

- he posted using a "self-aggrandising name" instead of his "real name";

- he posted a link to another website (oh the horror!!!);

- his post is "spam" (commercial, unsolicited advertising);

- he posted as a member of a group instead of an individual.

And that's pretty much it.

I reject any suggestion that Adam's post is "obnoxious" or that it is spam.
It is clearly on-topic. Frankly, I am ashamed at the closed-minded
hostility demonstrated here in this thread. Ben, I believe that your
behaviour goes against the spirit of the Python Community Code of Conduct,
if not the actual letter of CoC. Can you honestly say that you have been
Open, Considerate, and Respectful in telling Adam that his post
was "obnoxious" and that his post is "not appropriate" just because it is
hosted on YouTube?

This is supposed to be a welcoming place. Does anyone think we as a
community have been welcoming to Adam? 

- We jumped down his throat for a couple of minor social faux pas, like
failing to sign his post with a name. 

- We displayed the most odious double-standards: we attacked Adam for
posting on behalf of a group, but when members of the PSF or the Python
core developers make an announcement or post speaking for those groups, we
accept their right to do so without question.

- We allow long-time community members to link to external forums, we accept
them including links to their own blogs and websites, but accused Adam of
being a spammer because he linked to an on-topic video hosted on YouTube. 

- We've made the most egregious and unjustified generalisations, speaking
for others without their consent, by insisting that "most" of us here are
too experienced to care for Adam's post. I'm an experienced Python
programmer, I've been contributing here and on other forums for over a
decade, and I learned something new from Adam's video.

Earlier, I posted on how Adam could have, *should* have, engaged with us.
But we should have engaged with him too:

- we should have assumed good faith, instead of accusing him of being a
spammer;

- we should have been welcoming, instead of exclusionary and elitist;

- we should have given him constructive criticism for his video, since it is
on-topic, rather than being so carelessly dismissive;

- or even just ignored it, if you don't like instructional videos;

- we should be respectful of people's right to prefer video over text, as
misguided as I personally believe it to be, some people like it;

- and we should be forgiving of minor faux pas and gaffes, rather than going
on the attack as we did.

Adam, for myself, I am sorry that we allowed a few mild gaffes on your part
lead to such a hostile reception for you, but please have a belated
welcome.



-- 
Steven

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


Re: Python vs C++

2014-08-21 Thread Joseph Martinot-Lagarde

Le 21/08/2014 15:40, Chris Angelico a écrit :

On Thu, Aug 21, 2014 at 10:54 PM, David Palao  wrote:

Why to use C++ instead of python?

This is, perhaps, a bit off-topic, but I really want to know the
thoughts of experienced python programmers on it.


No, it's a fair question. Why are we all here?

The fact is, there's not a huge amount of reason left. If you're
linking against a C++ API, you may find it easiest to do the whole
program in C++, rather than use something like Cython (which, as far
as I'm aware, is C-only) or write a two-part project. And obviously if
you have an existing C++ codebase, then porting it has costs, and
maintaining it is probably better. But for the most part, I would
strongly recommend starting a project in a high level language like
Python unless there's a really compelling reason to do otherwise. C++
has, of late, been growing a number of features that belong in higher
level languages; but if you want those sorts of features, why not just
grab Python or Pike or something and save yourself the trouble?


For information, Cython works with C++ now: 
http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html.


Joseph

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


Re: 'is not' or '!='

2014-08-21 Thread Thomas Rachel

Am 20.08.2014 13:17 schrieb Chris Angelico:


That's true, but how easy is it to annotate a file with each line's
author (or, at least, to figure out who wrote some particular line of
code)? It's easy enough with 'git blame' or 'hg blame', and it
wouldn't surprise me if bzr had a similar feature; but that's all the
current generation of version control systems. I don't think cvs or
svn offered that kind of feature.


$ LANG=C svn help blame
blame (praise, annotate, ann): Output the content of specified files or
URLs with revision and author information in-line.
usage: blame TARGET[@REV]...

$ cvs help
Unknown command: `help'

CVS commands are:
add  Add a new file/directory to the repository
adminAdministration front end for rcs
annotate Show last revision where each line was modified
[...]

IMHO annotate does the same what blame does on other VCS.


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


Re: 'is not' or '!='

2014-08-21 Thread Dan Stromberg
On Mon, Aug 18, 2014 at 1:35 PM, ElChino  wrote:
> A newbie question to you; what is the difference between statements like:
>  if x is not None:
> and
> if x != None:
>
> Without any context, which one should be preferred?
> IMHO, the latter is more readable.

You've got some good answers.

I'd like to point out that this might make a good entry in a Python FAQ list...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread luofeiyu
This man is  crazy , he go on to send rubbish to waste our time ,i 
strongly strongly advise that python maillist administrator kick him off 
here.



On 8/21/2014 9:25 PM, Everything You Need To Know wrote:

On Thursday, 21 August 2014 01:06:37 UTC+9:30, Everything You Need To Know  
wrote:

These exercises were all linked together to make a 'python' board game, Thought 
it was really neat myself. This is something that would not interest this Forum 
I am to presume?

Thank you

Adam A


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


Re: 'is not' or '!='

2014-08-21 Thread ElChino

"Dan Stromberg"  wrote:


You've got some good answers.


I've counted around 210 messages in this thread!!


I'd like to point out that this might make a good entry in a Python FAQ list...


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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Grant Edwards
On 2014-08-21, luofeiyu  wrote:

> This man is crazy, he go on to send rubbish to waste our time ,i 
> strongly strongly advise that python maillist administrator kick him
> off here.

He's not wasting my time -- I filter out all posts from Google Groups.

What I do see is all of the responses.  Perhaps I should filter out
posts that have googlegroups.com in the References: header...

-- 
Grant Edwards   grant.b.edwardsYow! How's the wife?
  at   Is she at home enjoying
  gmail.comcapitalism?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Terry Reedy

On 8/21/2014 9:37 AM, luofeiyu wrote:

This man is  crazy


Such ad hominem slurs are a violation to the Python Community Code of 
Conduct.



he go on to send rubbish to waste our time ,


Everyone should stop bashing each other, including you.  What I see is 
people driving each other a bit crazy, and I would like it to stop.



i strongly strongly advise that python maillist administrator


I am one of them.


kick him off here.


This is a last resort, not first.

--
Terry Jan Reedy

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Terry Reedy

On 8/21/2014 12:50 PM, Steven D'Aprano wrote:

Ben Finney wrote:


Everything You Need To Know  writes:


I guess I have to agree and was mistaken, though vitriol I found
unnecessary and unproductive!


You've behaved obnoxiously, as has been pointed out.


People can point out anything they like, it does not mean it is necessarily
so. Adam ("Everything You Need To Know") has perhaps posted unwisely and
clumsily, but obnoxiously?

 Obnoxious (noun):
 very offensive; hateful; odious; reprehensible.

What did Adam do that was *obnoxious*? Here are some of the accusations
thrown at him:

- his "fancy" video is too simple for the "skilled Python programmers" at
this forum and is "barely original";

- he posted using a "self-aggrandising name" instead of his "real name";

- he posted a link to another website (oh the horror!!!);

- his post is "spam" (commercial, unsolicited advertising);

- he posted as a member of a group instead of an individual.

And that's pretty much it.

I reject any suggestion that Adam's post is "obnoxious" or that it is spam.
It is clearly on-topic. Frankly, I am ashamed at the closed-minded
hostility demonstrated here in this thread. Ben, I believe that your
behaviour goes against the spirit of the Python Community Code of Conduct,
if not the actual letter of CoC. Can you honestly say that you have been
Open, Considerate, and Respectful in telling Adam that his post
was "obnoxious" and that his post is "not appropriate" just because it is
hosted on YouTube?

This is supposed to be a welcoming place. Does anyone think we as a
community have been welcoming to Adam?

- We jumped down his throat for a couple of minor social faux pas, like
failing to sign his post with a name.

- We displayed the most odious double-standards: we attacked Adam for
posting on behalf of a group, but when members of the PSF or the Python
core developers make an announcement or post speaking for those groups, we
accept their right to do so without question.

- We allow long-time community members to link to external forums, we accept
them including links to their own blogs and websites, but accused Adam of
being a spammer because he linked to an on-topic video hosted on YouTube.

- We've made the most egregious and unjustified generalisations, speaking
for others without their consent, by insisting that "most" of us here are
too experienced to care for Adam's post. I'm an experienced Python
programmer, I've been contributing here and on other forums for over a
decade, and I learned something new from Adam's video.

Earlier, I posted on how Adam could have, *should* have, engaged with us.
But we should have engaged with him too:

- we should have assumed good faith, instead of accusing him of being a
spammer;

- we should have been welcoming, instead of exclusionary and elitist;

- we should have given him constructive criticism for his video, since it is
on-topic, rather than being so carelessly dismissive;

- or even just ignored it, if you don't like instructional videos;

- we should be respectful of people's right to prefer video over text, as
misguided as I personally believe it to be, some people like it;

- and we should be forgiving of minor faux pas and gaffes, rather than going
on the attack as we did.

Adam, for myself, I am sorry that we allowed a few mild gaffes on your part
lead to such a hostile reception for you, but please have a belated
welcome.


Thank you for posting this Steven. As a list admin, I pretty much agree 
with everything you said.  Some people are caught in a negative feedback 
cycle and all should step out of it and stop.


--
Terry Jan Reedy

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


Re: Distinguishing attribute name from varible name to make codes clear and definite

2014-08-21 Thread Ben Finney
luofeiyu  writes:

> I feel that self.x and x will be confused in the following codes.

I don't see how. The examples you give have the two quite distinct in
every case.

> exam=MyDescriptor("hallo")
>
> when class MyDescriptor  initiate , the `hallo` was passed into x in
> __init__(self, x);

That's correct; the argument ‘"hallo"’ (a text string) is the second
argument in the ‘__init__’ call, and the name ‘x’ is bound to that
value while the function executes.

> Literally  self.x maybe understood to be self.hallo ,assign a
> attribute named 'hallo' to instance exam.

No, the attribute ‘self.x’ is not to be understood as ‘self.hallo’. The
value is not the name.

If the value of the argument were 7.03, the attribute would not be named
‘self.7.03’, it would still be named ‘self.x’.

> There is a attribute y  in instance exam , the `hallo` was passed into
> x in __init__(self, x).No any relation between x and y ,`hallo` and y.
> My view is correct or not ?

You are correct that, if you were to name the attribute differently from
the parameter, there would no longer be any clear relationship.

You are, IMO, incorrect that this would help. Rather, the loss of the
clear relationship would make it much more difficult to see why the
relationship exists, and why different names were chosen.

Instead, the programmer is expected to understand that a value is
distinct from any name which is bound to that value.

-- 
 \  “Our products just aren't engineered for security.” —Brian |
  `\ Valentine, senior vice-president of Microsoft Windows |
_o__)development, 2002 |
Ben Finney

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Ben Finney
Steven D'Aprano  writes:

> Adam ("Everything You Need To Know") has perhaps posted unwisely and
> clumsily, but obnoxiously?
>
> Obnoxious (noun): 
> very offensive; hateful; odious; reprehensible.
>
> What did Adam do that was *obnoxious*? Here are some of the
> accusations thrown at him:
>
> - he posted using a "self-aggrandising name" instead of his "real
> name";

Using one's real name is helpful, but choosing not to is not obnoxious.

Using a name that is clearly not naming a person, and instead is a
marketing name for one's site elsewhere, is odious and reprehensible
because it approaches this community as no more than a market for
one-way messages.

> - his post is "spam" (commercial, unsolicited advertising);

Spam does not entail commercial; religious screeds that have no
commercial nature can qualify, for example.

His posts, repeatedly giving a link to a video and contributing to no
on-topic discussion, are unsolicited bulk messages. That's spam.

> - he posted as a member of a group instead of an individual.

No, he posted *as the group*, and his explanations made it clear that he
did not intend to engage as an individual. That's obnoxious in a
community discussion forum.

> I reject any suggestion that Adam's post is "obnoxious" or that it is
> spam. It is clearly on-topic.

I'm one of many who disagree.

> Frankly, I am ashamed at the closed-minded hostility demonstrated here
> in this thread.

Engaging a person with specific details on how their behaviour is
objectionable, and specific requests on how to improve, demonstrates
hope and optimism that the person can contribute positively. I don't
accept the claim of closed-mindedness.

Hostility? Yes, I'm hostile to behaviour which has already descended to
disrespecting the purpose of this community forum. That doesn't extend
to hostility to a person, though I understand it can be difficult for
the person to see the difference at the time their behaviour is
criticised.

> Ben, I believe that your behaviour goes against the spirit of the
> Python Community Code of Conduct, if not the actual letter of CoC. Can
> you honestly say that you have been Open, Considerate, and Respectful
> in telling Adam that his post was "obnoxious" and that his post is
> "not appropriate" just because it is hosted on YouTube?

Yes, I have respectfully explained at length to Adam why I'm criticising
his behaviour.

I have not, AFAIK, given any cause to think I lack respect for Adam as a
person — indeed, one of my main criticisms is that Adam should engage
*as a person*.

I also respect Adam enough to recognise that he's likely to be able to
learn what was objectionable about his behaviour and improve it.

> This is supposed to be a welcoming place. Does anyone think we as a
> community have been welcoming to Adam?

When the initial engagement is a continuous repeating of the same
disrespectful behaviour, and it continues oblivious to requests to
correct the mistakes, I think the welcome has worn out. We are not
obligated to endure everything, and respect for all the *other* persons
here is also needed and entailed in the Code of Conduct.

-- 
 \“[It's] best to confuse only one issue at a time.” —Brian W. |
  `\  Kernighan, Dennis M. Ritchie, _The C programming language_, 1988 |
_o__)  |
Ben Finney

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 21/08/2014 22:15, Ben Finney wrote:

Steven D'Aprano  writes:



[War and Peace snipped]

Frankly I think this entire debate has rapidly descended to the level of 
farce.  Can we move on please?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Rustom Mody
On Friday, August 22, 2014 1:45:23 AM UTC+5:30, Terry Reedy wrote:
> On 8/21/2014 12:50 PM, Steven D'Aprano wrote:
> > Ben Finney wrote:
> >> Everything You Need To Know writes:
> >>> I guess I have to agree and was mistaken, though vitriol I found
> >>> unnecessary and unproductive!
> >> You've behaved obnoxiously, as has been pointed out.
> > People can point out anything they like, it does not mean it is necessarily
> > so. Adam ("Everything You Need To Know") has perhaps posted unwisely and
> > clumsily, but obnoxiously?
> >  Obnoxious (noun):
> >  very offensive; hateful; odious; reprehensible.
> > What did Adam do that was *obnoxious*? Here are some of the accusations
> > thrown at him:
> > - his "fancy" video is too simple for the "skilled Python programmers" at
> > this forum and is "barely original";
> > - he posted using a "self-aggrandising name" instead of his "real name";
> > - he posted a link to another website (oh the horror!!!);
> > - his post is "spam" (commercial, unsolicited advertising);
> > - he posted as a member of a group instead of an individual.
> > And that's pretty much it.
> > I reject any suggestion that Adam's post is "obnoxious" or that it is spam.
> > It is clearly on-topic. Frankly, I am ashamed at the closed-minded
> > hostility demonstrated here in this thread. Ben, I believe that your
> > behaviour goes against the spirit of the Python Community Code of Conduct,
> > if not the actual letter of CoC. Can you honestly say that you have been
> > Open, Considerate, and Respectful in telling Adam that his post
> > was "obnoxious" and that his post is "not appropriate" just because it is
> > hosted on YouTube?
> > This is supposed to be a welcoming place. Does anyone think we as a
> > community have been welcoming to Adam?
> > - We jumped down his throat for a couple of minor social faux pas, like
> > failing to sign his post with a name.
> > - We displayed the most odious double-standards: we attacked Adam for
> > posting on behalf of a group, but when members of the PSF or the Python
> > core developers make an announcement or post speaking for those groups, we
> > accept their right to do so without question.
> > - We allow long-time community members to link to external forums, we accept
> > them including links to their own blogs and websites, but accused Adam of
> > being a spammer because he linked to an on-topic video hosted on YouTube.
> > - We've made the most egregious and unjustified generalisations, speaking
> > for others without their consent, by insisting that "most" of us here are
> > too experienced to care for Adam's post. I'm an experienced Python
> > programmer, I've been contributing here and on other forums for over a
> > decade, and I learned something new from Adam's video.
> > Earlier, I posted on how Adam could have, *should* have, engaged with us.
> > But we should have engaged with him too:
> > - we should have assumed good faith, instead of accusing him of being a
> > spammer;
> > - we should have been welcoming, instead of exclusionary and elitist;
> > - we should have given him constructive criticism for his video, since it is
> > on-topic, rather than being so carelessly dismissive;
> > - or even just ignored it, if you don't like instructional videos;
> > - we should be respectful of people's right to prefer video over text, as
> > misguided as I personally believe it to be, some people like it;
> > - and we should be forgiving of minor faux pas and gaffes, rather than going
> > on the attack as we did.
> > Adam, for myself, I am sorry that we allowed a few mild gaffes on your part
> > lead to such a hostile reception for you, but please have a belated
> > welcome.

> Thank you for posting this Steven. As a list admin, I pretty much agree 
> with everything you said.  Some people are caught in a negative feedback 
> cycle and all should step out of it and stop.

Thanks Steven, Terry for that.
I would like to add: Often behavior that is labeled obnoxious comes from
people who have no clue about it.

Google groups is a typical example because GG works (kinda) for people
who use GG. IOW GG hides its own problems; whereas it hits other
users.  [I had no idea that the long lines is an issue until rurpy
pointed it out] In this case the additional gaffe in the same direction
is that python-list is owned by Google(!!).

Adam: I do request you once again to read and
'action'¹ https://wiki.python.org/moin/GoogleGroupsPython

--
¹ Am I the only one who finds nouns used as verbs obnoxious?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Rustom Mody
On Thursday, August 21, 2014 7:07:36 PM UTC+5:30, luofeiyu wrote:
> This man is  crazy , he go on to send rubbish to waste our time ,i 
> strongly strongly advise that python maillist administrator kick him off 
> here.

> On 8/21/2014 9:25 PM, Everything You Need To Know wrote:
> > On Thursday, 21 August 2014 01:06:37 UTC+9:30, Everything You Need To Know  
> > wrote:
> > These exercises were all linked together to make a 'python' board game, 
> > Thought it was really neat myself. This is something that would not 
> > interest this Forum I am to presume?
> > Thank you
> > Adam A

I suggest you compute the product: OT-ness * quantity

And look for a mirror.


This very post is a top-post -- not to mention grammar and punctuation
issues.  Obnoxious? Not usually. But can become when the
quantity-multiplier of barely python-related posts swells to a barrage.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Everything You Need To Know
On Friday, 22 August 2014 06:45:07 UTC+9:30, Ben Finney  wrote:

> When the initial engagement is a continuous repeating of the same
> disrespectful behaviour, and it continues oblivious to requests to
> correct the mistakes, I think the welcome has worn out. We are not
> obligated to endure everything, and respect for all the *other* persons
> here is also needed and entailed in the Code of Conduct.
> 
Like your comment here, you simply have far too much time on your hand! Learn 
from your own words and stop saying the same thing over and over, it is like 
talking to a brick wall. I admitted my mistake, and am looking at this GG thing 
today, the link previous said I could clean my text, this doesn't seem to work. 
I am only using this account while still on this topic so GG is gone.

>"Hostility? Yes"

Get over yourself and grow up! this was my second post, you have not even given 
me a chance or time! watch that link and remember godlike programmers only 
cause problems! https://www.youtube.com/watch?v=csyL9EC0S0c 
keep programming fun!

and I'm sorry I couldn't help myself here:

"You have three options. 

1) Carry on the way you are and get plonked. 
2) Change and be accepted."

you only let me choose between two! that was funny!

could go on but no point, just ask what your comments are going to achieve 
before the post
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread Chris Angelico
On Fri, Aug 22, 2014 at 4:05 AM, Joseph Martinot-Lagarde
 wrote:
> For information, Cython works with C++ now:
> http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html.

Now isn't that cool!

Every time Cython gets discussed, I get a renewed desire to learn it.
Trouble is, I don't have any project that calls for it - there's
nothing I'm desperately wanting to do that involves both Python and
C/C++. Anyone got any suggestions? :)

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Dan Stromberg
Amusing.

It works in hexadecimal too:
numerator = 1
denominator = 0xffe001
shift = int(16 ** 30)
print(hex(int(numerator * shift / denominator)))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Joel Goldstick
On Thu, Aug 21, 2014 at 7:10 PM, Everything You Need To Know
 wrote:
> On Friday, 22 August 2014 06:45:07 UTC+9:30, Ben Finney  wrote:
>
>> When the initial engagement is a continuous repeating of the same
>> disrespectful behaviour, and it continues oblivious to requests to
>> correct the mistakes, I think the welcome has worn out. We are not
>> obligated to endure everything, and respect for all the *other* persons
>> here is also needed and entailed in the Code of Conduct.
>>
> Like your comment here, you simply have far too much time on your hand! Learn 
> from your own words and stop saying the same thing over and over, it is like 
> talking to a brick wall. I admitted my mistake, and am looking at this GG 
> thing today, the link previous said I could clean my text, this doesn't seem 
> to work.
> I am only using this account while still on this topic so GG is gone.
>
>>"Hostility? Yes"
>
> Get over yourself and grow up! this was my second post, you have not even 
> given me a chance or time! watch that link and remember godlike programmers 
> only cause problems! https://www.youtube.com/watch?v=csyL9EC0S0c
> keep programming fun!
>
> and I'm sorry I couldn't help myself here:
>
> "You have three options.
>
> 1) Carry on the way you are and get plonked.
> 2) Change and be accepted."
>
> you only let me choose between two! that was funny!
>
> could go on but no point, just ask what your comments are going to achieve 
> before the post
> --
> https://mail.python.org/mailman/listinfo/python-list

eyntk:

I have a certain affection for your videos.  I'm not sure they are
useful to all, but maybe interesting to some.  Kudos to all who try to
spread their interest and knowledge.  But this is a tough and very
fair and generous crowd here I believe.  Its probably better to listen
and participate than to just announce. Or just announce and disappear!
 This place is more for interaction -- asking and responding, ... and
debating.  I don't know the rules for announcements.  At any rate, if
you feel you have something useful to offer, maybe you can figure out
how to do that without given the impression that you are 'carpet
bagging' (an american term).  Using a name (even a nickname) makes you
a person.  Using a company name is kind of off-putting.  If your group
is more than you, then by all means, have all of you participate.  No
problem citing the group you are working with.  Email addresses are
more or less free, right?




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


the output in reference of descriptor.

2014-08-21 Thread luofeiyu

 class C(object):
a = 'abc'
def __getattribute__(self, *args, **kwargs):
print("__getattribute__() is called")
return object.__getattribute__(self, *args, **kwargs)
def __getattr__(self, name):
print("__getattr__() is called ")
return name + " from getattr"
def __get__(self, instance, owner):
print("__get__() is called", instance, owner)
return self
def foo(self, x):
print(x)


class C2(object):
d = C()


>>> c2.d
__get__() is called <__main__.C2 object at 0x0297BE10> '__main__.

C2'>
<__main__.C object at 0x0297BBA8>

I understant the result ,c2.d trigger the __get__ method in class C.
def __get__(self, instance, owner):
print("__get__() is called", instance, owner)
return self

It print "__get__() is called", instance, owner and return self 
`<__main__.C object at 0x0297BBA8>`



>>> c2.d.a
__get__() is called <__main__.C2 object at 0x0297BE10> '__main__.

C2'>
__getattribute__() is called
'abc'

Why the result of c2.d.a  is not :

__get__() is called <__main__.C2 object at 0x0297BE10> '__main__.

C2'>
__getattribute__() is called
'abc'

Why the` return self` in the __get__ method in class C  does not work?

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


Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Mark Lawrence

On 22/08/2014 00:28, Joel Goldstick wrote:


I don't know the rules for announcements.



https://mail.python.org/mailman/listinfo/python-announce-list also 
available through gmane.comp.python.announce


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Very basic question. How do I start again?

2014-08-21 Thread Seymore4Head
I want to give the computer 100 tries to guess a random number between
1 and 100 picked by the computer.

For the moment I am always using 37 as the random pick.  I want to
change the pick to pick=random.randrange(1,100).  The program works as
expected until the computer gets a correct guess.  I don't know what I
should be doing to restart the program when pick=guess.

It is supposed to let the computer pick a number between 1 and 100 and
then let the computer guess the answer.  If the computer picks a low
number the next guess is supposed to be limited to higher numbers than
the guess.  If the computer picks a high number, the next guess is
supposed to be limited to lower numbers than the first guess.

The program fails when guess=pick

import random
count = 1  #Start the counter at 1
low=1   # the low range of 1 to 10
high=100  #The high range of 1 to 100
pick = 37  # Will change to pick=random.randrange(1,100)
guess = 0 #Guess is the computer's guess at pick
print ("Time to play a guessing game.")
print ("")


while count < 100:
guess = random.randrange(low,high)
print (pick, guess)
if guess == pick:
print ("correct")

#"What I need is something here that says start over"

elif guess < pick:
low=guess+1
print ("Too low")
elif guess > pick:
high=guess-1
print ("Too high")
count = count +1

(I can see where adding a 25 then 10 increment later would speed up
the guessing)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Very basic question. How do I start again?

2014-08-21 Thread Ben Finney
Seymore4Head  writes:

> The program works as expected until the computer gets a correct guess.
> I don't know what I should be doing to restart the program when
> pick=guess.

There isn't a “restart the program” code we can give. But I think you
need only something rather simpler:

> while count < 100:
> guess = random.randrange(low,high)
> print (pick, guess)
> if guess == pick:
> print ("correct")
>
> #"What I need is something here that says start over"

You can end the current loop with the ‘break’ statement. See the docs
https://docs.python.org/3/reference/simple_stmts.html#the-break-statement>
to see exactly what its semantics are, and try using that in your code.

Feel free to ask further questions when you've tried that, if it's still
not clear.

-- 
 \ “Religious faith is the one species of human ignorance that |
  `\ will not admit of even the *possibility* of correction.” —Sam |
_o__) Harris, _The End of Faith_, 2004 |
Ben Finney

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Chris Angelico
On Fri, Aug 22, 2014 at 11:37 AM, Seymore4Head
 wrote:
> I want to give the computer 100 tries to guess a random number between
> 1 and 100 picked by the computer.
>

Suggestion: Be up-front about this being a homework assignment. Most
of us can tell anyway, and it's more honest that way :)

So, since this is homework, I'm not going to give you the answer. What
I'll do is point you in the direction you need to go.

The most important problem isn't in your code, it's actually here:

> The program fails when guess=pick

In Python, a program doesn't simply fail. It might do the wrong thing
(in which case you should tell us both what it does and what you
expect it to do), or it might terminate with an exception traceback.
Those tracebacks are incredibly useful; when you're asking for help
with a failing program, pasting the entire traceback, including the
full error message, is extremely helpful.

In this case, though, what I'm seeing is that the program will
errantly keep looping when it gets it right. (Not infinitely as you
have the "count < 100" check, but it still loops more than it should.)
So what you need to do is tell it to stop looping when it gets the
right guess. Do you know how to do that?

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Seymore4Head
On Fri, 22 Aug 2014 11:55:58 +1000, Ben Finney
 wrote:

>Seymore4Head  writes:
>
>> The program works as expected until the computer gets a correct guess.
>> I don't know what I should be doing to restart the program when
>> pick=guess.
>
>There isn't a “restart the program” code we can give. But I think you
>need only something rather simpler:
>
>> while count < 100:
>> guess = random.randrange(low,high)
>> print (pick, guess)
>> if guess == pick:
>> print ("correct")
>>
>> #"What I need is something here that says start over"
>
>You can end the current loop with the ‘break’ statement. See the docs
>https://docs.python.org/3/reference/simple_stmts.html#the-break-statement>
>to see exactly what its semantics are, and try using that in your code.
>
>Feel free to ask further questions when you've tried that, if it's still
>not clear.

Thanks for the tip, but my trial and error failed.

I tried puttingbreak_stmt ::=  "break"  at the point where I
want to start over:) ,but since there is no "start ove"r command,
I was happy to end the program.

I get "invalid syntax so I triedbreak_stmt

Traceback (most recent call last):
  File "C:/Documents and Settings/Administrator/Desktop/Python
3.4/Functions/random.py", line 11, in 
guess = random.randrange(low,high)
  File "C:\Python34\lib\random.py", line 196, in randrange
raise ValueError("empty range for randrange() (%d,%d, %d)" %
(istart, istop, width))
ValueError: empty range for randrange() (37,37, 0)

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Chris Angelico
On Fri, Aug 22, 2014 at 12:13 PM, Seymore4Head
 wrote:
> I tried puttingbreak_stmt ::=  "break"  at the point where I
> want to start over:) ,but since there is no "start ove"r command,
> I was happy to end the program.
>
> I get "invalid syntax so I triedbreak_stmt

Ah, that's part of the language of syntax. The page Ben linked you to
is the details of the grammar. This page from the tutorial might make
it a little clearer:

https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Seymore4Head
On Fri, 22 Aug 2014 11:58:00 +1000, Chris Angelico 
wrote:

>On Fri, Aug 22, 2014 at 11:37 AM, Seymore4Head
> wrote:
>> I want to give the computer 100 tries to guess a random number between
>> 1 and 100 picked by the computer.
>>
>
>Suggestion: Be up-front about this being a homework assignment. Most
>of us can tell anyway, and it's more honest that way :)
>
>So, since this is homework, I'm not going to give you the answer. What
>I'll do is point you in the direction you need to go.
>
>The most important problem isn't in your code, it's actually here:
>
>> The program fails when guess=pick
>
>In Python, a program doesn't simply fail. It might do the wrong thing
>(in which case you should tell us both what it does and what you
>expect it to do), or it might terminate with an exception traceback.
>Those tracebacks are incredibly useful; when you're asking for help
>with a failing program, pasting the entire traceback, including the
>full error message, is extremely helpful.
>
>In this case, though, what I'm seeing is that the program will
>errantly keep looping when it gets it right. (Not infinitely as you
>have the "count < 100" check, but it still loops more than it should.)
>So what you need to do is tell it to stop looping when it gets the
>right guess. Do you know how to do that?
>
>ChrisA

No homework.  This is just for personal enrichment.
Stopping the program when guess==pick is not really what I want the
program to do, but it that is what I am limited to do, that will have
to do.  I am also unable to get that working at the moment.  More
trial and error with the break statement is what I will be doing next.

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Steven D'Aprano
Seymore4Head wrote:

> I want to give the computer 100 tries to guess a random number between
> 1 and 100 picked by the computer.
> 
> For the moment I am always using 37 as the random pick.  I want to
> change the pick to pick=random.randrange(1,100).  The program works as
> expected until the computer gets a correct guess.  I don't know what I
> should be doing to restart the program when pick=guess.
> 
> It is supposed to let the computer pick a number between 1 and 100 and
> then let the computer guess the answer.  If the computer picks a low
> number the next guess is supposed to be limited to higher numbers than
> the guess.  If the computer picks a high number, the next guess is
> supposed to be limited to lower numbers than the first guess.
> 
> The program fails when guess=pick
> 
> import random
> count = 1  #Start the counter at 1
> low=1   # the low range of 1 to 10
> high=100  #The high range of 1 to 100
> pick = 37  # Will change to pick=random.randrange(1,100)
> guess = 0 #Guess is the computer's guess at pick
> print ("Time to play a guessing game.")
> print ("")
> 
> 
> while count < 100:
> guess = random.randrange(low,high)
> print (pick, guess)
> if guess == pick:
> print ("correct")
> 
> #"What I need is something here that says start over"

Start over as in "go back to the beginning".

There is no specific way to jump backwards to a previous line of code in
Python. Python has two ways to loop, `while` and `for`. In this case
`while` is the answer.

The idea is to think about the high-level structure of the game.

# Not python code, this is pseudo-code
while you want to play again:
play a game
ask "Do you want to play again?"


Now you can fill in some of the details, using a stub for things which will
be filled in later.

again = True  # Start off wanting to play at least once.
while again:
print("pretend that we just played a game")  # a stub
# Use input in Python 3, raw_input in Python 2.
again = input("Would you like to play again? [y/n] ") == "y"


That will (pretend to) play a game at least once, then give you the choice
to continue or not. If you would rather play a fixed number of games:

for counter in range(10):  # Play 10 games.
print("pretend that we just played a game")


Now let's stop pretending:


import random
again = True  # Start off wanting to play at least once.
while again:
# Here we actually play the game.
count = 1  # Start the counter at 1
low = 1# The low range of 1 to 100
high = 100 # The high range of 1 to 100
pick = random.randrange(1,100)
guess = 0  # Guess is the computer's guess at pick
print("Time to play a guessing game.")
print()
while count < 100:
guess = random.randrange(low,high)
print(pick, guess)
if guess == pick:
print("Correct!")
# Break out of this loop, which returns us to
# the outer loop.
break

elif guess < pick:
# And so on...

# Use input in Python 3, raw_input in Python 2.
again = input("Would you like to play again? [y/n] ") == "y"



Notice that indentation is important: the size of the indent tells Python
whether you are inside the inner loop, the outer loop, or the top level.
But hopefully you already know that.

As this starts getting bigger and more unwieldy, it's time to learn about
defining your own custom functions. But you'll get to that.


-- 
Steven

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Denis McMahon
On Thu, 21 Aug 2014 21:37:22 -0400, Seymore4Head wrote:

> I want to give the computer 100 tries to guess a random number between 1
> and 100 picked by the computer.
> 
> For the moment I am always using 37 as the random pick.  I want to
> change the pick to pick=random.randrange(1,100).  The program works as
> expected until the computer gets a correct guess.  I don't know what I
> should be doing to restart the program when pick=guess.
> 
> It is supposed to let the computer pick a number between 1 and 100 and
> then let the computer guess the answer.  If the computer picks a low
> number the next guess is supposed to be limited to higher numbers than
> the guess.  If the computer picks a high number, the next guess is
> supposed to be limited to lower numbers than the first guess.
> 
> The program fails when guess=pick
> 
> import random count = 1  #Start the counter at 1 low=1   #
> the low range of 1 to 10 high=100  #The high range of 1 to 100 pick
> = 37  # Will change to pick=random.randrange(1,100)
> guess = 0 #Guess is the computer's guess at pick print ("Time to
> play a guessing game.")
> print ("")
> 
> 
> while count < 100:
> guess = random.randrange(low,high)
> print (pick, guess)
> if guess == pick:
> print ("correct")
> 
> #"What I need is something here that says start over"
> 
> elif guess < pick:
> low=guess+1 print ("Too low")
> elif guess > pick:
> high=guess-1 print ("Too high")
> count = count +1
> 
> (I can see where adding a 25 then 10 increment later would speed up the
> guessing)

Write the problem out in basic english terms, then translate these to the 
program. The english might look like this (laid out in a pythonic manner):

while I want to play a game:
choose a number
guess the answer
tries = 1
while guess != choice:
guess another answer
tries = tries + 1
print "it took " + tries + " attempts to guess " + choice

This simplification doesn't take the calculation of ranges into account, 
but that's part of "guess the/another answer".

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-21 Thread alex23

On 21/08/2014 7:30 PM, [email protected] wrote:

On Thursday, August 21, 2014 2:27:08 AM UTC-7, Marko Rauhamaa wrote:

In practice, your proposal would not make life easier for Python
programmers.


neither did the lambda, yours truly supposes?


alex23 disagrees. alex23 finds the lambda extremely convenient for 
things like sort, filter etc where alex23 wants to provide a function.


alex23 finds this to be very readable:

odds_list = filter(lambda x: bool(x % 2), some_list)

By comparison, alex23 finds this to be more cumbersome for little gain:

def odds_only(x):
return bool(x % 2)
odds_list = filter(odds_only, some_list)

alex23 finds most examples for multiline anonymous functions to be far 
more difficult to parse than the both restricted lambda form and the 
separate function approach:


odds_list = filter((def(x):
return bool(x % 2)), some_list)

alex23 isn't even sure if that's the correct format for your proposed 
syntax, or whether `, some_list)` has to appear on a separate line, or 
even if the () around the anonymous function is even necessary (alex23 
assumed it was from your description of the closing parenthesis popping 
the "space-sensitivity-stack").

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Tim Roberts
Seymore4Head  wrote:
>
>I want to give the computer 100 tries to guess a random number between
>1 and 100 picked by the computer.

If it takes more than 7, you're doing it wrong...
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread dieter
David Palao  writes:
>  Why to use C++ instead of python?

Likely, you would not use Python to implement most parts of an
operating system (where, for efficiency reasons, some parts
are even implemented in an assembler language).

I can imagine that the GNU compiler developers, too, had good
reasons to implement them in C rather than a scripting language.
It makes a huge difference whether you wait one or several hours
before a large system is built.

"firefox", too, seems to be implemented in C/C++. There, too, I
see good reasons:
  *  it is nice when your pages are rendered quickly

  *  "firefox" depends on lots of external libraries, all of them
 with C/C++ interfaces; while is is possible to create
 Python bindings for them, this is quite some work

  *  as it is, "firefox" is a huge "memory eater"; one might
 fear that things would be worse if implemented in a
 higher level language (with everything on the heap).
 Though, the fear might not be justified.


All these examples are really large projects. I like Python a lot
for smaller projects.

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


Re: Very basic question. How do I start again?

2014-08-21 Thread Igor Korot
Hi,

On Thu, Aug 21, 2014 at 10:56 PM, Tim Roberts  wrote:
> Seymore4Head  wrote:
>>
>>I want to give the computer 100 tries to guess a random number between
>>1 and 100 picked by the computer.
>
> If it takes more than 7, you're doing it wrong...

I think he meant:
100 runs of the script...

Thank you.

> --
> Tim Roberts, [email protected]
> Providenza & Boekelheide, Inc.
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what is the difference between name and _name?

2014-08-21 Thread luofeiyu

I fix a mistake in Steven D'Aprano interpretation.

class Person(object):
 def __init__(self, name):
 self._name = name
 def getName(self):
 print('fetch')
 return self._name
 def setName(self, value):
 print('change...')
 self._name = value
 def delName(self):
 print('remove')
 del self._name
 _name = property(getName, setName, delName, "name property docs")


x=Person("peter")

It can not initinalize.
  File "", line 9, in setName
  File "", line 8, in setName
RuntimeError: maximum recursion depth exceeded while calling a Python 
object.


Steven D'Aprano interpretation:

10 Python finds the property _name
20 Python retrieves the getter, getName
30 Python runs the getName() method
40 which looks up self._name
50 go to 10

the right interpretation according to the error message:


10 python call __init__ method. self._name = name
20 python call setName method,
 print('change...')
 self._name = value
30 from self._name = value ,python call call setName method again

then we get a recursion error.

why i can not write  _name = property(getName, setName, delName, "name
property docs") ?

Because you will have infinite recursion.

When you look up instance._name:

10 Python finds the property _name
20 Python retrieves the getter, getName
30 Python runs the getName() method
40 which looks up self._name
50 go to 10

and you get a recursion error.





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


Re: Python vs C++

2014-08-21 Thread Chris Angelico
On Fri, Aug 22, 2014 at 4:12 PM, dieter  wrote:
> Likely, you would not use Python to implement most parts of an
> operating system (where, for efficiency reasons, some parts
> are even implemented in an assembler language).
>
> I can imagine that the GNU compiler developers, too, had good
> reasons to implement them in C rather than a scripting language.
> It makes a huge difference whether you wait one or several hours
> before a large system is built.
>
> "firefox", too, seems to be implemented in C/C++. There, too, I
> see good reasons:
>   *  it is nice when your pages are rendered quickly
>
>   *  "firefox" depends on lots of external libraries, all of them
>  with C/C++ interfaces; while is is possible to create
>  Python bindings for them, this is quite some work
>
>   *  as it is, "firefox" is a huge "memory eater"; one might
>  fear that things would be worse if implemented in a
>  higher level language (with everything on the heap).
>  Though, the fear might not be justified.
>
>
> All these examples are really large projects. I like Python a lot
> for smaller projects.

Yep. But it's not so much large vs small projects; these are all
situations where it's entirely plausible to saturate a CPU core for a
while, so the performance penalty of a high level language will
actually matter. (That said, though: Firefox has a lot of
non-performance-critical code, which AIUI is implemented in a higher
level language than C. And a long 'make' run probably involves some
shell scripting and such, not pure C code. Even high performance
projects have their less-critical parts.) Similarly, I'd be pretty
worried if someone rewrote X11 in Python. But if your program's going
to spend most of its time waiting (for the user, for the network, for
the real-time clock), halving its CPU usage won't materially affect
anything, and halving development time will make a huge difference.
That's when Python is an excellent choice.

At my last job, we had some parts written in Pike, some written in PHP
(not just the web site), and one back-end engine in C++. Toward the
end, I wanted to redo the C++ engine in Python or Pike, because I
didn't think the performance hit would be at all visible, and it would
have been much easier to work on. (I'd also been progressively taking
over jobs that PHP code had been doing and giving them to Pike
processes instead, with a not-so-secret goal of eventually ripping out
the PHP engine altogether. But that for other reasons.) As a back-end
process, its performance would be hard for the end user to see
directly, so the cost of a high level language would simply have been
that the server could cope with fewer requests per hour before we need
to requisition more hardware. Alas, there wasn't development time
available for the translation (we were far too busy doing things about
which I said "YAGNI" and the boss said "Do it anyway"), but I firmly
believe that we wouldn't have been suffering from the performance hit.

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


Re: Python vs C++

2014-08-21 Thread Stefan Behnel
dieter schrieb am 22.08.2014 um 08:12:
> David Palao writes:
>>  Why to use C++ instead of python?
> 
> Likely, you would not use Python to implement most parts of an
> operating system (where, for efficiency reasons, some parts
> are even implemented in an assembler language).
> 
> I can imagine that the GNU compiler developers, too, had good
> reasons to implement them in C rather than a scripting language.
> It makes a huge difference whether you wait one or several hours
> before a large system is built.
> 
> "firefox", too, seems to be implemented in C/C++. There, too, I
> see good reasons:
>   *  it is nice when your pages are rendered quickly
> 
>   *  "firefox" depends on lots of external libraries, all of them
>  with C/C++ interfaces; while is is possible to create
>  Python bindings for them, this is quite some work
> 
>   *  as it is, "firefox" is a huge "memory eater"; one might
>  fear that things would be worse if implemented in a
>  higher level language (with everything on the heap).
>  Though, the fear might not be justified.
> 
> 
> All these examples are really large projects. I like Python a lot
> for smaller projects.

While I agree that there are very valid reasons to write C/C++ code (and
operating systems clearly fall into that category), most of the above might
turn out to be fallacies. With a more high-level language, it is easier to
get a system running and then focus on optimisation than in a low-level
language that requires a lot of concentrated work just to get things done
at all. Especially in the long run, where the maintenance burden of
low-level code starts getting so much in the way that it becomes harder and
harder to keep improving the system and adding new features.

If, instead, you start with a high-level language, your first
implementation might not be as fast as your first C++ implementation could
have been, but it'll be almost certainly available much earlier, so that
you can then give it real world testing and performance evaluation. That
gives you a head start for optimisation and improvements, which then leads
to a faster system again. Thus, it's not unlikely that you already get an
even faster and better system (in terms of actual user experience) in the
same timeframe that you would otherwise have spent on getting even a first
working version of your system in a low-level language.

And the optimisation that you apply to your system may still include
rewriting parts of it in C++, but then really only those parts where real
world evaluation proved that it's worth the effort and maintenance overhead.

I've given a talk about this topic at PyCon-DE 2012. It's in German, but it
contains a lot of figures that should be understandable even if you don't
understand that language.

http://consulting.behnel.de/PyConDE/2012/ohnecpp.html

Stefan


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