I need an IronPython\Python example that would show C#/VB.NET developers how awesome this language really is.
I'm looking for an easy to understand code snippet or application I can use to demo Python's capabilities.
Any thoughts?
...
Reading thru Peter Norvig's Solving Every Sudoku Puzzle essay, I've encounted a few Python idioms that I've never seen before.
I'm aware that a function can return a tuple/list of values, in which case you can assign multiple variables to the results, such as
>>> def f():
... return 1,2
>>> a, b = f()
But what is the meaning of...
Following on from this question about DHTs in Python, my question is the same except that I'm developing on Python 3.x - I only want to know about implementations of the DHT concept which are known to be stable on Python 3.
There seem to be plenty of DHT products, for example Khashmir, however as far as I'm aware nobody has bothered to...
Hi,
Python 2.5.4. Fairly new to Python, brand new to decorators as of last night. If I have a class with multiple boolean attributes:
class Foo(object):
_bool1 = True
_bool2 = True
_bool3 = True
#et cetera
def __init__():
self._bool1 = True
self._bool2 = False
self._bool3 = True
#et ...
I'm trying to write some Python code that includes union/intersection of sets that potentially can be very large. Much of the time, these sets will be essentially set(xrange(1<<32)) or something of the kind, but often there will be ranges of values that do not belong in the set (say, 'bit 5 cannot be clear'), or extra values thrown in. F...
In Python, when should you use lists and when tuples?
Sometimes you don't have a choice, for example if you have
"hello %s you are %s years old" % x
then x must be a tuple.
But if I am the one who designs the API and gets to choose the data types, then what are the guidelines?
...
Hi All,
Im building a server in python, i need to convert a decimal value to hex like this :
let's say the packet start by 4 bytes which define the packet lenght :
00 00 00 00
if the len(packet) = 255 we would send :
00 00 00 ff
Now my problem is that sometimes the packet is bigger than 256 as for example 336, then it would be :
00 00...
I have two Numpy record arrays that have exactly the same fields. What is the easiest way to combine them into one (i.e. append one table on to the other)?
...
Could you recommend some python libraries or source code for OCR and handwritten character recognition?
...
Hello I am currently working on a django project, in one of my Models I have a file upload and image upload, with the parameters of these two fields both are set to blank=True, however there is a stipulatation with this and it is that field can only be blank if one of the two is not, so for example, if the imagefield is complete then the...
I know next to nothing about Python and I'm using scons. (if you're reading this and know Python but not scons, you can probably help me!)
Could someone help me out and explain how I could have a variable that contains two lists? I'm not sure of the syntax. Is this right?
buildinfo = // how do you initialize a variable that has fields?...
Hi Alls,
Im using the SocketServer module for a tcp server.
I'm experiencing some issue here with the recv() function, because the incoming packets always have a different size, so if i specify recv(1024) (i tried with bigger value, and smaller), it get stock after 2 or 3 requests because the packet length will be smaller (i think), and...
As you may have heard of, there is an online font recognition service call WhatTheFont
I'm curious about the tech behind this tool. I think basically we can seperate this into two parts:
Generate images from font files of various format, refer to http://www.fileinfo.com/filetypes/font for a list of font file extensions.
Compare submit...
Hi all
I have the following code.
class person(object):
def __init__(self, keys):
for item in keys:
setattr(self, item, None)
def __str__(self):
return str(self.__dict__)
def __eq__(self, other) :
return self.__dict__ == other.__dict__
Now I want to take this code and only do...
Note: This question originally applied to Xapian, but due to cross-platform issues and poor understanding of Xapian I (our team) chose Solr instead.
I'm looking for snippets, tricks, tips, links, and anything to watch out for (gotchas). My technology stack includes:
MySQL 5.1 (Not really pertinent)
Red Hat and Windows configurations w...
This is the first time I've came across this. Just printed a list and each element seems to have a u in front of it i.e.
[u'hello', u'hi', u'hey']
What does it mean and why would a list have this in front of each element?
As I don't know how common this is, if you'd like to see how I came across it, I'll happily edit the post...
I am getting started with django-cms and I am facing an exception when I try to edit a page in the admin inteface.
A TemplateSyntaxError exception is raised due to the {% page_submit_row %} templatetag.
TemplateSyntaxError at /admin/cms/page/1/
Caught an exception while rendering: admin/page_submit_line.html
Request Method: GET
Req...
I need to sort a coordinate list for a rectangle counterclockwise, and make the north-east corner the first coordinate. These are geographic coordinates (i.e. Longitude, Latitude) in decimal form.1
For example, here are the 4 corners of a rectangle, starting with the north-west corner and moving clockwise:
[
{ "lat": 34.495239, "lng"...
When running nosetests from the command line, how do you specify that 'non-ignored' warnings should be treated as errors?
By default, warnings are printed, but not counted as failures:
[snip]/service/accounts/database.py:151: SADeprecationWarning: Use session.add()
self.session.save(state)
[snip]/service/accounts/database.py:97: SADe...
How can I easily translate standard buttons (Yes, No) from QMessageBox? I can't use self.tr on those arguments, so I would like to achieve it in some other simple way. Do I have to use whole translation system?
...