یکی از معروفترین تلههای Python:
def add_user(name, users=[]):
users.append(name)
return users
print(add_user("Ali"))
print(add_user("Sara"))
خیلیها انتظار دارن:
["Ali"]
["Sara"]
ولی خروجی:
["Ali"]
["Ali", "Sara"]
چون مقدار پیشفرض تابع
([]) فقط یک بار هنگام تعریف تابع ساخته میشه، نه هر بار که تابع اجرا میشه.راه درست:
def add_user(name, users=None):
if users is None:
users = []
users.append(name)
return users
این کد رو ببین:
import copy
data = [[1, 2], [3, 4]]
new_data = copy.copy(data)
new_data[0].append(5)
print(data)
ممکنه فکر کنی فقط
new_data تغییر کرده...ولی خروجی:
[[1, 2, 5], [3, 4]]
چرا؟ چون
copy.copy()
فقط لایه اول رو کپی میکنه.
برای آبجکتهای تو در تو باید از:
copy.deepcopy(data)
استفاده کنی.
یکی از باگهای عجیب Python:
functions = []
for i in range(3):
functions.append(lambda: i)
for func in functions:
print(func())
خروجی:
2
2
2
نه:
0
1
2
چون Lambda مقدار i رو همون لحظه ذخیره نمیکنه؛ زمان اجرا مقدار نهایی متغیر رو میخونه.
راهحل:
functions.append(lambda i=i: i)
فرق برنامهنویس حرفهای فقط این نیست که کد بیشتری بنویسه؛
اینه که بدونه کجاها ممکنه کدش رفتار غیرمنتظره داشته باشه.
Please open Telegram to view this post
VIEW IN TELEGRAM
❤10👍2
github.com/pazguille/offline-first
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5👍3
مخصوصاً اگه با سرور، VPS، Docker و دیپلوی کردن پروژهها سروکار داشته باشی.
این ابزار خودش رو بهعنوان جایگزینی برای سرویسهایی مثل Vercel، Heroku، Netlify و Railway معرفی میکنه. یعنی بهجای اینکه پروژهت رو به این سرویسها بسپری، میتونی یه VPS برای خودت داشته باشی، Coolify رو روش نصب کنی و بعد همهچیز رو از طریق یه پنل گرافیکی مدیریت کنی.
نکته جالب اینه که Coolify از اتصال به سرویسهایی مثل GitHub و GitLab، دیپلوی خودکار، گواهی رایگان SSL و بکاپگیری هم پشتیبانی میکنه.
https://coolify.io/self-hosted
https://youtube.com/watch?v=6IZF_VOlOJM
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6
This media is not supported in your browser
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❤5🔥3👍1
از فرم و داشبورد گرفته تا جدول، تقویم و کانبان؛ نمونه رو میبینید و کد هر کامپوننتی که خواستید رو مستقیم داخل پروژهتون کپی میکنید.
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6👍1🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
همچین داکباری خواستید درست کنید (شبیه داکبار آپدیت جدید تلگرام) از این استفاده کنید :
🌐 http://jelly-docs.felipe.software
💻 TΔRS | تارس
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6👍1🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
یه توسعهدهنده به اسم slvDev تونسته یک مدل زبانی با ۲۸.۹ میلیون پارامتر رو روی چیپ ESP32-S3 اجرا کنه.
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7👍1🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
این ابزار کامپوننتهای مدرنی شبیه React داره، اما رابط کاربری، State و رفتار برنامه رو با خود Python مینویسید؛ نه HTML، نه CSS و نه JavaScript.
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7 3🔥1
جذابترین بخشش اینه که میتونه رنگها و فونتهای سایتتون رو استخراج کنه و ظاهر دیاگرامها رو دقیقاً با هویت بصری برندتون هماهنگ کنه؛ طوری که انگار یه طراح حرفهای ساختهشون.
https://cathrynlavery.github.io/diagram-design
https://github.com/cathrynlavery/diagram-design
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7👍1🔥1
Media is too big
VIEW IN TELEGRAM
https://anatomyatelier.vercel.app
https://github.com/thebuggeddev/anatomy
Please open Telegram to view this post
VIEW IN TELEGRAM
❤10👍2🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
https://upscayl.org/download
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7👍1👨💻1
pip install cactus-needlehttps://github.com/cactus-compute/needle
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5❤2 2
pip install opendataloader-pdfPlease open Telegram to view this post
VIEW IN TELEGRAM
👍14❤2
This media is not supported in your browser
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
👍12❤3🔥1
Please open Telegram to view this post
VIEW IN TELEGRAM
❤22👍8👨💻4
https://opengym.duarte-santos.ch
https://github.com/DuarteSantos8/openGym
Please open Telegram to view this post
VIEW IN TELEGRAM
👍6❤2
This media is not supported in your browser
VIEW IN TELEGRAM
https://anim-card-stack.appllama.io
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7👍1
.gram درخواست داده!🧩 مثلاً اکانت
@durov میتونه صاحب durov.gram و اکانت @monk صاحب monk.gram بشه.Please open Telegram to view this post
VIEW IN TELEGRAM
❤5👍1
This media is not supported in your browser
VIEW IN TELEGRAM
https://cursor.com/origin
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6 2👨💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❤12🔥3