text
stringlengths
256
65.5k
I got this error message Traceback (most recent call last): File "C:/Users/shengrong/Desktop/bigram", line 55, in <module> bg = bigram(file) File "C:/Users/shengrong/Desktop/bigram", line 43, in bigram return tt1.perplexity(my_bigrams) File "C:\Python27\lib\site-packages\nltk\model\ngr...
Suppose I had 2 lists that looked something like this: L1=['Smith, John, 2008, 12, 10, Male', 'Bates, John, 2006, 1, Male', 'Johnson, John, 2009, 1, 28, Male', 'James, John, 2008, 3, Male']L2=['Smith, Joy, 2008, 12, 10, Female', 'Smith, Kevin, 2008, 12, 10, Male', 'Smith, Matt, 2008, 12, 10, Male', 'Smith, Carol, 2000,...
I wrote a python code for getting random text into a .txt file. Now I want to send this random text into notification area via 'notify-send' command. How do we do that? We can always call #!/usr/bin/env python #-*- coding: utf-8 -*- import subprocess def sendmessage(message): subprocess.Popen(['notify-send', messag...
in curl i do this: curl -u email:password http://api.foursquare.com/v1/venue.json?vid=2393749 How i can do this same thing in python? Here's the equivalent in pycurl: import pycurl from StringIO import StringIO response_buffer = StringIO() curl = pycurl.Curl() curl.setopt(curl.URL, "http://api.foursquare.com/v1/venue....
I'm sort of a novice developer trying to expand my toolbox and learn some more tricks. I recently came across a pattern in Python called "decoration" and I was wondering if/how I could implement this in PHP as I have an existing PHP code base. Here is a short example of what I mean: import time def log_calls(func): ...
I want to query frames from the the middle of a video, beginning from some starting frame. Following OpenCV Seek Function/Rewind, I use CV_CAP_PROP_POS_FRAMES. To verify that it works as I expect, I seek to Frame 10 and print a slice from the image. Then I seek to Frame 10 again and print the same slice. In [1]: import...
You can do something like this: a = 360 * rand(5000) look_up = np.array([0, 1, 1, 2, 2, 3, 3, 0]) ind = (a//45).astype(np.int8) out = np.bincount(look_up[ind]) Basically you make a look-up array which has twice as many entries as you want bins (in your case). You than integer divide your values by half the bin spacing...
The following code (not directly in an interpreter, but execute as file) def top(deck): pass def b(): global deck produces the error SyntaxError: name 'deck' is local and global on python2.6.4 and SyntaxError: name 'deck' is parameter and global on python 3.1 python2.4 seems to accept this code, so does the 2....
here is my attempt: Example #1 class RevisionControlledValue(models.Model): created = models.DateTimeField(auto_now_add=True) created_by = models.ForeignKey(User) value = models.TextField() class Meta: ordering = ('-created', ) class DjangoPony(models.Model): names = models.ManyToManyField(R...
I'm having a very strange issue with Python's subprocess.Popen. I'm using it to call several times an external exe and keep the output in a list. Every time you call this external exe, it will return a different string. However, if I call it several times using Popen, it will always return the SAME string. =:-O It look...
Instead of words or numbers being the tick labels of the x axis, I want to draw a simple drawing (made of lines and circles) as the label for each x tick. Is this possible? If so, what is the best way to go about it in matplotlib? I would remove the tick labels and replace the text with patches. Here is a brief example...
I have wrote a basic web service using .net which I intend to use in a mobile app. It currently outputs Json however the structure it not quite what I need. The models I've created [DataContract] class PoiList { [DataMember] public List<Poi> Pois { get; set; } } [DataContract] class Poi { [DataMember] p...
nicky940 Re : Generateur de sources.list en Francais bonsoir je suis un nouvelle utilisateur d'ubuntu l'installation c'est dérouler a merveille version 9.10 jai depuis quelque temps un problème avec les mise jour qui m'indique un sens interdit qui m'indique ce message d'erreur :un problème irrémédiable est survenu pend...
Chris__ Re : gReemote, télécommande + prog TV pour Freebox HD Hmmm l'upload du fichier deb a raté... Désolé :-) Cette fois il a réussi Hors ligne tocks Re : gReemote, télécommande + prog TV pour Freebox HD Pour la barre sa fonctionne très bien. Moi aussi en regardant, je ne trouve pas vraiment d'endroit pour rajouter c...
The encoding error: print unicode(u'\xe4\xf6\xfc') The unicode() call does nothing here, since it's parameter is already a unicode object. print then tries to output that unicode object, and to do so print wants to convert it to a string in the encoding of your terminal. But python doesn't seems to know which encoding...
<TR VALIGN="bottom"> <TD BGCOLOR=#cc6600 ALIGN="center" ><FONT FACE="Verdana, Arial, Helvetica, sans-serif">1</FONT></TD> <TD BGCOLOR=#CC6600 ALIGN="left" ><FONT FACE="Verdana, Arial, Helvetica, sans-serif">Wachtell, Lipton</FONT></TD> <TD BGCOLOR=#CC6600 ALIGN="center" ><FONT FACE="Verdana, Arial, Helvetica, sans-seri...
popularexamples. Google Suggestions (now in production) and Gmail autocomplete logic would be implemented as a Trie (prefix tree). I could think of two ways this could be done using a Trie. The first wayis to DFS from the current prefix or node to get to all the possible words below. This approach is time-intensivedue ...
JavaScript paul_wilkins — 2013-04-26T23:39:48-04:00 — #1 While watching Nicholas Zakas' Maintainable JavaScript talk at the Fluent 2012 conference, there was a very informative section in there about keeping JavaScript separate from the HTML, and other similar concerns of separation. You can see it from the 25:40 secti...
patch a trigger hi can someone point me in a direction where i can find a variable trigger object To change the order of outputs of a trigger by a message sending a "patch 6 4 3 5 2 1" message to such obeject would bang the fifth outlet after the third – or before depending starting right or left … like this patch but ...
I'm not very satisfied with phonebook's ringtone assignment: they disappear sporadically and sometimes fail to play (default ringtone is played instead). Ideally I want an application that do this: Replaces usual phone ringtone player and listens for events. When there is incoming phone call, it starts my script (in Py...
#8526 Le 21/02/2013, à 22:33 The Uploader Re : Topic des Couche-Tard (cinquante-sept) Pas chez moi. Passer de Ubuntu 10.04 à Xubuntu 12.04 LTS ASUS N56VV (UEFI + GPT, Core i5-3230M @ 2.60GHz, Intel HD4000 + GeForce 750M, 12 Go de RAM, SSD 1 To) Système principal : Archlinux (amd64), avec KDE Système oublié la plupart d...
Pro-Tip: Use string.translate for the fastest string operations Python has. Some proof... First, the slow way (sorry pprzemek): >>> import timeit >>> S = 'Hey, you - what are you doing here!?' >>> def my_split(s, seps): ... res = [s] ... for sep in seps: ... s, res = res, [] ... for seq in s: .....
I'm having this annoying problem in Python 2.7, it won't let me do this numbers = raw_input(numbers + 1 + ': ') I want it to print out 'numbers + 1' as a number in the console but.. It comes up with this error message: Traceback (most recent call last): File "F:/Python/Conversation", line 25, in <module> numbers...
I currently have a client/server pair coded against PyBlueZ. Right now the server can connect to sequential clients - it will work until its completed with a client, then it will begin listening for another client. However, what I really want is to run client communication in separate threads so I have multiple clients...
It's a bird, it's a plane, no it is Guido Van Rossum and the App Engine Team. After cranking through writing an instructional application this weekend using Google App Engine, I have to say I am really impressed. In fact my exact thought are "Holy $!ck, this is awesome! If you haven't heard about Google App Engine yet,...
I have three lists of lists, and I'm trying to write a generator function to help me package up values in the same index. So my lists: list1 = [[1, 2, 3], [2, 3, 4],...]list2 = [[4, 5, 6], [5, 6, 7],...]list3 = [[8, 9, 10], [9, 10, 11],...] My desired output: result1 = [[1, 4, 8], [2, 5, 9],...]result2 = [[2, 5, 9], [3...
In SQLAlchemy Declarative, how do I set up default values for columns, such that transient or pending object instances will have those default values? A short example: from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tabl...
I am having a problem reading the logs of my Heroku app, please see the problem below: $heroku logs /usr/lib/ruby/1.9.1/net/http.rb:678:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) from /usr/lib/ruby/1.9.1/net/http.rb:678:in `bloc...
string.js, or simply S is a lightweight (< 5 kb minified and gzipped) JavaScript library for the browser or for Node.js that provides extra String methods. Originally, it modified the String prototype. But I quickly learned that in JavaScript, this is considered poor practice. Why? Personally, I prefer the cleanliness ...
I am developing a multi protocol client (currently Twitter, Facebook and Google Reader) for Windows using C# and wanted to extend its functions to send links to Facebook (currently I "only" have text status messages, comments and likes). So I wrote this quite small method here: public void PostLink(string text, string ...
I had done something like: I kind of want to undo that one. While trying to remove virtualbox-ose I get the error saying Removing virtualbox-ose ... * Stopping VirtualBox kernel modules [ OK ] Traceback (most recent call last): File "/usr/bin/pycentral", line 2300, in <module> ...
I'm trying to use Pygame's Clock.tick, but it's not there. I'm positive Pygame has it for Python 3, even if I use dir(pygame.time.Clock), it's still not there. I'm not sure if I'm doing something drastically wrong or Pygame doesn't have it for Python 3. Here's my code: import pygame, random, sys from pygame.locals impo...
Why arn't the following two scripts equivalent? (Taken from another question: Understanding Python Decorators) def makebold(fn): def wrapped(): return "<b>" + fn() + "</b>" return wrapped def makeitalic(fn): def wrapped(): return "<i>" + fn() + "</i>" return wrapped @makebold @makeitalic...
Manage passwords without state A few years ago I had a problem: I had a bunch of accounts that I accessed once a year when tax time came around, and I kept forgetting the passwords. Often I'd try a few before locking myself out, and then I'd have to spend an hour on the phone with customer service getting my account un...
basically i have a massive text file that has several lines that have nothing on them but an '@' symbol. i want to print every line that precedes the FIRST line that is nothing but a single '@' symbol. i'm new to python but pretty familiar with regex but i just can't figure this out. here's what i've got so far: origin...
smo Re : logiciel creation/remasterisation/clonage de distributions base ubuntu mwoe effectivement y s arrete direct y cree pas les fichiers et sort... je regarde ht5streamer, streaming youtube/dailymotion...: http://forum.ubuntu-fr.org/viewtopic.php?id=1299461 / http://ht5streamer.free.fr ubukey, createur ubuntu custo...
I have this in the Google App Engine python code, class ABC(db.Model): StringA = db.StringProperty() abcs = ABC.all() template_values = {'abcs': abcs,} path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values)) and this in the index.html, <script type...
duthen-mac [Résolu] Update Manager - firefox et libgrail => Hash Sum mismatch Bonjour, je n'arrive pas à résoudre mon problème de "Hash Sum mismatch"! Je précise que, si je connais bien Unix, je suis tout nouveau sur Linux. Chaque fois que j'essaie de faire des mises à jour avec l'Update Manager, il échoue toujours ave...
O'Reilly Book Excerpts: Python Cookbook, Second Edition Cooking with Python, Part 1 Editor's note: The second edition to Python Cookbook has been updated for Python 2.4 to include more than 200 recipes with solutions to problems that Python programmers face every day. We've selected two new recipes from the book to sho...
Weights define a probability distribution function (pdf). Random numbers from any such pdf can be generated by applying its associated inverse cumulative distribution function to uniform random numbers between 0 and 1. See also this SO explanation, or, as explained by Wikipedia: If Y has a U[0,1] distribution then F⁻...
I'm overriding a model's save() method to call an asynchronous task with Celery. That task also saves the model, and so I end up with a recursive situation where the Celery task gets called repeatedly. Here's the code: Model's save method: def save(self, *args, **kwargs): super(Route, self).save(*args, **kwargs) ...
Can I somehow use u1sdtool to find out which files have I published on Ubuntu One (and possibly with their public URL)? Now, I have to use the web interface for that. You can't use u1sdtool for this, but you can use from twisted.internet import glib2reactor glib2reactor.install() from dbus.mainloop.glib import DBusGMai...
strcpy(string_test,"\ float fvalue = 23,\ printf(\"Current value : %f\nPlease enter a value (float) : \", fvalue),\ scanf(\"%f\",&fvalue), 45 ,\ printf(\"The value : %f\n\",fvalue)"); devonrevenge wrote: hey will i be able to understand this child language? can i test it? L B wrote: Declare in header.hpp Define in sou...
The Dark Side of Decorators Recently a bug report was filed on the Flask-Classy issue tracker at Github which caught me by surprise. This was a bug so glaring that the fact I hadn’t seen it myself was a shock, but even more shocking was that nobody else had reported it either. The bug was simple to describe: If you use...
Consider the following piece of Markdown code: The is some regular text. >>> def factorial(n): ... return 1 if n < 2 else n * factorial(n - 1) ... * This is a list item. >>> def factorial(n): ... return 1 if n < 2 else n * factorial(n - 1) ... Notice that the second code block is prece...
It happened on my product env sometimes(most times it is ok). I doubt whether it has something to do with the parameter 'expire_on_commit' in sessionmaker func @close_session def func(): session = DBSession() # scoped_session, thread_local m = Model() m.content = 'content' session.add(m) try: ...
Although Bottle’s built-in mini-template language is remarkably useful, I nearly always prefer to use Jinja2 templates because the syntax is very close to Django’s template syntax (which I am more familiar with) and because the Bottle template syntax for filling in blocks from a parent template is a bit limiting (but t...
vince06fr Re : Nettoyage dans les noyaux (kernel) Umuntu : Si tu veux prendre le temps de traduire ce script, surtout ne te gêne pas comme tout est "hardcodé" dans le script, la seule chose à faire est... De modifier l'ensemble des textes en français présents dans le script pour les mettre en anglais. Une fois le scrip...
I have one model (company category) populated by a table - simple names etc. I then have a company model and I'd like to link these two together such that I have have categories in a populated drop down box. class CompanyCategory(db.Model): categoryname = db.StringProperty(required=True) class Company(db.Model): ...
I am going through the exercises in codecademy and am stuck at a place where my code isn't doing what I need it to do. All I need it to do is print the words but if the word is redacted, I need it to print "REDACTED". From what I can see, that is what my code is doing but I must have a symbol in the wrong place or some...
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...
JavaScript newguy99 — 2012-10-06T10:37:52-04:00 — #1 Hello Every one Im using window.open(URL,name,specs,replace) to open a new page it works fine with Chrome V22 and Firefox 12 But when i use it with IE9 it gives me a strange behavior When i click it open a new page but the original page changes to the main root of th...
Vicolaships [résolu]Affichage pourcentage batterie Salut, sous Ubuntu 12.04 j'aimerai un affichage du pourcentage de la batterie avec un raccourci. Je créé donc un script python qui va générer une notification en utilisant python-notify (sudo apt-get install python-notify) Par contre j'arrive pas à afficher proprement ...
With a class in Python, how do I define a function to print every single instance of the class in a format defined in the function? I see two options in this case: Garbage collector import gc for obj in gc.get_objects(): if isinstance(obj, some_class): dome_something(obj) This has the disadvantage of being...
GabLeRoux less info 101 reputation 1 bio website gableroux.com location Chicoutimi age 23 visits member for 2 years, 1 month seen Apr 10 at 14:55 stats profile views 0 I'm a programer, I speak french, english and python. Read my stuff on gableroux.com #!/usr/bin/env python # -*- coding: utf-8 -*- import sys, random, ma...
Depois de uma pequena pausa, chegamos finalmente à terceira parte da série de posts sobre o uso de frameworks Python no Google App Engine. Após abordar o uso do Django e do web2py no App Engine, agora veremos como usar o Flask, um microframework para Python baseado no Werkzeug, no Jinja2 e em boas intenções. Diferente ...
bowmore Re : Qarte arte.tv browser (ex Qarte+7) Si je lance python /usr/bin/qarte J'obtiens python /usr/bin/qarte (qarte:23575): Gtk-WARNING **: Impossible de trouver le moteur de thème dans module_path : « pixmap » Affiché une quinzaine de fois, puis Qarte-1 démarre bien. Dans le terminal, il y a ça: 15:33:40: INFO ...
When working with generators you can only pull out items on a single pass. An alternative is to load the generator into an list and do multiple passes but this involves a hit on performance and memory allocation. Can anyone think of a better way of computing the following metrics from a generator in a single pass. Idea...
I am trying to get a unicode version of calendar.month_abbr[6]. If I don't specify an encoding for the locale, I don't know how to convert the string to unicode. The example code below shows my problem: >>> import locale >>> import calendar >>> locale.setlocale(locale.LC_ALL, ("ru_RU")) 'ru_RU' >>> print repr(calendar....
Request preprocessors are run before validating the POST data against the model. Set a preprocessor on the API for POST requests that parses any colors key, altering the data dictionary in-place: def preprocess_colors(data): colors = data.pop('colors', None) if colors is not None: # set primary and seco...
I need to cut from wav files small pieces (phonemes), which are about 0.1 seconds (e.g. 0.3698125 - 0.466125 I'm using wave module, but it can't handle it :-/ Does anybody know how to handle it? This script should open file, cut the piece and add it to the new one data = fonemy[fonem][0] = start, end, path ([0.3698125,...
i've got some problems with my regex and removing my the strongs bounded by brackets. here's my code: import sys, re import codecs reload(sys) sys.setdefaultencoding('utf-8') reader = codecs.open("input",'r','utf-8') p = re.compile('s/[\[\(].+?[\]\)]//g', re.DOTALL) # i've also tried several regex but it didn't work # ...
obj = my_dict.get('obj') if obj: # <--- test is on truthiness of obj # if we are here, it means: # 1. my_dict has key 'obj', AND... # 2. at least one of the following, # my_dict['obj'].__nonzero__() returned True (__bool__ for python 3) # OR # my_dict['obj'].__len__() returned somet...
July 7th, 2012 at 9:12 pm by Dr. Drang After figuring out how to get time zones straightened out in my Twitter archiving script, it seemed like a good idea to use that knowledge to improve my embedded tweets before I forget how. Why don’t I just use Twitter’s own embedding code? Two reasons: I don’t especially like the...
Let's have 2 models that extends the user model called Ext1 and Ext2 declared as follow: class ExtN(models.Model): user = models.OneToOneField(User) extra_param = models.xxxField() then I declare in application specific admin.py file something like: class ExtNInline(admin.StackedInline): model = ExtN c...
I have problem to override method where from...import statement is used. Some example to illustrate the problem: # a.py module def print_message(msg): print(msg) # b.py module from a import print_message def execute(): print_message("Hello") # c.py module which will be executed import b b.execute() I'd like to...
This question already has an answer here: Sending arbitrary data with Twisted 1 answer I am using the autobhan websockets library with the following code: from twisted.internet import reactor from autobahn.websocket import WebSocketServerFactory, \ WebSocketServerProtocol, \ ...
I have windows in PyQt4 with simple simulation, now I want to add another window with second part of it. In first window is button (there''' be 2 in the end on that window, and each one of them have to work for both windows. For example one of them is "Start" and it should start simulations on both windows. How can I a...
When you concatenate anything with a null, it returns null. So I'm trying to concatenate a comma with the given column value and if that expression returns null, I use Coalesce to return an empty string. At the end, if I get a value, the entire result will start with a comma. So I remove that comma using the Stuff func...
In the argparse package the metavar parameter modifies the displayed help message of a program. The following program is not intended to work, it is simply used to demonstrate the behavior of the metavar parameter. import argparse if __name__ == '__main__': parser = argparse.ArgumentParser(description = "Print a ra...
Based on that solution and the comments below the article I have created the following Python 2.7 code: app.yaml: application: my_application version: 1 runtime: python27 api_version: 1 threadsafe: true builtins: - appstats: on #- remote_api: on handlers: - url: /remoteapi.* script: remote_api.app - url: /.* script...
I'm using the nifty Kivy framework to program a game for Android. I'm trying to create a clock callback to run a specified piece of code (used to draw) 60 times a second. For some reason, anything I draw inside of a Kivy clock event doesn't get drawn to the screen. To eliminate all variables I could, I took this sample...
I'm running Python 2.6.6 on Ubuntu 10.10. I understand that we can import a module and bind that module to a different name, e.g. import spam as eggs also, from eggs import spam as foo My problem is that when running the PySide examples, the following import code does not run: import PySide as PyQt4 from PyQt4 import...
Bismut Re : [HOW TO] adesklets : configuration des desklets Bon, je ne trouve toujours pas le moyen d'afficher mes desklets au bon endroit, voici le contenu de mes fichiers : .adesklets # This is adesklets configuration file. # # It gets automatically updated every time a desklet main window # parameter is changed, so ...
I have the following django URL: url(r'^companies/$', 'companies', name='companies'), If I go to http://localhost:8000/companies/ it works perfectly. However, if I try adding any GET variables to the URL django raises a 404. For example, if I go to http://localhost:8000/companies/?c=1 django raises a 404. What's stran...
I have a list of users. And i want to display it in template: {%- for user in listed_of_users -%} <P>{{ user.name }}</P> {%- endfor -%} i want to create hyperlink link to user's profile for each user using predefined function "create_link". This function will return the hyper link for each object. So ...
I am turning some piece of Python code into OO-code. I define a class and a two arguments constructor. class myclass: MAX=5000 FTOL = 10**(-10) TINY = 10**(-10) def __init__(self, initPt_,fun_): self.initPt = initPt_ self.fun = fun_ With this code, I expect initPt and fun to be cl...
naingenieu CSyD - divisez vos données Bonjour tout le monde Je viens vous présenter un projet tout droit tiré de mes cours de maths, j'ai nommé Can Split your Data Le principe Ce petit logiciel en python permet de décomposer un mot de passe, une phrase en plusieurs clés qui pourront être, toutes ou en parties, réunies ...
Recently, I was tasked with integrating a task queue into a web framework at work. For the purpose of this post, I would like note that I am operating with Python 2.7.5, Flask 0.9, Celery 3.0.21, and RabbitMQ 3.1.3. This post was written using IPython 0.13.2 in an IPython notebook. Now, I’ve never implemented a task qu...
Just a quick contribution. Since the current python docs don't have "window" in the itertool examples (i.e., at the bottom of http://docs.python.org/library/itertools.html), here's an snippet based on the code for grouper which is one of the examples given: import itertools as it def window(iterable, size): shifted...
Netscape 6, Part VI: Object-Oriented DOCJSLIB 1.2: Browser-Independent Superclass - Doc JavaScript Netscape 6, Part VI: Object-Oriented DOCJSLIB 1.2 Browser-Independent Superclass The superclass of DOCJSLIB 1.2 includes a single method, makeImage. This method is common to all browsers, so there is no need to duplicate ...
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 bought a new Sony Vaio S series laptop. It uses Insyde H2O BIOS EFI, and trying to install Linux on it is driving me crazy. root@kubuntu:~# parted /dev/sda print Model: ATA Hitachi HTS72756 (scsi) Disk /dev/sda: 640GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File s...
LANGUAGE_CODE = 'ru-RU' USE_I18N = True python manage.py custommenupython manage.py customdashboardADMIN_TOOLS_MENU = 'myproject.menu.CustomMenu'ADMIN_TOOLS_INDEX_DASHBOARD = 'myproject.dashboard.CustomIndexDashboard'ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'myproject.dashboard.CustomAppIndexDashboard'python manage.py makeme...
Emails and SMS Setting up email Web2py provides the gluon.tools.Mail class to make it easy to send emails using web2py. One can define a mailer with from gluon.tools import Mail mail = Mail() mail.settings.server = 'smtp.example.com:25' mail.settings.sender = 'you@example.com' mail.settings.login = 'username:password' ...
Say I have classes like: public class ServiceCall { public int ServiceCallID {get; set;} public DateTime ReportedTimestamp {get; set;} public bool IsPaid {get; set;} public decimal LabourNet { get; set;} public decimal LabourVat {get; set;} } public class UsedPart ...
indices = [i for i, x in enumerate(my_list) if x == "whatever"] is equivalent to: # Create an empty list indices = [] # Step through your target list, pulling out the tuples you mention above for index, value in enumerate(my_list): # If the current value matches something, append the index to the list if value ...
Web client programming is a powerful technique for querying the Web. A web client is any program that retrieves data from a web server using the Hyper Text Transfer Protocol (the http in your URLs). A web browser is a client; so are web crawlers, programs that traverse the Web automatically to gather information. You c...
I've been working with Tkinter for a week or two now and I've had no problems using buttons. But with this project, my script works fine until I add a button, then it won't run anymore. Can someone help me fiture this out. Thanks a lot in advance. from sys import argv from Tkinter import * from PIL import Image, ImageT...
sys.path: ['/usr/lib/update-notifier', '/usr/local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/local/lib/python2.6/plat-linux3', '/usr/local/lib/python2.6/lib-tk', '/usr/local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/site-packages'] terry@terrylaptop:/usr/lib$ s...
Hada de la Luna [résolu] 12.04 LTS : régler la luminosité de façon "définitive" Bonjour, pour une personne qui a des problèmes avec la luminosité excessive de l'écran, j'aimerais savoir comment régler cela de façon "fixe" qui ne soit pas remise en question à chaque démarrage. En effet, en utilisant : Paramètres système...
I have a JSON file with numerous entries like this: { "area1": "California", "area2": "Sierra Eastside", "area3": "Bishop Area", "area4": "Volcanic Tablelands (Happy/Sad Boulders)", "area5": "Fish Slough Boulders", "grade": "V6 ", "route": "The Orgasm", "type1": "Boulder", "t...
I started using Python in 2001. I loved the simplicity of the language, but one feature that annoyed the heck out of me was the / operator, which would bite me in subtle places like def mean(seq): """ Return the arithmetic mean of a list (unless it just happens to contain all ints) """ return sum(se...
Hello everyone, I am having trouble understanding this code: Specifically, what each line does. Here is what I think I know. 1. Defines a function maximumValue with positional parameters. 2. Assigns a variable to the value of x 3. Uses the if structure and comparison operator to create a condition, to assign higher val...
#8526 Le 21/02/2013, à 22:33 The Uploader Re : Topic des Couche-Tard (cinquante-sept) Pas chez moi. Passer de Ubuntu 10.04 à Xubuntu 12.04 LTS ASUS N56VV (UEFI + GPT, Core i5-3230M @ 2.60GHz, Intel HD4000 + GeForce 750M, 12 Go de RAM, SSD 1 To) Système principal : Archlinux (amd64), avec KDE Système oublié la plupart d...
I'm a completely new to Ubuntu server and am having a hard time connecting the server to the internet. I first ran ping -n 8.8.8.8 connect:Network is unreachable Then I ran ifconfig Link encap:Local Loopback inet addr:127.0.0.1 Mask 255.0.0.0 inet6 addr: ::1/28Scope:host UP LOOPBACK RUNNING MTU:16436 RX packets:192 err...
I need to plot a bar graph with asymmetrical error bars... The documentation of the matplotlib.pyplot.bar function says: Detail: xerr and yerr are passed directly to errorbar(), so they can also have shape 2xN for independent specification of lower and upper errors. But, I can not give an 2xN array to the yerr... impor...
I thought it would be interesting to explore the benefits of using a genexp, so here's my take. The example in the question uses square brackets to create a temporary list, and so is equivalent to: file.writelines( list( "%s\n" % item for item in list ) ) Which needlessly constructs a temporary list of all the lines t...
To introduce the problem, USB devices are typically hot-pluggableexternal devices. Linux (the kernel) assigns a number for each device inthe system at boot time, or later when the device is plugged into thesystem. This number (the minor device number) is used internally byseveral system (kernel) functions, but the user...
How do I create a GUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python? "The uuid module, in Python 2.5 and up, provides RFC compliant UUID generation. See the module docs and the RFC for detai...