bugpyFormex - Bugs: bug #43007, Can the default of class...

 
 

bug #43007: Can the default of class mydict.Dict be set to returnNone?

Submitted by:  francesco <francio>
Submitted on:  Sun 17 Aug 2014 09:46:43 PM UTC  
 
Category: CoreSeverity: 3 - Normal
Item Group: Feature requestStatus: None
Privacy: PublicAssigned to: Benedict Verhegghe <bverheg>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 21 Aug 2014 10:28:29 AM UTC, comment #4:

After the last discussion and clarifications from benedict. I suppose there is no need to introduce this change.
and I cannot see any place where it is needed. closing the bug

francesco <francio>
Project Member
Wed 20 Aug 2014 10:41:07 AM UTC, comment #3:

I think the possibility to switch CDictto cascade only thru
CDict directories is a good idea.

I will use the 'if k in ' option to check data in fe_abq
so do you think it is a good idea to store all additional keyword parameters in abaqus with key 'options'?

francesco <francio>
Project Member
Wed 20 Aug 2014 10:22:55 AM UTC, comment #2:

The PropertyDB class was not intended to be Abaqus specific. It uses CDict to allow different ways of specifying properties. E.g.

In all three cases you can just use `if propn.young_modulus:` to get the required value.

If you want to control the dict level where the property resides, you should indeed use `if 'key' in propn:`

Note that CDict was originally designed to cascade only thru
CDict directories. I do not remember why/when it was changed, but we could investigate the possibility to reintroduce the limitation of only cascading into CDicts, possibly as an option.

Change the default of Dict to returnNone is not a good idea, because that could break a lot of other code.

Benedict Verhegghe <bverheg>
Project AdministratorIn charge of this item.
Tue 19 Aug 2014 10:32:17 AM UTC, comment #1:

I am also wondering why properytDB returns the props as CDict.
this is sometimes a bit annoying when looking in the propertyDB because prevents using same keys in Dict or dict which are stored at a deeper level 'prop' . for example i want to create a property which has a key 'options' (a default name for a dictionary via fmtOptions to avoid check for all abaqus keyword options in fe_abq )

Should not be better to set it as a Dict with returnNone instead of CDict?

francesco <francio>
Project Member
Sun 17 Aug 2014 09:46:43 PM UTC, original submission:

Referring to the plugin fe_abq there are a lot of keys that should be checked. Now the problem is taht most of the key are checked in this way

if propdict.key:

if the key is not present this will not raise error only if you define a CDict or you set default to returnNone in Dict.
Though CDict will check if the key is present in any Dict which sometimes is not what is needed.the other option is to check if the key is present using

if 'key' in propdict:

can we change the default and keep

if propdict.key:

or when needed I have to use

if 'key' in propdict:

francesco <francio>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bverheg (Posted a comment)
  • -unavailable- added by francio (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 21 Aug 2014 10:28:29 AM UTCfrancioOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1