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
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
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
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
>
> - 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
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
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
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:
> >>>>...
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
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
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
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
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
):
> 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
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
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
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
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
28 matches
Mail list logo