Re: How do you refer to an iterator in docs?

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 5:21:20 AM UTC-7, Roy Smith wrote:
> Let's say I have a function which takes a list of words.  I might write 
> the docstring for it something like:
> 
> def foo(words):
>"Foo-ify words (which must be a list)"
> 
> What if I want words to be the more general case of something you can 
> iterate over?  How do people talk about that in docstrings?  Do you say 
> "something which can be iterated over to yield words", "an iterable over 
> words", or what?
> 
> I can think of lots of ways to describe the concept, but most of them 
> seem rather verbose and awkward compared to "a list of words", "a 
> dictionary whose keys are words", etc.

When I talk about an iterable, I say "iterable". Based on my recent readings of 
the style guide PEPs I would write something like:

"""Foo-ify some words.

Arguments:
words -- an iterable of words

"""

Just remember that types don't matter (until you get down to the C, really), 
just the methods associated with an object.

Have fun and happy coding!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: with statement

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 10:15:23 AM UTC-7, Kiuhnm wrote:
> A with statement is not at the module level only if it appears inside a 
> function definition or a class definition.
> Am I forgetting something?
> 
> Kiuhnm

That sounds about right to me. However, I haven't really used with's very much. 
So why would it matter where the statement is? (The only possibility that 
occurs to me is if your __enter__ or __exit__ methods reference a variable at 
some arbitrary level.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system()

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 11:09:22 AM UTC-7, Yigit Turgut wrote:
> When I use os.system() function, script waits for termination of the
> windows that is opened by os.system() to continue thus throwing errors
> and etc. How can i tell Python to let it go and keep on with the next
> execution after os.system() ?

You have to use threads. As in most programming languages (I believe), the 
program waits for a line to finish before moving on. So you'll have to create a 
new thread to deal with the windows, then move on to other stuff. Read the docs 
on the threading modules.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I overload operators like "=>", "->" or something like that?

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote:
> hi all,
> can I somehow overload operators like "=>", "->" or something like
> that? (I'm searching for appropriate overload for logical implication
> "if a then b")
> Thank you in advance, D.

I don't believe that you could overload those particular operators, since to my 
knowledge they do not exist in Python to begin with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Jacob MacDonald
On Thursday, April 19, 2012 11:09:52 PM UTC-7, Ben Finney wrote:
> alex23  writes:
> 
> > On Apr 20, 5:54 am, Jacob MacDonald  wrote:
> >
> > > On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote:
> > > > can I somehow overload operators like "=>", "->" or something like
> > > > that?
> > > I don't believe that you could overload those particular operators,
> > > since to my knowledge they do not exist in Python to begin with.
> 
> There is no ‘=>’ operator, and no ‘->’ operator, in Python
> http://docs.python.org/reference/lexical_analysis.html#operators>.
> >
> > It all depends on if the operators use special methods on objects:
> > http://docs.python.org/reference/datamodel.html#special-method-names
> >
> > You can overload => via object.__le__, for example.
> 
> No, ‘<=’ is the less-than-or-equal operator. There is no ‘=>’ operator
> in Python.
> 
> -- 
>  \  “I knew things were changing when my Fraternity Brothers threw |
>   `\   a guy out of the house for mocking me because I'm gay.” |
> _o__)  —postsecret.com, 2010-01-19 |
> Ben Finney

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


Re: How do you refer to an iterator in docs?

2012-04-20 Thread Jacob MacDonald
On Friday, April 20, 2012 6:41:25 AM UTC-7, Roy Smith wrote:
> In article <[email protected]>,
>  Steven D'Aprano  wrote:
> 
> > I refer you to your subject line:
> > 
> > "How do you refer to an iterator in docs?"
> > 
> > In documentation, I refer to an iterator as an iterator, just as I would 
> > refer to a list as a list, a dict as a dict, or a string as a string.
> 
> Except that "list of foos" and "sequence of foos" make sense from a 
> grammar standpoint, but "iterator of foos" does not.  Or maybe it does?

Unless you're writing the docstring for end users, I think you should be fine 
using Python words. After all, this is Python :)
-- 
http://mail.python.org/mailman/listinfo/python-list