1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2016
    Rep Power

    python: two differenet entities (a library and a command) with the same name

    I am trying to use a library and a command with the same name (from another library) in the same code but get an error.
    My code has:

    import copy #(from which I use deepcopy)
    from xlutils.copy import copy
    The error I get is: AttributeError: 'function' object has no attribute 'deepcopy'

    I guess this is because they have same name.
    I`ve also tried:

    from copy import deepcopy

    but got the same error. Any idea how to address this issue? Thanks
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    closing code tag needs slash [/code]

    from xlutils.copy import copy
    replaces the object to which `copy' refers. Many approaches will work.

    from copy import deepcopy
    and replace in your code where you have copy.deepcopy simply use deepcopy

    You could

    import copy
    import xlutils
    xlutils.copy.copy(args) # refering to xlutils copy

    import copy
    twisp = copy.deepcopy # subsequently referring to twisp instead of copy.deepcopy
    from xlutils.copy import copy
    oval_lake = copy # later use oval_lake in place of copy

    Comments on this post

    • Will-O-The-Wisp agrees : Fixed their tags!
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo