Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tut] How to Create Your Own Search Engine in a Single Line of Python?

#1
How to Create Your Own Search Engine in a Single Line of Python?

<div><p>This Python One-Liner is part of my<a href="https://www.amazon.com/gp/product/B07ZY7XMX8" target="_blank" rel="noreferrer noopener"> Python One-Liners book </a>with NoStarch Press.</p>
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<div class="ast-oembed-container"><iframe title="Python One-Liners - Trick 4 - How to Create Your Own Little Search Engine in One Line?" width="1400" height="788" src="https://www.youtube.com/embed/5egoqwCACkY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
</div>
</figure>
<p>Here’s the code from the video:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">letters_amazon = '''
We spent several years building our own database engine,
Amazon Aurora, a fully-managed MySQL and PostgreSQL-compatible
service with the same or better durability and availability as
the commercial engines, but at one-tenth of the cost. We were
not surprised when this worked. ''' find = lambda x, q: x[x.find(q)-18:x.find(q)+18] if q in x else -1 print(find(letters_amazon, 'SQL'))
</pre>
<p>Try It Yourself:</p>
<p> <iframe height="600px" width="100%" src="https://repl.it/@finxter/PythonOneLinerSearchEngine?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> </p>
<p>Related Articles:</p>
<ul>
<li><a href="https://blog.finxter.com/introduction-to-slicing-in-python/" target="_blank" rel="noreferrer noopener">Python Slicing</a></li>
<li><a href="https://blog.finxter.com/if-then-else-in-one-line-python/" target="_blank" rel="noreferrer noopener">Ternary Operator in Python</a></li>
<li><a href="https://blog.finxter.com/a-simple-introduction-of-the-lambda-function-in-python/">Lambda Function</a></li>
<li><a href="https://blog.finxter.com/python-re-findall/" target="_blank" rel="noreferrer noopener">Find Function</a></li>
</ul>
</div>


https://www.sickgaming.net/blog/2020/04/...of-python/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016