Ycecream

Latest version: v1.3.20.post0

Safety actively analyzes 685670 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 7

1.3.3

=========================
New functionality (0)
---------------------
Introduced a new attribute: enforce_line_length / ell .
If True, all output lines will be truncated to the current line_length.
This holds for all output lines, including as_str output.
Example:
y.configure(enforce_line_length=True, line_length=15)
s = "abcdefghijklmnopqrstuvwxyz"
y(s)
y(show_time=True)
prints something like
|y|
| s: 'abcdefg
|y| 35 08:14:

New functionality (0)
---------------------
New shorthand alternatives:
sdi for sort_dicts
i for indent
de for depth
wi for wrap_indent
ell for enforce_line_length

1.3.2

=========================
New functionality (0)
---------------------
y.new() has a new parameter ignore_json that makes it possible to ignore the ycecream.json file.
Thus, if you don't want to use any attributes that are overridden by an ycecream.json file:
y = y.new(ignore_json=True)

Internal changes (0)
--------------------
The PY2/PY3 specific code is clustered now to make maintenance easier.
In the pprint 3.8 module, the PrettyPrinter class is not even created for PY2,
so no more need to disable specifically several dispatch calls.

1.3.1

=========================
New functionality (0)
---------------------
The ycecream.json file may now also contain shorthand names,
like p for prefix.

New functionality (1)
---------------------
The attribute compact now has a shorthand name: c
So,
y(d, compact=True)
is equivalent to
y(d, c=1)

Changes in install ycecream.py (0)
----------------------------------
install ycecream.py will now also copy ycecream.json to site-packages, if present.


Older versions of Python support (0)
------------------------------------
Ycecream now runs also under Python 2.7.
The implementation required a lot of changes, most notably phasing out pathlib, f-strings,
some syntax incompatibilities and function signatures.
Under Python 2.7, the compact and sort_dicts attributes are ignored as the 2.7 version of
pprint.pformat (which is imported) does not support these parameters.

Also, the test script needed a lot of changes to be compatible with Python 2.7 and Python 3.x

Under Python 2.7, the scripts
install ycecream.py
and
install ycecream from github.py
require pathlib to be installed.

It is most likely that ycecream will run under Python 3.4 and 3.5, but that has not been tested (yet).

1.2.1

=========================
New functionality (0)
---------------------
Assigning delta a value is now alo propogated to any forked instances.
Also the delta value is copied to a cloned version.

Removed functionality (0)
-------------------------
The just introduced way of importing y with
import ycecream as y
has been removed as it caused a lot of problems and was not very stable.

1.2.0

=========================
New functionality (0)
---------------------
Instead of
from ycecream import y
it is now possible to use
import ycecream as y
, which is arguably easier to remember and saves 2 keystrokes: every little bit helps.

The readme now uses the 'import ycecream as y' style, although the
'from ycecream import y' is still available.

New functionality (1)
---------------------
From this version on, it is possible to fork an ycecream instance.
The forked instance will depend on (inherit from) the attributes of the parent instance.
That means that, unless overridden in the forked instance, a change of an attribute in the
parent instance will be propagated into the forked instance. E.g.
|y1 = y.fork()
|y2 = y.fork()
|y2.configure(prefix="y2| ")
|y1(1000)
|y2(2000)
|y.configure(prefix="==>") this also affects y1.prefix
|y1(1001)
|y2(2001)
prints
|y| 1000
|y2| 2000
|==>1001
|y2| 2001
Because of this new functionality, the ycecream.enable() functionality is not required anymore
and phased out:
|y1 = y.fork(show_line_numbers=True, prefix="y1| ")
|y2 = y.fork(show_delta=True, prefix="y2| ")
|y1(1000)
|y2(2000)
|y.enabled = False
|y1(1001)
|y2(2001)
|y.configure(enabled=True)
|y1(1002)
|y2(2002)
prints
|y1| 16 ==> 1000
|y2| delta=0.052 ==> 2000
|y1| 22 ==> 1002
|y2| delta=0.235 ==> 2002

New functionality (2)
---------------------
A number of shortcuts for attributes have been defined:
p prefix
o output
s serialize
sln show_line_number
st show_time
sd show_delta
se show_enter
sx show_exit
e enabled
ll line_length
vo values_only
rn return_none
d decorator
cm context_manager
So,
|y.configure(prefix="==>", show_time=True)
is equivalent to
|y.configure(p="==>", st=True)
This functionality is also present directly on 'attributes':
|y.prefix = "==>"
is equivalent to
|y.p = "==>"

Internal changes (0)
====================
Complete overhaul of the attributes and inheritance of instances.
Arguments do not default to None, but to ycecream.nv .
The __init__.py file in PyPI is different from before to support

1.1.10

==========================
New functionality (0)
---------------------
Added as_decorator and as_context_manager parameters to Y.__call__.
These can be used to use 'fast disabling' and still use y() as a decorator or context manager.
So, the table presented with version 1.1.9 should read now:
---------------------------------------------------------------------
enabled=True enabled=False enabled=[]
---------------------------------------------------------------------
execution speed normal normal fast
y() normal no output no output
y normal no output no output
y(as_decorator=True) normal no output no output
y(as_context_manager=True) normal no output no output
y() normal no output TypeError
with y(): normal no output AttributeError
y(as_str=True) normal normal normal
----------------------------------------------------------------------

If you want to use a y as a decorator and still want 'fast disabling':
|y.configure(enabled=[])
|y(as_decorator=True):
|def add2(x):
| return x + 2
|x34 = add2(30)
prints nothing, whereas
|y.configure(enabled=[])
|y():
|def add2(x):
| return x + 2
|x34 = add2(30)
would raise a TypeError.
On the other hand
|y.configure(enabled=False)
|y():
|def add2(x):
| return x + 2
|x34 = add2(30)
would also print nothing. It would however not run as fast as possible for ordinary y() calls.


New functionality (1)
---------------------
Added a new attribute `return_none`, which is False by default.
If True, `y(<arguments>)` will return None, rather than <parameter>. This can be useful when
using ycecream in notebooks. E.g.
|hello = "world"
|print(y(hello))
|y.configure(return_none=True)
|print(y(hello))
prints
|y| hello: 'world'
|world
|y| hello: 'world'
|None


Improved functionality (0)
--------------------------
Ycecream is now fully compatible with (Jupyter) notebooks.

Improved functionality (1)
--------------------------
When used from a REPL, usage as a decorator is now possible with the as_decorator parameter, like:
>>>y(as_decorator)
>>>def add2(x):
>>> return x + 2
>>>print(add2(x))
y| called add2(10)
y| returned 12 from add2(10) in 0.000312 seconds
12

When used from a REPL, usage as a context manager is now possible with the as_context_manager,like
>>>with y():
>>> pass
y| enter
y| exit in 0.000241 seconds

Note that line number are not available in the REPL.

Bug fix (0)
-----------
y.configure() returned the the instance itself rather than None. Fixed.

Page 4 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.