TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

Пронајдени 4 слични објави

Пребарај: #may2023

当前筛选 #may2023清除筛选
The Open Platform

@topco · Post #62 · 06.06.2023 г., 09:02

DeFi: May headlines - Curve Finance Deploys Decentralized Stablecoin on Ethereum - crvUSD is an over-collateralized stablecoin backed by assets like USDC, Ethereum, liquid staking derivatives like Frax’s sfrxETH, and liquidity provision tokens of stablecoin pools (source) - Cardano DeFi Total Value Locked Hits 400M ADA Milestone - in US Dollar terms, DeFi activities on Cardano had grown consistently since the start of the year when the TVL was just around $50 million (source) - Tenet, LayerZero partner to drive cross-chain liquid staking adoption - Tenet’s network allows users to create projects and tokens which will now be integrated with LayerZero technology. The interoperability opens up users to the broader DeFi ecosystem across a variety of smart contract blockchains (source) - DeFi space braces for possible increase in DAI savings rate from 1% to 3.3% - MakerDAO’s proposal to raise the DSR follows a series of rate hikes imposed by the U.S (source) - Uniswap to Launch on Polkadot via Moonbeam Parachain - the decision follows a near-unanimous governance vote first championed by Blockchain at Berkeley, a student educational group linked to UC Berkeley, and brought back to life by Blockchain at Michigan, another educational organization (source) - DeFi Project Bancor Hit With Lawsuit Over Impermanent Loss Protection Promises - investors claim promises fell short, adding that Bancor’s DAO was centralized and its liquidity pools operated as unregistered securities (source) #DeFi#May2023#trends

The Open Platform

@topco · Post #66 · 12.06.2023 г., 09:02

Metaverse: May headlines - Alibaba Cloud Builds Metaverse Launchpad on Avalanche named Cloudverse, the launchpad is designed to provide an end-to-end platform for companies to customize and maintain their metaverse spaces (source) - Top metaverse property investments suffer massive losses - Report: Popular metaverse properties, such as Otherdeeds, The Sandbox, Decentraland, Somnium and Voxels, have all depreciated in value over the past year (source) - Chinese city releases policy draft for metaverse industry development - the policies include a series of cash benefits to attract metaverse-related companies to set up shop in the city (source) - BuzzAR and Cypher Capital team up for Metaverse project - the partnership will allow the companies to leverage proprietary generative AI technologies on its Metaport (source) #metaverse#trends#May2023

The Open Platform

@topco · Post #64 · 08.06.2023 г., 09:01

Crypto Payment Solutions: May headlines - Ethereum: Payment Giant Visa Deploys First Paymaster Smart Contract on ETH Testnet - on March 1, 2023, ERC-4337 was rolled out to the Ethereum mainnet, adding the ability for smart contracts to transact on behalf of the user (source) - Tether and Strike have partnered to make USDT easily available for transactions via Strike's payment platform, the payment app is in expansion mode and has announced the move of its headquarters out of the United States (source) - Stripe Rolls Out New Fiat-to-Crypto Onramp To Make Digital Asset Purchases More Convenient - Web3 companies can now direct their US-based customers to the link without the need for any access code (source) - Transak Raises $20M - the startup offers on- and off-ramps that could make it easier for new users to interact with Web3 project (source) - Argentina Bans Payment Apps From Offering Bitcoin to Customers - the central bank said Thursday that payment platforms cannot offer crypto trading services to their customers (source) #trends#May2023#paymentsolutions

The Open Platform

@topco · Post #63 · 07.06.2023 г., 09:02

Wallets: May headlines - Ledger Crypto Wallet Under Fire Over Seed Phrase Recovery Service - in a nutshell, it’s an ID-based key recovery service that backs up users’ seed phrases. To use the service, users must provide a passport or national identity card to confirm their identity. While this service requires users to opt-in and pay a $9.99 monthly fee, some are concerned that this could even pose a security risk for those who don't opt in (source). - PayPal Ventures Leads $52M Round for Crypto Firm Magic - the startup offers non-custodial wallet infrastructure for an enterprise client list that includes Macy’s and Mattel (source) - Decentralized Wallet Developer Odsy Network Raises $7.5M at $250M Valuation - the funding round was led by Blockchange Ventures and included participation from Rubik Ventures, Node Capital and FalconX among others (source) - Openfort Raises $3 Million for 'Frictionless' Web3 Gaming Wallet - Openfort is building infrastructure for game developers and aims to reduce the number of times gamers have to engage with the blockchain (source) - Crypto Storage Firm Qredo's Revamped Self-Custody Wallet Goes Live - The New Qredo remains aimed at the institutional crypto market, but now it's low-cost and open to anyone, says COO Josh Goodbody (source) #trends#wallet#May2023