Does generator.close() prevent raising StopIteration?
I'm trying to get the return value from coroutine after terminating it.
Here is simple test code:
$ python3
Python 3.6.0 (default, Dec 23 2016, 12:50:55)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyrig
On Sunday, January 29, 2017 at 9:54:44 PM UTC-8, Chris Angelico wrote:
> ...
> When you close() a generator, it raises GeneratorExit into it, and
> then silences any StopIteration or GeneratorExit that comes out of it.
Chris,
Thanks for the info. Is this (GenExit silencing StopIteration) documente
On Sunday, January 29, 2017 at 10:47:09 PM UTC-8, Chris Angelico wrote:
> On Mon, Jan 30, 2017 at 5:38 PM, wrote:
> > On Sunday, January 29, 2017 at 9:54:44 PM UTC-8, Chris Angelico wrote:
> >> ...
> >> When you close() a generator, it raises GeneratorExit into it, and
> >> then silences any Stop
On Tue, Oct 04, 2005 at 11:22:24AM -0500, Michael Ekstrand wrote:
[...]
> I've never seen "stock" Python (stable release w/ only included modules)
> segfault, but did see a segfault with an extension module I was using
> the other week (lxml IIRC, but I'm not sure).
>
> - Michael
So far, this i
On Wed, Nov 16, 2005 at 03:09:56PM -0500, Shane wrote:
> Hi folks,
>
> I'm new to regular expressions (and a novice at Python) but it seems to be
> the tool I need for a particular problem. I have a bunch of strings that
> looks like this:
>
> 'blahblah_sf1234-sf1238_blahblah'
>
> and I would
I'm trying to extract module contents from Verilog, which has the form
of;
module foo (port1, port2, ... );
// module contents to extract here.
...
endmodule
To extract the module contents, I'm planning to do something like;
from pyparsing import *
ident = Word(alphas+
On Mon, Nov 28, 2005 at 09:00:58PM +, Paul McGuire wrote:
> "Inyeol Lee" <[EMAIL PROTECTED]> wrote in message
> [...]
> > How should I write the part of 'module_contents'? It's an arbitrary text
> > which doesn't contain 'endmodule&
.__init__(self, foo)
... self.bar = bar
...
>>> a = A(1)
Traceback (most recent call last):
File "", line 1, in ?
File "", line 4, in __init__
TypeError: A is base class.
>>> b = B(1)
>>> b.foo
1
>>> c = C(1, 2)
>>> c.foo, c.bar
(1, 2)
>>>
HTH
--Inyeol Lee
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Dec 02, 2005 at 10:43:56AM +0100, bruno at modulix wrote:
> Inyeol Lee wrote:
> (snip)
>
> >>>>class A(object):
> >>>>... def __init__(self, foo):
> >>>>... if self.__class__ is A:
> >>>>...
On Fri, Dec 02, 2005 at 09:45:10PM +0100, Gerhard H�ring wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Micah Elliott wrote:
> > On Dec 02, Dave Hansen wrote:
> >
> >>Python recognizes the TAB character as valid indentation. TAB
> >>characters are evil. They should be banned from
sing.
>
How about using python -m?
Assuming Make uses Bourne shell,
%.abc: %.def
PYTHONPATH=/path/to/stuff:/path/to/another python -m myscript
Don't forget to strip '.py' extension.
--Inyeol Lee
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Dec 02, 2005 at 08:10:41PM -0500, Mike Meyer wrote:
> Inyeol Lee <[EMAIL PROTECTED]> writes:
> > On Fri, Dec 02, 2005 at 07:33:20PM -0500, Mike Meyer wrote:
> >> > The problem is that myscript.py and some modules that myscript.py
> >> > imports a
After installing Python 2.4 from src tarball I found one new executable in
python/bin directory - "smtpd.py". I also found the same file in
python/lib/python2.4/. Is this intentional or just a minor bug in build
script?
Inyeol
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Apr 09, 2005 at 03:15:01AM +0530, Sidharth Kuruvila wrote:
> Python has a builtin function called locals which returns the local
> context as a dictionary
>
> >>> locals = locals()
> >>> locals["a"] = 5
> >>> a
> 5
> >>> locals["a"] = "changed"
> >>> a
> 'changed'
>From Python lib referen
def __init__(self):
... self.name = "A"
... print "typeA init"
...
>>> class typeB(baseClass):
... def __init__(self):
... self.name = "B"
... print "typeB init"
...
>>> a = baseClass.fromfile("A")
typeA init
>>> a.getName()
A
>>> b = baseClass.fromfile("B")
typeB init
>>> b.getName()
>>> B
>>>
--
Inyeol Lee
--
http://mail.python.org/mailman/listinfo/python-list
passed by value rather than by
> refrence?
>
What you're confused with is assignment. Check this example;
>>> def f(x):
... print id(x)
... x = x + 1
... print id(x)
...
>>> f(1234)
1617596
1617608
>>> a = 5678
#x27;a', 'a'), ('c', 'a', 'b'),
> ('c', 'a', 'c'), ('c', 'b', 'a'), ('c', 'b', 'b'), ('c', 'b', 'c'),
> ('c', 'c', 'a'), ('c', 'c', 'b'), ('c', 'c', 'c')]
>
> explanation of code: the files word1.txt, word2.txt and word3.txt are
> all identical conataining the letters a,b and c one letter per line.
> The lists I've added the "\n" so that the lists are identical to what
> is returned by the file objects. Just eliminating any possible
> differences.
You're comparing file, which is ITERATOR, and list, which is ITERABLE,
not ITERATOR. To get the result you want, use this instead;
>>> print [(i1.strip(),i2.strip(),i3.strip(),)
for i1 in open('word1.txt')
for i2 in open('word2.txt')
for i3 in open('word3.txt')]
FIY, to get the same buggy(?) result using list, try this instead;
>>> l1 = iter(['a\n','b\n','c\n'])
>>> l2 = iter(['a\n','b\n','c\n'])
>>> l3 = iter(['a\n','b\n','c\n'])
>>> print [(i1.strip(),i2.strip(),i3.strip(),) for i1 in l1 for i2 in l2 for i3
>>> in l3]
[('a', 'a', 'a'), ('a', 'a', 'b'), ('a', 'a', 'c')]
>>>
-Inyeol Lee
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote:
> I'm writing a class, where one of the methods is kinda complex. The
> method uses a function which I know for certain will not be used
> anywhere else. This function does not require anything from self, only
> the args passed by the
On Sun, Mar 11, 2007 at 06:36:02PM +0100, Bruno Desthuilliers wrote:
> Inyeol Lee a �crit :
> > On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote:
> >
> >>I'm writing a class, where one of the methods is kinda complex. The
> >>method uses a func
On Dec 7, 8:51 pm, [EMAIL PROTECTED] wrote:
> The following code works under 2.6
>
> def foo():
> a = 1
> <.tab..>b = 1
>
> but results in a TabError in Python 3k
>
> File "x.py", line 3
> b = 3
> ^
> TabError: inconsistent use of tabs and spaces in indentation
>
> T
On Nov 20, 1:18 pm, Johannes Bauer <[EMAIL PROTECTED]> wrote:
> Hello group,
>
> I'm porting some code of mine to Python 3. One class has the __cmp__
> operator overloaded, but comparison doesn't seem to work anymore with that:
>
> Traceback (most recent call last):
> File "./parse", line 25, in
On May 29, 9:26 am, たか <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I am developing the console which has the embedded Python interactive
> interpreter. So, I want to judge whether current command is complete
> or not. Below is good example to solve this problem.
> //
> //http://effbot.org/pyfaq/
On Jul 11, 12:58 pm, hardemr <[EMAIL PROTECTED]> wrote:
> Hello Everyone,
>
> I want to serialize and deserialize the objects into Memory not into
> file. How can i do that?
pickle.dumps and pickle.loads.
--Inyeol
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Mar 25, 2006 at 03:45:56AM -0800, Gerard Flanagan wrote:
[...]
> * If I want to do :
>
> mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz
>
> then tab-completion gives me the first occurrence of the file, but I
> have to type the second occurrence - is there a way of
On Jun 15, 3:22 pm, Peter wrote:
> I am puzzled by what appears to be a scope issue - obviously I have
> something wrong :-)
>
> Why does this work:
>
> if __name__ == 'main':
> execfile('test-data.py')
> print data
>
> and yet this doesn't (I get "NameError: global name 'data' not
> defined")
25 matches
Mail list logo