Python's sys module provides a function setrecursionlimit that lets you change Python's maximum recursion limit. The docs say:
The highest possible limit is platform-dependent.
My question is: What is the highest possible limits for various platforms, under CPython? I would like to know the values for Linux, Mac and Windows.
I'm new to Python, so this is probably a simple scoping question. The following code in a Python file (module) is confusing me slightly:
if __name__ == '__main__':
x = 1
print x
In other languages I've worked in, this code would throw an exception, as the x variable is local to the if statement and should not exist outside of it. But this code executes, and prints 1. Can anyone explain this behavior? Are all variables declared in a module global/available to the entire module?
I like the Android platform. Actually, with some friends, we even participate to the ADC with the Spoxt project.
But Java is not my favourite language at all. We are working on a S60 version and this platform has a nice Python API. Of course there is nothing official about Python on Android, but since Jython exists, does anybody know a way to let the snake and the robot work together ?
While studying C# I found it really strange, that dynamically typed Python will rise an error in the following code:
i = 5
print i + " "
whereas statically typed C# will normally proceed the similar code:
int i = 5;
Console.Write(i + " ");
I would expect other way around (in python I would be able to do this without any casting, but C# would require me to cast int to string or string to int).
Just to highlight, I am not asking what language is better, I am curious what was the reason behind implementing the language this way.
suppose I have a python list or a python 1-d array (represented in numpy). assume that there is a contiguous stretch of elements how can I find the start and end coordinates (i.e. indices) of the stretch of non-zeros in this list or array? for example,
a = [0, 0, 0, 0, 1, 2, 3, 4]
nonzero_coords(a) should return [4, 7]. for:
b = [1, 2, 3, 4, 0, 0]
nonzero_coords(b) should return [0, 2].
thanks.
Is it possible to control the standard streams of C++ code in python? The code is wrapped with SWIG and then exposed to Python where I call one of its functions.
I am getting all kinds of unwanted messages coming from C++ code and I want to suppress them either by not using the output stream or by redirecting it to a bit bucket, e.g. devnull from the os module.
Is it guaranteed that False == 0 and True == 1, in Python? For instance, is it in any way guaranteed that the following code will always produce the same results, whatever the version of Python (existing and in the foreseeable future)?
0 == False # True
1 == True # True
['zero', 'one'][False] # is 'zero'
Any reference to the official documentation would be much appreciated! Other comments would be appreciated too… :)
I want to incorporate a minified javascript library (for example http://sizzlejs.com/) into my own non minified javascript library. The reason is that my library plugs into other websites and I don't want to ask them to include the extra library (sizzle) as well.
Is there a way to include a minified library in a non minified library and have them both in one js file?
Hello people.
I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.)
Is there any Pythonlibrary that allows me to parse an HTML document similar to what jQuery does?
i.e. I'd like to be able to use CSS selector syntax to grab an arbitrary set of nodes from the document, read their content/attributes, etc.
The only Python HTML parsing lib I've used before was BeautifulSoup, and even though it's fine I keep thinking it would be faster to do my parsing if I had jQuery syntax available. :D
Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n):
"Largest number of McNuggets that cannot be bought in exact quantity: n"
I have a list which I shuffle with the Python built in shuffle function (random.shuffle)
However, the Python reference states:
Note that for even rather small
len(x), the total number of
permutations of x is larger than the
period of most random number
generators; this implies that most
permutations of a long sequence can
never be generated.
Now, I wonder what this "rather small len(x)" means. 100, 1000, 10000,...
Can anybody clarify?
Thanks!
I am planning to build an inverted index searching system with cassandra as its storage backend. But I need some guidances to build a highly efficient searching daemon server. I know a web server written in Python called tornado, my questions are:
Is Python a good choice for developing such kind of app?
Is Nginx(or Sphinx) a good example that I can look inside to learn its architecture to implement a highly efficient server?
Anything else I should learn to do this?
Thank you~
I'm new to Python, and I know I must be missing something pretty simple, but why doesn't this very, very simple code work?
class myClass:
pass
testObject = myClass
print testObject.__class__
I get the following error:
AttributeError: class myClass has no attribute '__class__'
Doesn't every object in Python have a __class__ attribute?
Do you know any application, the more interesting/useful the better, to introduce a new person to Python language and the Python code style, but not necessarily to OO programing, so as to learn the subtleties and idioms of the language and surrounding community?
I'm thinking along the lines of people that has worked with JavaScript, Java or .NET, and already have a strong hold of OO concepts.
I know that Ruby on rails is very famous on Web Application Development, and python have a powerful library. Which language do you think for a totally brand new web project? Ruby or Python is a gd start? Also, you can share your development experience in both language. thz u.
Is it possible to control the standard streams of C++ code in python? So the code is wrapped with SWIG and then exposed to python where I call its functions.
I am getting all kinds of unwanted messages coming from C++ code and I want to suppress them either by not using the stream or by redirecting it to a bit bucket.
I think in the past python scripts would run off CGI, which would create a new thread for each process.
I am a newbie so I'm not really sure, what options do we have?
Is the web server pipeline that python works under any more/less effecient than say php?
Hello people.
I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.)
if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks
I want to write a command line script using Python to access a user's Facebook Notes.
PyFacebook wrapper library doesn't have support for Facebook notes.
Is there any other way I can do this in python? I don't want to learn PHP.
Reasoning: I'm trying to convert a large library from Scheme to Python
Are there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.
Totally subjective so I'm making it community wiki