text stringlengths 256 65.5k |
|---|
I usually use Perl's -c switch to check the syntax of the program and then exit without executing it. Is there an equivalent way to do this for a Python script?
You can check the syntax by compiling it:
import sys
filename = sys.argv[1]
source = open(filename, 'r').read() + '\n'
compile(source, filename, 'exec')
Save ... |
I'm trying to use the graph-tool python module, which is really great by the way. To do so I have:
downloaded version 2.2.30 (http://downloads.skewed.de/graph-tool/graph-tool-2.2.30.tar.bz2)
followed the installation instructions (http://graph-tool.skewed.de/download)
to compile the module I had to use this option: --w... |
With PyLint, I actually broke my Eclipse set-up for this a while ago but when I got it reinstated it's reminded me of how useful it is. One thing I hate about about interpreted languages is the huge scope for runtime errors. The PyLint plugin gives immediate feedback in the margin of the editor window with error inform... |
forficule
ubuntu et sambaedu
bonjour à tous, je travaille sur un réseau sambaedu3/lcs, et je voudrais faire tourner des postes sous ubuntu (xubuntu/fluxbuntu) sur ce réseau.
Comme les machines sont vieillotes, je ne souhaite pas pour l'instant me lancer dans une authentification pam sur le ldap de sambaedu, avec créati... |
I am brand new to Python and am trying to write a monitor to determine whether a Java web app (WAR file) running on localhost (hosted by Apache Tomcat) is running or not. I had earlier devised a script that ran:
ps -aef | grep myWebApp
And inspected the results of the grep to see if any process IDs came back in those r... |
Ayu
Grub ne se lance pas
Bonsoir,
J'ai installé windows 7 et Xubuntu 11.10 sur un nouveau pc avec cette configuration:CM: Asus P8H67 B3Processeur: i5 2500kDD: 1TO 7200 RPMRAM: 2x4GOCG: Gigabyte GeForce GTX 560
Mais je boot toujours sur windows et Grub ne se lance pas
j'ai essayé de réinstaller grub depuis une session l... |
I have the following table:
==========================================================| Name_Level_Class_Section | Phone Num |==========================================================| Jacky_1_B2_23 | 1122554455 || Johnhy_1_B2_24 | 1122554455 || Peter_2_A5_3 | 1122554455 |==============================================... |
How can I programmatically (i.e., not using e.g. vi) convert DOS/Windows newlines to Unix?
The dos2unix and unix2dos commands are not available on certain systems, how can I emulate these with commands like sed/awk/tr?
You can use
tr -d '\015' <DOS-file >UNIX-file
Note that the name
You can't do it the other way round... |
Ras'
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
Hors ligne
ljere
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
voici le code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# auteur Gabriel Pettier
# license GPL V3 or later
# sert uniquement a compter le... |
There is a nice function that draws back to back histograms in Matlab. I need to create a similar graph in matplotlib. Can anyone show a working code example?
Thanks to the link pointed by Mark Rushakoff, following is what I finally did
import numpy as np
from matplotlib import pylab as pl
dataOne = get_data_one()
data... |
Here's a small python program that can do it:
import sys
def chunkCheck(fileObject, chunkSize=1024):
while True:
data = fileObject.read(chunkSize)
if not data:
return False
if data.strip("\0"):
return True
sys.exit(chunkCheck(open(sys.argv[1])))
And in action:
$ prin... |
Understanding Network I/O: From Spectator to Participant
by George Belotsky
11/06/2003
This series of two articles will show you how to participate in the global Internet. The architects of this greatest advance in communications since the printing press have strived to make such participation possible. The Internet is... |
We all know fibonacci series, when k = 2.
I.e.: 1,1,2,3,5,8,13
But this is the 2-fibonacci. Like this, I can count the third-fibonacci:
1,1,2,4,7,13,24
And the 4-fibonacci:
1,1,2,4,8,15,29
...and so goes on
What I'm asking is an algorithm to calculate an 'n' element inside a k-fibonacci series.
Like this: if I ask for ... |
Let me start off by saying, I'm not new to programming but am very new to python.
I've written a program using urllib2 that requests a web page that I would then like to save to a file. The web page is about 300KB, which doesn't strike me as particularly large but seems to be enough to give me trouble, so I'm calling i... |
Hey guys,
First of all, thanks for the 4.4 release! Very, very cool.
I grabbed the installer package from the site and everything went smoothly during compilation and install. I have not changed anything; I simply installed and restarted X. Also, I should add this is a brand new, fresh install of Slackware 11.0. The on... |
rodofr
Re : Voyager 12.04
Ah ! mais voyager n'est pas aussi parfaite que ça !!!:lol: Il y a toujours des erreurs et ainsi va le monde. C'est parfois un problème de droits mais je crois que c'est sur la 32 bits. Je l'ai déjà souligné sur le forum et sur astuces sur mon site.
Hors ligne
Tux35
Re : Voyager 12.04
Hello
Et ... |
raspouillas
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
Je ne faisait aucune allusion au problème de @souen.
Dernière modification par raspouillas (Le 15/06/2012, à 20:37)
ljere
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
alors voici la première partie du ... |
It just didn’t feel right to have KeySafe use a Windows-style INI file for its configuration so I started looking into using GConf instead.
I wrote this code for viewing the setting of the desktop background’s filename:
#! /usr/bin/python
import gtk
import gtk.glade
import gconf
class GConfViewer:
def __init__(self... |
Python programmers should be familiar with the following idiom:
>>> "A" * 3"AAA"
It can be used to create pre-allocated lists, mimicking arrays.
>>> [0] * 3
[0, 0, 0]
>>> [None] * 3
[None, None, None]
Thus, to a pre-allocated nested list, i.e. a 2-dimensional array representing a matrix, the first thing that came to m... |
In my application I use a function to show GtkInfoBars with a timeout (as described http://stackoverflow.com/a/1309257/406281) thanks to glib.timeout_add_seconds().
I understand that glib.timeout_add_seconds() is supposed to set a function to be called at regular intervals until said function returns False.
I'm not doi... |
Finally, I've found some time to do some improvements on this blog engine.
First thing which was more and more missing is reasonable content for description in HTML headers. This lead to sites like Google+ always fetch the constant text and that did not look that. So now, there is something really relevant to the conte... |
I am trying to run the code below to insert data stored in a CSV file into a MySQL table. The table has a MyISAM engine but I've also tried it with an InnoDB engine with the same results. The code runs without error with the output
Result set: ()DONE
and no data is written to the data table. If I set local_infile=0 I r... |
I am developing a small web application using cherrypy and I would like to generate some graphs from the data stored in a database. The web pages with tables are easy and I plan to use matplotlib for the graphs themselves, but how do I set the content-type for the method so they return images instead of plain text? Wil... |
Given two dictionaries, d1 and d2, and an integer l, I want to find all keys k in d1 such that either d2[k]<l or k not in l. I want to output the keys and the corresponding values in d2, except if d2 does not contain the key, I want to print 0. For instance, if d1 is
a: 1b: 1c: 1d: 1
and d2 is
a: 90b: 89x: 45d: 90
and ... |
I got this code:
myString = 'blabla123_01_version6688_01_01Long_stringWithNumbers'
versionSplit = re.findall(r'-?\d+|[a-zA-Z!@#$%^&*()_+.,<>{}]+|\W+?', myString)
for i in reversed(versionSplit):
id = versionSplit.index(i)
if i.isdigit():
digit = '%0'+str(len(i))+'d'
i = int(i) + 1
i = di... |
I know of the non-standard %uxxxx scheme but that doesn't seem like a wise choice since the scheme has been rejected by the W3C.
Some interesting examples:
The heart character. If I type this into my browser:
http://www.google.com/search?q=♥
Then copy and paste it, I see this URL
http://www.google.com/search?q=%E2%9... |
Python Decorators - Argumentos
Hoje estou dando continuidade ao post da semana passada, sobre Decorators em Python. Agradeço à todos que demonstraram interesse em saber mais sobre esse recurso da linguagem, que só agora está se tornando mais popular. Agradeço também àqueles que enviaram dúvidas por e-mail e peço que as... |
With Python's fractions module I can do something like:
>>> from fractions import Fraction
>>> import math
>>> target_number = str( 10 / math.pi )
>>> Fraction( target_number )
Fraction(39788735773, 12500000000)
But what should I do if I want a fraction in sixteenths? That is, Fraction(51, 16). Using limit_denominator... |
I'm looking for the number of integer partitions for a total N, with a number of parts S, having a maximum part that is exactly X, without enumerating all of them.
For example: all partitions of 100 that have 10 parts and 42 as the largest part.
I've found no theorems or partitioning identities that address this questi... |
PWhen I am trying to load something I dumped using cPickle, I get the error message:
ValueError: insecure string pickle
Both the dumping and loading work are done on the same computer, thus same OS: Ubuntu 8.04.
How could I solve this problem?
"are much more likely than a never-observed bug in Python itself in a functi... |
lines = []
lines.append('def print_success():')
lines.append(' print "sucesss"')
"\n".join(lines)
If you're building something complex dynamically:
class CodeBlock():
def __init__(self, head, block):
self.head = head
self.block = block
def __str__(self, indent=""):
result = indent + ... |
The underlying problem is that I am developing some Django, but on more than one host (with colleagues), all with different settings. I was hoping to do something like this in the project/settings.py file:
from platform import node
settings_files = { 'BMH.lan': 'settings_bmh.py", ... }
__import__( settings_files[ node... |
I am trying to get pyinstaller to work with a python script of mine which fails. So I tried a very basic script:
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import *
x=linspace(0,2*pi,200)
plot(x,sin(x))
show()
But this also fails with the error message below. I'm on a up-to-date Mountain Lion and... |
Topic: 500 Internal Server Error
I get the following:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done ... |
Pylades
Re : /* Topic des codeurs couche-tard [1] */
It works! \o/
Bon, alors, vous en pensez quoi ? On met le planeur ? Avant le titre ? Après ?
“Any if-statement is a goto. As are all structured loops.
“And sometimes structure is good. When it’s good, you should use it.
“And sometimes structure is _bad_, and gets int... |
I am a newbie to cython, so pardon me if I am missing something obvious here. I am trying to build c extensions to be used in python for enhanced performance. I have fc.py module with a bunch of function and trying to generate a .dll through cython using dsutils and running on win64:
c:\python26\python c:\cythontest\se... |
July 6th, 2012 at 12:52 am by Dr. Drang
If I were a little less anally retentive, it wouldn’t have bothered me that the timestamps in the tweet archive I generated from ThinkUp were off. But I am and it did. Some of the timestamps were right, some were off by one hour, some by five hours, and some by six hours. It drov... |
cracolinux
[script CLI]Surveillance de la température
Salut,
Pour surveiller les températures de mon PC, j'ai écris un petit script que j'utilise régulièrement avec un raccourci clavier.
Il me donne les températures processeur et chipset de la carte mère grâce à sensors
Pour ma carte graphique, une carte AMD/ATI, j'uti... |
I'm trying to make a list of all items in a binary search tree. I understand the recursion but I don't know how to make it return each value and then append it into a list. I want to create a function called makeList() that will return a list of all the items in my tree. All the functions in my programs work except the... |
omx.comp~ for noise gate… can't find the magic words
Is anyone successfully using omx.comp~ for noise gating?
A forum search revealed http://cycling74.com/forums/topic.php?id=26004 and this points to http://www.cycling74.com/docs/max5/tutorials/msp-tut/mspindex.html — many compression tutorials, and some mention of gat... |
My question is: What is it that makes those languages suitable? From what I know, they are slower than other languages, and operate at a higher abstraction level, which means they are too far from the hardware. The only reason I could think is because of their advanced string manipulation capabilities, but I believe th... |
lukophron
[python]Monsieur Cinéscript
Salut,
Suite à une demande, j'ai pondu un script python pour mettre à jour la liste des films trouvés sur le topic-jeu Quel film c'est ?
Ça tourne, ça remplit son objectif (et son deuxième objectif qui était de me remettre à apprendre Python ^^)
Maintenant, il y aurait mieux.
Je po... |
I am plotting the following data (stored as 'sample_bar_plot.csv' in C:\Plot):
X YA 12.60862266 13.88257739B 18.69422707 20.66625712C 13.54164413 18.49381352D 11.35545631 13.12407667E 9.979860808 11.33701054F 8.496320019 8.838461563G 11.94646631 16.28188825
Python code to draw horizontal output is as follows:
import nu... |
pops
logiciel d'animation en pixel art
Bonjour,
Je voulais vous présenter un petit logiciel d'animation en pixel art sur lequel je travaille depuis un peu plus d'un mois.
C'est encore très sommaire, mais il commence a être utilisable :
On peut dessiner avec des couleurs indexées, animer, il y a quelques brosse et on pe... |
JavaScript
hiyatran — 2011-08-24T22:56:44-04:00 — #1
I would like to display the elements in my array but it is NOT working. Here's my code:
<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
<script type="text/javascript">
function addtext() {
var openURL=new Array("http://google.com","http://yahoo.com","http://www.msn.com","... |
Why
SELECT Barraportfolioname
FROM portfolio
WHERE id IN (SELECT DISTINCT i1.portfolioid
FROM Import i1
LEFT OUTER JOIN Import i2
ON i1.PortfolioID = i2.PortfolioID
AND i2.ImportSetID = 82
WHERE i1.ImportSetID = 83
... |
CyrilouGarou
Création de miniatures pour dossiers d'artistes dans librairie amarok
Bonjour à tous,
Nous sommes nombreux à utiliser l'excellent amarok pour écouter notre zic.
Amarok permet de ranger sa collection de la façon suivante
(exemple de chemin pour la chanson hells bells d'ACDC)
/home/cyril/Ma\ Musique/A/AC_DC/... |
I wrote a very basic python script to port scan my system. I'm running linux-mint lisa:
open_ports = []
for port in xrange(65536):
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
conn.connect(('localhost', port))
open_ports.append(port)
conn.close()
except socket.error:... |
It should be possible to set up a separate database for the django-celery models using Django database routers:
https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#automatic-database-routing
I haven't tested this specifically with django-celery, but if it doesn't work for some reason, then it's a bug in django-ce... |
This is always possible, because you can emulate the call stack yourself. However, it's not always easy to do.
The easy cases are tail recursion: these don't even require a stack. For example, this guy is trivially converted into a for loop:
def countdown(n):
if n >= 0:
print n
countdown(n-1)
Even ... |
cracolinux
Re : [script/python] Télécharger les émissions quotidiennes de Canal+
Salut,
Bravo pour ton script qui fonctionne impeccablement !
Comment faire pour télécharger disons, le numéro 5 de la liste des GDI ?
Pixup : postez vos images vite et bien
« Ne devenez jamais pessimiste. Un pessimiste a plus souvent raiso... |
bowmore
Problème avec une HP Color LaserJet 4550N branchée en Ethernet .
Bonjour à tous.
J'essaye depuis quelques jour de faire fonctionner une imprimante HP Color LaserJet 4550N branchée en Ethernet sur un PC sous Lubuntu 12.04.
N'ayant pas de port USB sur l'imprimante, ni de port série sur ma carte mère, je n'ai que ... |
MEH-TECH
Re : [Support] Team Fortress 2
Je me disais aussi que c’était du pipo... Je me connecterai dans la soirée alors pour le récupérer
Merci
Hors ligne
MEH-TECH
Re : [Support] Team Fortress 2
C'est bon je l'ai reçu
Hors ligne
kurapika29
Re : [Support] Team Fortress 2
Bien le bonjour, chez moi depuis le début TF2 es... |
I've been working on the attacking in my RPG.The problem I have recently encountered is, I have to be in Exactly the same x coordinate as the Enemy. When I want to attack the enemy this is what happens:
...
elif event.key == pygame.K_SPACE:
attack = True
if attack == True:
if enx == x: #thi... |
Often times when we're drawing a GUI, we want our GUI to update based on the data changing in our program. At the start of the program, let's say I've drawn my GUI based on my initial data. That data will be changing constantly, so how can I redraw my GUI constantly?
The best way that I have found to do this is to run ... |
you can post row by row. using built in bulk loader.
http://code.google.com/appengine/docs/python/tools/uploadingdata.html
this is good article.
and here is my contactloader.py that i used 2 years ago for reference. it is more sophisticated since last i used but still.....
import datetime
from google.appengine.ext impo... |
Python is a multipurpose programming language: it is object oriented, is dynamic, can accomplish much in few lines of code, is syntactically clean and elegant, "fits the brain well," and is an excellent language for programmers of all ages and skill levels. These characteristics have contributed to building a loyal, kn... |
8.2 Git et les autres systèmes - Migrer sur Git
Migrer sur Git
Si vous avez une base de code dans un autre VCS et que vous avez décidé d'utiliser Git, vous devez migrer votre projet d'une manière ou d'une autre. Ce chapitre traite d'outils d'import inclus dans Git avec des systèmes communs et démontre comment développe... |
Enhanced Interactive Python with IPython
by Jeremy Jones
01/27/2005
Python is a multipurpose programming language: it is object oriented, is dynamic, can accomplish much in few lines of code, is syntactically clean and elegant, "fits the brain well," and is an excellent language for programmers of all ages and skill le... |
ogaby
Re : [ATTENTION] Faille de sécurité critique dans le noyau Linux !
vi...
Avec cette simple ligne, on peut bénéficier des mises-à -jour de sécurité plus rapidement que sur un dépà´t européen. Je dis "européen" car je vis en Allemagne et mon dépà´t "normal" n'a pas encore cette mise-à -jour.
Hors ligne
zappinggg
Re... |
Django 1.1.2 & Python 2.6.5
I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix for this bug. Has anybody dealt with something similar before?
Here... |
testing stuff
testing things out right now.... be patient please
Pages
Archives
Blog Stats
20,223 somethings
pyHandset
Hex-dump port-forwarding network proxy server « Python recipes « ActiveState Code
Proxy and Port Mapping With Python | Fred Chu
tsb.py - a telnet to serial bridge
M2M:Telit 865 modem- data to PC
Smartp... |
I am having a hard time figuring out what I'm doing wrong, so I thought I would ask this at SO. I am trying to automate a measurement task (Qualcomm QXDM), hence would like to access the COM interface exposed by a measurement tool. I wrote the following python code with works perfectly:
from comtypes.client import Crea... |
I like to think I'm not an idiot, but maybe I'm wrong. Can anyone explain to me why this isn't working? I can achieve the desired results using 'merge'. But I eventually need to join multiple Pandas DataFrames so I need to get this method working.
In [2]: left = pandas.DataFrame({'ST_NAME': ['Oregon', 'Nebraska'], 'val... |
i suggest using numpy for that you need to install it
On windows from this site :
http://sourceforge.net/projects/numpy/files/NumPy/
some example how you can use it .
import numpy as np
we will create an array , we name it mat
>>> mat = np.random.randn(2,3)
>>> mat
array([[ 1.02063865, 1.52885147, 0.45588211],
... |
I have a model that looks like this in part:
class Content(models.Model):
published = models.BooleanField(default=False)
public = models.BooleanField(default=False)
My search index inherits from CelerySearchIndex:
class ContentIndex(celery_haystack_indexes.CelerySearchIndex, indexes.Indexable):
When SearchInd... |
I'm new to Python,
After initialising an instance f of class Fraction, I want the method reduce has been invoked, so the print result is after reduced
f = Fraction(3,6)
print f #=> 1/2 not 3/6
here's the code:
class Fraction(object):
'''Define a fraction type'''
def __init__(self, num=0, denom=1):
'''C... |
Tony95
Re : Ella : projet de logiciel d'animation Flash & SVG pour Linux
Salut à tous je savais pas trop où poster donc je le fais ici. J'ai un petit soucis en GTK, j'aimerais créer une interface permettant de charger et sauvegarder des fichiers mais j'arrive vraiment pas à m'en sortir pour le code. En gros j'ai une fe... |
Hey everyone I am seeing this when I press Ctrl-C to exit my app
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function
p.join()
... |
I have a python module that defines a number of classes:
class A(object):
def __call__(self):
print "ran a"
class B(object):
def __call__(self):
print "ran b"
class C(object):
def __call__(self):
print "ran c"
From within the module, how might I add an attribute that gives me all of... |
EDIT: I've found a bug in the code; Now the result looks a lot better, too.
This isn't perfect, but it's a start.
The first step is to find the "chain elements" (what are those anyway? I'm guessing cells?)
The chain elements have a distinctive scale, so I can filter them out easily using a median filter:
Subtracting th... |
I am trying to use IMAP and it does not work. I tried the same with 'https' and it worked.
require 'net/imap'
=> true
irb(main):002:0> Net::IMAP.new("xxx", 993, true).login("redmine", "redmine")
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
... |
I am trying to produce a set of plots using grispec. There should be 5 rows and 2 columns. There should be an images shown in each of the axes (using imshow) in the top four rows. In the bottom left axes I want to show/plot some text. However, the text seems to be too long to be displayed in one line. Is there a way to... |
I'm implementing a simple code that calculates the distance between a point (x_a, y_a) in list_A and all points (x_b, y_b) in list_B and returns the minimum distance found. This is repeated for all points in list_A.
A MWE of my code:
# list_A points defined in array.
list_A = np.array([
[x_data_a, # x
y_data_... |
This is a guest post by Hendrik Bunke of the EDaWaX project, cross posted from the project blog. EDaWaX is a German project which aims to greatly increase the amount of research data in Economics that is made open.
One aim of EDaWaX is to develop and implement a web-platform prototype for a publication-related research... |
import os
import sys
import time
import base64
import hmac
import mimetypes
import urllib2
from hashlib import sha1
from poster.streaminghttp import register_openers
def read_data(file_object):
while True:
r = file_object.read(1 * 1024)
print 'rrr',r
if not r:
print 'r'
... |
ZePhYmA
Installation de sublime Text
Bonsoir,
J'aimerais installer Sublime Text, mais après divers essais je n'y arrive toujours pas. Le problème est que le logiciel ne semble pas trouver la bibliothèque Python. Pourtant j'ai fais très exactement ces trois commandes : http://minitoolkit.net/softs/installer_ … ext_2.htm... |
how can I declare initial value of radio button?
form.py
YESNO = (
('Yes','Yes'),
('No', 'No'),
)
class MyForm(forms.Form):
like = forms.ChoiceField(widget=forms.RadioSelect, choices=YESNO)
myhtml.html
{{form.like}}
i try to put:
like = forms.ChoiceField(widget=forms.RadioSelect, choices=YESNO, initial={'Y... |
I run a Slackware system and I'm trying to run some Python code, but getting a lot of errors such as this one below:
>>> import urllib2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/urllib2.py", line 91, in <module>
import hashlib
File "/usr/lib/python2.6/hash... |
I'm trying to set speed limits on downloading/uploading files and found that twisted provides twisted.protocols.policies.ThrottlingFactory to handle this job, but I can't get it right. I set readLimit and writeLimit, but file is still downloading on a maximum speed. What am I doing wrong?
from twisted.protocols.basic i... |
henry-006
Re : [script] Pixup : Poster une image rapidement sur un forum
ah désolé, moi ch'suis allé direct dans la logithèque, comme un bon bourrin,
OS: Ubuntu 12.10 (Quetzal quantal ) 64 bits + Windows XP pro SP2 x32 en double boot
PC Medion / Processeur: Intel core2 Duo (CPU 2.80GHz) Mémoire vive:3029 MiB
Carte Grap... |
I originally thought Python was a pure pass-by-reference language.
Coming from C/C++ I can't help but think about memory management, and it's hard to put it out of my head. So I'm trying to think of it from a Java perspective and think of everything but primitives as a pass by reference.
Problem, I have a list, contain... |
siscard
Re : Open Office, Reconnaissance de caractères, Xsane, Kooka et Cie...
L'erreur de segmentation est revenue comme elle avait disparue.
Si quelqu'un a une idée, je suis preneur.
Tout ce que j'ai trouvé, c'est que le logiciel essaie d'utiliser un espace de mémoire qui ne lui est pas attribué; alors cela provient ... |
I want to remove from the SCons log the long compiling/linking commands.
I followed what is written on this page : http://stackoverflow.com/questions/890142/what-do-you-do-to-make-compiler-lines-shorter
Here is exactly what I did :
AddOption("--verbose", action="store_true",
dest="verbose_flag", default=Fals... |
Introduction
The Python binding for XCB allows the X protocol to be accessed directly from Python. There are two components:
A Python extension written in C. This exposes XCB-specific objects and library functions, as well as providing various base classes used by the generated code.
Python modules which are generated ... |
So I was thinking about variations on the Dining Cryptographers problem - In some cases, it's useful to be able to post a message without revealing the source, but with the additional constraint of not revealing the entire group to one another.
For instance - Let's say you have 20 members in a ring. Each single member ... |
I have a UIScrollView and I wanted the frame height to adjust proportionally when I adjust the width, is this possible? Basically I am talking about auto adjusting the frame height of the UIScrollView when I adjust the width of the UIScrollView? I have tried setting the autoResizingMask to UIViewAutoresizingFlexibleWid... |
AuthorPosts
June 17, 2013 at 4:25 pm #24939
Hey,
I would like to change the english text to danish on this page, such as you are here, home, reply etc. How do I do that?
My website link is http://col323webdesign.dk/projekt51/indlaeg/indlaeg/
Mika
June 18, 2013 at 6:22 am #125241
Hi,
You are here: // Home
Edit framework... |
J.M.'s comment points you in the direction of why this doesn't work. Iterating $x^7$ 50 times (even if $k=0$) is $(x^7)^{50}$.
(x^7^50)
(* x^1798465042647412146620280340569649349251249 *)
That exceeds the maximum number representable in Mathematica:
In[1]:= $MaxNumber
Out[1]= 5.297557459040040*10^323228467
Even if we ... |
I have to create an "Expires" value 5 minutes in the future, but I have to supply it in UNIX Timestamp format. I have this so far, but it seems like a hack.
def expires():
'''return a UNIX style timestamp representing 5 minutes from now'''
epoch = datetime.datetime(1970, 1, 1)
seconds_in_a_day = 60 * 60 * 2... |
I believe I figured out a way to reduce a few redundant lines from my controller methods. I’m looking for opinions about whether this is a wise idea.
At the top of nearly every method in my controllers, I look up the current user and the hospital this user belongs to, sort of like this:
@expose('.templates.m1')
... |
Gaara
barre de progression sur notification en root [finalisé]
Bonjour,
J'essaie de me faire un petit script qui me prévient avec une notification quand mes mises à jours sont effectuées, en utilisant unattended-upgrades.
J'ai réussi à le faire fonctionner avec yad, mais c'est pas très joli. Je voudrais donc utiliser n... |
Pylades
Re : /* Topic des codeurs couche-tard [1] */
It works! \o/
Bon, alors, vous en pensez quoi ? On met le planeur ? Avant le titre ? Après ?
“Any if-statement is a goto. As are all structured loops.
“And sometimes structure is good. When it’s good, you should use it.
“And sometimes structure is _bad_, and gets int... |
I have a model called Answer which has a ForeignKey relationship to another model called Question. This means there can be several answers to question, naturally.
class Question(models.Model):
kind = models.CharField(max_length=1, choices=_SURVEY_QUESTION_KINDS)
text = models.CharField(max_length=256)
class Ans... |
I've recently started a project at working using the Play Framework and while its a great framework, I was having a lot of trouble with some of the simplest tasks. I wouldn't blame Play for my problems, returning to Java after a long hiatus, being spoiled by dynamicly typed languages, and lack of documentation really m... |
FelixP
[Résolu] Sources de Logiciels ne veut plus démarrer…
Salut ! Je reposte mon problème car il semblerait que mon ancien post soit tombé dans les abîsses…
Lorsque je veux ouvrir la liste des sources de logiciels, j'obtiens une erreur…
Ce problème est apparu, je crois, après ajout du dépot permettant d'installer cam... |
I propose this one:
First, like unutbu, I would use numpy.array to build list
import numpy as np
count_array = np.array([('foo',2),('bar',5),('baz',0)], dtype = np.object)
Then, I sort using operator.itemgetter:
import operator
newlist = sorted(count_array, key=operator.itemgetter(1))
which means: sort count_array w.... |
Python, simplest:
def a(n):
if n == 0: return 1
return 1 - 1 / float(a(n-1) + 3)
# limit is sqrt(3) - 1
limit = 3.0 ** 0.5 - 1.0
# get 9 digits' precision
i = 0
while abs(a(i) - limit) > 1.0e-9:
i += 1
print i
This emits 8, suggesting that optimizations such as recursion elimination or memoizing are likely not w... |
If you can adapt your solution, telnetlib seems like the right way to do it -- +1 to xitrium.
That said, though, if you're dead set on piping the output of telnet into your Python script, it'll be coming in on standard in. That means you can do something like this:
try:
while True:
line = raw_input()
... |
I basically have the same setup as in this example. With the .source code and picture of the output below
import numpy as np
import matplotlib.pyplot as plt
box = dict(facecolor='yellow', pad=5, alpha=0.2)
fig = plt.figure()
fig.subplots_adjust(left=0.2, wspace=0.6)
ax1 = fig.add_subplot(221)
ax1.plot(2000*np.random.ra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.