




class Foo:
pass
class Bar:
def __init__(self, f = Foo()):
self.f = f
b = Bar()
print(id(b))
print(id(b.f))
print('----')
b = Bar()
print(id(b))
print(id(b.f))
id(object) is to check if those are the same objects https://docs.python.org/3/library/functions.html#id

print(id(b.f)) matches but print(id(b)) does not
class Foo:
def __init__(self):
self.prop = None
class Bar:
def __init__(self, f = Foo()):
self.f = f
self.prop = None
b = Bar()
b.prop = "bar"
b.f.prop = "foo"
b = Bar()
print(b.prop)
print(b.f.prop)$ python3 fml.py
None
foo






class Bar:
def __init__(self, f = "f"):
self.f = f
self.g = "f"
b = Bar()
print(id(b.f))
print(id(b.g))
b = Bar()
print(id(b.f))
print(id(b.g))




4e87313 Update Turkey costs and funding by Learath2 (thanks!) - def-




=== Jurisdiction and legality of content ===
Publication of information found on wiki.ddnet.org may be in violation of the laws of the country or jurisdiction from where you are viewing this information. The wiki.ddnet.org database is stored on servers in Finland, and is maintained in reference to the protections afforded under local and federal law. Laws in your country or jurisdiction may not protect or allow the same kinds of speech or distribution. wiki.ddnet.org does not encourage the violation of any laws; and cannot be responsible for any violations of such laws, should you link to this domain or use, reproduce, or republish the information contained herein.
Thank you for spending the time to read this page, and please enjoy your experience at wiki.ddnet.org.































[] as default parameter, then it is shared through all calls, so if it is modified by a call, it is modified in all subsequent calls (edited)













































cargo add sum_positive_digits
















is-even-or-oddis-even and another one is-odd, extending the joke about pointless dependencies



fn is_odd_or_even(num: i32) { true }



















#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![deny(warnings)]
#![deny(clippy::nursery)]
#![deny(clippy::pedantic)]
#![deny(clippy::all)]

















// Get Search by Id
fn getSearchById(id: u32)
/* Get Search by ID
/* Parameters:
/* id: u32 -> The id (unsigned 32 bit integer) of the search to get
/* Returns:
/* Search -> The Search object that belongs to the id
*/
fn getSearchById(id: u32) -> Search hi `hi` hi 




/* Get Search by ID
/* Parameters:
/* id: u32 -> The id (unsigned 32 bit integer) of the search to get
/* Returns:
/* Search -> The Search object that belongs to the id
*/
fn getSearchById(id: u32) -> Search 
























double sin(double t)
I’d document it’s domain, the approximation I’ve used, and maybe performance characteristics.
Something like size_t container::length() doesn’t really need any documentation. At least imho, obv very very subjective
Hacker News • 2023-05-08 10:00:51Z 





double sin(double t)
I’d document it’s domain, the approximation I’ve used, and maybe performance characteristics.
Something like size_t container::length() doesn’t really need any documentation. At least imho, obv very very subjective 


































throws?













Result if it's an error condition or if the "failing" case needs to carry data











Option

Result<Box<T>, SingletonError> gets the same treatmentOption over Result)

io::Result is quite heavy though, even coming with a destructor)


io::Result is quite heavy though, even coming with a destructor) 
io::Error is basically an enum that has a variant storing a Box<dyn Error>io::Result leaves the scope, it needs to be checked whether there's a Box<dyn Error> that needs freeing


Result is when something unexpected might happen. A search not finding anything is not always unexpected, and if it is it might be a good idea to wrap it in a way that the search failing is an assert and you can just return the object itself
Result is also used when you need data in the "no value" caseResult<usize, usize>, I think
[T]. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors.

Option?


fn main() {
let strings = vec!["tofu", "93", "18"];
let (numbers, errors): (Vec<_>, Vec<_>) = strings
.into_iter()
.map(|s| s.parse::<i32>())
.partition(Result::is_ok);
println!("Numbers: {:?}", numbers);
println!("Errors: {:?}", errors);
}


fn main() {
let strings = vec!["tofu", "93", "18"];
let (numbers, errors): (Vec<_>, Vec<_>) = strings
.into_iter()
.map(|s| s.parse::<i32>())
.partition(Result::is_ok);
println!("Numbers: {:?}", numbers);
println!("Errors: {:?}", errors);
} 


Result<Option<T>, Error> in some places













const eql = std.mem.eql;
const ArrayList = std.ArrayList;
const test_allocator = std.testing.allocator;
test "arraylist" {
var list = ArrayList(u8).init(test_allocator);
defer list.deinit();
try list.append('H');
try list.append('e');
try list.append('l');
try list.append('l');
try list.append('o');
try list.appendSlice(" World!");
try expect(eql(u8, list.items, "Hello World!"));
}














