This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: I found a bug while checking string with find()
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: DongwonTTuna, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-11-10 07:11 by DongwonTTuna, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
스크린샷 2020-11-10 16.02.46.png DongwonTTuna, 2020-11-10 07:11
스크린샷 2020-11-10 16.14.28.png DongwonTTuna, 2020-11-10 07:15
Messages (3)
msg380636 - (view) Author: DongwonTTuna (DongwonTTuna) Date: 2020-11-10 07:11
USED THE PYTHON-BINANCE MODULE FOR THIS
------------------------------------------------
from binance.client import Client
from binance.exceptions import *

client = Client(api_key='Your_Public_Apikey',
                api_secret='Your_Secret_Apikey')

def buy_limit_test(coin, amount):
    client.create_test_order(
        symbol=coin + 'USDT',
        side=Client.SIDE_BUY,
        type=Client.ORDER_TYPE_MARKET,
        quantity=amount)

try:
    buy_limit_test(coin='HOT', amount=-19298.0)
except BinanceAPIException as E:
    print(E.message.find("'quaaantity'; legal range is"))
    if E.message.find("'quantity'; legal range is"):
        print(E.message)
    else:
        print("yes")
------------------------------------------------




And the parameters.

------------------------------------------------

E.message.find("'quantity'; legal range is") = 38

E.message = "Illegal characters found in parameter 'quantity'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'."

------------------------------------------------

If I run with this

if E.message.find("'quaaaaaaaaaaaaaaaaaaaaaaaaanatity'; legal range is"):

It should be run with print("yes"), but It shows print(E.message).

But If I run with
if E.message.find("'quaaaaaaaaaaaaaaaaaaaaaaaaanatity'; legal range is") == True:

It's now run with print("yes") not the print(E.message).

I think it's a bug
msg380637 - (view) Author: DongwonTTuna (DongwonTTuna) Date: 2020-11-10 07:15
That was a mistake.

upload another picture file.
msg380643 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-11-10 09:45
str.find() does not work like you think. Please read the documentation.

In your case you likely need to use the "in" operator.
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86469
2020-11-10 09:45:12serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg380643

resolution: wont fix -> not a bug
stage: resolved
2020-11-10 07:15:19DongwonTTunasetfiles: + 스크린샷 2020-11-10 16.14.28.png
resolution: wont fix
messages: + msg380637
2020-11-10 07:11:01DongwonTTunacreate