if x < 5]
[1, 2, 3, 4, 5]
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
https://mail.python.org/mailman/listinfo/python-list
hetic and style than the developer of logging,
or email, or re, and so on.
True story
If we had one person who had the authority to make doc-wide decisions,
then we might be able to move towards coherent guidelines for the docs
to be more uniform.
That could be a solution :-)
--
Ma
5.043s
I can expect this result when I run some processes in parallel on
different CPUs, but this code uses threads, so the GIL prevents the two
task() functions to be executed in parallel. What am I missing?
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Sela
namespace, it
raises a NameError
* enclosing scope (LOAD_DEREF): there is a closure, and Python looks for
the name in the enclosing namespace
Is that right, or am I missing something? Thanks, Marco
[1]
http://sebastianraschka.com/Articles/2014_python_scope_and_namespaces.html
--
Marco B
27;)
2
It seems to me not consistent, and maybe could also be error prone:
>>> f.seek(2)
2
>>> f.write('c')
1
>>> f.close()
>>> open('myfile').read()
...
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3...
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
On 27/02/2016 10:13, Steven D'Aprano wrote:
I think it would be more acceptable to me if the sender
labelled the subject line as "Advertising".
+1
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
E
I enabled the deprecation warning in Python 3.5.1 and Python 3.6 dev,
but I did not get any warning when assigning to async or await:
$ python -Wd -c "import sys; print(sys.version); async = 33"
3.5.1 (default, Jan 21 2016, 19:59:28)
[GCC 4.8.4]
Is it normal?
--
Marco Buttu
INAF-Os
On 22/01/2016 16:59, Ian Kelly wrote:
On Fri, Jan 22, 2016 at 4:12 AM, Marco Buttu wrote:
>I enabled the deprecation warnings in Python 3.5.1 and Python 3.6 dev, and I
>noticed that assigning to async or await does not issue any deprecation
>warning:
>
>$ python -Wd -c &qu
-c "import sys; print(sys.version); async = 33"
3.6.0a0 (default:4b434a4770a9, Jan 12 2016, 13:01:29)
[GCC 4.8.4]
Is it normal?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
es, as mentioned by Skip, we say that the term "buit-in function"
is also referred to a function written in C:
https://docs.python.org/3/library/types.html#types.BuiltinFunctionType
By using the same word (built-in) to indicate either objects written in
C or objects who live in the
are that you will not write a test after fixing the bug, i.e.
because you may have other priorities, so you will miss a regression test
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
):
...
AttributeError: 'tuple' object has no attribute 'foo'
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
https://mail.python.org/mailman/listinfo/python-list
lies every instance of a
class is an instance of object. And classes are instance of a class
(thier metaclass), so they are instance of objects too
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cag
parameters far away from the parameter list itself.
Then move it to the first line of the docstring...
I like this idea, because nevertheless the type hinting is optional, the
mypy syntax affects every Python programmer who has to read other code
that will use this syntax, while the do
s) and non-types (non-classes)
objects, instead of between objects and classes. The problem is in the
Python documentation there is also a bit of confusion about this... In
the descriptor howto: "The details of invocation depend on whether obj
is an object or a class" :/
--
Marco Buttu
IN
e to give a special meaning to the attribute.
Given `obj.attr`, we just have to know what kind of object is `obj`:
usually, like in this case, we have to differentiate between classes and
non-classes objects. In fact __bases__ is not listed by dir(Sub) because
Sub is a class, and the distinction between classes and non-classes
objects matters, especially for dir()
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
Python documentation there is also a bit of confusion about
this... In the descriptor howto: "The details of invocation depend on
whether obj is an object or a class" :/
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
(MyClass, Foo)
True
>>> MyClass.foo
33
But an instance of MyClass is not an instance of Foo, and so MyClass()
must not have the attribute foo. In fact:
>>> m = MyClass()
>>> isinstance(m, Foo)
False
>>> m.foo
Traceback (most recent call last):
...
on is. What do you do?
The batteries included: some useful and simple examples with only core
data type objects, built-in functions and standard library
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu.
o be taken as
example for writing good comments and docstrings:
https://hg.python.org/cpython/file/3.4/Lib/statistics.py
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
https://mail.python.org/mailman/listinfo/python-list
thing
like, for instance, `root` namespace, or using the name "core"
(inspect.iscore(), types.CoreFunctionType, ecc.) to indicate "written in
C or whatever underlying language"?
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
https://mail.python.org/mailman/listinfo/python-list
t live in
the builtin namespace :/ By using the same word (built-in) to indicate
either objects written in C or objects referenced by the builtin
namespace could be a bit muddler for everyone, beginner or not. Is it
too late for changing the name of the `builtin` namespace in something
like, fo
t the current session and
restart it, but as a challenge, can we recover from this state?
>>> [].__class__.__module__ # It is a string...
'__builtin__'
So, I do not have any idea about how to get a module without importing
something. Thanks for sharing :)
--
Marco
implify("x**3 + x**2 + x + 1")
>>> equation
x**3 + x**2 + x + 1
>>> diff(equation)
3*x**2 + 2*x + 1
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
implify("x**3 + x**2 + x + 1")
>>> equation
x**3 + x**2 + x + 1
>>> diff(equation)
3*x**2 + 2*x + 1
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it
--
https://mail.python.org/mailman/listinfo/python-list
a','b','c','x','y','z']
v1, _, _, v2, v3, _ = bar
I also like the solution with itemgetter:
v1, v2, v3 = itemgetter(0, 3, 4)(bar)
but I think it is less readable than the previous one
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
an issue on the bug tracker can another Windows user or
two please confirm that this is a genuine problem and not my
installation being corrupt or whatever.
Hi, it works for me (Windows XP, 32)
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
10)
Traceback (most recent call last):
...
AttributeError: Must be a positive number
But I cannot use the method as a function:
>>> Configuration.positiveCheck(-10)
Traceback (most recent call last):
...
Configuration instance as first argument (got int instance instead).
Furthemore, I cannot use the me
not skip the staticmethod decorator?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
local/bin
include-system-site-packages = false
version = 3.4.0
In this case (default), the site-package directory is not included in
the PYTHONPATH. If you want to include it, set:
include-system-site-packages = true
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
ame, value)
... super().__setattr__(name, value)
...
>>> class Foo(metaclass=MetaFoo):
... a = 33
...
In Namespace.__setitem__(): __module__ __main__
do something with __module__ __main__
In Namespace.__setitem__(): __qualname__ Foo
do something with __qualname__ Foo
In Namespace.__setitem__(): a 33
do something with a 33
>>> Foo.a = 33
In MetaFoo.__setattr__(): a 33
do something with a 33
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
last
command (the lambdify 1)
I get a syntax error. I think that is because I m using th1 and th2 as Function
of t. Can anyone help me on how to solve this?
There is just one error for me: array instead of np.array. Once changed
this, it works fine (Python 3.3, SymPy 0.7.3)
--
Marco Bu
, that works just fine. The compiler sees that super is
accessed within the method and creates the closure necessary to make
it work. This does fail, however:
f = super
class X(Y):
def method(self, arg):
f().method(arg)
Very interesting! Thanks :)
--
Marco Buttu
--
https://mail
27;t want to make a habit of it.
...
[1] Which is not necessarily a bad thing!
Thanks a lot for this anecdote :)
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
On 10/10/2013 01:04 PM, Ned Batchelder wrote:
On 10/10/13 3:22 AM, Marco Buttu wrote:
>>> import inspect
>>> class B(A):
... def bfoo(*args):
... frame = inspect.currentframe()
... for obj, value in frame.f_locals.items():
... pri
for obj, value in frame.f_locals.items():
... print(obj, value, sep=' --> ')
... # super().afoo(*args[1:])
...
>>> B().bfoo(1, 2, 3)
args --> (<__main__.B object at 0x7f28c960a590>, 1, 2, 3)
frame -->
So, why does not super use it?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
gt;>> class B(A):
... def bfoo(*args):
... super().afoo(*args[1:])
...
>>> B().bfoo(1, 2, 3)
Traceback (most recent call last):
File "", line 1, in
File "", line 3, in bfoo
RuntimeError: super(): no arguments
How come?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
On 10/09/2013 01:00 AM, Oscar Benjamin wrote:
> On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote:
>
> > Another question is: where is the place in which this transformation
> > occurs? Is it at the parser level, before the dictionary attribute is
> > gave as a
On 10/08/2013 01:07 PM, Ned Batchelder wrote:
On 10/8/13 6:13 AM, Marco Buttu wrote:
>>> class Foo:
... _Foo__a = 100
... __a = 33
...
>>> Foo._Foo__a
33
...
You also get a "problem" if you do this:
>>> class Foo:
... a = 100
On 10/08/2013 12:36 PM, Terry Reedy wrote:
On 10/8/2013 6:13 AM, Marco Buttu wrote:
In the following case:
>>> class Foo:
... _Foo__a = 100
... __a = 33
...
>>> Foo._Foo__a
33
I think this behavior, for a user who does not know the convention,
could be a
://docs.python.org/3/reference/lexical_analysis.html
http://docs.python.org/3/reference/expressions.html#atom-identifiers
but it is not clear when this transformation happens.
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
On 10/07/2013 04:27 AM, Steven D'Aprano wrote:
On Sun, 06 Oct 2013 20:17:33 +0200, Marco Buttu wrote:
>
> >>> class FooMeta(type):
>... def __call__(metacls, name, bases, namespace):
>...print("FooMeta.__call__()")
...
> From what I undes
Hi all, I have a question about class creation and the __call__ method.
I have the following metaclass:
>>> class FooMeta(type):
... def __call__(metacls, name, bases, namespace):
... print("FooMeta.__call__()")
From what I undestood, at the end of the class statement happens
some
Does that answer your question?
Yes, thanks a lot Steven, I saw the gc.collect() does not call the
__del__() method in Python 3.3, so I think I will look at the
documentation of gc in order to understand better. Thanks again, Marco
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
__init__(self):
self.b = A(self) # Reference cycle
print('In B.__init__()')
def __del__(self):
print('Goodbye from B()')
b = B()
del b
Regards, Marco
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
3 STORE_NAME 0 (a)
6 LOAD_CONST 5 (5)
9 STORE_NAME 0 (a)
12 LOAD_CONST 3 (None)
15 RETURN_VALUE
Regards, M.
--
Marco Buttu
--
http://mail.python.org/mailman/listinfo/python-list
On 08/27/2013 08:51 PM, Terry Reedy wrote:
BaseException was added just so it would be possible to catch nearly
everything but a few exceptions. The first two were KeyboardInterrupt
and SystemExit (in 2.5). GeneratorExit was switched in 2.6, but I forget
the details of why.
Maybe in order to d
On 08/27/2013 11:22 AM, Steven D'Aprano wrote:
What matters is that when you catch "nearly everything", StopIteration is
included in the "nearly everything", but SysExit and KeyboardInterrupt
should not be. Consider:
try:
main()
except Exception as e:
print('an unexpected error occur
On 08/26/2013 10:10 PM, random...@fastmail.us wrote:
The reason KeyboardInterrupt and SystemExit inherit from BaseException
is because you often want them to escape (allowing the program to quit)
from code that would otherwise catch them (by catching Exception). On
the contrary, StopIteration is
On 08/27/2013 08:17 AM, Marco Buttu wrote:
But if I want to catch it specifically (except BaseIteration),
Sorry, except StopIteration...
--
Marco Buttu
--
http://mail.python.org/mailman/listinfo/python-list
Since StopIteration is not an error, how come does it inherit directly
from Exception and not from BaseException?
Thanks in advance, Marco
--
Marco
--
http://mail.python.org/mailman/listinfo/python-list
On 05/18/2012 05:42 PM, jmfauth wrote:
Non official but really practical:
http://www.fileformat.info/info/unicode/index.htm
Very well ordered, thanks
--
Marco
--
http://mail.python.org/mailman/listinfo/python-list
On 05/17/2012 09:32 PM, Marco wrote:
Is it normal the str.isnumeric() returns False for these Cuneiforms?
'\U00012456'
'\U00012457'
'\U00012432'
'\U00012433'
They are all in the Nl category.
Marco
It's ok, I found that they don't have a number assigned in the
ftp://ftp.unicode.org/Public/U
On 05/18/2012 11:24 AM, jmfauth wrote:
Is it normal the str.isnumeric() returns False for these Cuneiforms?
>
> '\U00012456'
> '\U00012457'
> '\U00012432'
> '\U00012433'
>
> They are all in the Nl category.
Indeed there are, but Unicode (ver. 5.0.0) does not assign numeric
values to these
On 05/18/2012 02:50 AM, Steven D'Aprano wrote:
Is it normal the str.isnumeric() returns False for these Cuneiforms?
>
> '\U00012456'
> '\U00012457'
> '\U00012432'
> '\U00012433'
>
> They are all in the Nl category.
Are you sure about that? Do you have a reference?
I I was just playing
55 matches
Mail list logo