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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:49:27+00:00 2026-06-06T10:49:27+00:00

I have an issue with an object I created and then use in a

  • 0

I have an issue with an object I created and then use in a function.

class environnement:
    def __init__(self, n, dic={}, listr=[], listf=[]):
        self.taille=n
        self.reg=dict(dic)
        self.raccess=listr
        self.faccess=listf

First I create an environment in my function compilProgram and then I use compilInstruction with this environnement:

def compilProgram(fichierSortie, nbrRegDispo, AST):
    DICOFUN={}
    for elt in AST.children:
        if elt.type=='fonctionDef':
            DICOFUN[elt.leaf]=elt.children
            continue
        else :
            pass
    env=environnement(nbrRegDispo)
    print(type(env))
    compteurLabel=0
    for elt in AST.children:
        if elt.type!='fonctionDef':
            (env, compteurLabel)=compilInstruction(env, fichierSortie, elt, compteurLabel)

The print on compilProgram is to check what is env before I give it to compilInstruction (because I have an issue).

def compilInstruction(env, fichierSortie, instruction,compteurLabel):
    print(type(env))
    envInterne=environnement(env.taille, env.reg, env.raccess, env.faccess)
    ...

I’ve try many other way to copy env, but the problem seems to not come from it.
Here is what I get when I try compilProgram on propers arguments :

<class 'Environnement.environnement'> (this is the print from compilProgram)
<class 'Environnement.environnement'> (this is the print from compilInstruction)
<class 'NoneType'> (this again comes from the print in compilInstruction)
...
AttributeError: 'NoneType' object has no attribute 'taille'

Why does the print in compilInstruction run twice, and why does env disappear between the two runs?

  • 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-06-06T10:49:29+00:00Added an answer on June 6, 2026 at 10:49 am

    You are calling compilInstruction more than once:

    for elt in AST.children:
        if elt.type!='fonctionDef':
            (env, compteurLabel)=compilInstruction(env, fichierSortie, elt, compteurLabel)
    

    You have more than one elt in AST.children that is not ‘fonctionDef’ (a typo??), so you are invoking compilInstruction more than once. That’s why you get more than one print from it. The return value of compilInstruction is being assigned to env and compteurLabel, so env is overwritten with None.

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

Sidebar

Related Questions

I have the following issue: A java object contains two arrays of core datastore
I'm just starting with Object Oriented PHP and I have the following issue: I
I'm having an issue where I have a player object that I'm trying to
I'm having an issue with an if statement I have an object called enemy2
I am trying to return a newly created java class object in native to
I have an issue in my use of critical sections. My app has a
I have a function that I use to validate the contents of some text
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We are new to ROR, We have issue in creating Login/Logout process in ROR

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.