Repository: ipython/ipython

Issue:
rename or remove %profile magic
This is an issue to discuss what we should do with the `%profile` magic.

Background: This magic currently returns the name of the active profile. By name, it is easily confused with the functionality found in `%prun` and `%run -p`. Renaming or removing the current implementation of `%profile` opens up the possibility to use `%profile` for code profiling purposes.

Here are a few proposals: (please feel free to add others)
1. Rename `%profile` to `%profile_name` to better signify that it does not do code profiling. 
2. Deprecate and then remove `%profile` and tell users to use `get_ipython().profile`

rename or remove %profile magic
This is an issue to discuss what we should do with the `%profile` magic.

Background: This magic currently returns the name of the active profile. By name, it is easily confused with the functionality found in `%prun` and `%run -p`. Renaming or removing the current implementation of `%profile` opens up the possibility to use `%profile` for code profiling purposes.

Here are a few proposals: (please feel free to add others)
1. Rename `%profile` to `%profile_name` to better signify that it does not do code profiling. 
2. Deprecate and then remove `%profile` and tell users to use `get_ipython().profile`



Discussion:
:+1: to the general idea. I would lean toward 2, but both seem fine.  I don't think it's necessary to have a magic for printing a single public attribute on the shell object.

I agree with @minrk. 
I would also lean toward the option 2 for the reason @minrk presented, but maybe the people is used to use `%profile` and the change to `%profile_name` is less drastic than the change to `get_ipython().profile`. In the first case, you are renaming a magic, whereas in the second one, you are killing it at all and telling the people to access to other kind of element... OK, and the end, it is a little problem for the user, I just trying to think to as a conservative guy :bowtie:

In any case if we kill `%profile` it will probably stay around, deprecated for 1 cycle ? no ?
+1 for `get_ipython().profile` but you already know that.

I see that `%profile` is referenced only in the notebook examples files (such as "Cell Magics.pynb").

a)  What are the relevant files I should look into?
b) Is this only a name change?  

Yes, only a name change (or do we want deprecation warning ?).

```
In [2]: %profile?
Type:       Magic function
Namespace:  IPython internal
File:       /Users/matthiasbussonnier/ipython/IPython/core/magics/basic.py
```

So you should probably have a look at `IPython/core/magics/basic.py`

> or do we want deprecation warning ?

Maybe... at least for one release, to help people in the transition... 

@damianavila @Carreau In the PR, I placed a deprecation warning in both the docstring and error message of `%profile`. I added the new line magic `profile_name`. Feel free to code review. 

FWIW, I would also prefer to have us shift toward option 2, and after a deprecation cycle rename `%prun` to `%profile`

:+1: to the general idea. I would lean toward 2, but both seem fine.  I don't think it's necessary to have a magic for printing a single public attribute on the shell object.

I agree with @minrk. 
I would also lean toward the option 2 for the reason @minrk presented, but maybe the people is used to use `%profile` and the change to `%profile_name` is less drastic than the change to `get_ipython().profile`. In the first case, you are renaming a magic, whereas in the second one, you are killing it at all and telling the people to access to other kind of element... OK, and the end, it is a little problem for the user, I just trying to think to as a conservative guy :bowtie:

In any case if we kill `%profile` it will probably stay around, deprecated for 1 cycle ? no ?
+1 for `get_ipython().profile` but you already know that.

I see that `%profile` is referenced only in the notebook examples files (such as "Cell Magics.pynb").

a)  What are the relevant files I should look into?
b) Is this only a name change?  

Yes, only a name change (or do we want deprecation warning ?).

```
In [2]: %profile?
Type:       Magic function
Namespace:  IPython internal
File:       /Users/matthiasbussonnier/ipython/IPython/core/magics/basic.py
```

So you should probably have a look at `IPython/core/magics/basic.py`

> or do we want deprecation warning ?

Maybe... at least for one release, to help people in the transition... 

@damianavila @Carreau In the PR, I placed a deprecation warning in both the docstring and error message of `%profile`. I added the new line magic `profile_name`. Feel free to code review. 

FWIW, I would also prefer to have us shift toward option 2, and after a deprecation cycle rename `%prun` to `%profile`


Resolving patch:
diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py
--- a/IPython/core/magics/basic.py
+++ b/IPython/core/magics/basic.py
@@ -306,12 +306,13 @@ def page(self, parameter_s=''):
     @line_magic
     def profile(self, parameter_s=''):
         """Print your currently active IPython profile.
-       
+
         See Also
         --------
         prun : run code using the Python profiler
                (:meth:`~IPython.core.magics.execution.ExecutionMagics.prun`)
         """
+        warn("%profile is now deprecated. Please use get_ipython().profile instead.")
         from IPython.core.application import BaseIPythonApplication
         if BaseIPythonApplication.initialized():
             print(BaseIPythonApplication.instance().profile)


Test patch:
diff --git a/IPython/core/tests/test_profile.py b/IPython/core/tests/test_profile.py
--- a/IPython/core/tests/test_profile.py
+++ b/IPython/core/tests/test_profile.py
@@ -113,8 +113,8 @@ def test_startup_py(self):
 
     @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows")
     def test_startup_ipy(self):
-        self.init('00-start.ipy', '%profile\n', '')
-        self.validate('test')
+        self.init('00-start.ipy', '%xmode plain\n', '')
+        self.validate('Exception reporting mode: Plain')
 
     
 def test_list_profiles_in():