Hi all,
A week or so ago someone on StackOverflow asked why their Python code for connecting to an IPv6 link-local address wasn't working, and I replied that since it was a link-local address they needed to add a %en0 (or whatever the desired local-interface-name is) suffix to their target IP address. I thought I knew what I was talkin...
Hi, I have one multprocess demo here, and I met some problems with it. Researched for a night, I cannot resolve the reason.
Any one can help me?
I want to have one parent process acts as producer, when there are tasks come, the parent can fork some children to consume these tasks. The parent monitors the child, if any one exits with exc...
so i have a motion sensor connected to an avr micro that is communicating with my python app via usb. im using pyserial to do the comm. during my script i have an infinate loop checking for data from the avr micro. before this loop i start a timer with signal.alarm() that will call a function to end a subprocess. when this alarm goes it ...
Hi, I was just wondering if there was any way to set to %PATH% variables so I can compile my Java code, along with my Python code?
For instance.. PATH is currently C:\ ... JDK_bin blah blah, and that's it. To run my python code, I have to change my path variable completely.
Any answers?
...
I have multiple MySQL tables with names of the form "Shard_0", "Shard_1", "Shard_2" ... "Shard_n" All of them have identical table structure. They all live in the same database.
Say I want to add a column to all those tables. Is there a way to do that programmatically?
Something like:
# pseudo code
for i in range(n):
tablenam...
All,
foo.py
def foo_001(para): tmp = para + 2 return tmp
def foo_002(para): tmp = para * 2 return tmp
def foo_003(para): tmp = para / 2 return tmp
...
def foo_100(para): tmp = #complex algo, return tmp
main.py
from foo import *
fun_name = ["foo_001","foo_002","foo_002" ... "foo_100"]
src = 1
rzt = []
for i in fun_name: ...
Ok, so I need to build this application where I'll read images from a www.flickr.com account and use the images in my Python app. How will I do that? Any ideas? Thanks.
...
At http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Imports, it suggests:
Even if the module is in the same package, do not directly import the module without the full package name. This might cause the package to be imported twice (with unintended side effects) when the "main" module that is used to start an applicatio...
Why does Python complain about chrome being referenced before assignment? It does not complain about the dictionary. This is with Python 2.5 if it makes a difference.
def f():
google['browser'] = 'chrome'
chrome += 1
google = dict()
chrome = 1
f()
I can make it work with global chrome of course, but I'd like to know why Python do...
Since everything in python is an object, i was wondering if there was a way i could initialise a class object using the name of the class
for example,
class Foo:
"""Class Foo"""
How could i access this class by "Foo", ie something like c = get_class("Foo")
...
HI !
I guess everything is in the question ...
I was just wondering if there is a nice way in Python to shorten this pattern :
something = get_something()
if something:
do_a_thing_with(something)
Meaning that I would like to enter in the if context only if the variable something is not None (or False), and then in this context h...
I made a very simple interactive console that I'd like to use in a complicated scraping application. It looks like this:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, codecs, code
sys.__stdout__ = codecs.getwriter('utf8')(sys.__stdout__)
sys.__stderr__ = codecs.getwriter('utf8')(sys.__stderr__)
if 'DEBUG' in os.environ...
Hey, I have been using the Pymt library and they have this convention to referring their widgets:
from pymt import *
# create a slider from 0.-1.
sl = MTXYSlider()
@sl.event
def on_value_change(x, y):
print 'Slider value change', x, y
runTouchApp(sl)
what's with the "@"? What does it signify in Python?Thanks.
...
I have a hook function named precommit_bad_branch which imports hook_utils. When invoking precommit_bad_branch via a commit I get the following error message:
error: precommit.branch_check hook raised an exception: No module named hook_utils
abort: No module named hook_utils!
It looks like I'm not allowed to call hook_utils from preco...
I have a code that try to find the Eulerian path like this. But somehow it doesn't work.
What's wrong with the code?
use strict;
use warnings;
use Data::Dumper;
use Carp;
my %graphs = ( 1 => [2,3], 2 => [1,3,4,5], 3 =>[1,2,4,5], 4 => [2,3,5], 5 => [2,3,4]);
my @path = eulerPath(%graphs);
sub eulerPath {
my %graph = @_;
# ...
Hello!
This year me and a friend have to make a project for the final year of university. The plan is to make a proxy/sever that allows to store ontologies and RDF's, by this way this data is "chained" to a web, so you can make a request for that web and the proxy will send you the homepage with metadata.
We have been thinking to use p...
I have been playing around with the twisted framework for about a week now(more because of curiosity rather than having to use it) and its been a lot of fun doing event driven asynchronous network programming.
However, there is something that I fail to understand. The twisted documentation starts off with
Twisted is a framework desig...
I have instance of the my class. I want to save implementation of class with instance's pickle copy in file. After, I want to use this instance to another computer where there is no implementation of the my class. I don't want to save text of implementation manually.
How can I do this?
...
I'm just learning PyQt and looking at the Signals and Slots mechanism. I'm a bit baffled by the verbose syntax. Why do we have:
self.connect(dial, SIGNAL("valueChanged(int)"), spinbox.setValue)
I would much prefer to write the following:
self.connect(dial.valueChanged, spinbox.setValue)
Can anyone tell me why the connect() syntax n...
Hi ,
I need to iterate the fields and compute sum of few columns group by the value in another column .
For ex base table is
C1 C2 C3 C4 C5
a1 2 3 4 q
a1 4 5 7 a
a2 34 56 6 e
a2 4 5 5 5
a3 3 3 3 4
a3 3 3 3 3
The result table should be
c2 c3 c4
a1 6 8 11
a2 38 61 11
a3 6 6 6
50 75 28
I am able...