text
stringlengths
256
65.5k
03.10 The Nuit du Hack CTF 2013 Quals round was taking place yesterday. As usual, I’ll be posting a few writeups about fun exercises and/or solutions from this CTF. If you want more, my teammate w4kfu should be posting some writeups as well on his blog soon. TL;DR: auth(''.__class__.__class__('haxx2',(),{'__getitem__':...
Is there a list somewhere of recommendations of different Python-based REST frameworks for use on the serverside to write your own RESTful APIs? Preferably with pros and cons. Please feel free to add recommendations here. :) Something to be careful about when designing a RESTful API is the conflation of GET and POST, a...
In creating a Windows PDF generation app for a client of mine, I ran into a limitation of py2exe which prevents resource loading with pkg_resources. The module attempts to load resources from py2exe’s library.zip. As the zipfile is reserved for compiled bytecode, there’s no option to copy files into it. You can copy fi...
Until django 1.2.5 i could use the following code to create a user for testing and then log it in: class TestSomeLoginRequiredView(TestCase): urls = 'sonloop.tests.test_urls' def setUp(self): self.user = User.objects.create(username='testuser',password='some_password') def test_the_view(self): ...
I am new to machine learning in python, therefore forgive my naive question. Is there a library in python for implementing neural networks, such that it gives me the ROC and AUC curves also. I know about libraries in python which implement neural networks but I am searching for a library which also helps me in plotting...
If possible, can someone please review my code? Especially the use of the Global variables, indentation and comments. This is my first attempt at Python and it took me a month to come up with this. At lot of time was spent on matplotlib. A lot of answers I got from Stack Overflow. This program displays, either the time...
Suppose i have : models.py: class Person(models.Model): user = models.OneToOneField(User) def get_album(self): return self.album_set.all() class Album(models.Model): user = models.ForeignKey(Person) photo = models.ImageField(upload_to = 'blahblah') api.py: class PersonResource(ModelResource): ...
Hizoka Re : [glade2script-GTK2] Interface graphique pour script bash ou autre. bah le principe en lui même je le pige. mais c'est son application où j'ai du mal. Il va falloir que je me penche bien sur tes exemples. Hors ligne frafa Re : [glade2script-GTK2] Interface graphique pour script bash ou autre. CouCou ! oulah ...
What's a good way to list a "Contact Us" email address on a web site, while reducing the likelihood it will get spammed? Is putting the email address in an image the best technique, or are there others? I pass all contact forms through a throwaway Gmail account, that forwards mail to the real email address. It's free, ...
I have the following code, where most of the code seem to look awkward, confusing and/or circumstantial, but most of it is to demonstrate the parts of the much larger code where I have a problem with. Please read carefully # The following part is just to demonstrate the behavior AND CANNOT BE CHANGED UNDER NO CIRCUMSTA...
I am writing a encrypting/decrypting program and I am having trouble with the decryption process: phrase = 'WHO WATCHES THE WATCHERS' def chunker(seq, size): return (seq[pos:pos + size] for pos in xrange(0, len(seq), size)) # Thanks to http://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-itera...
How add custom field dynamicly? I'm trying that, but the field won't insert into database when I sync db: #It use as register(MyModel) def register(model, attr="my_attr"): if model in registry: raise AlreadyRegistered( _('The model %s has already been registered.') % model.__name__) registry...
Python Scripts as a Replacement for Bash Utility Scripts Often in Python scripts that are used on the command line, argumentsare used to give users options when they run a certain command. Forinstance, the head command takes a-n argument that takes the numberfollowing it and prints only that number of lines. Each argum...
Anarcheon Perte d'éléments suite à utilisation de compiz Bonjour à tous, Utilisateur relativement récent d'Ubuntu (<1 an), j'ai voulu faire mumuse avec compiz. J'essaie d'installer le cube et quelques autres "décorations", mais finis par me rendre compte que c'était aussi bien avant, et que j'irai bidouiller un peu plu...
What is the star operator doing to the input argument list in this example? def main(name, data_dir='.'): print 'name', type(name) if __name__ == '__main__': main(*sys.argv) Concretely, if I run the program with the star operator it prints: name <type 'str'> if run without the star main(sys.argv) it prints: na...
Class: Hitimes::Stats Inherits: Object Object Object Hitimes::Stats Defined in: lib/hitimes/stats.rb, ext/hitimes/hitimes_stats.c Overview The Stats class encapulsates capturing and reporting statistics. It ismodeled after the RFuzz::Sampler class, but implemented in C. For generaluse you allocate a new Stats object, a...
Altre ricette Aggiornamenti Nella pagina "site" dell'interfaccia amministrativa è presente un pulsante "upgrade now". In caso che questa opzione non funzioni (per esempio a causa di un lock su un file) l'aggiornamento manuale di web2py è comunque estremamente semplice: Decomprimere l'ultima versione di web2py sull'inst...
The tkList Widget Wrapper Fredrik Lundh | March 2008 The tkList module is a simple wrapper for the Tkinter Listbox widget, which provides a somewhat more convenient API. The wrapper adds two things: a vertical scrollbar, and a list-based API for populating and querying the widget. When adding data to the widget, the AP...
This series of articles by David Mertz assumes readers have a familiarity with basic object-oriented programming concepts: inheritance, encapsulation, and polymorphism. We pick up where the basics leave off; how some "exotic" techniques can make applied programming tasks easier, more maintainable, and just plain more e...
I'm trying to imeplement an edit formset. Then, i'm instancing the objects in the formset using modelformset_factory. When the request isn't POST, the formset loads perfectly, but, if the request is POST, the formset constructor raises a MultiValueDictKeyError. This is my code. forms.py class SchoolSectionForm(forms.Mo...
How can I extract elements in a list of lists and create another one in python. So, I want to get from this: all_list = [['1 2 3 4','2 3 4 5'],['2 4 4 5', '3 4 5 5' ]] a new list like this: list_of_lists = [[('3','4'),('4','5')], [('4','5'),('5','5')]] Following is what I did, and it doesn't work. for i in xrange(len(a...
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? The "dis" module disassembles the byte code for a function and is useful to see the difference between tuples and lists. In this case, you can see that accessing an element generates identical code, bu...
gtk.Action — an action which can be triggered by a menu or toolbar item (new in PyGTK 2.4) class gtk.Action(gobject.GObject): gtk.Action(name, label, tooltip, stock_id) def activate() def block_activate() def block_activate_from(proxy) def connect_accelerator() def connect_proxy(proxy) def c...
Today I needed to send email from a Python script. As always I searched Google and found the following script that fits to my need. import smtplib SERVER = "localhost" FROM = "sender@example.com" TO = ["user@example.com"] # must be a list SUBJECT = "Hello!" TEXT = "This message was sent with Python's smtplib." # Prepar...
I'm working through Learn Python the Hard Way, and trying to understand it rather than just hammer away. I got stuck on Exercise 16, as discussed already on SO here: but I'm still trying to figure out why this approach does not work: from sys import argv script, filename = argv print "Attempting to open the file now." ...
<div class="container"> <article> Sed posuere consectetur est at lobortis. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Nullam quis risus eget urna mollis ornare vel eu leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras mattis consectetur purus sit...
adelmorsux Bug Radio tray... Bonjour à toutes et tous, Sur QQ 12.10 beta depuis 15 jours et apres qqes bidouilles je voulais retrouvé toutes mes radios que j’écoute sur Radio tray et là.... rien... En faite si, j'ai tester l'install via la logiteque puis sous console et même résultat RIEN moi@moi:~$ sudo apt-get instal...
I've been having some difficulty pulling information from multiple foreign keys and getting that information to display in the django admin. I have four models: Subject, Study, Procedure, and Event. The first three are foreign keys to the last. I want information from each to display in the admin for Event as such: las...
I'm currently writing an AI assignment for class, and each time I try to debug (using ipdb or pdb) pdb closes immediately. The program takes a map as input, and right now I'm just piping the text file in and grabbing the lines from stdin. python value_iteration.py < l_track.txt This works fine, but I think it's causing...
Bybeu [résolu] Problème veille carte nvidia 4200 nvidia96 EDIT 27 mars 2013: j'ouvre un nouveau fil ici: http://forum.ubuntu-fr.org/viewtopic.php?id=1210781 Bonjour Mon portable 12.04 plante en sortie de veille; J'ai essayé sudo s2ram -n Machine matched entry 222: sys_vendor = 'Dell Computer Corporation' sys_...
I'm playing with codingbat.com, and I found this really easy problem to solve, so I started trying to play newbie code golf. Given a non-empty string and an int n, return a new string where the char at index n has been removed. The value of n will be a valid index of a char in the original string (i.e. n will be in the...
Im using the pytz module to translate a date in America/Los_Angeles timezone to utc by the code below : TZ = 'America/Los_Angeles' from = pytz.timezone(TZ) utc = from.localize(original_date).astimezone(pytz.utc) Now,i want to test if utc value is actually in UTC format or not. How to do that with pytz or datetime ? Pl...
If you don't care about sub strings than a simple >>> 'a short sized string with spaces '.split() Performance: >>> s = " ('a short sized string with spaces '*100).split() " >>> t = timeit.Timer(stmt=s) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 171.39 usec/pass Or string module >>> from s...
I have used RSS Feed with django, I have refer the below link https://docs.djangoproject.com/en/dev/ref/contrib/syndication/ And properly created the RSS, but Now I want to add the favicon for the RSS feeds pages. Can anybody suggest me? Thanks. My code is: In feeds/feed.py class LatestArticlesFeed(Feed): title='Ne...
I am using the following script to create some rss snapshots (just saying). The script runs on a backend and I am having some very heave ever increasing memory consumption. class StartHandler(webapp2.RequestHandler): @ndb.toplevel def get(self): user_keys = User.query().fetch(1000, keys_only=True) ...
n3o51 Re : ADesk Bar : Barre de lancement rapide [python/gtk/cairo] Ah ok je regarde ça merci, bone je n'arrive pas as avoir les options du plugins c'est ou ? je clique dessus est pas possible de modifier Dernière modification par n3o51 (Le 08/02/2012, à 21:10) Welcome to the real world ________________________________...
Generated by Cython 0.13 on Mon Dec 6 17:15:04 2010 Raw output: matmult.c 1: # cython: profile=True /* "/home/skipper/statsmodels/statsmodels-skipper/scikits/statsmodels/tsa/kalmanf/matmult.pyx":1 * # cython: profile=True # <<<<<<<<<<<<<< * from numpy cimport float64_t, ndarray, NPY_DOUBLE, npy_intp * ci...
Marquee = str.title Or, for backward compatibility with old versions of Python: import string Marquee = string.capwords For a class which does the same thing: class Mar: quee = str.title Marquee = Mar.quee Or, marginally more seriously: class MarqueeClass(object): def __call__(self, s): return s.titl...
I can get a list of instlled applications but how do I get the status using Jython? I dont think there is any direct method to get the application running status, You can get the object from the AdminControl using the following code serverstatus = AdminControl.completeObjectName('type=Application,name='your_application...
metalux Re : [Script] Mise à jour automatique pour tous les paquets (y compris PPA) Salut linuxm@c, Pour la notification, Gaara est le mieux placé et a fait un travail remarquable. Le mieux est de poster sur la discussion ouverte à ce sujet: https://forum.ubuntu-fr.org/viewtopic.php?id=1507071 j`aimerai que vous: - ajo...
I have 3 different pages and only the first one includes a little bit more logic and variables at the moment. When I am testing slider with my Nexus 7 I got this: 07-24 09:36:01.363: D/Cordova(10976): onPageFinished(file:///android_asset/www/index.html#/android_asset/www/testSlider.html) 07-24 09:36:01.363: D/CordovaWe...
I want to fix problem reported by valgrind: ==7182== Conditional jump or move depends on uninitialised value(s) ==7182== at 0x40EC75C: strstr (in /lib/libc-2.9.so) ==7182== by 0x804A977: search_graph_begin (compression.c:462) ==7182== by 0x804AB60: search_graph_end (compression.c:497) ==7182== by 0x804AA97:...
Here is my Python implementation of a simple fractions class: class frac: def __init__(self, a,b): self.a = a self.b = b def __add__(self, x): return frac(self.a*x.b + self.b*x.a, self.b*x.b) def __mul__(self, x): return frac(self.a*x.a, self.b*x.b) def __sub__(sel...
Gnome desktop application framework based on Webkit, HTML5, CSS3, Javascript and Python "AppKit" will be a framework for gnome desktop application powered by WebKit engine, which means we can bring web technology such as HTML5, CSS3, Javascript and Web browser engine to desktop. Linux, Gnome $ pip install appkit $ pip ...
I have a function which returns a list of tuples, that I would like to iterate through: def get_parameter_product(num_parameters, lower_range, upper_range): param_lists = [ xrange(lower_range, upper_range) for _ in xrange(num_parameters)] return list(itertools.product(*param_lists)) for p in get_parameter_pr...
I have a django listener that sends an email. It works perfectly under normal circumstances, but when it is triggered by AJAX, I see this error on the console: [Errno 32] Broken pipe I am using python manage.py runserver to test it, hence the error on the console. My suspicion is that because it only happens when the A...
Asynchronous I/O Asynchronous I/O is a technique specifically targeted at handling multiple I/O requests efficiently. In contrast, threads are a general concurrency mechanism that can be used in situations not related to I/O. Most modern operating systems, such as Linux and Windows, support asynchronous I/O. Asynchrono...
I'm trying to use Matplotlib & Python in Xcode to generate scientific graphics. My boss would like them to be in LaTeX with matching fonts. I know you can modify the fonts in python with something like this: from matplotlib import rc rc('font',**{'family':'serif','serif':['Computer Modern Roman']}) rc('text', usetex=Tr...
I'm building a new web app that has a requirement to generate an internal short URL to be used in the future for users to easily get back to a specific page which has a very long URL. My initial thoughts are to store a number in a database and output it in a HEXADECIMAL value to keep it shorter than an integer. TinyURL...
So I have an array (it's large - 2048x2048), and I would like to do some element wise operations dependent on where they are. I'm very confused how to do this (I was told not to use for loops, and when I tried that my IDE froze and it was going really slow). Onto the question: h = aperatureimage h[:,:] = 0 indices = np...
I have a class I use to "split" a string of SQL commands by a batch separator - e.g. "GO" - into a list of SQL commands that are run in turn etc. ... private static IEnumerable<string> SplitByBatchIndecator(string script, string batchIndicator) { string pattern = string.Concat("^\\s*", batchIndicator, "\\s*$"); ...
maltamirano wrote: Can I modify iRedAdmin-Pro LDAP code to access filesystem and remove folders? Please, point out which file/files should be modified. I'm not a Python geek, but understand MVC architecture and can code... Alright, here we go: *) WARNING: Please test your code on a testing machine first, don't do it on...
I'm trying to parse some Json, my code goes like this: Json = '{"status":"Success", "resultsMethod":"database", "lastScrape":"2012-05-28 00:03:52", "domainCount":"45", "remoteAddress":"www.digg.com", "remoteIpAddress":"64.191.203.30", "domainArray":[["567gu.com", ""], ["64.191.203.30", ""], ["64.191.203.30.", ""], ["be...
I'm making a pong game for my software development class, and I should probably state that this is homework, hence my limited understanding. and I'm having some problems creating the AI for my NPC paddle. I'm using Kivy and Python. Currently I can create impossible to beat AI by doing this: #ai self.player2.center_y = ...
Using NISTNet The way you'd usually use NISTNet is to install the software on a Linux-based router installed in your test environment. The router would have a number of network interfaces configured. For example, you might have two Ethernet interfaces configured, each supporting a different IP network. You'd place your...
What are metaclasses? What do you use them for? A metaclass is the class of a class. Like a class defines how an instance of the class behaves, a metaclass defines how a class behaves. A class is an instance of a metaclass. While in Python you can use arbitrary callables for metaclasses (like Jerub shows), the more use...
O'Reilly Book Excerpts: Python Cookbook, Second Edition Cooking with Python, Part 2 Editor's note: If you missed recipes from part one of this two-part series of excerpts from Python Cookbook, 2nd Edition, then you missed how to handle international text with Unicode, and how to select elements from an unsorted sequenc...
UPDATED: Changed to simpler python script I have a website hosted in Google App Engine which is mostly static. Now I have a python script that would return a list of files under a specific folder in the server. I need this list of files in JavaScript. helloworld.py import webapp2 class MainPage(webapp2.RequestHandler):...
I. Introduction▲ Cet article va vous apprendre à utiliser les bases de données avec PureBasic, et principalement SQLite. L'interface graphique et le code le gérant ne seront pas expliqués. Mais qu'est ce donc que SQLite ? SQLite est un gestionnaire de base de données sans serveur, utilisant un fichier comme stockage. I...
I'm trying to read an XML file into a numpy record array. Times are in Zulu time, u'2013-06-06T17:47:38Z', and the other columns are floats. The times and the floats can both be converted into numpy arrays, but if I try to make a recordarray, it fails in a variety of ways (which probably indicate that I don't know how ...
malbo Re : Windows 8.1+Ubuntu... Ton Boot-Info est là : Boot Info Script e7fc706 + Boot-Repair extra info [Boot-Info 27Sep2013] ============================= Boot Info Summary: =============================== => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 175118912 of the same hard ...
Revision 3 - 2014-04-06 at 10:06:36 Home node for Alfamart official partner merchandise FIFA piala dunia Brazil 2014 TERMS & CONDITION Peraturan Lomba : Lomba dimulai tanggal 16 Januari - 16 April 2014 Penutupan Pendaftaran tanggal 16 April 2014 Pukul 17:00 WIB Pemenang akan diumumkan pada tanggal 5 Mei 2014 Penyerahan...
Cooking with Python, Part 1 Pages: 1, 2 Recipe 5.10: Selecting the nth Smallest Element of a Sequence Credit: Raymond Hettinger, David Eppstein, Shane Holloway, Chris Perkins Problem You need to get from a sequence the nth item in rank order (e.g., the middle item, known as the median). If the sequence was sorted, you ...
Update (Sept. 28, 2012): the method for archiving tweets using IFTTT and Dropbox describe here no longer works thanks to Twitter cutting off IFTTT’s access for anything except posting tweets to Twitter. I am looking into alternatives, but don’t know of any drop-in replacements currently. Justin Blanton recently posted ...
You can work it out with a recursive algorithm. I'm not sure if there is a neater way, for example with a closed formula - you have to account for the different numbers of doughnuts of each type at some point. The line of thinking goes like this: if you look at the first type of doughnuts, you can choose freely how man...
I need to strip the character "'" from a string in python. how do I do this? I know there is a simple answer. Really what I am looking for is how to write ' in my code. for example \n = newline. As for how to represent a single apostrophe as a string in Python, you can simply surround it with double quotes ( To remove ...
gtk.glade.XML — Allows dynamic loading of user interfaces from XML descriptions. class gtk.glade.XML(gobject.GObject): gtk.glade.XML(fname, root=None, domain="", typedict={}) def signal_connect(handler_name, func) def signal_autoconnect(dict) def get_widget(name) def get_widget_prefix(name) def ...
Initially I installed Python 3.3 from source, but then I removed and deleted the directory /usr/lib/python3.3. When I am installing it using aptitude, I am getting this error. Unpacking python3.3 (from .../python3.3_3.3.1-1ubuntu5_i386.deb) ... Processing triggers for man-db ... Processing triggers for bamfdaemon ... R...
For academic purposes, I am creating software that can manage a company's clients, project, and staff members. I figured out that by referencing a foreignkey in a separate model, you can get two models to display next to each other and be related. The problem is, is that it only displays one item for each model. For ex...
The windows version is a self-extracting zip file. You can get the files by: unzip ti83pkeys.exe Archive: ti83pkeys.exe inflating: Ti83keys.txt inflating: TI83____.PFB inflating: TI83____.PFM inflating: TI83____.TTF inflating: README.TXT You can t...
I'm writing a reproducible paper, and the paper has computational results that are generated by a Python script (a similar MATLAB script generates nearly identical results). I feel that the paper would be easier to understand for readers if they could match up the calculations in the paper with calculations in the code...
How do you generate passwords? Random Characters? Passphrases? High Ascii? Something like this? cat /dev/urandom | strings Mac OS X's "Keychain Access" application gives you access to the nice OS X password generator. Hit command-N and click the key icon. You get to choose password style (memorable, numeric, alphanume...
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. Find the...
I am looking for code to automatically generate lots of colorful unicorns. I would also like to randomly generate clouds and rainbows in the image. How does one go about automatically generating meaningful images? In python: from libutils import unicorns unicorns.generate() There you go: I just published the code. Thi...
Of the implementations of Fibonacci Fibonacci’s sequence My first post generated more interest than expected, but evenmore rewarding, some people pointed out some of my mistakes,corrected me, and actually taught me a couple of things. I’ll try to keep up the rythm and publish at least once a week. I’ve been asked once ...
I am doing some regression testing (changes to underlying database structures) where I'm lucky enough to two separate environments which should contain the same data. What I'd like to do is open a browser session in each environment and then have one browser mirror the other (ie I click on a control for example) so I c...
I want to execute code for an online-judge project. What are the defaults when creating a sandbox? Is it secure by default? I want to execute untrusted code and - Limit CPU - Limit Memory - Limit execution time - Allow read/write access only to a specific folder and limit the size of this folder. - Block network IO. - ...
if you are just trying to find the minimum number of moves and not necessarily a solution you can use the Frame–Stewart algorithm that you linked to earlier this builds up a solution to the number of moves to achieve a solution. def FrameStewart(ndisks,npegs): if ndisks ==0: #zero disks require zero moves ...
I’ve been reading Peter Harrington’s “Machine Learning in Action,” and it’s packed with useful stuff! However, while providing a large number of ML (machine learning) algorithms and sufficient example code to learn how they work, the book is a bit dry. So I’ve decided to make my contribution to democratizing ML by post...
Oni Re : [How-to] Desktop Screenlets Salut. Je viens de réinstaller screenlets. Lorsque je lance une musique avec Listen (mon lecteur par défaut), le module "Now Playing" me renvoie une erreur comme vous pouvez le voir sur la capture ci-dessous. J'ai installé le paquet "python-dcop" au cas où... mais même problème. Si ...
I'm trying to solve a two-dimensional random walk problem from the book, exploring python. But, I couldn't figure out how can I solve this problem.I made some research but those were too complicated to understand what is it about. I'm a beginner learner. So, I can't understand the code by looking it. Please explain me ...
aeacides Re : Ultimate Smash Friends: un smash bros like en python Kewl! Bon boulot! De mon côté il me reste une semaine et demi de labeur, et après je devrais pouvoir m'y mettre :- ) @+ http://www.q-be.ca Hors ligne tshirtman Re : Ultimate Smash Friends: un smash bros like en python cool . Mon petit frère (qui a dessi...
I am relatively new to Python and Python web application development. Currently I am creating a hello world application in Python using mod_wsgi Here are my configurations. Apache configuration <VirtualHost *:80> ServerName mysite.com DocumentRoot /var/www/mysite WSGIDaemonProcess mysite threads=5 WSGIS...
Silly hacks One thing that keeps me procrastinating about writing programs I have is doing up a user interface for them. It just seems like so much hassle writing GUI code or HTML, and if I just write for the command line, no one else will use it. Of course, most of the reason I don’t mind writing for the command line ...
inconnu Re : Petit guide pour aider au choix d'un langage Encore une fois merci pour toutes ces références (j'ai déjà trois bouquins de 300 pages à m'infuser ). Bon c'est quand même passionnant, dès fois un peu complexe, mais je suis globalement assez surpris de la qualité. Pour tout dire, je ne pensais pas qu'il exist...
I always got this question in my mind. How to run a command line within python, get the output and manipulates it. Before I learn python, I was doing bash scripts all the while to helps me manipulates text which I get it from log files, or pipes out from some certain command line. To do it in bash script is straight fo...
I have the following (simplified) models: class Donation(models.Model): entry_date = models.DateTimeField() class Category(models.Model): name = models.CharField() class Item(models.Model): donation = models.ForeignKey(Donation) category = models.ForeignKey(Category) I'm trying to display the total num...
I have a problem with dbus and python. Running python from the command line, telling it import dbus and then systembus = dbus.SystemBus() results in no errors, nor does running a program written by a friend which also uses the exact same code. However, when running a program I'm trying to write, I get this error: Trace...
I've written a complex search form in Django. Here is my example model: class student(models.Model): name = models.CharField(max_length=255) school = models.ForeignKey('school', null=True, blank=True) class school(models.Model): name = models.CharField(max_length=255) So student uses a FK for school. It shou...
CherryPy deliberately doesn't require you to subclass from a framework-provided base class so that you are free to design your own inheritance mechanism, or, more importantly, use none at all. You are certainly free to define your own base class and inherit from it; in this way, you can standardize handler construction...
Python 2.6+ - 334 322 316 characters 397 368 366 characters uncompressed #coding:l1 exec'xÚEPMO!½ï¯ i,P*Ýlš%ì­‰=‰Ö–*†­þz©‰:‡—Lò¾fÜ”bžAù,MVi™.ÐlǃwÁ„eQL&•uÏÔ‹¿1O6ǘ.€LSLÓ’¼›î”3òšL¸tŠv[ѵl»h;ÁºŽñÝ0Àë»Ç‡ÛûH.ª€¼âBNjr}¹„V5¾3Dë@¼¡•...
I am trying to follow an example from an online tutorial regarding basic client-server socket programming using standard Python libraries (version 2.7), but I cannot get the example to work under Windows (Vista). It works fine in Ubuntu 11.10, so I know that the following code at least works in a UNIX-based environment...
Python Standard Logging by Jeremy Jones 06/02/2005 Python 2.3 introduced the logging module to the Python standard library. logging provides a standard interface for outputting information from a running application. The classic example of a logging mechanism is writing data to a text file, which is a plain old log fil...
ElGatoNegro Re : Mettre en place un serveur HTTP en une ligne de commande @ Qid le script pour lancer le serveur, par clic droit dans le dossier à partager : #!/bin/bash #script-nautilus. Lance facilement un serveur HTTP dans le dossier en cours, pour partage en réseau. #nécessite zenity zenity --question --text="Ce do...
I'm trying to understand the numpy fft function, because my data reduction is acting weirdly. But now that I've transformed a simple sum of two sines, I get weird results. The peaks I have is extremely high and several points wide around zero, flattening the rest. Does anybody have a clue of what I might be doing wrong...
Another thing that makes using Python pleasing is decorators. A decorator is a wrapper for a function (or method) that takes a function (or method) as an argument and returns a new function (or…) which is then bound to the name for the original function. The newly-decorated function can then do things like checking the...
ProDy works quite well, especially from within an existing Python script. The following code takes an existing PDB file, performs some selection query on it, then saves it to another file. import prody def pdbsubset(inpdb, outpdb, selection): with open(inpdb) as protf: prot = prody.parsePDBStream(protf) ...
There's a program called granola which is theoretically used for energy saving. Instead of that, I use it for using the full speed of my CPU. To install it, if you're NOT using Quantal, just follow the instructions on the download page. Note it's freeware, to download it for free enter just $0 on the Custom Ammount tex...
In a framework like kivy, or any app using it it can happen that there is a bug that precise interaction is needed to reproduce, and it can be frustrating to manually test every time, sometime a complex or repetitive manipulation. Kivy has a not-so-well known module, called recorder that allows to record and replay use...
An Introduction to Haskell, Part 1: Why Haskell Pages: 1, 2 Writing this function in a more modern language like Java, C++ or C# isn't as odious, because automatic memory management takes care of the first half of this function. Writing the expression 'filter even [1..10]' in dynamic languages like Perl, Python and Rub...