Search Results

Showing results 1 to 40 of 885
Search took 0.05 seconds.
Search: Posts Made By: Gribouillis
Forum: Python 4 Hours Ago
Replies: 8
Views: 88
Posted By Gribouillis
A complete answer requires to browse python's source code. However, consider a piece of python code like this

x = aValue()
F( G(), x )

Since the value returned by G() is a new reference, it...
Forum: Python 5 Hours Ago
Replies: 8
Views: 88
Posted By Gribouillis
Steal means that the item will be referenced in the tuple, but without increasing it's reference count. When the tuple is deleted, the object will be decrefed.
For example if you create a python...
Forum: Python 10 Hours Ago
Replies: 2
Views: 97
Posted By Gribouillis
See also this (http://en.wikipedia.org/wiki/Primitive_type)
Forum: Python 17 Hours Ago
Replies: 2
Views: 76
Posted By Gribouillis
Try to run the loop 1 000 000 times instead of 1000. On my machine, it takes 0.0818829536438 seconds for 1 million times. See also the module timeit.
Forum: Python 1 Day Ago
Replies: 2
Views: 106
Posted By Gribouillis
You could write something like

from time import sleep
import os

def wait_file(filename):
cnt = 3 * 60
while cnt > 0:
if os.path.isfile(filename):
return
Forum: Python 1 Day Ago
Replies: 3
Views: 107
Posted By Gribouillis
If your compile can't find Python.h, you must add an include directory. On my system, I get

>>> from distutils import sysconfig
>>> sysconfig.get_python_inc()
'/usr/include/python2.6'

So for...
Forum: Python 1 Day Ago
Replies: 7
Views: 6,844
Posted By Gribouillis
You can write

from os.path import join as pjoin
targetfolder = raw_input('enter a target folder:\n').strip()
newname = raw_input('enter a new base name:\n')
newname = pjoin(targetfolder,...
Forum: Python 1 Day Ago
Replies: 8
Views: 211
Posted By Gribouillis
First, if it's crashing your program, there must be an exception traceback.
Also why don't you simply create a normal class and a single instance of the class ?
Forum: Python 3 Days Ago
Replies: 0
Views: 172
Posted By Gribouillis
This snippet defines a context to execute a block of statements in a different working directory (with the help of the with statement). After the block is exited, the initial working directory is...
Forum: Python 4 Days Ago
Replies: 5
Views: 190
Posted By Gribouillis
Google found a patch for scapy.all..sniff, wich allows to stop the sniff function programmatically. You should try this http://trac.secdev.org/scapy/wiki/PatchSelectStopperTimeout
Forum: Python 6 Days Ago
Replies: 6
Solved: drawing an eye?
Views: 224
Posted By Gribouillis
You can write

if colour in ("Green", "Blue", "Red"):
... # do something
else:
... # do something else
Forum: Python 6 Days Ago
Replies: 4
Views: 235
Posted By Gribouillis
For a crash reference, there is PQRC (http://www.limsi.fr/Individu/pointal/python/pqrc/versions/PQRC-2.4-A4-latest.pdf).
There is also another one (http://home.uchicago.edu/~gan/file/python.pdf)...
Forum: Python 6 Days Ago
Replies: 9
Views: 237
Posted By Gribouillis
Note that in python 3, there are no 'old style class', so that your class is implicitely a subclass of object. Here is a small experiment with python 2.6 and python 3.1

Python 2.6.4 (r264:75706,...
Forum: Python 7 Days Ago
Replies: 6
Views: 283
Posted By Gribouillis
This may work

SP.Popen("c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe d:\\rodin\\rodin.mp4 -stime"+str(d), shell=True)
Forum: Python 7 Days Ago
Replies: 6
Tutorial: Useful input trick
Views: 243
Posted By Gribouillis
That's a problem with these code snippet. In the active state snippets, people can update their code long after the initial post.
Forum: Python 7 Days Ago
Replies: 6
Tutorial: Useful input trick
Views: 243
Posted By Gribouillis
nice, it looks like a kind of 'scanf' for python.
Forum: Python 7 Days Ago
Replies: 6
Views: 283
Posted By Gribouillis
The str(d) in the argument doesn't work. I suggest that you use the subprocess module

import subprocess as SP
SP.Popen(["c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe", "-stime="+str(d),...
Forum: Python 7 Days Ago
Replies: 7
Views: 244
Posted By Gribouillis
Is this what you mean ?

class Agent:
def __init__(self):
exec "import random" in self.__dict__


ag = Agent()

print ag.random.randrange(100) # this works
Forum: Python 8 Days Ago
Replies: 3
Views: 162
Posted By Gribouillis
You can make a list with your functions

import random
funcs = [func0, func1,func2,func3,func4,func5,func6,func7,func8,func9,]
funcs[random.randrange(10)]() # <- call a random function...
Forum: Python 8 Days Ago
Replies: 2
Views: 120
Posted By Gribouillis
This one (http://blog.doughellmann.com/2007/07/pymotw-subprocess.html) perhaps ?
Forum: Python 8 Days Ago
Replies: 5
Views: 171
Posted By Gribouillis
It seems worth trying. In any case, if there is a significant difference in performance, it's a good idea to find out where it comes from. The cProfile module allows you to spot the function calls...
Forum: Python 8 Days Ago
Replies: 5
Views: 171
Posted By Gribouillis
You could replace threads with processes to get parallelism, using the multiprocessing module.
Forum: Python 8 Days Ago
Replies: 5
Views: 171
Posted By Gribouillis
Perhaps you could use the cProfile module to find out where time is spent ?
Forum: Python 8 Days Ago
Replies: 7
Views: 178
Posted By Gribouillis
It's true, suppose that mypackage contains __init__.py, foo.py, bar.py and baz.py. You could have this in __init__.py

import foo
import bar
import baz

then, if you simply write import...
Forum: Python 8 Days Ago
Replies: 7
Views: 178
Posted By Gribouillis
When the package system was added to python, the idea was that a folder could be a python module and it could have submodules. If the folder is a module, you need some place to put python code which...
Forum: Python 8 Days Ago
Replies: 1
Views: 149
Posted By Gribouillis
What they mean is that you must run these commands

patch-p1-i clammwin/patches/wxPython-2424.maskededit.patch
patch-p1-i clamwin/patches/wxPython-2424.throbber.patch
patch-p1-i...
Forum: Python 8 Days Ago
Replies: 7
Views: 178
Posted By Gribouillis
You could go this way, assuming that you have a folder named 'mypackage' wich contains a file '__init__.py'

# tested with py 2.6
import os
import mypackage

def module_names(package):
#...
Forum: Python 8 Days Ago
Replies: 11
Views: 362
Posted By Gribouillis
The author of the article meant that the "property" function replaces getters and setters. In fact python's "property" encapsulates the attribute, and also encapsulates getters and setters !
Forum: Python 8 Days Ago
Replies: 13
Views: 290
Posted By Gribouillis
When you call Py_Initialize, the program creates the module __main__ where your commands are run, and allocates all the memory it needs for the __builtin__ module, etc, exactly as if you were...
Forum: Python 8 Days Ago
Replies: 6
Solved: drawing an eye?
Views: 224
Posted By Gribouillis
You can add a loop in eyePicker until the user enters a valid colour:

from graphics import *

eye_colours = set("""green brown blue""".strip().split())

def drawCircle(win, centre, radius,...
Forum: Python 8 Days Ago
Replies: 13
Views: 290
Posted By Gribouillis
No, the interpreter runs in the main thread. Its role is to execute python code. For example, you can call PyImport_ImportModule, and this will run the python code contained in the given module....
Forum: Python 8 Days Ago
Replies: 2
Views: 159
Posted By Gribouillis
Notice getpass.getuser() which finds your login name (does it work on mac ?).
Forum: Python 8 Days Ago
Replies: 6
Solved: drawing an eye?
Views: 224
Posted By Gribouillis
I modified your code to give you a first running version

from graphics import *
def drawCircle(win, centre, radius, colour):
circle = Circle(centre, radius)
circle.setFill(colour)
...
Forum: Python 8 Days Ago
Replies: 13
Views: 290
Posted By Gribouillis
Few people write C programs for python 3. I think you should experiment a while with these functions. I interface C++ and python 2.6, but for the main part, I use Py++...
Forum: Python 9 Days Ago
Replies: 5
Views: 175
Posted By Gribouillis
I think that Van Rossum prefers OSX, and he works for Google, which makes 2 other obstacles.
Forum: Python 9 Days Ago
Replies: 16
Views: 791
Posted By Gribouillis
Good luck with your struggle !
Forum: Python 10 Days Ago
Replies: 16
Views: 791
Posted By Gribouillis
-1
lol
lol
Forum: Python 10 Days Ago
Replies: 16
Views: 791
Posted By Gribouillis
I don't mean to win anything, I think this is a place to discuss python programming, with people having different levels, who like and learn this language. Hundreds of threads here are about...
Forum: Python 10 Days Ago
Replies: 16
Views: 791
Posted By Gribouillis
I think it's pure paranoia to suspect someone from stealing someone else's property just because he is extracting data from their web page. Why not jail people who post in the web development forums...
Forum: Python 10 Days Ago
Replies: 13
Views: 290
Posted By Gribouillis
The implementation of PyBytes_asString in python 3.1.1 is

char *
PyBytes_AsString(register PyObject *op)
{
if (!PyBytes_Check(op)) {
PyErr_Format(PyExc_TypeError,
"expected bytes,...
Showing results 1 to 40 of 885

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC