question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python 3 Incompatibility (?)

See original GitHub issue

On lines 691-692 of __init__.py in the minConflicts.getSolution(...) method, you have the following:

lst = domains.keys()
random.shuffle(lst)

The call to random.shuffle() fails on python 3, because in python3 the dictionary .keys() method returns a set, which can't be indexed. So lst must be converted from this set into a list:

lst = list(domains.keys())
random.shuffle(lst)

Not sure how you would write the code to be compatible in both Python2 and Python3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
decezecommented, Oct 17, 2017

Same issue in Constraint.preProcess, trying to access variables[0], coming from domain.keys() in Problem._getArgs.

0reactions
coditocommented, Jun 4, 2018

Created a PR for Constraint.preProcess issue: https://github.com/python-constraint/python-constraint/pull/37. Please review.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Porting Python 2 Code to Python 3 — Python 3.11.1 ...
Modernize, on the other hand, is more conservative and targets a Python 2/3 subset of Python, directly relying on six to help provide...
Read more >
Cheat Sheet: Writing Python 2-3 compatible code
Easy, clean, reliable Python 2/3 compatibility · File IO with open() · reduce() · raw_input() · input() · file() · exec · execfile()...
Read more >
Python Language Tutorial => Incompatibilities moving from ...
Python 3 intentionally broke backwards-compatibility, to address concerns the language developers had with the core of the language. Python 3 receives new ...
Read more >
Supporting Python 2 and 3 without 2to3 conversion
Python 2.7 has some small improvements on Python 3 compatibility, but it's likely that if you want to run the same code under...
Read more >
1 - Stack Overflow
Code incompatibility issues - Python 2.x/ Python 3.x ; from · import ABCMeta, abstractmethod class ; Instruction · object): __metaclass__ = ABCMeta ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found