Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:11:34+00:00 2026-05-24T02:11:34+00:00

am trying to build a logic which am not quit sure how to do

  • 0

am trying to build a logic which am not quit sure how to do with python. I have the following dictionary

{datetime.datetime(2011, 7, 18, 13, 59, 25): (u'hello-world', u'hello world'), datetime.datetime(2011, 7, 17, 15, 45, 54): (u'mazban-archeticture', u'mazban arch'), datetime.datetime(2011, 7, 7, 15, 51, 49): (u'blog-post-1', u'blog post 1'), datetime.datetime(2011, 7, 8, 15, 54, 5): (u'blog-post-2', u'blog post 2'), datetime.datetime(2011, 7, 18, 15, 55, 32): (u'blog-post-3', u'blog post 3')}

I want to iterate through the dictionary, find out if the date is equal today’s date and then use the inner dictionary to build a url using the first value as a slug. Am able to iterate but I don’t know how to fetch the inner value

# will only print dates
for i in dic:
 print i
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:11:35+00:00Added an answer on May 24, 2026 at 2:11 am

    In python when you use ‘for x in dic’ it is the same as to use ‘for x in dic.keys()’ – you are iterating trough only keys not (key,value) pairs.
    To do what you want you can take a look at the items() and iteritems() dictionary methods, they allows you to get access to (key,value) pairs:

    for key,value in dic.iteritems():
        if key == datetime.today(): # or (datetime.today() - key).seconds == <any value you expect>
            # since value is a tuple(not a dict) and you want to get the first item you can use index 0
            slug = value[0]
    

    Read more about dictionaries and supported methods

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build an application which does the following : 1) write
Im trying to build a 'last user login' script but im not sure how
We are trying to build a jmeter testcase which does the following: login to
I'm trying to build a control logic that depends on the current gsp page
I'm trying build a method which returns the shortest path from one node to
I'm trying to build a grammar with the following: NUMERIC: INTEGER | FLOAT |
I am trying to build a django service to which numerous clients will send
I have been following the post below trying to hook my SubVersion installation to
I'm trying to build a modified role system that has the following class/relationship structure:
I've been trying to build a little bot which will be using Reddit's API.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.