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 4610838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:11:15+00:00 2026-05-22T01:11:15+00:00

I am starting migration process from python to jython. Has anyone done this with

  • 0

I am starting migration process from python to jython. Has anyone done this with ease before?
What are the gotchas? Should I build first inside Jython IDE then deploy or what?

  • 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-22T01:11:15+00:00Added an answer on May 22, 2026 at 1:11 am

    Keep in mind that in jython, while running under Java everything thing is ‘Big-Endian’ no matter what platform you’re on, whereas on a PC/Linux/Mac(x86) platform python is Little Endian. Make sure that when you’re using struct.pack and struct.unpack you use the appropriate prefix

    without prefix

    write data (enessw.py)

    import struct 
    f = file('tmp.dat', 'wb') # binary 
    f.write(struct.pack('IIII', 1,2,3,4)) # default endianess
    

    read data (enessr.py)

    import struct
    f = file('tmp.dat', 'rb')
    data = f.read()
    ints = struct.unpack('IIII', data) # default endianess
    print repr(ints)
    

    Results

    Write with python, read with jython

    C:\Documents and Settings\mat99856\My Documents\tmp>python enessw.py
    
    C:\Documents and Settings\mat99856\My Documents\tmp>python enessr.py
    (1, 2, 3, 4)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessr.py
    (16777216L, 33554432L, 50331648L, 67108864L)
    

    Write with jython read with python

    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessw.py
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessr.py
    (1L, 2L, 3L, 4L)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>python enessr.py
    (16777216, 33554432, 50331648, 67108864)
    

    The Fix

    Use the < in the format string for pack and unpack. This will instruct pack/unpack that the data is to be specifically little endian in format.

    With ‘<IIII’ as pack/unpack format

    C:\Documents and Settings\mat99856\My Documents\tmp>python enessw.py
    
    C:\Documents and Settings\mat99856\My Documents\tmp>python enessr.py
    (1, 2, 3, 4)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessr.py
    (1L, 2L, 3L, 4L)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessw.py
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessr.py
    (1L, 2L, 3L, 4L)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>python enessw.py
    
    C:\Documents and Settings\mat99856\My Documents\tmp>python enessr.py
    (1, 2, 3, 4)
    
    C:\Documents and Settings\mat99856\My Documents\tmp>jython enessr.py
    (1L, 2L, 3L, 4L)
    

    References

    struct.pack

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

Sidebar

Related Questions

No related questions found

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.