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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #397 · 12 ное.

Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs

Резултати

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

Пребарај: #rugpull

当前筛选 #rugpull清除筛选
Mirracoin Новости

@MirraChannel · Post #118 · 03.05.2024 г., 07:06

#nft#RugPull#архив Frosties. История обмана… В 2022 году случилась первая самая громкая афера Rug pulls NFT — это проект Frosties, на котором инвесторы потеряли 1,3 миллиона долларов😮. Идея была основана на продаже коллекции мультяшных персонажей, похожих на шарики мороженого 🍨. Создатели проекта заманивали инвесторов бесплатными раздачами, обещали ранний доступ и привилегии в игре. Вокруг Frosties разгорелся огромный ажиотаж, поскольку игра в метавселенной и механизм ставок были обещаны как часть будущей дорожной карты. 🔴Распознать аферу было сложно. У проекта был профессиональный сайт, сообщество насчитывало 40 тыс. активных пользователей. Каждая NFT Frosties стоила в среднем 0,04 ETH и когда были проданы 8 888 «мороженных» NFT, вкладчики обнаружили, что все соцсети, каналы в Discord, сайт и команда — исчезли 😐. Инвесторы так и не вернули деньги 😔. @MirraChannel😎

Venture Village Wall 🦄

@venturevillagewall · Post #4139 · 13.02.2025 г., 10:00

Hackers Target Crypto Figure for Scam Hackers compromised World Liberty co-founder Zach Vitkoff's X account to promote a fake Trump meme token. Victims were lured by claims of imminent announcements from President Trump. Despite warnings from Vitkoff, the established token BARRON (market cap over $10B) continues to rise, indicating a scam. Another similar project executed a rug pull, draining liquidity. More details here: ForkLog #Hacking#Crypto#Trump#MemeToken#Scam#BARRON#Liquidity#RugPull#WorldLiberty

Venture Village Wall 🦄

@venturevillagewall · Post #4036 · 31.01.2025 г., 07:00

Errol Musk's Token Plans to Raise Millions Errol Musk aims to raise $150-$200 million through the "Musk It" memecoin, leveraging his family name. Proceeds will support the newly established Musk Institute. Recently, the crypto space has faced various rug pulls linked to projects of the same name. 🪙💰Read more here #Musk#Memecoin#Crypto#ETFs#USDC#Ethereum#DeFi#Blockchain#Investment#Finance#ElonMusk#Bitcoin#WhaleAlert#RugPull#MuskInstitute#CryptoMarket#DigitalAssets#TokenSale#Cryptocurrency#MarketTrends#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4168 · 16.02.2025 г., 19:00

Argentina's Opposition Eyes Impeachment Over LIBRA Argentina's opposition is considering impeachment for President Milei after conflicting support for the LIBRA token. This follows a controversial launch that saw rapid investment and then a significant drop in value, leading to accusations of mismanagement and deception. The situation raises questions about political influence in cryptocurrency projects. Read more: Reuters #Argentina#LIBRA#Crypto#Impeachment#Milei#Investment#MarketManipulation#EconomicCrisis#Blockchain#DeFi#RugPull#Politics#Cryptocurrency#TokenLaunch#InsiderTrading#Securities#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4164 · 16.02.2025 г., 04:00

Argentina Investigates LIBRA Token Misconduct Argentina's President Javier Milei calls for an investigation into LIBRA token's rug pull, requesting the Anti-Corruption Office's involvement to assess potential misconduct by government members. Findings will be forwarded to the court. Opposition considers impeachment due to the incident. Links: Statement, Watch, Details. #LIBRA#Crypto#Argentina#investigation#rugpull#president#JavierMilei#impeachment#KIPProtocol#AntiCorruption#fundflow#temporalanalysis#MELANIA#ENRON#Solana#ETF#Bitcoin#adoption#blockchain#corruption#misconduct