-2

Is it possible to assign < to a variable, let's say b ?

For example:

b = < .

Edit:

My plan is the following:

a < b < c < d .

I want add the "compares" to a permutation. I know that I can add a b c d to a permutation but I have to change the < too. Please believe me that this is important for my plan. I have to find all possibilities.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Dan Ru
  • 7
  • 5
  • No. And I would strongly reconsider trying something like this. – Varun Nayak Jun 04 '20 at 06:09
  • 2
    No, not directly. If you were to tell us what you actually want to achieve instead of saying how you plan to solve a tiny little detail of it, we might actually be able to help you to find an elegant solution to your problem. – Roland Illig Jun 04 '20 at 06:10
  • @ Varun Nayak Why? – Dan Ru Jun 04 '20 at 06:11
  • Does this answer your question? [assign operator to variable in python?](https://stackoverflow.com/questions/2983139/assign-operator-to-variable-in-python) – deadshot Jun 04 '20 at 06:11
  • Duplicate of [less-than-or-greater-than-comparison-as-a-variable-in-python](https://stackoverflow.com/questions/23349136/less-than-or-greater-than-comparison-as-a-variable-in-python)? – mime Jun 04 '20 at 06:16

1 Answers1

4

You can do it like so

b = '<'
c = '+'

When you want to use it, you have to use the eval function.

eval('5' + b + '10') # '5<10'
>>> True
eval('5' + c + '10') # '5+10'
>>> 15
Eeshaan
  • 1,557
  • 1
  • 10
  • 22