Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77286 > unrolled thread
| Started by | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| First post | 2014-08-29 16:40 -0400 |
| Last post | 2014-08-30 14:46 +1000 |
| Articles | 14 — 7 participants |
Back to article view | Back to comp.lang.python
Typing help brings up a screen that says type help() Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-29 16:40 -0400
Re: Typing help brings up a screen that says type help() Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-29 17:10 -0400
Re: Typing help brings up a screen that says type help() Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-29 17:15 -0400
Re: Typing help brings up a screen that says type help() Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-29 18:14 -0400
Re: Typing help brings up a screen that says type help() Chris Angelico <rosuav@gmail.com> - 2014-08-30 08:22 +1000
Re: Typing help brings up a screen that says type help() Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-29 18:40 -0400
Re: Typing help brings up a screen that says type help() Grant Edwards <invalid@invalid.invalid> - 2014-09-02 16:36 +0000
Re: Typing help brings up a screen that says type help() Chris Angelico <rosuav@gmail.com> - 2014-08-30 08:54 +1000
Re: Typing help brings up a screen that says type help() Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-29 19:02 -0400
Re: Typing help brings up a screen that says type help() Chris Angelico <rosuav@gmail.com> - 2014-08-30 09:10 +1000
Re: Typing help brings up a screen that says type help() Terry Reedy <tjreedy@udel.edu> - 2014-08-29 21:41 -0400
Re: Typing help brings up a screen that says type help() Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-29 22:55 -0400
Re: Typing help brings up a screen that says type help() Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-08-29 21:13 -0500
Re: Typing help brings up a screen that says type help() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-30 14:46 +1000
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-29 16:40 -0400 |
| Subject | Typing help brings up a screen that says type help() |
| Message-ID | <12p10atdufggrba3e5k9ie7kla17thh1ha@4ax.com> |
What is the logic behind that? Couldn't help do the same thing as help()? But the reason I ask is that I see (from a video of Getting Started with Python) that older versions of python would allow ? as help. I get syntax error when I try ?
[toc] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-08-29 17:10 -0400 |
| Message-ID | <mailman.13619.1409346640.18130.python-list@python.org> |
| In reply to | #77286 |
On Fri, Aug 29, 2014 at 4:40 PM, Seymore4Head <Seymore4Head@hotmail.invalid> wrote: > What is the logic behind that? It would seem that help() is a function. You are in the python shell when you type it, and it runs the function that displays help. > Couldn't help do the same thing as help()? > But the reason I ask is that I see (from a video of Getting Started > with Python) that older versions of python would allow ? as help. I > get syntax error when I try ? > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-08-29 17:15 -0400 |
| Message-ID | <mailman.13620.1409346914.18130.python-list@python.org> |
| In reply to | #77286 |
Your invalid email address is annoying to anyone who uses gmail to respond to this group. It requires send all, and every time I answer you, I get a mail notice telling me about your bad email address. What exactly is the reason you don't supply a correct address? -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-29 18:14 -0400 |
| Message-ID | <kgu10apch34mqqvcoqtrheqc5l8ov1k3cg@4ax.com> |
| In reply to | #77288 |
On Fri, 29 Aug 2014 17:15:11 -0400, Joel Goldstick <joel.goldstick@gmail.com> wrote: >Your invalid email address is annoying to anyone who uses gmail to >respond to this group. It requires send all, and every time I answer >you, I get a mail notice telling me about your bad email address. >What exactly is the reason you don't supply a correct address? Yes. There are some kooky people on the Internet. There are also spammers. IMO there are more reasons not to use real email or real name than vaild reasons to use it. It is not my intention to annoy sane people. Sorry
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-30 08:22 +1000 |
| Message-ID | <mailman.13621.1409351395.18130.python-list@python.org> |
| In reply to | #77286 |
On Sat, Aug 30, 2014 at 7:15 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote: > Your invalid email address is annoying to anyone who uses gmail to > respond to this group. It requires send all, and every time I answer > you, I get a mail notice telling me about your bad email address. > What exactly is the reason you don't supply a correct address? Gmail does *not* require "reply all", and even if you do use it, you can delete his address. Please don't always use reply-all - it ends up accumulating superfluous destination addresses. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-08-29 18:40 -0400 |
| Message-ID | <mailman.13624.1409352038.18130.python-list@python.org> |
| In reply to | #77286 |
On Fri, Aug 29, 2014 at 6:22 PM, Chris Angelico <rosuav@gmail.com> wrote: > On Sat, Aug 30, 2014 at 7:15 AM, Joel Goldstick > <joel.goldstick@gmail.com> wrote: >> Your invalid email address is annoying to anyone who uses gmail to >> respond to this group. It requires send all, and every time I answer >> you, I get a mail notice telling me about your bad email address. >> What exactly is the reason you don't supply a correct address? > > Gmail does *not* require "reply all", and even if you do use it, you > can delete his address. Please don't always use reply-all - it ends up > accumulating superfluous destination addresses. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list On this list I use reply all (using gmail) because reply takes the first recipient, which is the poster. I am on another list where this isn't true. -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-09-02 16:36 +0000 |
| Message-ID | <lu4rlj$sgd$1@reader1.panix.com> |
| In reply to | #77294 |
On 2014-08-29, Joel Goldstick <joel.goldstick@gmail.com> wrote:
> On this list I use reply all (using gmail) because reply takes the
> first recipient, which is the poster. I am on another list where this
> isn't true.
It's because of people like you that people like me post with invalid
addresses in the headers. But there Is a valid address below if needed.
--
Grant Edwards grant.b.edwards Yow! Let's send the
at Russians defective
gmail.com lifestyle accessories!
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-30 08:54 +1000 |
| Message-ID | <mailman.13625.1409352854.18130.python-list@python.org> |
| In reply to | #77286 |
On Sat, Aug 30, 2014 at 8:40 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote: > On this list I use reply all (using gmail) because reply takes the > first recipient, which is the poster. I am on another list where this > isn't true. Yes, and I've been on a few lists that have gone through the discussion of why it should be one way or the other way. The biggest problem is that Gmail doesn't have a "reply to list" option to select as the default. (Nor do a number of other mail clients; I'm not knocking Gmail specifically here, but it's what several of us use, so it's the example I'm discussing.) In the absence of such, there are basically four possibilities: 1) The list can be set to send replies to the list 1a) You might want to send to the list 1b) You might want to send a private message 2) The list can be set to send replies to the original poster 2a) As above 2b) As above 3) The list can also be set to send replies somewhere else, but that's not germane to this discussion. In case 1a, it's easy. Everything happens as it should. In case 2b, it's also easy. You hit reply, it goes to the original poster, like you want. So how do we handle the cross cases? Case 2a is what python-list and Savoynet are set to. You want to reply to the list? Hit Reply-All and then remove the original poster, or hit Reply and change the destination. (That's a great option if you have only one list. It's a terrible option if you have as many lists as I have, because you'll change the destination wrongly.) Case 1b is how I set up the Gilbert & Sullivan Society Committee mailing list. It's meant primarily to be for discussions amongst a small group (the committee consists of maybe a dozen people), and most of them are not particularly technically adept (the G&S Society is an artistic society (we perform light opera/operetta), so most of the people who run it are artistic people, although we have for example a treasurer who's an accountant); sending replies to the list makes the most sense, and keeps the discussion where it needs to be. But how do you go about sending a private reply? It's unusual on the committee list, but it does happen; and you have to hit Reply or Reply-All, then delete the list's name and manually copy and paste (or retype!) the sender's address. This is VERY error-prone. It's really easy to accidentally tell the list what was supposed to be private. The bigger the list, the more common private replies will tend to be. I would advise huge lists of unrelated people (python-list, Savoynet, any general interest group) to have replies go to the poster, and small lists of closely related people can consider having replies to the list by default. But of course, there'll be exceptions either way. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-08-29 19:02 -0400 |
| Message-ID | <mailman.13626.1409353362.18130.python-list@python.org> |
| In reply to | #77286 |
On Fri, Aug 29, 2014 at 6:54 PM, Chris Angelico <rosuav@gmail.com> wrote: > On Sat, Aug 30, 2014 at 8:40 AM, Joel Goldstick > <joel.goldstick@gmail.com> wrote: >> On this list I use reply all (using gmail) because reply takes the >> first recipient, which is the poster. I am on another list where this >> isn't true. > > Yes, and I've been on a few lists that have gone through the > discussion of why it should be one way or the other way. > > The biggest problem is that Gmail doesn't have a "reply to list" > option to select as the default. (Nor do a number of other mail > clients; I'm not knocking Gmail specifically here, but it's what > several of us use, so it's the example I'm discussing.) In the absence > of such, there are basically four possibilities: > > 1) The list can be set to send replies to the list > 1a) You might want to send to the list > 1b) You might want to send a private message > 2) The list can be set to send replies to the original poster > 2a) As above > 2b) As above > 3) The list can also be set to send replies somewhere else, but that's > not germane to this discussion. > > In case 1a, it's easy. Everything happens as it should. In case 2b, > it's also easy. You hit reply, it goes to the original poster, like > you want. So how do we handle the cross cases? > > Case 2a is what python-list and Savoynet are set to. You want to reply > to the list? Hit Reply-All and then remove the original poster, or hit > Reply and change the destination. (That's a great option if you have > only one list. It's a terrible option if you have as many lists as I > have, because you'll change the destination wrongly.) > > Case 1b is how I set up the Gilbert & Sullivan Society Committee > mailing list. It's meant primarily to be for discussions amongst a > small group (the committee consists of maybe a dozen people), and most > of them are not particularly technically adept (the G&S Society is an > artistic society (we perform light opera/operetta), so most of the > people who run it are artistic people, although we have for example a > treasurer who's an accountant); sending replies to the list makes the > most sense, and keeps the discussion where it needs to be. But how do > you go about sending a private reply? It's unusual on the committee > list, but it does happen; and you have to hit Reply or Reply-All, then > delete the list's name and manually copy and paste (or retype!) the > sender's address. This is VERY error-prone. It's really easy to > accidentally tell the list what was supposed to be private. The bigger > the list, the more common private replies will tend to be. > > I would advise huge lists of unrelated people (python-list, Savoynet, > any general interest group) to have replies go to the poster, and > small lists of closely related people can consider having replies to > the list by default. But of course, there'll be exceptions either way. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list That was enlighting Chris. I apologize to list readers if they are getting two versions of everything I send. I don't get two versions sent to me, so I assumed others wouldn't either. I'm not sure why I assumed that, as it really doesn't make sense. Maybe gmail filters one of them for me. Anyway, I'll do reply all and delete the OP. -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-30 09:10 +1000 |
| Message-ID | <mailman.13627.1409353841.18130.python-list@python.org> |
| In reply to | #77286 |
On Sat, Aug 30, 2014 at 9:02 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote: > That was enlighting Chris. I apologize to list readers if they are > getting two versions of everything I send. I don't get two versions > sent to me, so I assumed others wouldn't either. I'm not sure why I > assumed that, as it really doesn't make sense. Maybe gmail filters > one of them for me. Anyway, I'll do reply all and delete the OP. I think Mailman is set to not send duplicates if it notices a destination in the headers, so anyone who receives the mailing list won't get two copies. But people who read the corresponding newsgroup will be getting one copy in news and another copy in email. But hey. You didn't know that what you were doing could annoy people, and as soon as you found out, you changed. That puts you better than, sadly, a lot of people on this list... ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-08-29 21:41 -0400 |
| Message-ID | <mailman.13635.1409362912.18130.python-list@python.org> |
| In reply to | #77286 |
On 8/29/2014 4:40 PM, Seymore4Head wrote: > What is the logic behind that? You should better ask, "How does that happen?". Attend carefully and you should learn much. In expressions, python replaces names with the object the name is bound to. In batch mode, a bare name is equivalent to 'pass'. In interactive mode, a bare "name" is equivalent to "print(repr(name))". >>> s = 'abc' >>> s 'abc' >>> print(str(s)) abc >>> print(repr(s)) 'abc' This is a handy shortcut. "repr(name)" in turn, is also a shortcut. It looks for the .__repr__ attribute of type(name) or one of the superclasses. If there in no override in the inheritance tree, you see the default from object: >>> object() <object object at 0x00000000001B2C70> You have probably seen this pattern already. Now, what is the class of the object bound to 'help' (and 'quit' and 'exit')? >>> type(help) <class '_sitebuiltins._Helper'> >>> type(quit) <class '_sitebuiltins.Quitter'> >>> type(exit) <class '_sitebuiltins.Quitter'> Each of these classes has a .__repr__ method and a .__call__ method. The first simply echoes a fixed string regardless of input. >>> type(help).__repr__(object()) 'Type help() for interactive help, or help(object) for help about object.' We can play the same game with python code. >>> class Helper: def __repr__(self): return 'Type myhelp() for interactive help, or myhelp(object) for help about object.' def __call__(self, arg): help(arg) >>> myhelp = Helper() >>> myhelp Type myhelp() for interactive help, or myhelp(object) for help about object. >>> myhelp(Helper) Help on class Helper in module __main__: class Helper(builtins.object) | Methods defined here: | | __call__(self, arg) | | __repr__(self) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) > Couldn't help do the same thing as help()? Couldn't python stab people in the back by violating its own rules ;-? (See the doc for what repr and hence .__repr__ are supposed to do.) You should now understand that the interpreter has *no special knowledge* about help, exit, or quit. The special behavior is built into their classes. That is how Python objects work in relation to a few simple syntax rules, like "callable(args)" meaning 'call callable with args'. > older versions of python would allow ? as help. If I ever knew that, I have forgotten. The interpreter must have treated '?' as a special case for interactive input. I suspect help was changed when quit and exit were added. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-29 22:55 -0400 |
| Message-ID | <48f20a14mi4oat1001k3fjg68k350sufn1@4ax.com> |
| In reply to | #77307 |
On Fri, 29 Aug 2014 21:41:30 -0400, Terry Reedy <tjreedy@udel.edu> wrote: >On 8/29/2014 4:40 PM, Seymore4Head wrote: >> What is the logic behind that? > >You should better ask, "How does that happen?". Attend carefully and >you should learn much. > >In expressions, python replaces names with the object the name is bound >to. In batch mode, a bare name is equivalent to 'pass'. In interactive >mode, a bare "name" is equivalent to "print(repr(name))". > > >>> s = 'abc' > >>> s >'abc' > >>> print(str(s)) >abc > >>> print(repr(s)) >'abc' > >This is a handy shortcut. "repr(name)" in turn, is also a shortcut. It >looks for the .__repr__ attribute of type(name) or one of the >superclasses. If there in no override in the inheritance tree, you see >the default from object: > > >>> object() ><object object at 0x00000000001B2C70> > >You have probably seen this pattern already. Now, what is the class of >the object bound to 'help' (and 'quit' and 'exit')? > > >>> type(help) ><class '_sitebuiltins._Helper'> > >>> type(quit) ><class '_sitebuiltins.Quitter'> > >>> type(exit) ><class '_sitebuiltins.Quitter'> > >Each of these classes has a .__repr__ method and a .__call__ method. >The first simply echoes a fixed string regardless of input. > > >>> type(help).__repr__(object()) >'Type help() for interactive help, or help(object) for help about object.' > >We can play the same game with python code. > > >>> class Helper: > def __repr__(self): > return 'Type myhelp() for interactive help, or myhelp(object) for help >about object.' > def __call__(self, arg): > help(arg) > > >>> myhelp = Helper() > >>> myhelp >Type myhelp() for interactive help, or myhelp(object) for help about object. > >>> myhelp(Helper) >Help on class Helper in module __main__: > >class Helper(builtins.object) > | Methods defined here: > | > | __call__(self, arg) > | > | __repr__(self) > | > | ---------------------------------------------------------------------- > | Data descriptors defined here: > | > | __dict__ > | dictionary for instance variables (if defined) > | > | __weakref__ > | list of weak references to the object (if defined) > > >> Couldn't help do the same thing as help()? > >Couldn't python stab people in the back by violating its own rules ;-? > >(See the doc for what repr and hence .__repr__ are supposed to do.) > >You should now understand that the interpreter has *no special >knowledge* about help, exit, or quit. The special behavior is built >into their classes. That is how Python objects work in relation to a >few simple syntax rules, like "callable(args)" meaning 'call callable >with args'. > > > older versions of python would allow ? as help. > >If I ever knew that, I have forgotten. The interpreter must have >treated '?' as a special case for interactive input. I suspect help was >changed when quit and exit were added. I think that is more than I wanted to know. :) Thanks
[toc] | [prev] | [next] | [standalone]
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| Date | 2014-08-29 21:13 -0500 |
| Message-ID | <mailman.13636.1409364834.18130.python-list@python.org> |
| In reply to | #77286 |
On Fri, Aug 29, 2014 at 8:41 PM, Terry Reedy <tjreedy@udel.edu> wrote: > On 8/29/2014 4:40 PM, Seymore4Head wrote: >> older versions of python would allow ? as help. > > If I ever knew that, I have forgotten. The interpreter must have treated > '?' as a special case for interactive input. I suspect help was changed when > quit and exit were added. I don't believe '?' has ever been a feature of Python itself. However, IPython does use '?' as a syntax for help; you can try it with the in-browser interpreter at python.org. -- Zach
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-08-30 14:46 +1000 |
| Message-ID | <54015740$0$6512$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #77286 |
Seymore4Head wrote:
> What is the logic behind that?
> Couldn't help do the same thing as help()?
Not without being annoyingly, obnoxiously "too clever by half".
In Python, all values are objects, so apart from a handful of statements
(such as "if blah blah:", "for x in blah:" etc.) everything you type in
Python is an object. That includes functions like len() and help() itself.
In the interactive interpreter, hitting Enter with an object on the command
line displays that object. That's the expected behaviour, and so
conveniently the help object is designed to display:
Type help() for interactive help ...
It does this by having __repr__ and __str__ methods which return the message
we want to be displayed.
Now, it is *technically* possible to have those __repr__ and __str__ methods
automatically call the help object, as if you had typed help() with the
round brackets. But that would be Just Plain Wrong. Python makes a
fundamental distinction between displaying a function or method, and
calling it:
py> from random import random
py> random
<built-in method random of Random object at 0x90f6ca4>
py> random()
0.016599200602883224
and it would be surprising to break that distinction for the help object. It
would lead to deeply disturbing behaviour. E.g. suppose you ended up
somehow with a list or dict containing the help object, which is quite easy
to do when exploring interactively. For example, in Python 2:
py> import __builtin__
py> print __builtin__.__dict__
or in Python 3:
py> import builtins
py> print(builtins.__dict__)
Or even something like this:
py> stuff = [len, help, dict]
py> print(stuff)
You wouldn't expect those simple commands to launch the help system, would
you? And if they did, it would probably make it difficult to debug exactly
how and why that was happening, since you couldn't print the dict or list
to see what was in it without launching the help system.
> But the reason I ask is that I see (from a video of Getting Started
> with Python) that older versions of python would allow ? as help. I
> get syntax error when I try ?
Regular Python has never accepted ? however the custom IPython interactive
interpreter does.
--
Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web