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

  • Home
  • SEARCH
  • 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 7091497
In Process

The Archive Base Latest Questions

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

I have a project using python and i want to convert the php to

  • 0

I have a project using python and i want to convert the php to python. I have confused in the array of php in converting it to python…

in the old code of the php… it looks like this,

array(
      "Code"          => 122,
      "Reference"     => 1311,
      "Type"          => 'NT',
      "Amount"        => 100.00
);

and this is what i did in converting it to python …

dict = {
          "Code":122,
          "Reference":1311,
          "Type":'NT',
          "Amount":100.00
}

is my converting php to python is correct?

  • 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-28T08:11:35+00:00Added an answer on May 28, 2026 at 8:11 am

    Your conversion is essentially correct (though I wouldn’t use dict as a variable name since that masks a built-in class constructor of the same name). That being said, PHP arrays are ordered mappings, so you should use a Python OrderedDict instead of a regular dict so that the order of insertion gets preserved:

    >>> import collections
    >>> od = collections.OrderedDict([
            ('Code', 122),
            ('Reference', 1311),
            ('Type', 'NT'),
            ('Amount', 100.00),
    ])
    
    >>> print od['Amount']
    100.0
    
    >>> od.keys()
    ['Code', 'Reference', 'Type', 'Amount']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a python project that we want to start testing using buildbot. Its
I'm using SQLalchemy for a Python project, and I want to have a tidy
We have an old project written using Managed C++ syntax. I would like to
I have a small project I am doing in Python using web.py. It's a
I'm using the SQLAlchemy Python ORM in a Pylons project. I have a class
I am working on a google app engine project using python. I want to
Edit: Just for clarification I am using python, and would like to do this
I want to implement my project using interface oriented programming. Since Python itself does
I have a small project I want to try porting to Python 3 -
I want to link my Python project to a wsgi file. I am using

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.