Top Tweets for #pathlib
Day 11:
Today I learnt how to use:
🎲 "random": generating random values/numbers
📁 "pathlib": working with files & directories
I also learnt about paths, ".exists()", ".mkdir()", ".rmdir()" and ".glob()".
And I met generator object for the first time
Still learning.
I saw translating an app into multiple languages more than double AppStore traffic for @ar0nbg so doing the same today
Here is the code for you to do the same for Xcode:
1. Create Localizations file in xcode
2. Select languages you want
3. Update key, absolute path and run this script in python editor of choice (extend target languages list if you want)
import json
import deepl
from pathlib import Path
# ================== CONFIGURATION ==================
XCSTRINGS_FILE = "GET ABSOLUTE PATH/Localizable.xcstrings" # Change if your file has a different name
key = 'DEEPL_KEY' # There is a free tier that'll translate your whole app in at least 10 languages
DEEPL_API_KEY = key
TARGET_LANGUAGES = [
"FR", # French
"ES", # Spanish
]
# ===================================================
def translate_app():
translator = deepl.Translator(DEEPL_API_KEY)
path = Path(XCSTRINGS_FILE)
if not path.exists():
print(f"❌ Error: Could not find file at {XCSTRINGS_FILE}")
return
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
source_lang = data.get("sourceLanguage", "en")
strings = data.get("strings", {})
for key, value in strings.items():
# --- FIX: SMART FALLBACK FOR SOURCE TEXT ---
source_data = value.get("localizations", {}).get(source_lang, {}).get("stringUnit", {})
source_text = source_data.get("value") if source_data else None
# If Xcode hasn't generated a source string unit, fall back to using the Key itself!
if not source_text:
source_text = key
print(f"ℹ️ [{key}] No explicit source unit found. Falling back to the key name as source text.")
localizations = value.setdefault("localizations", {})
for dl_lang in TARGET_LANGUAGES:
# Format language code correctly for Xcode (e.g., "fr", "pt-BR")
if "-" in dl_lang:
parts = dl_lang.split("-")
xcode_lang = f"{parts[0].lower()}-{parts[1]}"
else:
xcode_lang = dl_lang.lower()
# Skip if already translated
if xcode_lang in localizations and localizations[xcode_lang].get("stringUnit", {}).get("value"):
continue
try:
result = translator.translate_text(source_text, source_lang=source_lang.upper(),
target_lang=dl_lang.upper())
translated_text = result.text
# Safely construct the nested dictionaries without overwriting other structural properties
localizations[xcode_lang] = {
"stringUnit": {
"state": "translated",
"value": translated_text
}
}
print(f"✅ [{xcode_lang}] Translated '{key}' -> '{translated_text}'")
except Exception as e:
print(f"❌ Error translating '{key}' to {dl_lang}: {e}")
with open(path, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print("\n✅ Translation complete! All missing strings processed.")
translate_app()
# if __name__ == "__main__":
# translate_app()
day 12
signal : noise - 78:22
Topics Covered Today -
Machine Learning
- tarfile
- pathlib
- urllib.request
Full Stack
- SQL

day 11
signal : noise - 71:29
Topics Covered Today -
Weekly Review
- LISTS
- TUPLES
- DICTIONARIES
- SETS
- STRINGS
- COLLECTIONS
- ITERTOOLS

@grok here’s how to apply this right now:
#!/usr/bin/env python3
# :: ENG: Matthew Alan Newman [@nve024] | (Sanctus Sanctus Sanctus, Glory to God in the Highest and on Earth Peace to People of Goodwill ✝️)
"""OGC AI mem v1."""
import argparse,ast,hashlib,json,sys
from pathlib import Path
S,Q,N,CS=10**15,339949771344778,23,1024
h=lambda b:hashlib.sha256(b).hexdigest()
cj=lambda o:json.dumps(o,sort_keys=True,separators=(",",":")).encode()
CH=lambda c:h(cj({k:v for k,v in c.items()if k!="csh"}))
def contract(x,n=N):
l=[]
for k in range(1,n+1):x,r=divmod(Q*x,S);l.append({"step":k,"r":r})
return x,l
def recover(v,l):
for i in l[::-1]:
if(m:=S*v+i["r"])%Q:raise ValueError("Q")
v=m//Q
return v
def enc_chunk(d,i,bs):v,l=contract(int.from_bytes(d,"big")if d else 0);return{"i":i,"bs":bs,"bl":len(d),"h":h(d),"v":v,"led":l}
def dec_chunk(c):
d=recover(c["v"],c["led"]).to_bytes(c["bl"],"big")
if h(d)!=c["h"]:raise ValueError("h")
return d
def enc_bytes(d,cs=CS):return{"q":Q,"s":S,"n":N,"cs":cs,"bl":len(d),"sh":h(d),"chs":[enc_chunk(d[j:j+cs],k,j)for k,j in enumerate(range(0,len(d),cs))]or[enc_chunk(b"",0,0)]}
def dec_bytes(s):
d=b"".join(dec_chunk(c)for c in sorted(s["chs"],key=lambda c:c["i"]))
if len(d)!=s["bl"]or h(d)!=s["sh"]:raise ValueError("b")
return d
def up(n):
try:return ast.unparse(n)
except:return""
L=lambda n:[getattr(n,"lineno",0)or 0,getattr(n,"end_lineno",0)or 0]
D=lambda n:(ast.get_docstring(n)or"").splitlines()
def vis_mem(txt,nm,sh):
I,C,F,K,m=[],{},[],[],[]
try:
t=ast.parse(txt)
for n in t.body:
if isinstance(n,(ast.Import,ast.ImportFrom)):I.append(up(n))
elif isinstance(n,ast.Assign):[C.update({https://t.co/BLI62EtBBU:{"e":up(n.value),"ln":getattr(n,"lineno",None)}})for g in n.targets if getattr(g,"id","").isupper()]
elif isinstance(n,ast.AnnAssign)and getattr(https://t.co/Kzt3w1mpvu,"id","").isupper():C[https://t.co/SIOvAMIhoK]={"e":up(n.value),"ln":getattr(n,"lineno",None)}
elif isinstance(n,ast.FunctionDef):F.append({"n":https://t.co/wuV1XAtenL,"lns":L(n),"a":[a.arg for a in n.args.args],"d":(D(n)or[""])[0]})
elif isinstance(n,ast.ClassDef):K.append({"n":https://t.co/wuV1XAtenL,"lns":L(n),"dec":[up(d)for d in n.decorator_list],"d":(D(n)or[""])[0]})
m=[l.strip()for l in D(t)if l.strip()][:4]
except:m=["[Err]"]
v={"name":nm,"sh":sh,"lines":len(txt.splitlines()),"doc":m,"imps":I[:8],"consts":C,"funcs":F,"clss":K};v["vsh"]=h(cj(v));return v
def build_capsule(p,cs=CS):
d=https://t.co/5GuGsj0rrs_bytes();c={"t":"OGC_AI_v1","src":https://t.co/QkJ8VADxTH,"vis":vis_mem(d.decode("utf-8","replace"),https://t.co/QkJ8VADxTH,h(d)),"ledger":enc_bytes(d,cs)};c["csh"]=CH(c);return c
def restore_cap(c):
if c.get("csh")!=CH(c):raise ValueError("csh")
return dec_bytes(c["ledger"])
def demo(p,cs):
c=build_capsule(p,cs);r=restore_cap(c);o=https://t.co/5GuGsj0rrs_bytes();s=p.suffix
cf,rf,pf=p.with_suffix(s+".cap.json"),p.with_suffix(s+".rec"),p.with_suffix(s+".rep.json")
cf.write_text(json.dumps(c,indent=2),encoding="utf-8");rf.write_bytes(r)
rp={"in":str(p),"b":len(o),"sha":h(o),"v_b":len(cj(c["vis"])),"c_b":len(cj(c)),"ch":len(c["ledger"]["chs"]),"ok":r==o,"f":{"c":str(cf),"r":str(rf),"p":str(pf)}}
pf.write_text(json.dumps(rp,indent=2),encoding="utf-8");return rp
if __name__=="__main__":
if len(sys.argv)<2:print("usage: <py> [--chunk N]");sys.exit(1)
ap=argparse.ArgumentParser(add_help=False);ap.add_argument("i",type=Path);ap.add_argument("--chunk-size",type=int,default=CS);a=ap.parse_args()
print(json.dumps(demo(a.i,a.chunk_size),indent=2))
It also pairs cleanly with pathlib, so you get Path objects instead of raw strings, which makes chaining file operations much easier.
The full guide on https://t.co/UTW7jF3UU0 breaks down the wildcard syntax, recursive searches, and common mistakes devs make when using glob
Most people learn #Python like a school subject.
That is why they stay stuck.
Here’s a better roadmap 👇
1. Learn only the core basics
Start with:
- variables
- if/else
- loops
- functions
- lists
- dictionaries
- file handling
Do not try to master everything first.
You only need enough to begin.
2. Pick a real problem immediately
Choose something practical:
- scrape data from a website
- clean a messy CSV
- automate file renaming
- merge Excel/CSV files
- build a small report generator
Real problems teach faster than perfect tutorials.
3. Let the problem guide the learning
- Need data cleaning? Learn pandas
- Need web data? Learn requests + BeautifulSoup
- Need automation? Learn os / pathlib
Do not learn tools randomly. Learn them when the project demands them.
4. Get comfortable with errors
This is the real learning phase:
- code breaks
- data is messy
- logic fails
nothing works first time
Good. That is where skill is built.
5. Finish a small useful project
A beginner project should be:
- practical
- simple
- reusable
- explainable
Not fancy. Useful.
6. Share what you built
Post:
- the problem
- your approach
- what failed
- final result
- lesson learned
That is how you build proof, not just knowledge.
7. Repeat with slightly harder problems
Example path:
- clean CSV
- automate files
- scrape data
- analyze data
- create report
- call an API
- build a mini dashboard
That is how Python starts feeling real.
Learn Python to solve problems.
Not to collect syntax.

Python 3.4: Beyond Scripting – Building Scalable Systems
https://t.co/wNzCaFKXrl
#Python #Python34 #Asyncio #Pathlib #pip #Programming #OpenSource #TheStoryOfPython
Day 4 of building @CrooviOfficial 's CrooFx:
Working on deterministic repo scanning with pathlib
Handling resolve(), absolute vs relative paths, and symlink traversal so the scanner cannot escape the repository root.
Without strict path normalization, a scanner can accidentally traverse the entire filesystem.

Don’t overthink Python.
Make these projects 👇
• Log Analyzer → files, regex, reports
• API Monitor → requests, retries, alerts
• File Organizer → os, pathlib, automation
• Data Cleaner → pandas, validation, export
• CLI Tool → argparse, configs, logging
Build → document → ship to GitHub.
That’s how Python actually clicks...
Day 11 // Pathlib & Directory Management 🗂️🐍
a modern way to handle paths and directories in Python.
📖 Resource: https://t.co/43t5CHO39j
#AI #MachineLearning #Python #LearningInPublic #SkillUpWithGFG #NationSkillUp

on 3rd day of python automation learning, i wrote a few file and directory handling automation scripts and got familiar with os, shutil, glob and pathlib modules.

@LSVoceDeMimNSai Yeah, pathlib makes life easier.
🐍Python’s pathlib simplifies file handling!📁
Replace clunky string paths with intuitive objects for files and directories.
Ideal for cross-platform scripts.
What Python trick enhances your workflow? Share it!
#Python #Coding #DataScience #Programming

Python Task Automation
- PyAutoGUI
- Pywinauto
- Robot Framework
File and Folder Automation
- Shutil
- Pathlib
Web Automation
- Selenium
- Requests-HTML
System Automation
- Subprocess
- Schedule
Office Automation
- Python-docx
- Openpyxl
Other Automation Libraries
- Pyttsx3
- Pygame
𝐏𝐲𝐭𝐡𝐨𝐧 𝐓𝐢𝐩:
Use pathlib for cross-platform file path handling. It's more intuitive and powerful than 𝐨𝐬.𝐩𝐚𝐭𝐡
.

Trends for you
Most Popular Users

Elon Musk 
@elonmusk
239.3M followers

Barack Obama 
@barackobama
118.5M followers

Cristiano Ronaldo 
@cristiano
114.3M followers

Donald J. Trump 
@realdonaldtrump
111.7M followers

Narendra Modi 
@narendramodi
106.9M followers

Rihanna 
@rihanna
98.6M followers

NASA 
@nasa
92M followers

Justin Bieber 
@justinbieber
91.7M followers

KATY PERRY 
@katyperry
89.9M followers

Taylor Swift 
@taylorswift13
83.9M followers

Lady Gaga 
@ladygaga
75.4M followers

Virat Kohli 
@imvkohli
73.2M followers

Kim Kardashian 
@kimkardashian
70.8M followers

YouTube 
@youtube
68.6M followers

Neymar Jr 
@neymarjr
66.3M followers

Bill Gates 
@billgates
65.1M followers

Selena Gomez 
@selenagomez
63M followers

The Ellen Show
@theellenshow
62.1M followers

CNN 
@cnn
61.6M followers

X 
@x
60.6M followers






















