Re: GeneratorExit masks StopIteration?

2017-01-29 Thread inyeol . lee
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

Re: GeneratorExit masks StopIteration?

2017-01-29 Thread inyeol . lee
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

GeneratorExit masks StopIteration?

2017-01-29 Thread inyeol . lee
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

Re: Which coding style is better? public API or private method inside class definition

2011-01-04 Thread Inyeol
I found typo after posting: local name 'numbers' and 'number' are mixed. Plz don't report bug but focus on coding style only :-) -- http://mail.python.org/mailman/listinfo/python-list

Which coding style is better? public API or private method inside class definition

2011-01-04 Thread Inyeol
For example: I'm writing simple class: class Numbers: def __init__(self, numbers): self._numbers = numbers def get_all(self): for number in self._numbers: yield number If I want to add another method for yielding even numbers only, I may

Interaction btw unittest.assertRaises and __getattr__. Bug?

2010-10-26 Thread Inyeol
x27;t matter what kind of exception it raises. Any exception inside __getattr__ bypasses assertRaises. This happens both with 3.1.2 and 2.6.5. Any idea? Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Scope (?) question

2010-06-15 Thread Inyeol Lee
mystifying) sentence: > > "execfile() cannot be used reliably to modify a function’s locals." > > Thanks > Peter This is due to CPython's static optimization of local name lookup. Dummy 'exec' statement disables this and makes your example work: def X(): exec "None" execfile('test-data.py') print data --inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: tabs and spaces in py3k

2008-12-07 Thread inyeol . lee
e section numbers > back in the docs.) No mention of this change > (that I noticed) in What's New or NEWS.txt. > > Do the Py3k docs need correction? -tt option in python 2.x is now default in python 3.0. Apparently it got slipped from any documentation, including what's new. --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Inyeol . Lee
): >   File "./parse", line 25, in >     print(x < y) > TypeError: unorderable types: IP() < IP() > > Was there some kind of semantic change? Overload __lt__ method. Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: How to serialize and deserialize the objects into memory?

2008-07-11 Thread Inyeol . Lee
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

Re: How do I tell "imconplete input" from "valid input"?

2008-05-29 Thread Inyeol . Lee
INCOMPLETE from this function, but I didn't. > > How should I do it? > > Thanks, > urai I guess you should use "Py_single_input" instead of "Py_file_input" in your code, which requires extra NEWLINE to end complex statement. Plz check details in Grammar/Grammar from python source distribution --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Best place for a function?

2007-03-13 Thread Inyeol Lee
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

Re: Best place for a function?

2007-03-09 Thread Inyeol Lee
rgs passed by the method. > > Where should I put the function? Use staticmethod. It's a normal function with class namespace. --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: scared about refrences...

2006-11-01 Thread Inyeol Lee
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

Re: inheritance?

2006-08-16 Thread Inyeol Lee
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

Re: Strange behavior with iterables - is this a bug?

2006-05-30 Thread Inyeol Lee
#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

Re: OT: unix newbie questions

2006-03-27 Thread Inyeol Lee
kage-1.0.2.tar.gz subdir/!#:1.backup This works for both bash and (t)csh. --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Setting PYTHONPATH from Makefile

2005-12-02 Thread Inyeol Lee
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

Re: Setting PYTHONPATH from Makefile

2005-12-02 Thread Inyeol Lee
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

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-02 Thread Inyeol Lee
arser/Compiler" Feature Request for this [...] > > Read PEP 666 first. > And this one too ;-) http://www.artima.com/weblogs/viewpost.jsp?thread=101968 --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Instances behaviour

2005-12-02 Thread Inyeol Lee
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: > >>>>...

Re: Instances behaviour

2005-12-01 Thread Inyeol Lee
.__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

Re: [pyparsing] How to get arbitrary text surrounded by keywords?

2005-11-28 Thread Inyeol Lee
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&

[pyparsing] How to get arbitrary text surrounded by keywords?

2005-11-28 Thread Inyeol Lee
obe code not tested.) How should I write the part of 'module_contents'? It's an arbitrary text which doesn't contain 'endmodule' keyword. I don't want to use full scale Verilog parser for this task. -Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: repeating regular expressions in one string

2005-11-16 Thread Inyeol Lee
n/listinfo/python-list You can simplify your pattern myString = re.compile('sf[0-9][0-9][0-9][0-9]') to myString = re.compile(r"sf\d{4}") >>> import re >>> s = 'blahblah_sf1234-sf1238_blahblah' >>> pat = re.compile(r"sf\d{4}&quo

[OT] Re: how to debug when "Segmentation fault"

2005-10-04 Thread Inyeol Lee
> > - Michael So far, this is the simplest way to crash stock python, at least in Unix/Linux; $ python < /bin If you redirect directory instead of file, python crashes. I think this bug was introduced around 2.1 or 2.2, and not yet fixed as of 2.4.1. - Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: Declaring variables from a list

2005-04-08 Thread Inyeol Lee
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

smtpd.py in python2.4/bin directory?

2005-01-11 Thread Inyeol Lee
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