Anthropy :verified_dragon: on Nostr: Did you know you can specify parameters with an if/else statement inside a function ...
Did you know you can specify parameters with an if/else statement inside a function call in python?
e.g:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
is completely valid in python3.
Published at
2024-05-31 17:00:10Event JSON
{
"id": "049402ddc8f71dd3b42904ddf4bab9a6c15617886768b8df3ee068b56d40cda3",
"pubkey": "e6da4b3c3bae782bfec1f845f8e41da3a15b43920ba660b8e195b43a8ee136a2",
"created_at": 1717174810,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.derg.nz/@anthropy/112536768399786777",
"web"
],
[
"proxy",
"https://mastodon.derg.nz/users/anthropy/statuses/112536768399786777",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.derg.nz/users/anthropy/statuses/112536768399786777",
"pink.momostr"
]
],
"content": "Did you know you can specify parameters with an if/else statement inside a function call in python? \n\ne.g: \ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\nis completely valid in python3.",
"sig": "36720d4576651c612d4f3934510e41265f931f59e9dc79806b08c19be3e59efc7ccad9965575e6a99d23060538a86e0a4de59923a249e994618b03bd19d871eb"
}