Picon

Re: PYTHONPATH works for modules but not scripts


This would work, but I would have to define an alias for every single script. 
I hope that there will eventually be some fix to IPython that makes it check
the PYTHONPATH for scripts that are not found in the current/working
directory.

> You might consider defining an alias within IPython.

--

-- 
View this message in context: http://www.nabble.com/PYTHONPATH-works-for-modules-but-not-scripts-tp24762511p24766080.html
Sent from the IPython - User mailing list archive at Nabble.com.
Gökhan Sever | 2 Aug 16:46
Picon
Gravatar

Re: [IPython-dev] IPython tab-completion behaviour in Linux

The following seems like another bug, that matters only for bare list instantiation "[]". String "" and dict {} objects seemingly works as expected.

RC1 also has the same issue.

Could you confirm?


Python 2.6 (r26:66714, Jun  8 2009, 16:07:26)
IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.

In [1]: a = [3, 1, 6, -2]

In [2]: a.sort()

In [3]: a
Out[3]: [-2, 1, 3, 6]

In [4]: b = [3, 1, 6, -2].sort()

In [5]: b

In [6]: whos
Variable   Type        Data/Info
--------------------------------
a          list        [-2, 1, 3, 6]
b          NoneType    None


Thanks.

On Mon, Jul 27, 2009 at 12:05 PM, Brian Granger <ellisonbg.net <at> gmail.com> wrote:

Thanks for posted this bug report.

Brian

On Mon, Jun 29, 2009 at 9:25 AM, Gökhan SEVER <gokhansever <at> gmail.com> wrote:
On Mon, Jun 29, 2009 at 9:04 AM, Jeff Kaufman<jeff <at> alum.swarthmore.edu> wrote:
> G??khan SEVER wrote:
>>
>> See the examples below:
>>
>> [gsever <at> ccn ~]$ ipython
>>  Logging to /home/gsever/.ipython/2009-06-29.py
>>
>> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
>> Type "copyright", "credits" or "license" for more information.
>>
>> IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
>> ...
>>
>> In [1]: "".
>> Display all 104 possibilities? (y or n)
>>
>> In [1]: "".s
>> .sage             .serverauth.5593  .subversion
>> .scribus          .ssh
>>
>> In [1]: [].
>> Display all 104 possibilities? (y or n)
>>
>> In [1]: [].sort()
>>
>> In [2]: [].sort?
>> Type:         list
>> Base Class:   <type 'list'>
>> String Form:  []
>> Namespace:    Interactive
>> Length:               0
>> Docstring:
>>     list() -> new list
>>     list(sequence) -> new list initialized from sequence's items
>>
>
> Note that some of this does work for strings:
>
>  In [1]: ''.join?
> Type:           str
> Base Class:     <type 'str'>
> String Form:
> Namespace:      Interactive
> Length:         0
> Docstring:
>    str(object) -> string
>
>    Return a nice string representation of the object.
>    If the argument is a string, the return value is the same object.
>
>  In [2]: "".join?
> Type:           str
> Base Class:     <type 'str'>
> String Form:
> Namespace:      Interactive
> Length:         0
> Docstring:
>    str(object) -> string
>
>    Return a nice string representation of the object.
>    If the argument is a string, the return value is the same object.
>
> And the issues are not limited to empty strings:
>
>  In [3]: "test".<tab>
> .svn/entries    .svn/prop-base  .svn/text-base
> .svn/format     .svn/props      .svn/tmp
>
>  In [3]: "test".svn/
>
> (In this case, .svn is the only dotfile in the curdir)
>
> Spaces change the matter:
>
>  In [4]: "this is a test".<tab>
>
> Does nothing.
>
> The problem has something to do with the interaction of tab completion
> and quote marks, and the current behavior doesn't make much sense.
>
> Jeff
>

I am pinging the devel list, just in case someone might say something
about this issue. If not, I will post a bug at
https://bugs.launchpad.net/ipython/

>From my IPy shell, as also Jeff noted, empty or non-empty objects
cannot list their associated methods and attributes without assigning
them to names.

Some additional information, I use:

Linux ccn 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 10)
Python 2.5.2
IPython 0.10.bzr.r1174
GNU bash, version 3.2.39

In [1]: [1,2,3].
Display all 104 possibilities? (y or n)

In [1]: {1:'a', 2:'b'}.
Display all 104 possibilities? (y or n)

In [2]: a = {1:'a', 2:'b'}

In [3]: a.
a.__class__         a.__le__            a.get
a.__cmp__           a.__len__           a.has_key
a.__contains__      a.__lt__            a.items
a.__delattr__       a.__ne__            a.iteritems
a.__delitem__       a.__new__           a.iterkeys
a.__doc__           a.__reduce__        a.itervalues
a.__eq__            a.__reduce_ex__     a.keys
a.__ge__            a.__repr__          a.pop
a.__getattribute__  a.__setattr__       a.popitem
a.__getitem__       a.__setitem__       a.setdefault
a.__gt__            a.__str__           a.update
a.__hash__          a.clear             a.values
a.__init__          a.copy
a.__iter__          a.fromkeys
_______________________________________________
IPython-dev mailing list
IPython-dev <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-dev




--
Gökhan
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Kenneth Arnold | 2 Aug 20:30
Picon

Re: [IPython-dev] IPython tab-completion behaviour in Linux

list.`sort` modifies the list in-place, so it returns None (so you
don't think you still have the unsorted copy somewhere).

Try  `sorted([1,2,3])`.

-Ken

On Sun, Aug 2, 2009 at 10:46 AM, Gökhan Sever<gokhansever <at> gmail.com> wrote:
> The following seems like another bug, that matters only for bare list
> instantiation "[]". String "" and dict {} objects seemingly works as
> expected.
>
> RC1 also has the same issue.
>
> Could you confirm?
>
>
> Python 2.6 (r26:66714, Jun  8 2009, 16:07:26)
> IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
>
> In [1]: a = [3, 1, 6, -2]
>
> In [2]: a.sort()
>
> In [3]: a
> Out[3]: [-2, 1, 3, 6]
>
> In [4]: b = [3, 1, 6, -2].sort()
>
> In [5]: b
>
> In [6]: whos
> Variable   Type        Data/Info
> --------------------------------
> a          list        [-2, 1, 3, 6]
> b          NoneType    None
>
>
> Thanks.
>
> On Mon, Jul 27, 2009 at 12:05 PM, Brian Granger <ellisonbg.net <at> gmail.com>
> wrote:
>>
>> Thanks for posted this bug report.
>>
>> Brian
>>
>> On Mon, Jun 29, 2009 at 9:25 AM, Gökhan SEVER <gokhansever <at> gmail.com>
>> wrote:
>>>
>>> On Mon, Jun 29, 2009 at 9:04 AM, Jeff Kaufman<jeff <at> alum.swarthmore.edu>
>>> wrote:
>>> > G??khan SEVER wrote:
>>> >>
>>> >> See the examples below:
>>> >>
>>> >> [gsever <at> ccn ~]$ ipython
>>> >>  Logging to /home/gsever/.ipython/2009-06-29.py
>>> >>
>>> >> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
>>> >> Type "copyright", "credits" or "license" for more information.
>>> >>
>>> >> IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
>>> >> ...
>>> >>
>>> >> In [1]: "".
>>> >> Display all 104 possibilities? (y or n)
>>> >>
>>> >> In [1]: "".s
>>> >> .sage             .serverauth.5593  .subversion
>>> >> .scribus          .ssh
>>> >>
>>> >> In [1]: [].
>>> >> Display all 104 possibilities? (y or n)
>>> >>
>>> >> In [1]: [].sort()
>>> >>
>>> >> In [2]: [].sort?
>>> >> Type:         list
>>> >> Base Class:   <type 'list'>
>>> >> String Form:  []
>>> >> Namespace:    Interactive
>>> >> Length:               0
>>> >> Docstring:
>>> >>     list() -> new list
>>> >>     list(sequence) -> new list initialized from sequence's items
>>> >>
>>> >
>>> > Note that some of this does work for strings:
>>> >
>>> >  In [1]: ''.join?
>>> > Type:           str
>>> > Base Class:     <type 'str'>
>>> > String Form:
>>> > Namespace:      Interactive
>>> > Length:         0
>>> > Docstring:
>>> >    str(object) -> string
>>> >
>>> >    Return a nice string representation of the object.
>>> >    If the argument is a string, the return value is the same object.
>>> >
>>> >  In [2]: "".join?
>>> > Type:           str
>>> > Base Class:     <type 'str'>
>>> > String Form:
>>> > Namespace:      Interactive
>>> > Length:         0
>>> > Docstring:
>>> >    str(object) -> string
>>> >
>>> >    Return a nice string representation of the object.
>>> >    If the argument is a string, the return value is the same object.
>>> >
>>> > And the issues are not limited to empty strings:
>>> >
>>> >  In [3]: "test".<tab>
>>> > .svn/entries    .svn/prop-base  .svn/text-base
>>> > .svn/format     .svn/props      .svn/tmp
>>> >
>>> >  In [3]: "test".svn/
>>> >
>>> > (In this case, .svn is the only dotfile in the curdir)
>>> >
>>> > Spaces change the matter:
>>> >
>>> >  In [4]: "this is a test".<tab>
>>> >
>>> > Does nothing.
>>> >
>>> > The problem has something to do with the interaction of tab completion
>>> > and quote marks, and the current behavior doesn't make much sense.
>>> >
>>> > Jeff
>>> >
>>>
>>> I am pinging the devel list, just in case someone might say something
>>> about this issue. If not, I will post a bug at
>>> https://bugs.launchpad.net/ipython/
>>>
>>> >From my IPy shell, as also Jeff noted, empty or non-empty objects
>>> cannot list their associated methods and attributes without assigning
>>> them to names.
>>>
>>> Some additional information, I use:
>>>
>>> Linux ccn 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 10)
>>> Python 2.5.2
>>> IPython 0.10.bzr.r1174
>>> GNU bash, version 3.2.39
>>>
>>> In [1]: [1,2,3].
>>> Display all 104 possibilities? (y or n)
>>>
>>> In [1]: {1:'a', 2:'b'}.
>>> Display all 104 possibilities? (y or n)
>>>
>>> In [2]: a = {1:'a', 2:'b'}
>>>
>>> In [3]: a.
>>> a.__class__         a.__le__            a.get
>>> a.__cmp__           a.__len__           a.has_key
>>> a.__contains__      a.__lt__            a.items
>>> a.__delattr__       a.__ne__            a.iteritems
>>> a.__delitem__       a.__new__           a.iterkeys
>>> a.__doc__           a.__reduce__        a.itervalues
>>> a.__eq__            a.__reduce_ex__     a.keys
>>> a.__ge__            a.__repr__          a.pop
>>> a.__getattribute__  a.__setattr__       a.popitem
>>> a.__getitem__       a.__setitem__       a.setdefault
>>> a.__gt__            a.__str__           a.update
>>> a.__hash__          a.clear             a.values
>>> a.__init__          a.copy
>>> a.__iter__          a.fromkeys
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev <at> scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
>
> --
> Gökhan
>
> _______________________________________________
> IPython-user mailing list
> IPython-user <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Gökhan Sever | 3 Aug 17:55
Picon
Gravatar

Re: [IPython-dev] IPython tab-completion behaviour in Linux

Yes,

I see your point, it is a subtle detail indeed.

Thanks for correction :)

On Sun, Aug 2, 2009 at 1:30 PM, Kenneth Arnold <kenneth.arnold <at> gmail.com> wrote:
list.`sort` modifies the list in-place, so it returns None (so you
don't think you still have the unsorted copy somewhere).

Try  `sorted([1,2,3])`.

-Ken



On Sun, Aug 2, 2009 at 10:46 AM, Gökhan Sever<gokhansever <at> gmail.com> wrote:
> The following seems like another bug, that matters only for bare list
> instantiation "[]". String "" and dict {} objects seemingly works as
> expected.
>
> RC1 also has the same issue.
>
> Could you confirm?
>
>
> Python 2.6 (r26:66714, Jun  8 2009, 16:07:26)
> IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
>
> In [1]: a = [3, 1, 6, -2]
>
> In [2]: a.sort()
>
> In [3]: a
> Out[3]: [-2, 1, 3, 6]
>
> In [4]: b = [3, 1, 6, -2].sort()
>
> In [5]: b
>
> In [6]: whos
> Variable   Type        Data/Info
> --------------------------------
> a          list        [-2, 1, 3, 6]
> b          NoneType    None
>
>
> Thanks.
>
> On Mon, Jul 27, 2009 at 12:05 PM, Brian Granger <ellisonbg.net <at> gmail.com>
> wrote:
>>
>> Thanks for posted this bug report.
>>
>> Brian
>>
>> On Mon, Jun 29, 2009 at 9:25 AM, Gökhan SEVER <gokhansever <at> gmail.com>
>> wrote:
>>>
>>> On Mon, Jun 29, 2009 at 9:04 AM, Jeff Kaufman<jeff <at> alum.swarthmore.edu>
>>> wrote:
>>> > G??khan SEVER wrote:
>>> >>
>>> >> See the examples below:
>>> >>
>>> >> [gsever <at> ccn ~]$ ipython
>>> >>  Logging to /home/gsever/.ipython/2009-06-29.py
>>> >>
>>> >> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
>>> >> Type "copyright", "credits" or "license" for more information.
>>> >>
>>> >> IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
>>> >> ...
>>> >>
>>> >> In [1]: "".
>>> >> Display all 104 possibilities? (y or n)
>>> >>
>>> >> In [1]: "".s
>>> >> .sage             .serverauth.5593  .subversion
>>> >> .scribus          .ssh
>>> >>
>>> >> In [1]: [].
>>> >> Display all 104 possibilities? (y or n)
>>> >>
>>> >> In [1]: [].sort()
>>> >>
>>> >> In [2]: [].sort?
>>> >> Type:         list
>>> >> Base Class:   <type 'list'>
>>> >> String Form:  []
>>> >> Namespace:    Interactive
>>> >> Length:               0
>>> >> Docstring:
>>> >>     list() -> new list
>>> >>     list(sequence) -> new list initialized from sequence's items
>>> >>
>>> >
>>> > Note that some of this does work for strings:
>>> >
>>> >  In [1]: ''.join?
>>> > Type:           str
>>> > Base Class:     <type 'str'>
>>> > String Form:
>>> > Namespace:      Interactive
>>> > Length:         0
>>> > Docstring:
>>> >    str(object) -> string
>>> >
>>> >    Return a nice string representation of the object.
>>> >    If the argument is a string, the return value is the same object.
>>> >
>>> >  In [2]: "".join?
>>> > Type:           str
>>> > Base Class:     <type 'str'>
>>> > String Form:
>>> > Namespace:      Interactive
>>> > Length:         0
>>> > Docstring:
>>> >    str(object) -> string
>>> >
>>> >    Return a nice string representation of the object.
>>> >    If the argument is a string, the return value is the same object.
>>> >
>>> > And the issues are not limited to empty strings:
>>> >
>>> >  In [3]: "test".<tab>
>>> > .svn/entries    .svn/prop-base  .svn/text-base
>>> > .svn/format     .svn/props      .svn/tmp
>>> >
>>> >  In [3]: "test".svn/
>>> >
>>> > (In this case, .svn is the only dotfile in the curdir)
>>> >
>>> > Spaces change the matter:
>>> >
>>> >  In [4]: "this is a test".<tab>
>>> >
>>> > Does nothing.
>>> >
>>> > The problem has something to do with the interaction of tab completion
>>> > and quote marks, and the current behavior doesn't make much sense.
>>> >
>>> > Jeff
>>> >
>>>
>>> I am pinging the devel list, just in case someone might say something
>>> about this issue. If not, I will post a bug at
>>> https://bugs.launchpad.net/ipython/
>>>
>>> >From my IPy shell, as also Jeff noted, empty or non-empty objects
>>> cannot list their associated methods and attributes without assigning
>>> them to names.
>>>
>>> Some additional information, I use:
>>>
>>> Linux ccn 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 10)
>>> Python 2.5.2
>>> IPython 0.10.bzr.r1174
>>> GNU bash, version 3.2.39
>>>
>>> In [1]: [1,2,3].
>>> Display all 104 possibilities? (y or n)
>>>
>>> In [1]: {1:'a', 2:'b'}.
>>> Display all 104 possibilities? (y or n)
>>>
>>> In [2]: a = {1:'a', 2:'b'}
>>>
>>> In [3]: a.
>>> a.__class__         a.__le__            a.get
>>> a.__cmp__           a.__len__           a.has_key
>>> a.__contains__      a.__lt__            a.items
>>> a.__delattr__       a.__ne__            a.iteritems
>>> a.__delitem__       a.__new__           a.iterkeys
>>> a.__doc__           a.__reduce__        a.itervalues
>>> a.__eq__            a.__reduce_ex__     a.keys
>>> a.__ge__            a.__repr__          a.pop
>>> a.__getattribute__  a.__setattr__       a.popitem
>>> a.__getitem__       a.__setitem__       a.setdefault
>>> a.__gt__            a.__str__           a.update
>>> a.__hash__          a.clear             a.values
>>> a.__init__          a.copy
>>> a.__iter__          a.fromkeys
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev <at> scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
>
> --
> Gökhan
>
> _______________________________________________
> IPython-user mailing list
> IPython-user <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>



--
Gökhan
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Fernando Perez | 3 Aug 23:57
Picon
Gravatar

Re: IPython tab-completion behaviour in Linux

Hi Gokhan,

On Sun, Jun 28, 2009 at 10:43 PM, Gökhan SEVER<gokhansever <at> gmail.com> wrote:
> I am wondering whether not getting attributes or models of some empty
> objects in the right way is a pre-defined behaviour or not? For
> example when I do "". and hit the tab instead of getting a list that
> is associated with the string object I get a list of hidden files in
> the current working directory. However in the []. case if I explicitly
> write sort I can see that a list object has a sort method.
>
> Is this an Ipython bug or could be fixed somehow?

Sorry for not replying earlier... The reason for this is that we avoid
evaluating the user input before tab completing, because doing so
would have many potentially problematic side effects.  We query the
namespace, so if you do

foo.bar.<tab>

we look for 'foo.bar' in your namespace, but we don't do
eval('foo.bar') at all.  Since '{}' is not in your namespace, it isn't
found, and the next available completer (for files) tries to fill in.

Early in its life ipython used to eval() user input before completion,
and that was the source of many problems, so it has been removed.

Is that clear?

Cheers,

f
Fernando Perez | 4 Aug 00:02
Picon
Gravatar

Re: PYTHONPATH works for modules but not scripts

Hi Philip,

On Fri, Jul 31, 2009 at 9:54 PM, Dr. Phillip M.
Feldman<pfeldman <at> verizon.net> wrote:
> This would work, but I would have to define an alias for every single script.
> I hope that there will eventually be some fix to IPython that makes it check
> the PYTHONPATH for scripts that are not found in the current/working
> directory.
>

could you please file a wishlist bug on this item so we don't forget?

https://bugs.launchpad.net/ipython/+filebug

I'm not sure that I'd want it to be the default %run behavior to
search all of PYTHONPATH, but certainly it could be available as:

- an optional flag to run
- a separate magic that does the searching and calls %run with the full path
- a option to toggle this on/off for %run, so users who want it can
activate it, aware that they will be running non-local scripts.

Which of these to use, I'm not sure about yet.  But we can discuss it
further to find a solution, and implement it after Brian's refactoring
lands.

Cheers,

f
Kenneth Arnold | 4 Aug 00:07
Picon

Re: IPython tab-completion behaviour in Linux

On Mon, Aug 3, 2009 at 5:57 PM, Fernando Perez<fperez.net <at> gmail.com> wrote:
> we look for 'foo.bar' in your namespace, but we don't do
> eval('foo.bar') at all.  Since '{}' is not in your namespace, it isn't
> found, and the next available completer (for files) tries to fill in.

I occasionally forget something about a built-in type, so I too wish I
could do [].<TAB>. But it's no big deal; I just type []<ENTER>, then
_.<TAB>.

Modules are also dynamically loaded if you do 'from module import
<TAB>', which is helpful but can itself run into problems if you're
not careful. I think there are optional completers for particular
things that require evaluation, like dict keys, but I never got around
to looking that up. You really need to be careful about introspection
in dynamic environments; there are lots of possible hidden side
effects. There's a subtle art between introspecting too much and too
little, and I think the devs have done an overall good job at finding
that balance.

> Early in its life ipython used to eval() user input before completion,
> and that was the source of many problems, so it has been removed.

Another source of random problems in my experience is autocall. If you
don't use it, turn it off (or learn how to use it <grin>).

-Ken
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Fernando Perez | 4 Aug 00:10
Picon
Gravatar

Re: Ipython print function problems

On Fri, Jul 31, 2009 at 1:15 PM, Dr. Phillip M.
Feldman<pfeldman <at> verizon.net> wrote:
>
> How about the following?
>
> print str(x) + '+' + str(y) + '=' + str(x+y)
> 1+2=3
>
>
> DeR13 wrote:
>>
>> Hi everyone,
>>
>> I am a complete noob at Ipython and have run across a problem.
>> If I type a simple code into the regular python terminal I get this
>> output:
>>
>>>>> x=1
>>>>> y=2
>>>>> print x, "+", y, "=", x+y
>> 1 + 2 = 3
>>
>> However in Ipython the same input yields:
>> In [1]: x=1
>>
>> In [2]: y=2
>>
>> In [3]: print x, "+", y, "=", x+y
>> ------> print(x, "+", y, "=", x+y)
>> (1, '+', 2, '=', 3)
>>
>> Is it possible to configure Ipython to output without the syntax?
>>  1 + 2 = 3 instead of (1, '+', 2, '=', 3)
>>
>> Thanks D

I can't find the original post on this, but I think I can help a little.

This is a consequence of the new 'print as a function' which is
available in Python 2.6, and can be a little surprising.

The behavior that's bothering you is:

In [3]: print x, "+", y, "=", x+y
------> print(x, "+", y, "=", x+y)
(1, '+', 2, '=', 3)

That's because ipython  finds print as a function and automatically
calls it.  You can't directly delete the print function:

In [4]: del print
------------------------------------------------------------
   File "<ipython console>", line 1
     del print
             ^
SyntaxError: invalid syntax

But you can do it with a little workaround:

In [5]: import __builtin__

In [6]: del __builtin__.__dict__['print']

In [7]: print x, "+", y, "=", x+y
1 + 2 = 3

Alternatively, you can turn autocalling off:

In [4]: autocall 0
Automatic calling is: OFF

In [5]: print x, "+", y, "=", x+y
1 + 2 = 3

But then you lose  autocalling for everything.

Which solution  you prefer is up to you.

Cheers,

f
Fernando Perez | 4 Aug 00:20
Picon
Gravatar

Re: IPython tab-completion behaviour in Linux

On Mon, Aug 3, 2009 at 3:07 PM, Kenneth Arnold<kenneth.arnold <at> gmail.com> wrote:
> On Mon, Aug 3, 2009 at 5:57 PM, Fernando Perez<fperez.net <at> gmail.com> wrote:
>> we look for 'foo.bar' in your namespace, but we don't do
>> eval('foo.bar') at all.  Since '{}' is not in your namespace, it isn't
>> found, and the next available completer (for files) tries to fill in.
>
> I occasionally forget something about a built-in type, so I too wish I
> could do [].<TAB>. But it's no big deal; I just type []<ENTER>, then
> _.<TAB>.
>
> Modules are also dynamically loaded if you do 'from module import
> <TAB>', which is helpful but can itself run into problems if you're
> not careful. I think there are optional completers for particular
> things that require evaluation, like dict keys, but I never got around
> to looking that up. You really need to be careful about introspection
> in dynamic environments; there are lots of possible hidden side
> effects. There's a subtle art between introspecting too much and too
> little, and I think the devs have done an overall good job at finding
> that balance.

You describe the problem very well.  I *hope* we've found a reasonable
balance, though it's unfortunately one of those problems where one day
you wish it was more aggressive, and the next that it were less,
depending on precisely what you are doing.  From having been bitten
early on by being too aggressive, I've backed off into a position that
I'd rather have something robust and reliable even if it's a little
less convenient sometimes.

One area that remains a problem (and this isn't ipython, the plain
rlcompleter.py from the stdlib does the same) is that introspecting
foo.bar for completions already triggers getattr on foo to extract
.bar, and that may already be one side effect too many for some.
Unfortunately, short of removing all dynamic introspection from
ipython, I don't think this is solvable, but I'm open to good ideas on
this problem...

>> Early in its life ipython used to eval() user input before completion,
>> and that was the source of many problems, so it has been removed.
>
> Another source of random problems in my experience is autocall. If you
> don't use it, turn it off (or learn how to use it <grin>).

Yup, very true and well timed (see my other post on print() woes) :)

Thanks!

f
Fernando Perez | 4 Aug 00:24
Picon
Gravatar

Re: Unable to delete files accessed by iPython

On Thu, Jul 30, 2009 at 1:03 PM, Brian Granger<ellisonbg.net <at> gmail.com> wrote:
> This works fine for me.  But the details of IO are very OS dependent.  What
> OS are you using?  I am using OS X.  Also, please try this in the standard
> python shell.  My feeling is that this is an OS related thing that is
> independent of IPython.

I suspect the same thing.  I also just tried it on win XP and I was
able to delete the file without any problems (linux is also OK).

Cheers,

f

Gmane