I want to use the new and delete operators for creating and destroying my objects.
The problem is python seems to break it into several stages. tp_new, tp_init and tp_alloc for creation and tp_del, tp_free and tp_dealloc for destruction. However c++ just has new which allocates and fully constructs the object and delete which destructs ...
What is the correct way to initialise a python object into already existing memory (like the inplace new in c++)
I tried this code however it causes an access violation with a debug build because the _ob_prev and _ob_next are not set..
//PyVarObject *mem; -previously allocated memory
Py_INCREF(type);
//couldnt get PyObject_HEAD_INIT o...
Hi,
I'm using this code to get standard output from an external program:
>>> from subprocess import *
>>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]
The communicate() method returns an array of bytes:
>>> command_stdout
b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0...
I read dive into python for Python 2.x but is there any e-books for Python 3.x?
...
Python 3.x (aka Python 3000, Py3k, etc) is now available. When and why are you planning on porting your project or code to the new Python?
edit: I'm particularly interested in any features that don't exist in 2.6 that make porting worth it. Right now seems like a lot of negatives (x hasn't been ported yet), but I don't know what people ...
I am currently developing an application in python 3 and i need to be able to hide certain files from the view of people. i found a few places that used the win32api and win32con but they don't seem to exist in python 3.
Does anyone know if this is possible without rolling back or writing my own attribute library in C++
...
Many methods that used to return lists in Python 2.x now seem to return iterators in Py3k
Are iterators also generator expressions? Lazy evaluation?
Thus, with this the memory footprint of python is going to reduce drastically. Isn't it?
What about for the programs converted from 2to3 using the builtin script?
Does the builtin tool e...
How to access a COM object from a python file using python 3.0.
And, yes, I know that not a lot of people are using Python 3.0. Switching back to 2.6 is a huge hassle for me, so I don't want to unless I absolutely have to.
I appreciate your time, and any assistance!
...
I had expected this to work:
>>> import urllib.request as r
>>> import zlib
>>> r.urlopen( r.Request("http://google.com/search?q=foo", headers={"User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11", "Accept-Encoding": "gzip"}) ).read()
b'af0\r\n\x1f\x8b\x08...(long binary string)'
>>> zlib.decompress(_)
Traceb...
Does wxPython have a version for Python 3?
If it does, where can I get it?
...
I am just wondering if there is a super global(like PHP) in python. I have certain variables i want to use throughout my whole project in separate files, classes and functions and i don't want to have to keep declaring it throughout each file.
...
I ask this for deployable reasons. As in, if I write a solution in python, I feel bound to write to 2.x due to the lack of adoption of python 3. This is a major daily concern of mine, and I want to figure out what's going on.
For many of the python-based questions here, people are giving solutions that simply do not work in python 3.x.
...
I'm using mod_wsgi and was wondering if it's possible to over-write the print() command (since it's useless).
Doing this doesn't work:
print = myPrintFunction
Since it's a syntax error. :(
...
I have a question about how python treats the methods passed to sorted(). Consider the following small script:
#!/usr/bin/env python3
import random
class SortClass:
def __init__(self):
self.x = random.choice(range(10))
self.y = random.choice(range(10))
def getX(self):
return self.x
def getY(self):
...
Hello,
I am writing an rather simple http web server in python3. The web server needs to be simple - only basic reading from config files, etc. I am using only standard libraries and for now it works rather ok.
There is only one requirement for this project, which I can't implement on my own - virtual hosts. I need to have at least tw...
In python 2, it was possible to get debug output from urllib by doing
import httplib
import urllib
httplib.HTTPConnection.debuglevel = 1
response = urllib.urlopen('http://example.com').read()
However, in python 3 it looks like this has been moved to http.client.HTTPConnection.set_debuglevel(level).
However, I'm using urllib not http....
Hi there,
I would like to start learning Python (zero past experience). I am a bit inclined to start with Python 3.0. However, I am not sure if at this time there exists a GUI editor that would be compatible with Python 3.0. I've tried installing Glade, but the one I've got works only with Python 2.5. What could I possibly use with Pyt...
Hi,
I was trying to install "setuptool" package for python3.0. But unfortunately while
I try to install it says module names "dist" is missing.
pls help me to resolve this issue.
...
I'm learning Python-this gives me an IO error-
f = open('money.txt')
while True:
currentmoney = float(f.readline())
print(currentmoney, end='')
if currentmoney >= 0:
howmuch = (float(input('How much did you put in or take out?:')))
now = currentmoney + howmuch
print(now)
str(now)
f.cl...
IDLE's subprocess didn't make
connection. Either IDLE can't start a
subprocess or personal firewall
software is blocking the connection.
Don't think this has been asked-how come this comes up occasionally when running very simple programs-I then have to go to Task Manager & stop all Pythonw processes to get it to work again?
...