I m learning python c api functions and keen to learn python 3.1 stable version.
Found a same kind of issue recently and tried
PyModule_AddIntConstant(PyObject *module, const char *name, long value)
Runtime error occurred for this function call.
Is there something wrong with the function in python 3.1?
...
here is an example of the dict
ActivePython 3.1.2.3 (ActiveState Software Inc.) based on
Python 3.1.2 (r312:79147, Mar 22 2010, 12:20:29) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dict = {}
>>> dict[("127.0.0.1", "127.0.0.2")] = ["value", "value2", "value3"]
>>> dict...
Exactly what the title says. All the highlighting right now uses python2.6 and that makes me very sad face.
...
Hi there,
I have a csv DictReader object (using Python 3.1), but I would like to know the number of lines/rows contained in the reader before I iterate through it. Something like as follows...
myreader = csv.DictReader(open('myFile.csv', newline=''))
totalrows = ?
rowcount = 0
for row in myreader:
rowcount +=1
print("Row %d/...
What am I doing wrong/what can I do?
import sys
import string
def remove(file):
punctuation = string.punctuation
for ch in file:
if len(ch) > 1:
print('error - ch is larger than 1 --| {0} |--'.format(ch))
if ch in punctuation:
ch = ' '
return ch
else:
retur...
Possible Duplicate:
Tips on upgrading to python 3.0?
I am beginning Python and Python 3 is hardly a choice today. But I want the new code I write to have no problems running or being converted to Python 3. Are there any issues known that I should keep in mind for this?
...
I'm developing a package called garlicsim. (Website.) The package is intended for Python 2.X, but I am also offerring Python 3 support on a different fork called garlicsim_py3.(1)
So both of these packages live side by side on PyPI, and Python 3 users install garlicsim_py3, and Python 2 users install garlicsim.
The problem is: When thi...
I would like to pickle an unbound method in Python 3.x. I'm getting this error:
>>> class A:
... def m(self):
... pass
>>> import pickle
>>> pickle.dumps(A.m)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
pickle.dumps(A.m)
File "C:\Python31\lib\pickle.py", line 1358, in dumps
Pickler(...
Hi all -
I'm going to start on a long (~1-year) programming project in Python. I want to use wxPython for my GUI (supports 2.6), but I also want to use 3.1 for the rest of the project (to start using the 3.x syntax).
Is there any way for me to design a project that mixes 2.x and 3.x modules? Or should I just bite the bullet and use eit...
I was trying to import inpout32.dll to the program and do the parallel port interfacing.
When the execution reaches the statement PortAccess.Output(888,0); it throws the above exception.
The PortAccess class is defined in the dll file. Can somebody help me?
...
In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or FALSE if there is no response?
...
I found this example on stack overflow. I understand it, but seems like a bit much for such a simple method concept... removing several chars from a string.
import string
exclude = set(string.punctuation)
s = ''.join(ch for ch in s if ch not in exclude)
is there a builtin string method in python 3.1 to do something to the tune of:
...
I have a multidimensional array in python like:
arr = [['foo', 1], ['bar',2]]
Now, if I want to print out everything in the array, I could do:
print(arr[:][:])
Or I could also just do print(arr). However, If I only wanted to print out the first element of each box (for arr, that would be 'foo', 'bar'), I would imagine I would do s...
How can I replace a string with another string, within a given text file. Do I just loop through readline() and run the replacement while saving out to a new file? Or is there a better way?
I'm thinking that I could read the whole thing into memory, but I'm looking for a more elegant solution...
Thanks in advance
...
this may not be an earth-shattering deficiency of python, but i still
wonder about the rationale behind the following behavior: when i
run
source = """
print( 'helo' )
if __name__ == '__main__':
print( 'yeah!' )
#"""
print( compile( source, '<whatever>', 'exec' ) )
i get ::
File "<whatever>", line 6
#
^
SyntaxError: inv...
The title describes the question pretty much.
...
I already posted this, but here is the exact code:
x1 = input("")
x2 = input("-")
x3 = input("-")
x4 = input("-")
So, how would I do it so that there are no spaces between the first input and the next "-"?
Example:
1234-5678-9101-1121
...
I have Python 3.1.2 and I'm using Windows XP.
Where can I see Python's implementation of the Mersenne Twister? In the Python docs it is stated that the Mersenne Twister was written in C and the Python History and License ( http://docs.python.org/py3k/license.html?highlight=mersenne%20twister ) states that "The _random module includes c...
Let's say that I routinely have to work with files with an unknown, but large, number of lines. Each line contains a set of integers (space, comma, semicolon, or some non-numeric character is the delimiter) in the closed interval [0, R], where R can be arbitrarily large. The number of integers on each line can be variable. Often times I ...
If you look at the following line of python code:
bpy.ops.object.particle_system_add({"object":bpy.data.objects[2]})
you see that in the parameters there is something enclosed in braces. Can anyone tell me what the braces are for (generically anyway)? I haven't really seen this type of syntax in python and I can't find any documenta...