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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:06:58+00:00 2026-05-17T23:06:58+00:00

I am trying to find all occurrences of a literal float value in Python

  • 0

I am trying to find all occurrences of a literal float value in Python code. Can I do that in Komodo (or in any other way)?

In other words, I want to find every line where something like 0.0 or 1.5 or 1e5 is used, assuming it is interpreted by Python as a float literal (so no comments, for example).

I’m using Komodo 6.0 with Python 3.1.

If possible, a way to find string and integer literals would be nice to have as well.

  • 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-05-17T23:06:59+00:00Added an answer on May 17, 2026 at 11:06 pm

    Our SD Source Code Search Engine (SCSE) can easily do this.

    SCSE is a tool for searching large source code bases, much faster than grep, by indexing the elements of the source code languages of interest. Queries can then be posed, which use the index to enable fast location of search hits. Queries and hits are displayed in a GUI, and a click on a hit will show the block of source code containing the hit.

    The SCSE knows the lexical structure of each language it has indexed with the precision as that langauge’s compiler. (It uses front ends from family of accurate programming language processors; this family is pretty large and happens to include the OP’s target langauge of Python/Perl/Java/…). Thus it knows exactly where identifiers, comments, and literals (integral, float, character or string) are, and exactly their content.

    SCSE queries are composed of commands representing sequences of language elements of interest. The query

    'for' ... I '=' N=103
    

    finds a for keyword near (“…”) an arbitrary identifier(I) which is initialized (“=”) with the numeric value (“N”) of 103. Because SCSE understands the language structure, it ignores language-whitespace between the tokens, e.g., it can find this regardless off intervening blanks, whitespace, newlines or comments.

    The query tokens I, N, F, S, C represent I(dentifier), Natural (number), F(loat), S(tring) and C(omment) respectively. The OP’s original question, of finding all the floats, is thus the nearly trivial query

    F
    

    Similarly for finding all String literals (“S”) and integral literals (“N”). If you wanted to find just copies of values near Pi, you’d add low and upper bound constraints:

    F>3.14<3.16
    

    (It is pretty funny to run this on large Fortran codes; you see all kinds of bad approximations of Pi).

    SCSE won’t find a Float in a comment or a string, because it intimately knows the difference. Writing a grep-style expression to handle all the strange combinations to eliminate whitespace or surrounding quotes and commente delimiters should be obviously a lot more painful. Grep ain’t the way to do this.

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

Sidebar

Related Questions

I'm trying to find about ALL the possible options that I can set in
I'm trying to find all occurrences of items in HTML page that are in
I'm trying to use Notepadd++ to find all occurrences of width=xxx so I can
I'm trying to use XPath to find all elements that have an element in
Because regular expressions scare me, I'm trying to find a way to remove all
I'm trying to write an algorithm that will find the set of all vertices
I'm trying to find all the occurrences of Arrows in text, so in <----=====><==->>
I'm trying to find the positions of all occurrences of a string in another
I am trying to make a regex that matches all occurrences of words that
Hi i'm trying to find all occurences of '<?' in my php code. I

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.