Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Problem with if statements checking True
-
@Webmaster4o Already had tried this in the initial debugging, but I also think there is an issue the way the variable is created- So I'm going to set up
config.py
and import that. I think it'll make things easier in the long run anyway. -
Watch out for the line
twitter_mode = str(settings['twitter'])
becausebool(False) != bool('False')
. -
Try removing the local copies of
config.twitter_mode
andconfig.feed
and always use the attributes ofconfig
instead. That way you won't have any issues with the local copy being different from theconfig
attribute. -
@ccc Already took care of it ;) accidentally did this somehow..
@dgelessus Could you explain more in depth? Not sure what you mean.
-
Near the beginning of your gist, you have these two lines:
news_url = config.feed twitter_mode = config.twitter_mode
What you're doing here is you're assigning the current values of
config.feed
andconfig.twitter_mode
to the local (well, actually global, from the perspective of the current module) variablesnews_url
andtwitter_mode
. Although the variables' values are the same, the variables themselves are not linked in any way. If you changeconfig.twitter_mode
, the global variabletwitter_mode
doesn't change, and vice versa.Further on in your
settings_action
method, you declarenews_url
andtwitter_mode
as global, but never assign to them - instead you assign toconfig.feed
andconfig.twitter_mode
. Now the variables fromconfig
and the current module are no longer in sync. To avoid this issue, simply remove the globalsnews_url
andtwitter_mode
, and always useconfig.feed
andconfig.twitter_mode
. -
@dgelessus Gotcha. Thanks for explaining that for me. It's been a long day...
-
Would changing the variables be like writing to a file but writing over the current .py file?
-
Not sure what you mean exactly. If you assign something to an attribute of the
config
module, you don't modify the actual source file. The changes are as temporary as any other variable. The important part is that you store your data in a single place (theconfig
module) and not under multiple separate names. -
@dgelessus Let me rephrase, How would I edit the variables in config.py? Would I edit it like any other text file?
-
Yes, edit it like any other file.