standard-library

Is it a good idea to use undocumented public code from the Python standard library?

For instance, in multiprocessing.managers there is a function called MakeProxyType. This function isn't in the multiprocessing documentation at all, but its name doesn't begin with an underscore either. Disregarding the subject of whether or not it's actually useful to use MakeProxyType, would it be ok to use this function in my code? ...

How can I tell if a Perl module is core or part of the standard install?

How can I check if a Perl module is part of the core - i.e. it is part of the standard installation? I'm looking for: a command-line command: a Perl subroutine/function to check within code Thanks in advance. Update Perhaps I should re-write the question to be: "How can I tell what modules were originally provided with the specifi...

queue from the stl

I am trying to get the following code to compile using g++ 4.2.1 and am receiving the following errors CODE: #include <iostream> #include <queue> using namespace std; int main (int argc, char * const argv[]) { queue<int> myqueue(); for(int i = 0; i < 10; i++) myqueue.push(i); cout << myqueue.size(); retu...

(syntax trees) recursively iterating over trees bottom-up with current top-down path

Hi I have an abstract syntax tree which I need to iterate. The AST is generated by the lemon port to PHP. Now "normally", I'd do it with the brand new and shiny (PHP 5.3.1) SPL classes, and it would look like this: $it = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($ast['rule']), \RecursiveIteratorIterator::SELF_FI...

Alternative ways to browse the python api

Is it just me, or the python standard library documentation is extremely difficult to browse through? http://docs.python.org/3.1/library/index.html http://docs.python.org/3.1/modindex.html Java has its brilliant Javadocs, Ruby has its helpful Ruby-Docs, only in python I cannot find a good way to navigate through the standard library ...

Where to find algorithms for standard math functions?

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being: You can't use assembly language. Y...

std::vector overwriting final value, rather than growing?

I'm having an issue where using vector.push_back(value) is overwriting the final value, rather than appending to the end. Why might this happen? I have a sample item in the vector, so it's size never hits zero. Below is the code.. void UpdateTable(vector<MyStruct> *Individuals, MyStruct entry) { MyStruct someEntry; bool isNew...

What is the address of back() in an empty container?

I mistakenly took the address of the reference returned by the back() operator in an empty container and was surprised to see that the address wasn't zero. If a container e.g. std::deque is empty, what does back() return? ...

What does the "c" mean in cout, cin, cerr and clog?

What does the "c" mean in the cout, cin, cerr and clog names? I would say char but I haven't found anything to confirm it. ...

Python's standard library - is there a module for balanced binary tree?

Is there a module for AVL or Red-Black or some other type of a balanced binary tree in the standard library of Python? I have tried to find one, but unsuccessfully (I'm relatively new to Python). ...

Python: Getting a machine's external IP address

Looking for a better way to get a machines current external IP #...Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x import os import urllib2 def check_in(): fqn = os.uname()[1] ext_ip = urllib2.urlopen('...

Why isnt int pow(int base, int exponent) in the standard C++ libraries?

I feel like I must just be unable to find it. Is there any reason that the c++ pow function does not implement the "power" function for anything except floats and doubles? I know the implementation is trivial, I just feel like I'm doing work that should be in a standard library. A robust power function (ie handles overflow in some consi...

How can I use functools.partial on multiple methods on an object, and freeze parameters out of order?

I find functools.partial to be extremely useful, but I would like to be able to freeze arguments out of order (the argument you want to freeze is not always the first one) and I'd like to be able to apply it to several methods on a class at once, to make a proxy object that has the same methods as the underlying object except with some o...

Simplest way to mix sequences of types with iostreams?

I have a function void write<typename T>(const T&) which is implemented in terms of writing the T object to an ostream, and a matching function T read<typename T>() that reads a T from an istream. I am basically using iostreams as a plain text serialisation format, which obviously works fine for most built-in types, although I'm not sure...

What are the C functions from the standard library that must / should be avoided ?

I've read on stackoverflow that some C functions are 'obsolete' or should be 'avoided'. Can you please give me some examples of this kind of functions + the reason why. What alternatives of those function exists ? Can we use them safely - any good practices ? Later edit: From the answers: gets : can cause buffer overflows. scanf : f...

Is it acceptable to wrap PHP library functions solely to change the names?

I'm going to be starting a fairly large PHP application this summer, on which I'll be the sole developer (so I don't have any coding conventions to conform to aside from my own). PHP 5.3 is a decent language IMO, despite the stupid namespace token. But one thing that has always bothered me about it is the standard library and its lack o...

Read whole ASCII file into C++ std::string

Hello, I need to read a whole file into memory and place it in a C++ std::string. If I were to read it into a char, the answer would be very simple: std::ifstream t; int lenght; t.open("file.txt"); // open input file t.seekg(0, std::ios::end); // go to the end length = t.tellg(); // report location (this is the leng...

Alternative Python standard library reference

I love Python; I absolutely despise its official documentation. Tutorials do not count as library references, but that appears to be what they're attempting. What I really want is the ability to find a class in the standard library and view documentation for all of its properties and methods. Actionscript, MSDN, and Java all do this jus...

Does std::multiset guarantee insertion order?

I have a std::multiset which stores elements of class A. I have provided my own implementation of operator< for this class. My question is if I insert two equivalent objects into this multiset is their order guaranteed? For example, first I insert a object a1 into the set and then I insert an equivalent object a2 into this set. Can I exp...

Should I consider memmove() O(n) or O(1) ?

Hello, this may be a silly question, but I want to calculate the complexity of one of my algorithms, and I am not sure what complexity to consider for the memmove() function. Can you please help / explain ? void * memmove ( void * destination, const void * source, size_t num ); So is the complexity O(num) or O(1). I suppose it's O(...