Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread dmaziuk via Rdkit-discuss
On 9/23/2020 1:55 PM, Michal Krompiec wrote: Uhm, you’re right. This is not unique to python, python just adds the name-binding twists to the confusion. E.g. C++ methods aren't any different: they exist on code pages regardless of whether their classes have been instantiated or not, and are

Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Michal Krompiec
Uhm, you’re right. On Wed, Sep 23, 2020 at 7:46 PM Rocco Moretti wrote: > Python translates object.method() to method(object). > > > Well, yes and no. "Yes" in the sense that instance methods are internally > implemented equivalently to a free method which takes an instance as the > first

Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Rocco Moretti
> > Python translates object.method() to method(object). Well, yes and no. "Yes" in the sense that instance methods are internally implemented equivalently to a free method which takes an instance as the first parameter. "No" in the sense that from a namespace and user perspective there

Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Michal Krompiec
Hi Rocco & Norwid, Actually, this is expected given the fact that Python translates object.method() to method(object). Hence, m.Compute2DCoords(), although "incorrect" (because Compute2DCoords() is not a method of the Mol class), is valid Python code and is understood as Compute2DCoords(m). And

Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Rocco Moretti
Hi Norwid, There's a subtle but significant difference between the two examples: >>> AllChem.Compute2DCoords(m) versus >>> m.Compute2DCoords() For the former, it's pretty standard Python behavior not to be able to see a function from a module if you haven't loaded the module yet. That's

Re: [Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Norwid Behrnd via Rdkit-discuss
Hi Thomas, could your report be already backed by the section titled «Working with 2D molecules: Generating Depictions» of the upper half of page https://www.rdkit.org/docs/GettingStartedInPython.htm about the 2020.03.1 documentation with the following example? 8>< begin snippet ---

[Rdkit-discuss] TIL: Mol objects having varying attributes depending on rdkit imports

2020-09-23 Thread Thomas Strunz
Dear readers, just wasted an amazing amount of time and reporting this in case someone else happens to run into this problem. if you simply do: from rdkit import Chem m = Chem.MolFromSmiles('c1c1') m.Compute2DCoords() you will get an error Mol object has no attribute Compute2DCoords.