Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
5 votes
2 answers
158 views

Python object creation behavior

Coming from Java, I have trouble understanding how objects are allocated in Python. Consider this Python script: x = ("a", "b") y = ("a", "b") print(x is y) # ...
Mohammad Javad's user avatar
0 votes
1 answer
24 views

Why could I be experiencing an unresolved reference error in Python? [closed]

Unresolved reference error with the code below; I've included all the references in the same file, however, I'm still getting an error class sample: @staticmethod def some_method(): print(&...
Th333w1's user avatar
  • 39
0 votes
0 answers
18 views

Dereferencing with mongoengine

I have an AuctionDocument which reference an ItemDocument. I want to be able to query all auctions for a selleruuid, and iterate over the results (and have access to Auction.item.auctioned for ...
lordslair's user avatar
-1 votes
1 answer
27 views

Why am I getting a "local variable 'connector' might be referenced before assignment" message?

Heres my code: class AccountsDatabase: def __init__(self): try: connector = sqlite3.connect('AccountsDB.db') except sqlite3.Error as e: self.return_error(e) ...
Phantom's user avatar
  • 37
0 votes
0 answers
18 views

Python patched function mock called_with compares with modified data -- best way to fix?

I have a function (validate.py): def _validate_data(data: dict[string,Any]): pass It's not implemented yet so its a stub. I want to verify that another function calls this one with an empty dict ...
Edward Strange's user avatar
0 votes
1 answer
27 views

i need to restructure code for the addition of more equations with many similar use variables and keep the code succinct

I need to add 20 or so countries with part variable names like UK, US with multiple equations for each, each of which is structurally identical. Some typical lines of code are shown ('model.add' etc ...
ocopa's user avatar
  • 77
0 votes
2 answers
76 views

Working with SQLAlchemy and python. How can I get past Lazy Loading / Argument Errors

I've been trying to acquire a list of id's for all the accounts that a certain user follows. My database is defined below. UserFollowers = Table( "UserFollowers", Base.metadata, ...
RHO's user avatar
  • 49
3 votes
1 answer
157 views

How to bind functions returning references with pybind11?

When binding C++ with pybind11, I ran into an issue regarding a couple of class members that return (const or non-const) references; considering the following snippet: struct Data { double value1; ...
joaocandre's user avatar
  • 1,745
0 votes
0 answers
28 views

Excel coding enter value chronologically

I'm trying to automate a spreadsheet to enter a value referencing another workbook but populate the next consecutive cell with the value from the same reference the following day but I don't want the ...
Philip Salter's user avatar
0 votes
1 answer
33 views

Relative Import In Unittest

I have reviewed several posts re: Relative vs Absolute imports, but none of the solutions proposed seemed to solve my problem. I have a directory structure like the following: --src --dir1 ...
StormsEdge's user avatar
0 votes
1 answer
41 views

References working differently than expected

I wrote some code to help me see references in action when using the * to "multiply" lists. The program follows: empty_row = [None] * len(A[0]) empty_matrix = [ empty_row ] * len(A) for i ...
user778806's user avatar
0 votes
1 answer
34 views

Referencing Environment with Global Python Variables

In the following program, there is a global variable, a, that I want to check the number of references to at each of the points 1, 2, 3, and 4. import sys a = 'my-string' print(sys.getrefcount(a)) b ...
yigitkucuk's user avatar
2 votes
1 answer
43 views

Python Read from csv1 and reference csv2 to write to csv3

I have two csv files, csv1 is the working file that changes, csv2 is static and used as a reference set. csv1 - input.csv Name Type Owner Status Date Group bananas fruit Joe In Stock 1/1/23 apples ...
Happy.Hartman's user avatar
3 votes
1 answer
112 views

Unresolved reference 'turtle'

I was trying to import Turtle and Screen from turtle using the below code: from turtle import Turtle, Screen nora = turtle.Turtle() screen = turtle.Screen() but the editor(pycharm) shows--> &...
user101's user avatar
  • 55
0 votes
1 answer
59 views

SWIG C++ to Python: Initialize class by struct reference not working

I have a C++ library that contains a class that is constructed using a reference to a struct: myclass.hpp: className::className (params& pars): memberInitList { //some code that modifies state of ...
shanedrum's user avatar
  • 129

15 30 50 per page
1
2 3 4 5
53