content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: Dynamic sort with Redis Let's say I have 5 entries in my Redis database: news::id: the ID of the last news; news::list: a list of all news IDs; news:n where n is the news ID: a hash containing fields such as title, url, etc.; news:n:upvotes: a list of all users' IDs who upvoted the news, thus giving the number of...
Dynamic sort with Redis
Let's say I have 5 entries in my Redis database: news::id: the ID of the last news; news::list: a list of all news IDs; news:n where n is the news ID: a hash containing fields such as title, url, etc.; news:n:upvotes: a list of all users' IDs who upvoted the news, thus giving the number of upvotes. news:n:downvotes: a...
[ "You can sort by constants stored in keys.\nIn your example, I can sort 1. almost trivially using Redis. If you store the other expression values after calculating them, you can sort by them too. For 1., you will need to store the list count somewhere, I will assume news:n:upvotes:count.\nThe catch is to use the SO...
[ 0 ]
[]
[]
[ "python", "redis" ]
stackoverflow_0008589737_python_redis.txt
Q: dynamically import submodules in python Suppose I provide a module in the command line and want to import it using the "imp" module: $ foo.py mod.a.b.c What is the proper way of doing this? Split the "mod.a.b.c" and add each path? The behaviour of "imp" does not seem to be parallel to "import". A: Given a modul...
dynamically import submodules in python
Suppose I provide a module in the command line and want to import it using the "imp" module: $ foo.py mod.a.b.c What is the proper way of doing this? Split the "mod.a.b.c" and add each path? The behaviour of "imp" does not seem to be parallel to "import".
[ "Given a module path as a string (modulename), you can import it with\nmodule = __import__(modulename,fromlist='.') \n\nNote that __import__('mod.a.b.c') returns the package mod, while __import__('mod.a.b.c',fromlist='.') returns the module mod.a.b.c. \n" ]
[ 5 ]
[]
[]
[ "imp", "import", "python" ]
stackoverflow_0008593475_imp_import_python.txt
Q: python xlxml xpath expression to match substring in attribute Let's say I have the below XML <root> <element class="Page" style="background: url(/images/RlEguQY3_ghsdr.png?1324483033) repeat left top;" /> <element class="User" /> <element class="Image" src="/images/bg.png" /> </root> I am looking for a x...
python xlxml xpath expression to match substring in attribute
Let's say I have the below XML <root> <element class="Page" style="background: url(/images/RlEguQY3_ghsdr.png?1324483033) repeat left top;" /> <element class="User" /> <element class="Image" src="/images/bg.png" /> </root> I am looking for a xpath expression which 1) matches all elements that have /images in...
[ " //element[contains(@style, '/images') or (@class='Image' and contains(@src, '/images'))]\n\n(or something similar) should do it.\n", "\nI am looking for a xpath expression which 1) matches all elements that\n have /images in the style attribute\n\nDirectly translated to XPath:\n/*/element[contains(@style, '/im...
[ 10, 1, 0 ]
[]
[]
[ "lxml", "python", "xpath" ]
stackoverflow_0008592885_lxml_python_xpath.txt
Q: Is there a GDAL build available for Python 3.2 Windows 7 64-bit? I am interested in using GDAL for Python 3.2 Windows 7 64 bit. I have not come across a suitable build. If there is not a build available, how would I go about building GDAL myself for Python 3.2 Windows 7 64 bit. A: Yes there is and I'm using i...
Is there a GDAL build available for Python 3.2 Windows 7 64-bit?
I am interested in using GDAL for Python 3.2 Windows 7 64 bit. I have not come across a suitable build. If there is not a build available, how would I go about building GDAL myself for Python 3.2 Windows 7 64 bit.
[ "Yes there is and I'm using it :)\nI know this post is a bit old but I hope this link is useful:\nYou can download it from Tamas Szekeres' excellent repository of precompiled binaries. You'll need to browse a bit to identify the version you want depending on your version of MSVC (he compiles against 2003, 2005, 2...
[ 2 ]
[]
[]
[ "gdal", "python", "python_3.x" ]
stackoverflow_0006628140_gdal_python_python_3.x.txt
Q: Doctests that contain string literals I have a unit test that I'd like to write for a function that takes XML as a string. It's a doctest and I'd like the XML in-line with the tests. Since the XML is multi-line, I tried a string literal within the doctest, but no success. Here's simplified test code: def test()...
Doctests that contain string literals
I have a unit test that I'd like to write for a function that takes XML as a string. It's a doctest and I'd like the XML in-line with the tests. Since the XML is multi-line, I tried a string literal within the doctest, but no success. Here's simplified test code: def test(): """ >>> config = \"\"\"\ <?xml vers...
[ "This code works, e.g. with Python 2.7.12 and 3.5.2:\ndef test():\n \"\"\"\n >>> config = '''<?xml version=\"1.0\"?>\n ... <test>\n ... <data>d1</data>\n ... <data>d2</data>\n ... </test>'''\n >>> print(config)\n <?xml version=\"1.0\"?>\n <test>\n <data>d1</data>\n <data>d2</data>\n </test>\n\n ...
[ 15 ]
[]
[]
[ "comments", "doctest", "python", "python_2.4" ]
stackoverflow_0008593315_comments_doctest_python_python_2.4.txt
Q: JSON load/dump in Python From the docs: http://docs.python.org/library/json.html >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') [u'foo', {u'bar': [u'baz', None, 1.0, 2]}] I modified it like this: >>> the_dump=json.dumps("['foo', {'bar':['baz', null, 1.0, 2]}]") >>> the_load = json.loads(the_dump) u"['fo...
JSON load/dump in Python
From the docs: http://docs.python.org/library/json.html >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') [u'foo', {u'bar': [u'baz', None, 1.0, 2]}] I modified it like this: >>> the_dump=json.dumps("['foo', {'bar':['baz', null, 1.0, 2]}]") >>> the_load = json.loads(the_dump) u"['foo', {'bar':['baz', null, 1.0, ...
[ ">>> the_dump=json.dumps(\"['foo', {'bar':['baz', null, 1.0, 2]}]\")\n\nYou're asking it to json encode a string, so it's not surprising that you get a string back when you decode. Try instead:\n>>> the_dump=json.dumps(['foo', {'bar':['baz', None, 1.0, 2]}])\n\n" ]
[ 12 ]
[]
[]
[ "json", "python" ]
stackoverflow_0008594158_json_python.txt
Q: Jython zxJDBC / Python cx_oracle wrong number or types of arguments when calling to oracle's stored procedure Trying to make a django test application which will use stored oracle's procedures to insert/get data. Using jython with zxJDBC but same error applies with python and cx_oracle too. here is some code snipe...
Jython zxJDBC / Python cx_oracle wrong number or types of arguments when calling to oracle's stored procedure
Trying to make a django test application which will use stored oracle's procedures to insert/get data. Using jython with zxJDBC but same error applies with python and cx_oracle too. here is some code snipets: models.py from django.db import models from django.db import connection class ALEX_TEST_PKG(): def get_dat...
[ "You're passing the value from request.POST, where it's always a string, but your stored procedure is expecting an integer.\nUse form.cleaned_data['inparam1'] instead - the form will have converted it to the proper type, ie an integer.\n", "The parameters to callproc are expected to be passed in via a list. You ...
[ 0, 0 ]
[]
[]
[ "django", "jython", "oracle", "python" ]
stackoverflow_0008577201_django_jython_oracle_python.txt
Q: Replacing a list item and returning a copy of the list (in one line) with Python I'm working on something that uses search, so each recursive call needs a separate copy of a list but with a single element replace. I'd like to do it (neatly) in one line, and so far I have this which goes in the recursive call: [new...
Replacing a list item and returning a copy of the list (in one line) with Python
I'm working on something that uses search, so each recursive call needs a separate copy of a list but with a single element replace. I'd like to do it (neatly) in one line, and so far I have this which goes in the recursive call: [new_value if x == replace_index else my_list[x] for x in range(len(my_list))] But is the...
[ "Maybe something like this:\n[new_value if i == replace_index else element\n for i, element in enumerate(my_list)]\n\nor:\nnew_list = my_list[:]\nnew_list[replace_index] = new_value\n\nor:\nnew_list = my_list[:replace_index] + [new_value] + my_list[replace_index+1:]\n\nIn this case, I think I prefer the second opti...
[ 2, 0 ]
[]
[]
[ "copy", "list", "python", "replace" ]
stackoverflow_0008594399_copy_list_python_replace.txt
Q: How to compare column value from csv file to the column value in mysql table How to check if combination of two column value from a csv are present in a table having csv data in columns ? Example : For every a, b in the csv file: i. Check if it exists in ...
How to compare column value from csv file to the column value in mysql table
How to check if combination of two column value from a csv are present in a table having csv data in columns ? Example : For every a, b in the csv file: i. Check if it exists in the database NO: Add (a, b, "and other relevant field") to a different table in t...
[ "take a and b value from csv file as separate variables. now i assume that you are able to extract every row of csv as an array. so:\nvariable a = csv_row_array['a'];\nvariable b = csv_row_array['b'];\n\nNow for sql part, i hope u know column names that correspond to values in and b, so check:\nSET @tempVar = 0;\nS...
[ 0 ]
[]
[]
[ "csv", "mysql", "python" ]
stackoverflow_0008594376_csv_mysql_python.txt
Q: Cookiejar use in an opener I have the following code at the moment: tw_jar = cookielib.CookieJar() tw_jar.set_cookie(c1) tw_jar.set_cookie(c2) o = urllib2.build_opener( urllib2.HTTPCookieProcessor(tw_jar) ) urllib2.install_opener( o ) Now I later in my code I don't want to use any of the cookies (Also new cookie...
Cookiejar use in an opener
I have the following code at the moment: tw_jar = cookielib.CookieJar() tw_jar.set_cookie(c1) tw_jar.set_cookie(c2) o = urllib2.build_opener( urllib2.HTTPCookieProcessor(tw_jar) ) urllib2.install_opener( o ) Now I later in my code I don't want to use any of the cookies (Also new cookies created meanwhile). Can I do ...
[ "This is how HTTPCookieProcessor is defined in my Python installation:\nclass HTTPCookieProcessor(BaseHandler):\n def __init__(self, cookiejar=None):\n import cookielib\n if cookiejar is None:\n cookiejar = cookielib.CookieJar()\n self.cookiejar = cookiejar\n\n def http_request(self, request):\n ...
[ 2, 0 ]
[]
[]
[ "cookiejar", "cookielib", "python", "urllib2" ]
stackoverflow_0008594474_cookiejar_cookielib_python_urllib2.txt
Q: Iterate a tuple of dictionaries and pass the nested dictionaries to a function #!/usr/bin/python -tt # A dictionary Of Each New SSID WirelessNetwork = {} WirelessNetwork['name'] = 'baz' WirelessNetwork['type'] = 'bar' WirelessNetwork['pass'] = 'foo' # A list of all SSIDs networkAddList = (WirelessNetwork) def a...
Iterate a tuple of dictionaries and pass the nested dictionaries to a function
#!/usr/bin/python -tt # A dictionary Of Each New SSID WirelessNetwork = {} WirelessNetwork['name'] = 'baz' WirelessNetwork['type'] = 'bar' WirelessNetwork['pass'] = 'foo' # A list of all SSIDs networkAddList = (WirelessNetwork) def addWireless(passedDict={}): print 'Adding SSID: %s' % passedDict['name'] print 'O...
[ "When debugging in python you can confirm your suspicion that the value being passed is a string with the type function:\nprint type(passedDict)\n\nWhen you create your tuple with one element, you need a trailing \",\". Also note that a tuple is different from a list in python. The primary difference is that tuples...
[ 2, 0, 0 ]
[ "Just ran a quick check of the types being referenced, and I'm believing that you were only missing a serial comma (in WirelessNetwork).\nSo, your code would look something like this:\nnetworkAddList = (WirelessNetwork,)\nYour for loop will then properly iterate over the dictionaries.\n" ]
[ -1 ]
[ "dictionary", "enumeration", "list", "python", "tuples" ]
stackoverflow_0008594714_dictionary_enumeration_list_python_tuples.txt
Q: Realtime art project --- input: sound --- output: image (better title?) I am not quite sure if I should ask this question here. I want to make an art project. I want to use voice as an input, and an image as output. The image changes accordingly to the sound. How can I realise this? Because I need realtime or a d...
Realtime art project --- input: sound --- output: image (better title?)
I am not quite sure if I should ask this question here. I want to make an art project. I want to use voice as an input, and an image as output. The image changes accordingly to the sound. How can I realise this? Because I need realtime or a delay under 50 ms. At first I thougt it would be better to use a micro control...
[ "Have you thought about using a graphical dataflow environment like Pure Data (Pd) or Max? Max is a commercial product, but Pd is free.\nEven if you don't end up using Pd for your final project, it makes an excellent rapid prototyping tool. Whilst the graphics processing capabilities of Pd are limited, there are ex...
[ 5, 1 ]
[]
[]
[ "audio", "microcontroller", "processing", "python", "real_time" ]
stackoverflow_0008554168_audio_microcontroller_processing_python_real_time.txt
Q: how to use string as list's indices in Python for line in f.readlines(): (addr, vlanid, videoid, reqs, area) = line.split() if vlanid not in dict: dict[vlanid] = [] video_dict = dict[vlanid] if videoid not in video_dict: video_dict[videoid] = [] video_dict[video...
how to use string as list's indices in Python
for line in f.readlines(): (addr, vlanid, videoid, reqs, area) = line.split() if vlanid not in dict: dict[vlanid] = [] video_dict = dict[vlanid] if videoid not in video_dict: video_dict[videoid] = [] video_dict[videoid].append((addr, vlanid, videoid, reqs, area)) He...
[ "Use a dictionary instead of a list:\nif vlanid not in dict:\n dict[vlanid] = {}\n\nP.S. I recommend that you call dict something else so that it doesn't shadow the built-in dict.\n", "Don't use dict as a variable name. Try this (d instead of dict):\nd = {}\nfor line in f.readlines():\n (addr, vlanid, video...
[ 4, 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008593086_python.txt
Q: Using a single database file in django is feasible? I would like to start a project in django.My doubt is that ,since django is using a single database file. Is that feasible? Actually planned to create a 'wiki' like application that stores articles in a database. Using a single database file ??? Will it be? A: ...
Using a single database file in django is feasible?
I would like to start a project in django.My doubt is that ,since django is using a single database file. Is that feasible? Actually planned to create a 'wiki' like application that stores articles in a database. Using a single database file ??? Will it be?
[ "From the SQLite3 documentation: \n\nGenerally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite. The 100K hits/day figure is a conservative estimate, not a hard upper bound. SQLite has been demonstrated to work with 10 times that amount of traffic.\n\nSo it should be fine to use it...
[ 2, 0, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008591910_django_python.txt
Q: Python multiprocessing pipe recv() doc unclear or did I miss anything? I have been learning how to use the Python multiprocessing module recently, and reading the official doc. In 16.6.1.2. Exchanging objects between processes there is a simple example about using pipe to exchange data. And, in 16.6.2.4. Connec...
Python multiprocessing pipe recv() doc unclear or did I miss anything?
I have been learning how to use the Python multiprocessing module recently, and reading the official doc. In 16.6.1.2. Exchanging objects between processes there is a simple example about using pipe to exchange data. And, in 16.6.2.4. Connection Objects, there is this statement, quoted "Raises EOFError if there is n...
[ "When you start a new process with mp.Process, the child process inherits the pipes of the parent. When the child closes conn, the parent process still has child_conn open, so the reference count for the pipe file descriptor is still greater than 0, and so EOFError is not raised. \nTo get the EOFError, close the en...
[ 10 ]
[]
[]
[ "multiprocessing", "pipe", "python" ]
stackoverflow_0008594909_multiprocessing_pipe_python.txt
Q: How can you call a function of the creator of an instance, in python? I have 2 modules, each contains a class. My main program instantiates an object of class One, which instantiates many objects of class Two. I need to be able to call a function in class One from the instances of class Two. This is a general look...
How can you call a function of the creator of an instance, in python?
I have 2 modules, each contains a class. My main program instantiates an object of class One, which instantiates many objects of class Two. I need to be able to call a function in class One from the instances of class Two. This is a general look of what I have: module mod_one.py: import mod_two class One: def __in...
[ "I think there's a trade-off here between simplicity and loose coupling. In my opinion, the simplicity would be passing the callback to an object, while loose coupling would be using a framework to pass signals between the objects.\nFor instance, if you use blinker signaling library you could use this alternative d...
[ 2, 1, 0 ]
[]
[]
[ "callback", "class", "python" ]
stackoverflow_0008594549_callback_class_python.txt
Q: How to use python NLP POS tagger in C# code? I came across and successfully used a python NLP POS tagger.The problem is that my code was in c# and I used a python pos tagger because I could not find a good c# pos tagger.Now,I don't know how to use this python NLP POS tagger in my c# code.Could anyone guide me?Also...
How to use python NLP POS tagger in C# code?
I came across and successfully used a python NLP POS tagger.The problem is that my code was in c# and I used a python pos tagger because I could not find a good c# pos tagger.Now,I don't know how to use this python NLP POS tagger in my c# code.Could anyone guide me?Also please do suggest any C# POS tagger.Thankx EDIT: ...
[ "You can use the SharpNLP project.\n", "If you really want to keep using the NLP tagger for python, you can always try and host it with the DLR: http://blogs.msdn.com/b/srivatsn/archive/2008/09/16/hosting-ironpython-made-easier.aspx\n" ]
[ 2, 0 ]
[]
[]
[ "c#", "nlp", "pos_tagger", "python" ]
stackoverflow_0008595120_c#_nlp_pos_tagger_python.txt
Q: Using djangoTemplate and db.Model in Google App Engine I have a small app that has a form that grabs data about a new hire, emails people about it, and stores the data for future use. Everything is working fine, but I can't seem to find info on using djangoforms and check boxes. These are obviously a boolean value...
Using djangoTemplate and db.Model in Google App Engine
I have a small app that has a form that grabs data about a new hire, emails people about it, and stores the data for future use. Everything is working fine, but I can't seem to find info on using djangoforms and check boxes. These are obviously a boolean value, but if I add a db.Boolean value to my db.Model class, and ...
[ "Wobble answered it for me \nshould be TextProperty and BooleanProperty. db.Text is just an alias to datastore_types.Text, not a Property subclass, and db.Boolean should raise an exception as far as I can see\n" ]
[ 0 ]
[]
[]
[ "django", "google_app_engine", "python" ]
stackoverflow_0008595159_django_google_app_engine_python.txt
Q: A better pattern for ajax loading with pyramid? I've read up on using different renderers or overriding renderer but I'm wondering if there's a better way to handle this pattern. Right now, in my view I'm returning a set of items to the template: @view_config( route_name = 'name', permission = 'perm', ...
A better pattern for ajax loading with pyramid?
I've read up on using different renderers or overriding renderer but I'm wondering if there's a better way to handle this pattern. Right now, in my view I'm returning a set of items to the template: @view_config( route_name = 'name', permission = 'perm', renderer = 'r.mako' ) def r( request ): items ...
[ "I would suggest using 2 views which properly allow you to apply a different \"look-and-feel\" (responses) to the same data.\ndef get_items(request):\n return {} # values that you can pick and choose from in each view\n\n@view_config(route_name='name', permission='perm', xhr=True, renderer='json')\ndef r_ajax(re...
[ 8, 1 ]
[]
[]
[ "pyramid", "python" ]
stackoverflow_0008594437_pyramid_python.txt
Q: How to install python module on Heroku cedar stack with Rails We have a rails app running on the Heroku Cedar stack, and we have a need for an external python module, namely 'pyPdf'. Unfortunately it is not one of the pre-installed python modules. Is there a way to install python modules on the Cedar stack? I've t...
How to install python module on Heroku cedar stack with Rails
We have a rails app running on the Heroku Cedar stack, and we have a need for an external python module, namely 'pyPdf'. Unfortunately it is not one of the pre-installed python modules. Is there a way to install python modules on the Cedar stack? I've tried to add a requirements.txt at the root of my app, but this does...
[ "Is this module something that you're trying to access from your Rails application? If so, you can always access bash on a dyno to download and compile a library (if compilation is needed) and then stuff the resultant file into your application codebase (somewhere like /app/bin). Then you can refer to this binary...
[ 1 ]
[]
[]
[ "cedar", "heroku", "module", "python", "ruby_on_rails" ]
stackoverflow_0008591433_cedar_heroku_module_python_ruby_on_rails.txt
Q: How to fill a textArea in an online form automatically using Python? I am wondering how I can fill an online form automatically. I have researched it and it tuned out that, one can uses Python ( I am more interested to know how to do it with Python because it is a scripting language I know) but documentation about...
How to fill a textArea in an online form automatically using Python?
I am wondering how I can fill an online form automatically. I have researched it and it tuned out that, one can uses Python ( I am more interested to know how to do it with Python because it is a scripting language I know) but documentation about it is not very good. This is what I found: Fill form values in a web page...
[ "See if my answer to the other question you linked helps:\nhttps://stackoverflow.com/a/5685569/711017\nEDIT:\nHere is the explicit code for your example. Now, I don't have mechanize installed right now, so I haven't been able to check the code. No online IDE's I checked have it either. But even if it doesn't work, ...
[ 2 ]
[]
[]
[ "forms", "linux", "mechanize", "python", "web_applications" ]
stackoverflow_0008594200_forms_linux_mechanize_python_web_applications.txt
Q: Best way to download all artifacts listed in an HTML5 cache.manifest file? I am attempting to look at how an HTML5 app works and any attempts to save the page inside the webkit browsers (chrome, Safari) includes some, but not all of the cache.manifest resources. Is there a library or set of code that will parse th...
Best way to download all artifacts listed in an HTML5 cache.manifest file?
I am attempting to look at how an HTML5 app works and any attempts to save the page inside the webkit browsers (chrome, Safari) includes some, but not all of the cache.manifest resources. Is there a library or set of code that will parse the cache.manifest file, and download all the resources (images, scripts, css)? (...
[ "I originally posted this as part of the question... (no newbie stackoverflow poster EVER does this ;)\nsince there was a resounding lack of answers. Here you go:\nI was able to come up with the following python script to do so, but any input would be appreciated =) (This is my first stab at python code so there m...
[ 0 ]
[]
[]
[ "html", "parsing", "python" ]
stackoverflow_0007394861_html_parsing_python.txt
Q: Sphinx autodoc django not working I've started using Sphinx for a django project, and I've hit a brick wall: The modules are documented with something like this: :mod:`models` Module -------------------- .. automodule:: userprofile.models :members: :undoc-members: :show-inheritance: The relevant code...
Sphinx autodoc django not working
I've started using Sphinx for a django project, and I've hit a brick wall: The modules are documented with something like this: :mod:`models` Module -------------------- .. automodule:: userprofile.models :members: :undoc-members: :show-inheritance: The relevant code looks like this: # models is django.db...
[ "This is a tentative answer, and it might be wrong. It was simply too long to be put as a comment... However, if you take a look at the django source you will notice that Model and Manager have a different inheritance three. In particular, the Model class uses the __metaclass__ attribute:\nManager:\nclass Manager(o...
[ 1 ]
[]
[]
[ "django", "python", "python_sphinx" ]
stackoverflow_0008593368_django_python_python_sphinx.txt
Q: How to download gzip files using urllib2, without corrupting them? I'm writing a script to download gzipped XML sitemaps; the files download, but they are corrupt. The gzipped files outputted by the script are a little larger than they should be, and the decompressed files are smaller than they should be, because ...
How to download gzip files using urllib2, without corrupting them?
I'm writing a script to download gzipped XML sitemaps; the files download, but they are corrupt. The gzipped files outputted by the script are a little larger than they should be, and the decompressed files are smaller than they should be, because data is missing. Any idea what I'm doing wrong? saveAddress = "test.xml....
[ "Open the file in binary mode:\nopen(saveAddress, \"wb\").write(pageText)\n\n" ]
[ 7 ]
[]
[]
[ "gzip", "python", "urllib2" ]
stackoverflow_0008595624_gzip_python_urllib2.txt
Q: Programmatically comparing two MP4 (mpeg-4) videos I'm working on software that will create MP4 videos using the MLT Framework. I need to create some unit tests for my processes that will compare a pre-testing creating video with the one that is created. I am using Python for the code. I need to ensure that the...
Programmatically comparing two MP4 (mpeg-4) videos
I'm working on software that will create MP4 videos using the MLT Framework. I need to create some unit tests for my processes that will compare a pre-testing creating video with the one that is created. I am using Python for the code. I need to ensure that the content of the videos is the same. What are the ways t...
[ "One common metric for comparing video files is SSIM (structural similarity) -- videos with a high SSIM are likely to be \"equal\".\nThere are a number of tools available for calculating the SSIM of two video files; one such tool is available at: https://github.com/kahkeng/vqats\n" ]
[ 4 ]
[]
[]
[ "mp4", "python", "video_encoding", "video_processing" ]
stackoverflow_0008596035_mp4_python_video_encoding_video_processing.txt
Q: Alternative to urllib.urlencode for encoding a URL I'm trying to send a request to an API that only accepts XML. I've used elementtree.SimpleXMLWriter to build the XML tree and it's stored in a StringIO object. That's all fine and dandy. The problem is that I have to urlencode the StringIO object in order to send ...
Alternative to urllib.urlencode for encoding a URL
I'm trying to send a request to an API that only accepts XML. I've used elementtree.SimpleXMLWriter to build the XML tree and it's stored in a StringIO object. That's all fine and dandy. The problem is that I have to urlencode the StringIO object in order to send it to the API. But when I try, I get: File "C:\Python2...
[ "You can get a string from your StringIO by calling its getvalue() method, and pass that to urllib.\n", "StringIO instance is like a file, not like a string. It does not have a len(). Use my_string_io_varaible.getvalue() to get the string value, and pass it to urlencode() which expects a string.\nMaybe you could ...
[ 2, 2 ]
[]
[]
[ "python", "stringio", "urlencode" ]
stackoverflow_0008595689_python_stringio_urlencode.txt
Q: ArcGIS Eclipse PyDev - code autocomplete not working I have ArcGIS 9.3, Eclipse Indigo with PyDev plugin installed. I am unable to configure PyDev so the autocompletion of arcgis functions will work. I have added python interpreter and path to arcgis bin folder. I am able to run script, import of arcgiscripting wo...
ArcGIS Eclipse PyDev - code autocomplete not working
I have ArcGIS 9.3, Eclipse Indigo with PyDev plugin installed. I am unable to configure PyDev so the autocompletion of arcgis functions will work. I have added python interpreter and path to arcgis bin folder. I am able to run script, import of arcgiscripting works but autocompletion shows only functions that i already...
[ "There isn't a similar folder for ArcGIS 9.3. ESRI did a major refactor of the Python API when going from 9.3 to 10 and there are many differences, of which this is one. I found Eclipse very useful for geocoding but I don't recall autocomplete working with ArcGIS 9.3, but I do recall there was an ESRI folder you ...
[ 0 ]
[]
[]
[ "arcgis", "autocomplete", "eclipse", "pydev", "python" ]
stackoverflow_0008078073_arcgis_autocomplete_eclipse_pydev_python.txt
Q: Django QuerySet values_list returning unknown characters I am using django to pull some data from the MySQL server I have. Currently I have it pulling a whole column of data (the "light" column) from the SQL server. To do this I am using the following code weather = weatherdata.objects.values_list('light', fla...
Django QuerySet values_list returning unknown characters
I am using django to pull some data from the MySQL server I have. Currently I have it pulling a whole column of data (the "light" column) from the SQL server. To do this I am using the following code weather = weatherdata.objects.values_list('light', flat=True) lightdata = list(weather) When I do this the lightda...
[ "You can do something like this:\nl = [35L, 53L, 77L, 99L, 49L, 46L, 28L, 13L, 2L, 0L, 0L, 0L]\nl = [int(item) for item in l]\n\nAlso if you want to delete the replicated items:\nl = [35L, 53L, 77L, 99L, 49L, 46L, 28L, 13L, 2L, 0L, 0L, 0L]\nl = list(set(l))\nl = [int(item) for item in l]\n\n", "The L at the end i...
[ 4, 2, 1 ]
[]
[]
[ "django", "django_queryset", "list", "python" ]
stackoverflow_0008596589_django_django_queryset_list_python.txt
Q: Timeout and high cpu load problems using multiple telnet connection threads in python I want to connect to multiple telnet hosts using threading in python, but I stumbled about an issue I'm not able to solve. Using the following code on MAC OS X Lion / Python 2.7 import threading,telnetlib,socket class ReaderThre...
Timeout and high cpu load problems using multiple telnet connection threads in python
I want to connect to multiple telnet hosts using threading in python, but I stumbled about an issue I'm not able to solve. Using the following code on MAC OS X Lion / Python 2.7 import threading,telnetlib,socket class ReaderThread(threading.Thread): def __init__(self, ip, port): threading.Thread.__init__(...
[ "Ok, You have overridden join(), and you are not supposed to do that. The main thread calls join() on each thread when the main thread finishes, which is right after the last line in your code. Since your join() method returns before your telnet thread actually exits, Python gets confused and tries to call join() a...
[ 0 ]
[]
[]
[ "connection", "python", "python_multithreading", "telnet", "telnetlib" ]
stackoverflow_0008594397_connection_python_python_multithreading_telnet_telnetlib.txt
Q: Python: create a polynomial of degree n I have a feature set [x1,x2....xm] Now I want to create polynomial feature set What that means is that if degree is two, then I have the feature set [x1.... xm,x1^2,x2^2...xm^2, x1x2, x1x3....x1,xm......xm-1x1....xm-1xm] So it contains terms of only of order 2.. same is if...
Python: create a polynomial of degree n
I have a feature set [x1,x2....xm] Now I want to create polynomial feature set What that means is that if degree is two, then I have the feature set [x1.... xm,x1^2,x2^2...xm^2, x1x2, x1x3....x1,xm......xm-1x1....xm-1xm] So it contains terms of only of order 2.. same is if order is three.. then you will have cubic te...
[ "Use\nitertools.combinations(list, r)\n\nwhere list is the feature set, and r is the order of desired polynomial features. Then multiply elements of the sublists given by the above. That should give you {x1*x2, x1*x3, ...}. You'll need to construct other ones, then union all parts.\n[Edit] \nBetter: itertools.combi...
[ 5, 3, 0 ]
[]
[]
[ "algorithm", "python" ]
stackoverflow_0008596818_algorithm_python.txt
Q: Python: Change Pitch of Audio File this is my first post on stack. So far this site has been very helpful, but I am a novice and need a clear explanation to my problem, which is related to pitch-shifting audio in Python. I have the current modules installed: numpy, scipy, pygame, and the scikits "samplerate" api. ...
Python: Change Pitch of Audio File
this is my first post on stack. So far this site has been very helpful, but I am a novice and need a clear explanation to my problem, which is related to pitch-shifting audio in Python. I have the current modules installed: numpy, scipy, pygame, and the scikits "samplerate" api. My goal is to take a stereo file and pla...
[ "Your problem is that pygame works with numpy.int16 arrays but the call to resample return a numpy.float32 array:\n>>> snd_array.dtype\ndtype('int16')\n>>> snd_resample.dtype\ndtype('float32')\n\nYou can convert resample result to numpy.int16 using astype:\n>>> snd_resample = resample(snd_array, 1.5, \"sinc_fastest...
[ 11, 3, 0, 0 ]
[]
[]
[ "audio_processing", "pygame", "python", "scipy" ]
stackoverflow_0008501141_audio_processing_pygame_python_scipy.txt
Q: HTTP error 415 what am I doing wrong? I am sending a SOAP POST and I am getting a "HTTPError: HTTP Error 415: Unsupported Media Type" @ response = urllib2.urlopen(req) data = """<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org...
HTTP error 415 what am I doing wrong?
I am sending a SOAP POST and I am getting a "HTTPError: HTTP Error 415: Unsupported Media Type" @ response = urllib2.urlopen(req) data = """<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:/...
[ "The Content-Length value in the headers dictionary seems wrong\n'Content-Length: len(data)' \n\nand also some other values.\nI would fix it with:\nheaders = {\n 'Content-Type': 'application/soap+xml; charset=utf-8',\n 'Host': 'webservices.autotask.net',\n 'Content-Length': len(data),\n 'SOAPAction': 'h...
[ 7, 4, 2 ]
[]
[]
[ "http", "post", "python", "soap" ]
stackoverflow_0005213673_http_post_python_soap.txt
Q: blobkey from blobstore google apps engine python How do you return the blob key from a blob store? and subsequently return the image URL? Example code: class Next(webapp.RequestHandler): def get(self): userTable_name=self.request.get('userTable_name') data = db.GqlQuery("SELECT * " ...
blobkey from blobstore google apps engine python
How do you return the blob key from a blob store? and subsequently return the image URL? Example code: class Next(webapp.RequestHandler): def get(self): userTable_name=self.request.get('userTable_name') data = db.GqlQuery("SELECT * " "FROM userTable " ...
[ "Worked it out! As it turns out, I was confusing \"adding an image to the datastore as a blob\" vs vs adding an image to the blobstore. \n\na BlobReferenceProperty references an object uploaded and stored in\n the blobstore while a BlobProperty stores blob data directly in the\n datastore. see: How to use get_ser...
[ 0 ]
[]
[]
[ "blobstore", "google_app_engine", "python" ]
stackoverflow_0008485587_blobstore_google_app_engine_python.txt
Q: Looking for annotating vector editor I'm looking for a 2D vector graphics editor that can tag/annotate objects. I want to load the files into python+tkinter or java+SWT canvas (other GUI toolkits could also work). Then I want to uses the tags to have the program animate things like color, on/off, line type, etc....
Looking for annotating vector editor
I'm looking for a 2D vector graphics editor that can tag/annotate objects. I want to load the files into python+tkinter or java+SWT canvas (other GUI toolkits could also work). Then I want to uses the tags to have the program animate things like color, on/off, line type, etc. I need it to run on Linux and Windows. T...
[ "Inkscape. You can edit the SVG to add tags (from within the program).\nThere are existing SVG → SWT Canvas toolkits, so, no need to reinvent the wheel, I'd expect.\n" ]
[ 1 ]
[]
[]
[ "java", "python", "vector_graphics" ]
stackoverflow_0008596828_java_python_vector_graphics.txt
Q: How to replace a particular comma in a CSV file using Python? I have quite a big CSV file where lines have varying length: 215080,49,3,0.0,22,42,0.0 215082,49,3,0.0,22,43,59.999 215083,49,3,0.0,22,45,0.0 215085,49,3,0.0,22,46,59.999 215086,49,3,0.0,22,48,0.0 215087,49,3,0.0,22,49,0.001 215088,49,3,0.0,22,49,59.9...
How to replace a particular comma in a CSV file using Python?
I have quite a big CSV file where lines have varying length: 215080,49,3,0.0,22,42,0.0 215082,49,3,0.0,22,43,59.999 215083,49,3,0.0,22,45,0.0 215085,49,3,0.0,22,46,59.999 215086,49,3,0.0,22,48,0.0 215087,49,3,0.0,22,49,0.001 215088,49,3,0.0,22,49,59.999 215089,49,3,0.0,22,51,0.0 215090,49,3,0.0,22,52,0.001 215688,49,...
[ "import csv\nwith open('source.csv','rb') as source:\n rdr= csv.reader( source )\n with open('revised.csv','wb') as target:\n wtr= csv.writer( target )\n for r in rdr:\n wtr.writerow( (r[0], r[1], r[2], '{0};{1}'.format(r[3],r[4]), r[5], r[6]) )\n\n", "You could do something like th...
[ 7, 4, 2 ]
[]
[]
[ "csv", "python" ]
stackoverflow_0008597551_csv_python.txt
Q: Django - get distinct dates from timestamp I'm trying to filter users by date, but can't until I can find the first and last date of users in the db. While I can have my script filter out dups later on, I want to do it from the outset using Django's distinct since it significantly reduces. I tried User.objects.val...
Django - get distinct dates from timestamp
I'm trying to filter users by date, but can't until I can find the first and last date of users in the db. While I can have my script filter out dups later on, I want to do it from the outset using Django's distinct since it significantly reduces. I tried User.objects.values('install_time').distinct().order_by() but s...
[ "When doing reports on larger datasets itertools.group_by might be too slow. In those cases I make postgres handle the grouping:\ntruncate_date = connection.ops.date_trunc_sql('day','timestamp')\nqs = qs.extra({'date':truncate_date})\nreturn qs.values('date').annotate(Sum('amount')).order_by('date')\n\n", "I've ...
[ 8, 0 ]
[]
[]
[ "django", "django_models", "python" ]
stackoverflow_0008596856_django_django_models_python.txt
Q: Grouping dates in Django My question is almost exactly the same as this post, except that I'm using Python and Django instead of PHP. The task is to take: id date 1 2009-01-01 10:15:23 2 2009-01-01 13:21:29 3 2009-01-02 01:03:13 4 2009-01-03 12:20:19 5 2009-01-03 13:01:06 And output: 2009-01-01 1 ...
Grouping dates in Django
My question is almost exactly the same as this post, except that I'm using Python and Django instead of PHP. The task is to take: id date 1 2009-01-01 10:15:23 2 2009-01-01 13:21:29 3 2009-01-02 01:03:13 4 2009-01-03 12:20:19 5 2009-01-03 13:01:06 And output: 2009-01-01 1 2 2009-01-02 3 2009-01...
[ "You can solve this with the regroup and date templatetags.\n{% regroup object_list by start_date|date:\"Y-m-d\" as objects_by_day %}\n{% for d in objects_by_day %}\n### DO SOMETHING HERE\n{% endfor %}\n\n", "itertools.groupby is your dear, dear friend:\nimport itertools\n\ndates = [\n (1,'2009-01-01 10:15:23')...
[ 38, 16, 9, 8, 2 ]
[]
[]
[ "django", "django_forms", "python" ]
stackoverflow_0001236865_django_django_forms_python.txt
Q: How to create an adjacency matrix of mutual friendships from facebook in python I am doing a project on Social Network Analysis of Facebook Network. I had to get all my friends and who of my friends are friends with each other, mutual frindships inside my network. I did that, I got all id's of my friends and adjac...
How to create an adjacency matrix of mutual friendships from facebook in python
I am doing a project on Social Network Analysis of Facebook Network. I had to get all my friends and who of my friends are friends with each other, mutual frindships inside my network. I did that, I got all id's of my friends and adjacencies and now I have to form an adjacency matric which indicates if 2 of my friends ...
[ "I solved the problem, it just required 2 for loops to go thorugh the list and compare whether the users id is in the adjacency list, if that is the case, make that entry 1, otherwise 0.\n", "I think this structure is better implemented as a graph. For example, take a look at NetworkX.\nAnyway, if you really need...
[ 1, 0 ]
[]
[]
[ "adjacency_matrix", "facebook", "facebook_fql", "python" ]
stackoverflow_0008554283_adjacency_matrix_facebook_facebook_fql_python.txt
Q: python script exits when a shell command(to terminate a different tool) is run from os.system() I am running a shell command from within my python script using os.system("some shell command") This command essentially terminates a tool. I need to check that this tool is terminated in my script. But as soon as the t...
python script exits when a shell command(to terminate a different tool) is run from os.system()
I am running a shell command from within my python script using os.system("some shell command") This command essentially terminates a tool. I need to check that this tool is terminated in my script. But as soon as the tool is terminated the script is terminated too!
[ "Is the script, by any chance, launched by that same tool? If yes, you need to run os.setsid() to stop being dependent on it.\n", "Your script is probably terminating correctly. Try adding the following line after your last line of code to illustrate to you that it is done.\nraw_input('Press any key to exit.')\n\...
[ 1, 1 ]
[]
[]
[ "operating_system", "python", "shell" ]
stackoverflow_0008597906_operating_system_python_shell.txt
Q: Positioning an easygui.enterbox or easygui.multenterbox Is there a way to specify the position of an easygui.enterbox or easygui.multenterbox on the screen? And hopefully to read the current position if the user moves the window? I have an infinite loop asking for user input and want to keep the window in the s...
Positioning an easygui.enterbox or easygui.multenterbox
Is there a way to specify the position of an easygui.enterbox or easygui.multenterbox on the screen? And hopefully to read the current position if the user moves the window? I have an infinite loop asking for user input and want to keep the window in the same place if the user moves it rather than having it return t...
[ "There is no direct way to do it. As a workaround you could patch easygui.rootWindowPosition:\nfrom Tkinter import Tk\nimport easygui\n\n# calculate window position\nroot = Tk()\npos = int(root.winfo_screenwidth() * 0.5), int(root.winfo_screenheight() * 0.2)\nroot.withdraw()\nrootWindowPosition = \"+%d+%d\" % pos\n...
[ 2 ]
[]
[]
[ "easygui", "python" ]
stackoverflow_0008584613_easygui_python.txt
Q: How to import only one Tkinter widget method instead of a whole package? I am writing a python application using tkinter. One of my classes only uses the delete method on an Entry widget object. I wanted to know if there was a way to only import that method instead of importing the entire package. I have tried loo...
How to import only one Tkinter widget method instead of a whole package?
I am writing a python application using tkinter. One of my classes only uses the delete method on an Entry widget object. I wanted to know if there was a way to only import that method instead of importing the entire package. I have tried looking around online and have tried different things, but I have not had much lu...
[ "No, there is no way to import only one method of a widget, or only one method of any class. When you import a class you get the whole class. \nWhy do you think it would be advantageous to import only one method? If you're concerned about memory consumption, don't be. \n" ]
[ 2 ]
[]
[]
[ "import", "python", "tkinter" ]
stackoverflow_0008597543_import_python_tkinter.txt
Q: python: Accessing an instance variable using a name containing a variable in python I'm trying to access a instance variable where I need to use the value of another variable to determine the name: Example Instance Variable: user.remote.directory where it point to the value of 'servername:/mnt/.....' and user por...
python: Accessing an instance variable using a name containing a variable
in python I'm trying to access a instance variable where I need to use the value of another variable to determine the name: Example Instance Variable: user.remote.directory where it point to the value of 'servername:/mnt/.....' and user portion contains the userid of the user, such as joe.remote.directory from another...
[ "Unsure quite what you want, but I think getattr(obj, 'name') might help. See http://docs.python.org/library/functions.html#getattr\n", "You can refer to instance variable called name of object obj this way:\nobj.__dict__['name']\n\nTherefore, if you have another variable prop which holds the name of the instance...
[ 15, 7, 1 ]
[]
[]
[ "instance", "python", "variables" ]
stackoverflow_0008598095_instance_python_variables.txt
Q: How to delete a complete directory tree as quick as possible? Python This is what I do but takes forever: >>> import shutil,os >>> for d in os.listdir("."): ... if os.path.isdir(d): ... shutil.rmtree(d) Directories are full of files in the order of several thousands files. What is the fastest way to d...
How to delete a complete directory tree as quick as possible? Python
This is what I do but takes forever: >>> import shutil,os >>> for d in os.listdir("."): ... if os.path.isdir(d): ... shutil.rmtree(d) Directories are full of files in the order of several thousands files. What is the fastest way to do it instead?
[ "Unfortunately that's FS speed-bound. There's no real way to speed it up if directories are filled up with many files.\n" ]
[ 5 ]
[]
[]
[ "directory", "filesystems", "python" ]
stackoverflow_0008598226_directory_filesystems_python.txt
Q: Using Cheetah Templating Engine with Tornado Web Framework Has anyone used the Cheetah Templating Engine with the Tornado Web Framework before? Do they work well together and are you able to use Cheetah's caching components within the Tornado Framework? I've been looking for a good, python only solution for this. ...
Using Cheetah Templating Engine with Tornado Web Framework
Has anyone used the Cheetah Templating Engine with the Tornado Web Framework before? Do they work well together and are you able to use Cheetah's caching components within the Tornado Framework? I've been looking for a good, python only solution for this. I originally looking at Twisted for the Web Framework but it is ...
[ "I have used Cheetah and Tornado both, but never together. Cheetah's caching is not all that super (as far as time saving). From what I remember, and this may be wrong, but it's caching is just a way of preventing the lookup in the lookup table from taking place. But you still have to actually provide the lookup...
[ 0 ]
[]
[]
[ "caching", "cheetah", "python", "tornado" ]
stackoverflow_0008598332_caching_cheetah_python_tornado.txt
Q: Constructing function from lists within lists in Python I'm stumped on how to construct a function that works on lists within lists from inside out (I guess that's how you could poorly describe it). I'm trying to dynamically turn a list like res = SomeDjangoQuerySet x = ['neighborhood', ['city', ['metro', 'metro'...
Constructing function from lists within lists in Python
I'm stumped on how to construct a function that works on lists within lists from inside out (I guess that's how you could poorly describe it). I'm trying to dynamically turn a list like res = SomeDjangoQuerySet x = ['neighborhood', ['city', ['metro', 'metro']]] into: getattr(getattr(getattr(getattr(res, 'neighborhood...
[ "This sounds like recursion and iteration might be useful. Does this do what you want?\ndef flatten(data):\n res = []\n if hasattr(data, '__iter__'):\n for el in data:\n res.extend(flatten(el))\n else:\n res.append(data)\n return res\n\n\nreduce(getattr, flatten(x), res)\n\n", ...
[ 3, 1, 1 ]
[]
[]
[ "function", "list", "python" ]
stackoverflow_0008587154_function_list_python.txt
Q: How to evaluate a python module is thread-safe or not? Well, the initial thing to my mind was how to make sure if pydispatcher or pubsub is thread-safe or not. pubsub might be a little tricky or complex to figure out but pydispatcher seems simple to realize. Then I started to wonder how to figure out if a python m...
How to evaluate a python module is thread-safe or not?
Well, the initial thing to my mind was how to make sure if pydispatcher or pubsub is thread-safe or not. pubsub might be a little tricky or complex to figure out but pydispatcher seems simple to realize. Then I started to wonder how to figure out if a python module thread-safe or not. Any heuristics?
[ "For determining if a library or application is thread safe, without author input, I would look for mechanisms for synchronizing threads: http://effbot.org/zone/thread-synchronization.htm \nor that it contains threading methods: http://docs.python.org/library/threading.html\nHowever, none of that will tell you how ...
[ 4, 0 ]
[]
[]
[ "multithreading", "python", "thread_safety" ]
stackoverflow_0007467995_multithreading_python_thread_safety.txt
Q: Reverse Inlines in Django Admin with more than one model Say I have some django models, something like this: class Address(models.Model): pass class Person(models.Model): address = models.ForeignKey(Address) class Store(models.Model): address = models.ForeignKey(Address) class Company(models.Model):...
Reverse Inlines in Django Admin with more than one model
Say I have some django models, something like this: class Address(models.Model): pass class Person(models.Model): address = models.ForeignKey(Address) class Store(models.Model): address = models.ForeignKey(Address) class Company(models.Model): address = models.ForeignKey(Address) So, in the Admin in...
[ "Try the following\nfrom django.db import models\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.contrib.contenttypes import generic\n\nclass Address(models.Model):\n object_id = models.PositiveIntegerField()\n content_type = models.ForeignKey(ContentType)\n of = gener...
[ 6, 3 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008597960_django_python.txt
Q: Is there any fast way to modify this kind of dictionary? I have a such dict with following data structure: {'index_1':[('time_1',[ ['a',1],['b',1],['c',1] ]), ('time_2',[ ['a',100],['c',100] ]), ('time_3',[ ['a',200],['b',200],['c',200] ]), ('someting_time', [ ['something_name',...
Is there any fast way to modify this kind of dictionary?
I have a such dict with following data structure: {'index_1':[('time_1',[ ['a',1],['b',1],['c',1] ]), ('time_2',[ ['a',100],['c',100] ]), ('time_3',[ ['a',200],['b',200],['c',200] ]), ('someting_time', [ ['something_name','something_val'] ... ]) ], 'index_2':['something s...
[ "I don't know of any faster ways to re-organize a dict than going through everything using loops. I've found that if you have really complicated dictionary entries, you probably should be using a class.\nHere's a quick code snippet to do what you asked. It doesn't do the 'NO_VAL', but if the time_x isn't in there y...
[ 1 ]
[]
[]
[ "dictionary", "parsing", "python" ]
stackoverflow_0008598769_dictionary_parsing_python.txt
Q: easy_install--failure to import I'm trying to learn web.py and I'm running into issues. I'm using Mac OSX Lion and what I'm doing is that I installed Python using Homebrew and then installed easy_install. I then did sudo easy_install web.py and it appeared to build correctly. However, when I run Python, I can't ru...
easy_install--failure to import
I'm trying to learn web.py and I'm running into issues. I'm using Mac OSX Lion and what I'm doing is that I installed Python using Homebrew and then installed easy_install. I then did sudo easy_install web.py and it appeared to build correctly. However, when I run Python, I can't run "import web" because it can't find ...
[ "Is your /usr/local/bin/python set to the version in your cellar? If so, then \npython setup.py install \n\nshould do the trick.\nYou could try creating a symbolic link in /usr/local/bin that points to the cellar. Example:\nln -s python /usr/local/Cellar/python/2.7.2/bin/python\n\nI use homebrew on Mac OS X (10.5....
[ 0 ]
[]
[]
[ "easy_install", "python" ]
stackoverflow_0007777009_easy_install_python.txt
Q: How to find same lines in two large text files? I'd like to compare two large text files(200M) to get the same lines of them. How to do that in Python? A: since they are just 200M, allocate enough memory, read them, sort the lines in ascending order for each, then iterate through both collections of lines in par...
How to find same lines in two large text files?
I'd like to compare two large text files(200M) to get the same lines of them. How to do that in Python?
[ "since they are just 200M, allocate enough memory, read them, sort the lines in ascending order for each, then iterate through both collections of lines in parallel like in a merge operation and delete those that only occur in one set.\npreserve line numbers in the collections and sort them by line number after the...
[ 1, 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008599317_python.txt
Q: Calling of variable in python Hii I have a requirement of calling the variable in function which is having it declaration and definition in another function.Could any one help me please. import sys import os import tkMessageBox from Tkinter import * from tkCommonDialog import Dialog import shutil import tkFileDial...
Calling of variable in python
Hii I have a requirement of calling the variable in function which is having it declaration and definition in another function.Could any one help me please. import sys import os import tkMessageBox from Tkinter import * from tkCommonDialog import Dialog import shutil import tkFileDialog import win32com.client win = Tk...
[ "i updated your code (and made the corrections needed after reading your feedback) to use class variables/attributes and fixed your error message, check it out. Please note, using class variables means you can only use this class as a singleton, only one of these classes can be used at a time because every instance...
[ 3, 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008585356_python.txt
Q: Copying Directories in Python I am trying to copy a directory from a location to other location and i have written code for that. On executing the IDE is giving me an exception. import sys import os from Tkinter import * from tkCommonDialog import Dialog import shutil import tkFileDialog import win32com.client wi...
Copying Directories in Python
I am trying to copy a directory from a location to other location and i have written code for that. On executing the IDE is giving me an exception. import sys import os from Tkinter import * from tkCommonDialog import Dialog import shutil import tkFileDialog import win32com.client win = Tk() win.title("Copying the Dor...
[ "Look at the code you have, with a few added comments by me.\nclass Copy:\n def __init__(self,Obj):\n la = Label(win, text = \"Source Directory is\",font = \"verdana 12 italic bold\", width = 20,fg = \"Red\", bg = \"WHITE\", )\n la.grid(row=1, column =1)\n #SET abc HERE\n abc = \"tk_c...
[ 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008571799_python.txt
Q: Remove rows with same ID from two lists in Django I have a list of objects called checkins that lists all the times a user has checked into something and another set of objects called flagged_checkins that is certain checkins that the user has flagged. They both reference a 3rd table called with a location_id I'd ...
Remove rows with same ID from two lists in Django
I have a list of objects called checkins that lists all the times a user has checked into something and another set of objects called flagged_checkins that is certain checkins that the user has flagged. They both reference a 3rd table called with a location_id I'd like to take the two lists of objects, and remove any o...
[ "As per this SO question,\ncheckins.objects.filter( location_id__in = list(flagged_checkins.objects.values_list('location_id', flat=True)) ).delete()\n\n", "If you are talking about a queryset then, you can definitely try:\ncheckins.objects.exclude( location_id__in = list(flagged_checkins.objects.values_list('loc...
[ 0, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008599336_django_python.txt
Q: How do I append an item to a list within a list in python? OK, check out the following codes first: Demo1 = [[], []] Demo2 = [[]] * 2 Demo1[0].append(1) Demo2[0].append(1) print "Demo1: ", Demo1 print "Demo2: ", Demo2 And here's the output: Demo1: [[1], []] Demo2: [[1], [1]] I need to create a list whose items...
How do I append an item to a list within a list in python?
OK, check out the following codes first: Demo1 = [[], []] Demo2 = [[]] * 2 Demo1[0].append(1) Demo2[0].append(1) print "Demo1: ", Demo1 print "Demo2: ", Demo2 And here's the output: Demo1: [[1], []] Demo2: [[1], [1]] I need to create a list whose items are all list as well just like Demo1 and Demo2, of course I use...
[ "For you first question: It is happening because in Demo2 case your list contains two copies of the same object. See for example below where I print the memory locations of those elements, noting that they differ for Demo1 but match for Demo2. \n>>> Demo1 = [[], []]\n>>> Demo2 = [[]] * 2\n>>> print id(Demo1[0]), ...
[ 4, 2 ]
[]
[]
[ "list", "python" ]
stackoverflow_0008600018_list_python.txt
Q: IndentationError in Python I am performing one python program and the part of the code is as follows while 1: data = conn.recv(BUFFER_SIZE) if not data: break print "received data:", data com = "echo " + data print com conn.send(data) conn.close() but when i am trying to execute the code i...
IndentationError in Python
I am performing one python program and the part of the code is as follows while 1: data = conn.recv(BUFFER_SIZE) if not data: break print "received data:", data com = "echo " + data print com conn.send(data) conn.close() but when i am trying to execute the code i am getting the following error....
[ "check that you either consistently have tabs or spaces not a mix of both. \n" ]
[ 4 ]
[]
[]
[ "python" ]
stackoverflow_0008600078_python.txt
Q: Python/Cython custom formatter string presentation types I know one could extend Formatter to provide additional presentation types as discussed in PEP3101, but this is entirely too slow for my needs. I'm curious what some other options might be for injecting custom presentation types for strings. Currently, the o...
Python/Cython custom formatter string presentation types
I know one could extend Formatter to provide additional presentation types as discussed in PEP3101, but this is entirely too slow for my needs. I'm curious what some other options might be for injecting custom presentation types for strings. Currently, the only other option that comes to mind is to inspect the {vars} o...
[ "I worked out a solution that seems to have significantly less overhead in cython, though the same could be done in python and ill provide the example here (not sure of the overhead).\nAccording to the python docs, an object can implement the __ format__ method and receive the format spec. In cython Im implementing...
[ 1 ]
[]
[]
[ "cython", "formatter", "python" ]
stackoverflow_0008592249_cython_formatter_python.txt
Q: couchDB-Python storing Date Value I was following the CouchDb tutorial from http://packages.python.org/CouchDB/mapping.html. This seems to be outdated since the modules dont work as per the program. So I just re wrote the CouchDB python script to store few values and here is my script. But when I lookup the CouchD...
couchDB-Python storing Date Value
I was following the CouchDb tutorial from http://packages.python.org/CouchDB/mapping.html. This seems to be outdated since the modules dont work as per the program. So I just re wrote the CouchDB python script to store few values and here is my script. But when I lookup the CouchDb database I can find the name and age ...
[ "The Couchdb example refers to a default value of datetime.now but you are using datetime.datetime.now(). The extra datetime is not an issue but you might want to consider using from datetime import datetime for readability.\nThe issue is that you are calling a function and returning its value, while the example pa...
[ 0, 0 ]
[]
[]
[ "couchdb", "database", "python" ]
stackoverflow_0008116100_couchdb_database_python.txt
Q: Paramiko hang when use ssh-keygen command I am creating one user and want to set the ssh key for that user My script is import paramiko ssh_conn = paramiko.SSHClient() ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_conn.load_system_host_keys() ssh_conn.connect('localhost', username='test', p...
Paramiko hang when use ssh-keygen command
I am creating one user and want to set the ssh key for that user My script is import paramiko ssh_conn = paramiko.SSHClient() ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_conn.load_system_host_keys() ssh_conn.connect('localhost', username='test', password='test') cmd = 'ssh-keygen -t dsa' std...
[ "Before attempting to read the stdout issue:\nstdin.channel.shutdown_write()\n\nSee also this question for reference.\n" ]
[ 5 ]
[]
[]
[ "paramiko", "python", "ssh", "unix" ]
stackoverflow_0008600367_paramiko_python_ssh_unix.txt
Q: How to pick a free port number in python? Possible Duplicate: On localhost, how to pick a free port number? My requirement is different from this question. On localhost, how to pick a free port number? I am writing a test setup of another process using python. The other process needs a port number to be passed (...
How to pick a free port number in python?
Possible Duplicate: On localhost, how to pick a free port number? My requirement is different from this question. On localhost, how to pick a free port number? I am writing a test setup of another process using python. The other process needs a port number to be passed (say as a command line parameter). I cannot har...
[ "There likely is not a safe way to do what you're asking. Even if the OS could return a port to you that is currently free, there's no guarantee that another process wouldn't bind a socket to that port between the time where you request the port and when the application you invoke attempts to bind to it.\nGiven tha...
[ 15 ]
[]
[]
[ "python" ]
stackoverflow_0008599984_python.txt
Q: Django template, how to display value in dropdown box which is in template i doing a small project in django by using python. In that admin can add tasks with high,medium or low priority in database. THen he can see the status of tasks i.e. completed or pending. I am able to dynamically populate a table with data ...
Django template, how to display value in dropdown box which is in template
i doing a small project in django by using python. In that admin can add tasks with high,medium or low priority in database. THen he can see the status of tasks i.e. completed or pending. I am able to dynamically populate a table with data of pending tasks. Above the table, I have given a dropdown box with all priority...
[ "When you display the data after the user selects the priority, change the add the selected attribute to the option that you want selected by default.\n<select>\n <option>One</option>\n <option>Two</option>\n <option>Three</option>\n</select>\n\nIn the above, the first option One will be selected by default.\...
[ 2 ]
[]
[]
[ "django", "javascript", "python" ]
stackoverflow_0008600837_django_javascript_python.txt
Q: Python loops: Precise way to handle mapping matching lists A function returns two lists which are logically mapped one-to-one. Suppose name = ["facebook", "twitter", "myspace"] hits = [4000, 2500, 1800] Therefore, hits for facebook are 4000, twitter 2500, and myspace 2500. I want to convert these two separate li...
Python loops: Precise way to handle mapping matching lists
A function returns two lists which are logically mapped one-to-one. Suppose name = ["facebook", "twitter", "myspace"] hits = [4000, 2500, 1800] Therefore, hits for facebook are 4000, twitter 2500, and myspace 2500. I want to convert these two separate lists into a list of dictionaries like [ {name: 'facebook',data: ...
[ "You could do:\n[{\"name\": n, \"data\": [h]} for n, h in zip(name, hits)]\n\nWhile this does what you asked for, there's probably more data structure here than you really need. Consider:\n>>> dict(zip(name, hits))\n{'twitter': 2500, 'myspace': 1800, 'facebook': 4000}\n\nThis provides the same data set in an easier...
[ 12, 4, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008600516_python.txt
Q: Embed image into xls sheet via python Currently I have a data export going on that does a CSV file like: name, file foo, http://www.google.com/favicon.ico But now I need to make something that embeds the image in a way that it would be visible in excel. How can I accomplish that? A: xlwt is a nice package for c...
Embed image into xls sheet via python
Currently I have a data export going on that does a CSV file like: name, file foo, http://www.google.com/favicon.ico But now I need to make something that embeds the image in a way that it would be visible in excel. How can I accomplish that?
[ "xlwt is a nice package for creating .xls files. And as these examples (1, 2) suggest, it can embed images. Though it can only embed Windows Bitmap format, namely .bmp files. If you have images in a different format, you may need to process them first. \n" ]
[ 1 ]
[]
[]
[ "excel", "export_to_excel", "python" ]
stackoverflow_0008599937_excel_export_to_excel_python.txt
Q: Add Python script to Blender 2.6.1 on mac 10.6.8? I added my Python script to the scripts folder of Blender (which were hidden) however, i'm not sure how to add the script from that point? Eventually I want the model to be added to xcode. A: First of all, don't use the link supplied in the answer to your last q...
Add Python script to Blender 2.6.1 on mac 10.6.8?
I added my Python script to the scripts folder of Blender (which were hidden) however, i'm not sure how to add the script from that point? Eventually I want the model to be added to xcode.
[ "First of all, don't use the link supplied in the answer to your last question How can I use models developed in Blender within an iOS application? it's for Blender 2.4x. Use the recent version from iphonewavefrontloader instead.\nTo install a Blender add-on just go to User Preferences / Add-Ons then press Install ...
[ 0 ]
[]
[]
[ "blender", "blender_2.50", "macos", "python", "xcode4" ]
stackoverflow_0008595594_blender_blender_2.50_macos_python_xcode4.txt
Q: python: passing multiple parameters for Popen command I have spent multiple hours trying to figure out how to pass multiple parameters to python script which is supposed to be executed by subprocess.Popen without any luck. Script: command = ['/usr/bin/python', '/tmp/script.py mcl=NULL mtp=data mnm=DS4INST \ ...
python: passing multiple parameters for Popen command
I have spent multiple hours trying to figure out how to pass multiple parameters to python script which is supposed to be executed by subprocess.Popen without any luck. Script: command = ['/usr/bin/python', '/tmp/script.py mcl=NULL mtp=data mnm=DS4INST \ mno=NULL mse=NULL mce=cll01'] result = subprocess.P...
[ "Try this:\ncommand = ['/usr/bin/python', '/tmp/script.py', 'mcl=NULL', 'mtp=data', 'mnm=DS4INST', 'mno=NULL' 'mse=NULL', 'mce=cll01'] \n\nIn your code, the second element of command is considered as one single argument and interpreted as:\n/usr/bin/python \"/tmp/script.py mcl=NULL mtp=data mnm=DS4INST mno=NULL mse...
[ 6 ]
[]
[]
[ "parameter_passing", "popen", "python" ]
stackoverflow_0008601312_parameter_passing_popen_python.txt
Q: Entering large amount of entries in a SQLite Database I use the following python3 code to add and update entries in an sqlite3 database: def increment_person_counts(count_per_person): with sqlite3.connect(r'./people_database') as connection: cursor = connection.cursor() for person in count_per_perso...
Entering large amount of entries in a SQLite Database
I use the following python3 code to add and update entries in an sqlite3 database: def increment_person_counts(count_per_person): with sqlite3.connect(r'./people_database') as connection: cursor = connection.cursor() for person in count_per_person: if cursor.execute('select * from personCounts w...
[ "You can read your whole 'select * from personCounts' into a python set() at the beginning and then check just against this set.\ndef increment_person_counts(count_per_person):\n with sqlite3.connect(r'./people_database') as connection:\n cursor = connection.cursor()\n cursor.execute('select person from...
[ 2 ]
[]
[]
[ "python", "python_3.x", "sqlite" ]
stackoverflow_0008601414_python_python_3.x_sqlite.txt
Q: Nested for loop (list comprehension) in python; outer loop not looping I am trying to compare data from columns from two different files. I've attempted to use a for, and now a list comprehension. The issue is that the outer for loop is not being iterated through, but the inner one is. I've checked individually an...
Nested for loop (list comprehension) in python; outer loop not looping
I am trying to compare data from columns from two different files. I've attempted to use a for, and now a list comprehension. The issue is that the outer for loop is not being iterated through, but the inner one is. I've checked individually and iteration is just fine; but once I nest I get this issue. Is there somethi...
[ "Note that in your solution the for loops are nested, so that's why one loop seems to iterate while the other one doesn't seem to.\nWhat you need to use to get one element of both iterators at a time is itertools.izip:\n[ oldrow[5] + \" \" + newrow[3]\nfor oldrow, newrow in itertools.izip(origInv, newInv)]\n\n", ...
[ 9, 3, 3, 1, 1 ]
[]
[]
[ "list_comprehension", "nested", "python" ]
stackoverflow_0008595803_list_comprehension_nested_python.txt
Q: Django ModelForm, having a foreign key as a hidden field I'm basically building a very trivial form. Let's stick to the books/publisher examples given in the django tutorials and build upon that. I have a user login to the web app, at which point the first thing they can do is click on a publisher. This publisher ...
Django ModelForm, having a foreign key as a hidden field
I'm basically building a very trivial form. Let's stick to the books/publisher examples given in the django tutorials and build upon that. I have a user login to the web app, at which point the first thing they can do is click on a publisher. This publisher then gets saved for their session. Upon that I take them to a ...
[ "Retrieving the instance of the publisher does protect against client-side changes that might reference a completely invalid publisher.\nTo your second question, yes you can include that field as a hidden field by overriding the field in the ModelForm with the approriate form field setting the widget to HiddenInput...
[ 1, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0001817286_django_python.txt
Q: generate html table with potentially expanding columns and need to reordering columns, using django I have created a list of dictionary in a format as below: [{u'PLAN_A': True, u'PLAN_B': True, u'PLAN_C': True, u'PLAN_D': True, u'PLAN_E': True, u'PLAN_F': True, 'date': u'2011-08-01', u'PLAN_G': True} {u'PLAN_A...
generate html table with potentially expanding columns and need to reordering columns, using django
I have created a list of dictionary in a format as below: [{u'PLAN_A': True, u'PLAN_B': True, u'PLAN_C': True, u'PLAN_D': True, u'PLAN_E': True, u'PLAN_F': True, 'date': u'2011-08-01', u'PLAN_G': True} {u'PLAN_A': True, u'PLAN_B': True, u'PLAN_C': True, u'PLAN_D': True, u'PLAN_E': True, u'PLAN_F': True, 'date': ...
[ "Here's some code that given a list in the above format (with the missing comma in the right place) produces something you can work with:\nbydate = []\nplanNames = set()\nfor d in data:\n ddict = {'date': d['date']}\n plans = d\n del plans['date']\n planNames = planNames.union(plans.keys())\n ddict['...
[ 1 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0008598908_django_django_templates_python.txt
Q: django / haystack / solr simple config - partial field matching issue I have a simple config of haystack/solr on my django app: from the models.py of this app: class device(models.Model): ... hostname = models.CharField(max_length=45, help_text="The hostname for this device") ... from the search_sites...
django / haystack / solr simple config - partial field matching issue
I have a simple config of haystack/solr on my django app: from the models.py of this app: class device(models.Model): ... hostname = models.CharField(max_length=45, help_text="The hostname for this device") ... from the search_sites.py of this app: class devIndex(indexes.SearchIndex): '''Haystack class...
[ "It's likely an analysis problem. I'd guess you are using the StandardTokenizer in your schema.xml file for this field. \nThe standard tokenizer tokenizes host names as a single token. (ref: http://www.lucidimagination.com/search/document/CDRG_ch05_5.5.1), so you can only match it with the full host name. \nIf you ...
[ 0, 0 ]
[]
[]
[ "django", "django_haystack", "pysolr", "python", "solr" ]
stackoverflow_0002189436_django_django_haystack_pysolr_python_solr.txt
Q: Everything is ok, but my 127.0.0.1:8000 can't show anything, why ? I used django-sphinx from djangosphinx.models import SphinxSearch def xx(request): queryset =File.search.query('test') #return HttpResponse(queryset)#<------1 return render_to_response('a.html',{'a':queryset})#<--------2 and class Fil...
Everything is ok, but my 127.0.0.1:8000 can't show anything, why ? I used django-sphinx
from djangosphinx.models import SphinxSearch def xx(request): queryset =File.search.query('test') #return HttpResponse(queryset)#<------1 return render_to_response('a.html',{'a':queryset})#<--------2 and class File(models.Model): name = models.CharField(max_length=200) tags = models.CharField(max_...
[ "Since you are not giving a lot of info, I will make a educated guess. You probably didn't build you search index. Try building it before quering, sphynx search in the sindex, not in the DB.\n" ]
[ 0 ]
[]
[]
[ "django", "django_sphinx", "python", "sphinx" ]
stackoverflow_0002204686_django_django_sphinx_python_sphinx.txt
Q: Error when using Django SVN version I've written some code that works fine when I use Django 1.1, but raises an exception when I use the SVN version: class TribeForm(forms.ModelForm): slug = forms.SlugField(max_length=20, help_text = _("a short version of the name consisting only of letters, numbers, u...
Error when using Django SVN version
I've written some code that works fine when I use Django 1.1, but raises an exception when I use the SVN version: class TribeForm(forms.ModelForm): slug = forms.SlugField(max_length=20, help_text = _("a short version of the name consisting only of letters, numbers, underscores and hyphens."), error_...
[ "It's saying error_message was an unexpected keyword argument. Try error_messages instead: http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages\n", "Error message passed from one error message to un unlimited number and 's' was added. Error messages are not expected to be added as a dictionary, n...
[ 0, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0002175286_django_python.txt
Q: Properties file (ini file) isn't included in python package How do I include a properties/ini file in a python package that is to be used on both Linux and Windows? I tried creating a python package by placing the ini file under the Project folder so that I can access it by using code like: File = open("props.ini"...
Properties file (ini file) isn't included in python package
How do I include a properties/ini file in a python package that is to be used on both Linux and Windows? I tried creating a python package by placing the ini file under the Project folder so that I can access it by using code like: File = open("props.ini", 'r') Then I deploy my package into a .tar.gz file as such: $ p...
[ "One way to do this is to put your configuration file in a directory under your source code.\nFor example, if your source code is under src directory, you can add your configuration files under src/config. After that, for any code in the src directory you can access to the config file using:\nconfig_filename = os.p...
[ 6 ]
[]
[]
[ "package", "pip", "python" ]
stackoverflow_0008601686_package_pip_python.txt
Q: How to generate lots of redundant ajax elements like checkboxes and pulldowns in Django? I've been getting lots of answers from stackoverflow now that I'm in Django just by searching. Now I hope my question will also create some value for everybody. In choosing Django, I was hoping there was some similar mechanis...
How to generate lots of redundant ajax elements like checkboxes and pulldowns in Django?
I've been getting lots of answers from stackoverflow now that I'm in Django just by searching. Now I hope my question will also create some value for everybody. In choosing Django, I was hoping there was some similar mechanism to the way you can do partials in ROR. This was going to help me in two ways. One was in g...
[ "I'm not sure I understand your question, but here's what I think you want, expressed in pseudo-code:\nfor photo in photos:\n form = forms[photo.id]\n generate_some_html(photo, form)\n\nProbably the best way to achieve this is with inclusion tags: http://docs.djangoproject.com/en/dev/howto/custom-template-tag...
[ 0, 0 ]
[]
[]
[ "django", "forms", "list", "python", "templates" ]
stackoverflow_0002460014_django_forms_list_python_templates.txt
Q: Long (>20million element) array summation in python numpy I am new to python and numpy so please excuse me if this problem is so rudimentary! I have an array of negative values (it is sorted): >>>neg [ -1.53507843e+02 -1.53200012e+02 -1.43161987e+02 ..., -6.37326136e-1 -3.97518490e-10 -3.73480691e-10] >>>neg.s...
Long (>20million element) array summation in python numpy
I am new to python and numpy so please excuse me if this problem is so rudimentary! I have an array of negative values (it is sorted): >>>neg [ -1.53507843e+02 -1.53200012e+02 -1.43161987e+02 ..., -6.37326136e-1 -3.97518490e-10 -3.73480691e-10] >>>neg.shape (12922508,) I need to add this array to its duplicate (bu...
[ "As noted in the comments, you get float roundoff problems from summing up many millions of equal-signed numbers. One possible way around this could be to mix positive and negative numbers in the combined array, so that any intermediate results while summing up always stay roughly within the same order of magnitude...
[ 3 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0008599333_numpy_python.txt
Q: Invalid command 'py2exe' I have python 2.5 and 2.6 installed. I'm running my project on 2.6. First I had py2exe for 2.5 installed but it didn't work so I installed py2exe for 2.6 and deleted the other version but then the module wasn't found. Now I changed the sys path: import sys sys.path.append('F:\Program File...
Invalid command 'py2exe'
I have python 2.5 and 2.6 installed. I'm running my project on 2.6. First I had py2exe for 2.5 installed but it didn't work so I installed py2exe for 2.6 and deleted the other version but then the module wasn't found. Now I changed the sys path: import sys sys.path.append('F:\Program Files\Python26\Lib\site-packages\p...
[ "Here is your problem:\nsys.path.append('F:\\Program Files\\Python26\\Lib\\site-packages\\py2exe')\n\nA backslash (\\) is an escape character and interperted in a special way by almost all programming languages, including Python.\nIt's unfortunate that DOS (And by extension Windows) also uses the backslash as a dir...
[ 4 ]
[ "The solution is very simple.\nAdd install.\nSo instead of\n\nsetup.py py2exe\n\nwrite\n\nsetup.py py2exe install\n\nand it works\n" ]
[ -1 ]
[ "py2exe", "python" ]
stackoverflow_0006871520_py2exe_python.txt
Q: Timing out a multiprocessing function I need to set a time limit on a python function which use some multiprocessing stuff (I don't know if it matters). Something like this: function(a_list): p1 = Process(a_list[0:len(a_list/2)]) p2 = Process(a_list[len(a_list)/2: len(a_list)]) //start and join p1...
Timing out a multiprocessing function
I need to set a time limit on a python function which use some multiprocessing stuff (I don't know if it matters). Something like this: function(a_list): p1 = Process(a_list[0:len(a_list/2)]) p2 = Process(a_list[len(a_list)/2: len(a_list)]) //start and join p1, p2 I look around the net and I found a t...
[ "You should be able to do that with this code:\nprocess.join(timeout)\nif process.is_alive():\n process.terminate()\n\nSo instead of setting a timeout in the function, you can join with a timeout the process and if the process hasn't finished after that timeout, then terminate it.\n" ]
[ 11 ]
[]
[]
[ "python", "timeout" ]
stackoverflow_0008601856_python_timeout.txt
Q: Help on my django models for my shoe review website What i'm trying to achieve at this point: Allow me to add new shoe objects, and shoe review objects. complete Allow "Owner Reviews" on each shoe complete (I think, but there might be somewhere in my model I can improve) Allow ratings of attributes defined by me ...
Help on my django models for my shoe review website
What i'm trying to achieve at this point: Allow me to add new shoe objects, and shoe review objects. complete Allow "Owner Reviews" on each shoe complete (I think, but there might be somewhere in my model I can improve) Allow ratings of attributes defined by me which are linked to a particular shoe. Preferably, having...
[ "Instead of that:\nShoeReview.objects.filter(owner_review__ratings__rating_attribute = 'overall').sort_by(owner_review__ratings__rating)\n\nyou should call:\nShoeReview.objects.filter(owner_review__ratings__rating_attribute__attribute = 'overall').order_by(owner_review__ratings__rating)\n\nowner_review__ratings__ra...
[ 1, 1 ]
[]
[]
[ "database_design", "django", "django_models", "python" ]
stackoverflow_0002375365_database_design_django_django_models_python.txt
Q: does python have any service like jndi? I wanted to know if python had any service like Java's JNDI. More specifically, I want a service where providers can register themselves and then consumers can ask fro where certain provider end-points are. For example, assume that I want to implement a mailbox for all my fr...
does python have any service like jndi?
I wanted to know if python had any service like Java's JNDI. More specifically, I want a service where providers can register themselves and then consumers can ask fro where certain provider end-points are. For example, assume that I want to implement a mailbox for all my friends. Each of them have their own end-point,...
[ "You don't have the exact equivalent, but you can read this study to get an overview of what available. Remember you can always use Jython if you feel like using Python and Java tech together.\nIn the end, I tend to agree with @msw, JNDI is probably overkill.\n" ]
[ 2 ]
[]
[]
[ "jndi", "python", "service" ]
stackoverflow_0002688261_jndi_python_service.txt
Q: Python regexp to match e-mail against domain names I'm looking for the "perfect" regexp's to validate if an e-mail belongs to a domain name (including sub-domains), for example: www.domain.com : some1@domain.com sub.domain.com : some1@sub.domain.com domain2.com : some1@domain2.com A: Taken from django: email_re ...
Python regexp to match e-mail against domain names
I'm looking for the "perfect" regexp's to validate if an e-mail belongs to a domain name (including sub-domains), for example: www.domain.com : some1@domain.com sub.domain.com : some1@sub.domain.com domain2.com : some1@domain2.com
[ "Taken from django:\nemail_re = re.compile(\n r\"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\" # dot-atom\n r'|^\"([\\001-\\010\\013\\014\\016-\\037!#-\\[\\]-\\177]|\\\\[\\001-011\\013\\014\\016-\\177])*\"' # quoted-string\n r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+[A-Z]{2,6}\\...
[ 1, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0002640414_python_regex.txt
Q: local variable 'sresult' referenced before assignment I have had multiple problems trying to use PP. I am running python2.6 and pp 1.6.0 rc3. Using the following test code: import pp nodes=('mosura02','mosura03','mosura04','mosura05','mosura06', 'mosura09','mosura10','mosura11','mosura12') def pptester(): ...
local variable 'sresult' referenced before assignment
I have had multiple problems trying to use PP. I am running python2.6 and pp 1.6.0 rc3. Using the following test code: import pp nodes=('mosura02','mosura03','mosura04','mosura05','mosura06', 'mosura09','mosura10','mosura11','mosura12') def pptester(): js=pp.Server(ppservers=nodes) tmp=[] ...
[ "I can't read your code because it's not formatted properly, but I can tell you your exact problem: you're trying to modify a global variable named \"sresult\" from inside a function, but you did not add this line to the beginning of your function:\nglobal sresult\nIf you don't declare a variable global, Python wil...
[ 2, 0 ]
[]
[]
[ "cluster_computing", "parallel_python", "python" ]
stackoverflow_0002616220_cluster_computing_parallel_python_python.txt
Q: Help Replacing Non-ASCII character in Python I have a bunch of HTML files I downloaded using HTTPLIB2 package in Python. ' ' are showing as 'Â '. <font color="#ff0000">02/12/2004Â </font> is showing while <font color="#ff0000">02/12/2004&nbsp;</font> is the desired format. How do I replace the 'Â ' with '&nbsp;' ...
Help Replacing Non-ASCII character in Python
I have a bunch of HTML files I downloaded using HTTPLIB2 package in Python. ' ' are showing as 'Â '. <font color="#ff0000">02/12/2004Â </font> is showing while <font color="#ff0000">02/12/2004&nbsp;</font> is the desired format. How do I replace the 'Â ' with '&nbsp;' in Python? Thanks a lot!
[ "You've got an encoding problem. Instead of trying to remove this characters, look for the encoding of the page, then when you read the file, use the codecs module instead of open(), using the proper character encoding.\n", "filtered_content = filter(lambda x: x in string.printable, content)\n\nThis solved my pro...
[ 1, 0 ]
[ "s.replace('Â ', '&nbsp;');\n\nHowever, while I haven't used HTTPLIB2, I'm pretty sure something is wrong if the source of the HTML files is being changed when you download them. It may be that there's a decoding problem going on. What version of Python are you using? If it's Python 3, the contents will be byte seq...
[ -1 ]
[ "non_ascii_characters", "python", "replace" ]
stackoverflow_0002921815_non_ascii_characters_python_replace.txt
Q: Calling a method with getattr in Python How to call a method using getattr? I want to create a metaclass, which can call non-existing methods of some other class that start with the word 'oposite_'. The method should have the same number of arguments, but to return the opposite result. def oposite(func): retu...
Calling a method with getattr in Python
How to call a method using getattr? I want to create a metaclass, which can call non-existing methods of some other class that start with the word 'oposite_'. The method should have the same number of arguments, but to return the opposite result. def oposite(func): return lambda s, *args, **kw: not oposite(s, *ar...
[ "class Negate(type):\n def __getattr__(self, name):\n if name.startswith('oposite_'):\n def oposite(*args,**kwargs):\n return not getattr(self,name[8:])(*args,**kwargs)\n return oposite\n else:\n raise AttributeError(\"%r object has no attribute %r\" ...
[ 2, 0, 0 ]
[]
[]
[ "getattr", "metaclass", "python" ]
stackoverflow_0002917595_getattr_metaclass_python.txt
Q: Convert timestamp to datenum I have the following timestamp: 20111122051342.582000 I'm using the following code to convert the timestamp to datenum, but with this I'm loosing the millisecons time.mktime( ( datetime.datetime.strptime( rows['TStamp'], "%Y%m%d%H%M%S.%f" ) ).timetuple() ) For 20111122051342.582000 I...
Convert timestamp to datenum
I have the following timestamp: 20111122051342.582000 I'm using the following code to convert the timestamp to datenum, but with this I'm loosing the millisecons time.mktime( ( datetime.datetime.strptime( rows['TStamp'], "%Y%m%d%H%M%S.%f" ) ).timetuple() ) For 20111122051342.582000 I'm getting 1321935222.0 How can I ...
[ "strptime does not read microseconds. Try this:\nymdhms, usec = rows['TStamp'].split('.')\ntime.mktime((datetime.datetime.strptime(ymdhms, \"%Y%m%d%H%M%S\" ) ).timetuple()) + int(usec) / 1000000.\n\nThis works for six (zero-padded) digits after the decimal point.\n" ]
[ 2 ]
[]
[]
[ "datetime", "python", "time" ]
stackoverflow_0008603115_datetime_python_time.txt
Q: Is there a difference between `%`-format operator and `str.format()` in python regarding unicode and utf-8 encoding? Assume that n = u"Tübingen" repr(n) # `T\xfcbingen` # Unicode i = 1 # integer The first of the following files throws UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 82...
Is there a difference between `%`-format operator and `str.format()` in python regarding unicode and utf-8 encoding?
Assume that n = u"Tübingen" repr(n) # `T\xfcbingen` # Unicode i = 1 # integer The first of the following files throws UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 82: ordinal not in range(128) When I do n.encode('utf8') it works. The second works flawless in both cases. # Python File 1...
[ "You're using string.format while you don't have a string but an unicode object.\nprint u'{id}, {name}'.format(id=i, name=n)\n\nwill work, since it uses unicode.format instead.\n" ]
[ 10 ]
[]
[]
[ "encoding", "python", "string", "string_formatting" ]
stackoverflow_0008603333_encoding_python_string_string_formatting.txt
Q: Java equivalent of Python's "construct" library Is there a Java equivalent of Python's "construct" library? I want to write "structs" like so: message = Struct("message", UBInt8("protocol"), UBInt16("length"), MetaField("data", lambda ctx: ctx["length"]) ) It doesn't have to specifically be a library ...
Java equivalent of Python's "construct" library
Is there a Java equivalent of Python's "construct" library? I want to write "structs" like so: message = Struct("message", UBInt8("protocol"), UBInt16("length"), MetaField("data", lambda ctx: ctx["length"]) ) It doesn't have to specifically be a library with some sort of abstraction using the Java language...
[ "I've looked a lot around and all I could find was Ragel (www.complang.org/ragel), that can also produce Java code.\nIt looked too complex for me so I've started some work to port Construct to Java.\nI suspect it would be easier to make something like that in Scala, Groovy or JavaScript.\nConstruct on GitHub: http...
[ 2, 0 ]
[]
[]
[ "construct", "equivalent", "java", "python" ]
stackoverflow_0005211604_construct_equivalent_java_python.txt
Q: Pycurl perform() method, writefunc execution model When pycurl executes its perform() method, does the Python script wait until it gets executed (WRITEFUNCTION) or python immediately proceeds to the next line even if WRITEFUNCTION hasn't been entered or hasn't returned a result? E.g. curl.setopt(pycurl.WRITEFUNCT...
Pycurl perform() method, writefunc execution model
When pycurl executes its perform() method, does the Python script wait until it gets executed (WRITEFUNCTION) or python immediately proceeds to the next line even if WRITEFUNCTION hasn't been entered or hasn't returned a result? E.g. curl.setopt(pycurl.WRITEFUNCTION, receive) curl.perform() some_call() # is this line ...
[ "pycurl is a wrapper around the C implementation (libcurl), and the C implementation calls its WRITEFUNCTION callback during the execution of it's curl_easy_perform or curl_multi_perform functions (the equivalent of the pycurl perform).\nSo you can expect your callback to have finished executing before perform retu...
[ 1 ]
[]
[]
[ "curl", "http", "libcurl", "python" ]
stackoverflow_0008602945_curl_http_libcurl_python.txt
Q: How to use django-notification to inform a user when somebody comments on their post I have been developing in django for sometime now, and have developed a neat website having functionality such as writing blogs, posting questions, sharing content etc. However there is still one thing that is missing and i.e. cre...
How to use django-notification to inform a user when somebody comments on their post
I have been developing in django for sometime now, and have developed a neat website having functionality such as writing blogs, posting questions, sharing content etc. However there is still one thing that is missing and i.e. creating notification for users. What I want to do is to inform users in their profiles, when...
[ "Yes django-notifications is only designed for email notifications.\nHere is a signal slot that you can add to your models.py and tweak to your own needs:\nfrom django.db import models\nfrom django.contrib.sites.models import Site\nfrom django.db.models import signals\nfrom notification import models as notificatio...
[ 13 ]
[]
[]
[ "django", "django_apps", "django_notification", "django_signals", "python" ]
stackoverflow_0008603469_django_django_apps_django_notification_django_signals_python.txt
Q: How to build a Python p2p application? I am new to Python programming and have covered sockets a bit. I couldn't find any simple implementation on the web. Its basic functionality should cover: simple chat file sharing peer lookup How do I start, and what should be the p2p model? I don't want to use any library ...
How to build a Python p2p application?
I am new to Python programming and have covered sockets a bit. I couldn't find any simple implementation on the web. Its basic functionality should cover: simple chat file sharing peer lookup How do I start, and what should be the p2p model? I don't want to use any library such as Twisted, as it is complex.
[ "You could write the library yourself, if you're willing to work with sockets directly. Have each node contain a list of peers that is regularly updated, and set each node to advertise its presence to a central server. You'd need to look into network traversal algorithms, hash tables, etc but it could be done. As X...
[ 1, 0 ]
[]
[]
[ "p2p", "python" ]
stackoverflow_0008600796_p2p_python.txt
Q: how to set unequal x axis intervals in Matplotlib Now I just simply use plt.plot(x,y1,'b.-') to plot a figure, but it turns out so many data are displayed between 0 to 10 on the x axis, so I want to set x axis like this 0,1,5,10,100,1000,100000 thus, the massive data between 0 to 10 can be more spread out. How can...
how to set unequal x axis intervals in Matplotlib
Now I just simply use plt.plot(x,y1,'b.-') to plot a figure, but it turns out so many data are displayed between 0 to 10 on the x axis, so I want to set x axis like this 0,1,5,10,100,1000,100000 thus, the massive data between 0 to 10 can be more spread out. How can I do it in Python, I am using Matplotlib
[ "0,1,5,10,100,1000,100000?\nIf you can live with (0.01, 0.1,), 1, 10, 100, 1000, 10000, 100000,… - then change the xscale to log:\nplt.xscale('log')\n\n", "See the accepted answer to the question How do I convert (or scale) axis values and redefine the tick frequency in matplotlib? Essentially, the matplotlib.pyp...
[ 4, 2 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0008604002_matplotlib_python.txt
Q: Execute a command on the PATH using Python I have the DVCS Mercurial on my PATH in a Windows system respective in a GNU/Linux system. If I open a Bash shell in GNU/Linux I can execute hg (the Mercurial command), the same goes if I open a Command Prompt in Windows. I would like to execute hg and check exit status a...
Execute a command on the PATH using Python
I have the DVCS Mercurial on my PATH in a Windows system respective in a GNU/Linux system. If I open a Bash shell in GNU/Linux I can execute hg (the Mercurial command), the same goes if I open a Command Prompt in Windows. I would like to execute hg and check exit status and capture the output. I know about the subproce...
[ "If you already have hg in your path you shouldn't need anything special in the call to subprocess since you should get the same environment.\nAnyway, if you want to explicitly add a PATH environment variable to your subprocess, you can do this:\nenv = os.environ.copy()\nenv['PATH'] = <whatever you need here>\nsubp...
[ 3 ]
[]
[]
[ "python", "python_2.7", "subprocess" ]
stackoverflow_0008604378_python_python_2.7_subprocess.txt
Q: Using a simple map-reduce to list all keys in a bucket vs. bucket.get_keys()? According to Riak's docs (using Python bindings), get_keys() is extremely expensive and not suitable for production. My question is whether a very simple map query is suitable. For instance, using a map stage only with the function: fu...
Using a simple map-reduce to list all keys in a bucket vs. bucket.get_keys()?
According to Riak's docs (using Python bindings), get_keys() is extremely expensive and not suitable for production. My question is whether a very simple map query is suitable. For instance, using a map stage only with the function: function(v) { return [v.key]; } is this going to perform better than get_keys()? wh...
[ "The get_keys() function calls list_keys in the back end and is considered to be an expensive operation because it performs a full scan of the key space. Depending on your Riak back end, this could also involve a full scan of the data as stored on disk (InnoStore springs to mind). The default storage back end (Bitc...
[ 2, 2 ]
[]
[]
[ "database", "mapreduce", "nosql", "python", "riak" ]
stackoverflow_0007592224_database_mapreduce_nosql_python_riak.txt
Q: How can I validate a date in Python 3.x? I would like to have the user input a date, something like: date = input('Date (m/dd/yyyy): ') and then make sure that the input is a valid date. I don't really care that much about the date format. Thanks for any input. A: You can use the time module's strptime() funct...
How can I validate a date in Python 3.x?
I would like to have the user input a date, something like: date = input('Date (m/dd/yyyy): ') and then make sure that the input is a valid date. I don't really care that much about the date format. Thanks for any input.
[ "You can use the time module's strptime() function:\nimport time\ndate = input('Date (mm/dd/yyyy): ')\ntry:\n valid_date = time.strptime(date, '%m/%d/%Y')\nexcept ValueError:\n print('Invalid date!')\n\nNote that in Python 2.x you'll need to use raw_input instead of input.\n", "def validDate(y, m, d):\n Result...
[ 27, 3, 2 ]
[]
[]
[ "date", "python", "python_3.x", "validation" ]
stackoverflow_0002216250_date_python_python_3.x_validation.txt
Q: Getting CPU or motherboard serial number? I'm trying to get the CPU serial or motherboard serial using C or Python for licensing purposes. Is it possible? I'm using Linux. A: Under Linux, you could use "lshw -quiet -xml" and parse its output. You'll find plenty of system information here: cpuid, motherboard id a...
Getting CPU or motherboard serial number?
I'm trying to get the CPU serial or motherboard serial using C or Python for licensing purposes. Is it possible? I'm using Linux.
[ "Under Linux, you could use \"lshw -quiet -xml\" and parse its output. You'll find plenty of system information here: cpuid, motherboard id and much more. \n", "You need to use the CPUID instruction.\nCPUID\nMost C compilers have some support for inline assembly, but you will need to know what you are doing.\n", ...
[ 7, 4, 3, 2, 0 ]
[]
[]
[ "c", "cpu", "licensing", "motherboard", "python" ]
stackoverflow_0004216009_c_cpu_licensing_motherboard_python.txt
Q: Deleting certain instances of a class attribute I am working with classes in Python for the first time and I need to loop through my class attributes and delete certain instances under certain conditions. The problem is that I cannot find any examples of deleting instances of certain attributes. To be a little mor...
Deleting certain instances of a class attribute
I am working with classes in Python for the first time and I need to loop through my class attributes and delete certain instances under certain conditions. The problem is that I cannot find any examples of deleting instances of certain attributes. To be a little more specific, my class is phone_bills and one of my att...
[ "\nI am starting to wonder if working with classes is wrong for this particular project.\n\nNo, certainly not, no worries :)\n\nLets say we have the following class:\nclass PhoneBills(object):\n def __init__(self, minutes_used):\n self.minutes_used = minutes_used\n\nThen you can delete the attribute minut...
[ 4, 1, 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008604187_python.txt
Q: DLL use in Python 2.7 with ctypes I have a problem about using DLL file. The code I used is below. In handbook of DLL it writes the signiture of function. I'm using Python 2.7 from ctypes import * mtrs= windll.LoadLibrary("mtrs.dll") mtrs.sw_Open("SystemWorks", 0, c_ulong( 0x100 | 0x10000), None, None) 0 In handb...
DLL use in Python 2.7 with ctypes
I have a problem about using DLL file. The code I used is below. In handbook of DLL it writes the signiture of function. I'm using Python 2.7 from ctypes import * mtrs= windll.LoadLibrary("mtrs.dll") mtrs.sw_Open("SystemWorks", 0, c_ulong( 0x100 | 0x10000), None, None) 0 In handbook of DLL it writes the signature of f...
[ "If you are using Python 3x, you should use b\"SystemWorks\" because first argument has LPCSTR type.\n", "#!/usr/bin/env python3\nfrom ctypes import *\nmtrs= windll.LoadLibrary(\"mtrs.dll\")\nmtrs.sw_Open.argtypes = [c_char_p, c_ulong, c_ulong, c_void_p, c_void_p]\nmtrs.sw_Open.restype = c_bool\nmtrs.sw_Open(b\"S...
[ 0, 0 ]
[]
[]
[ "ctypes", "parameters", "python" ]
stackoverflow_0008604705_ctypes_parameters_python.txt
Q: Sorting a list of list of tuples based on the sum of first field in the tuple in Python I have an outermost list which contains a monthly total count of different items in this format. Every month has the same items. big_list = [ [ (20, 'Item A', 'Jan'), (30, 'Item B', 'Jan'), (12, 'Item C', 'Jan'), ...
Sorting a list of list of tuples based on the sum of first field in the tuple in Python
I have an outermost list which contains a monthly total count of different items in this format. Every month has the same items. big_list = [ [ (20, 'Item A', 'Jan'), (30, 'Item B', 'Jan'), (12, 'Item C', 'Jan'), ], [ (22, 'Item A', 'Feb'), (34, 'Item B', 'Feb'), (15, 'Item C', 'Feb'), ]...
[ "big_list = [\n [\n (20, 'Item A', 'Jan'),\n (30, 'Item B', 'Jan'),\n (12, 'Item C', 'Jan'),\n ],\n [\n (22, 'Item A', 'Feb'),\n (34, 'Item B', 'Feb'),\n (15, 'Item C', 'Feb'),\n ]]\n\ns = {}\nfor l in big_list:\n for m in l:\n s[m[1]] = s.get(m[1], 0) + m[0]\n\ngives us s - the sums...
[ 3, 1, 0, 0 ]
[]
[]
[ "list", "python", "sorting", "tuples" ]
stackoverflow_0008605189_list_python_sorting_tuples.txt
Q: Programming a GSM phone/modem to make phone calls I want to use a program written in a high level language like Java or Python to talk to a GSM Modem. I want to be able to tell the modem what number to call and when to call it. I also want to be able to read and send text messages. I do NOT need to handle voice t...
Programming a GSM phone/modem to make phone calls
I want to use a program written in a high level language like Java or Python to talk to a GSM Modem. I want to be able to tell the modem what number to call and when to call it. I also want to be able to read and send text messages. I do NOT need to handle voice transmission in either direction of the call. I'd apprec...
[ "There are a set of relatively standard \"AT\" commands that can be used for these types of operations - including placing phone calls and sending text messages. Some details around this are at http://www.smssolutions.net/tutorials/gsm/sendsmsat/ and http://www.dreamfabric.com/sms/ (simply first results of a littl...
[ 3, 0 ]
[]
[]
[ "gsm", "java", "mobile", "modem", "python" ]
stackoverflow_0008549259_gsm_java_mobile_modem_python.txt
Q: if statement against each item in a list I am trying to do something like the following in python, but i am getting an invalid syntax error: network_n = 192.168.38 octate_n = network_n.split(".") if (len(o) [for o in octate_n]) == 3: But when i am run it, i get: if (len(o) [for o in octate_n]) == 3: ...
if statement against each item in a list
I am trying to do something like the following in python, but i am getting an invalid syntax error: network_n = 192.168.38 octate_n = network_n.split(".") if (len(o) [for o in octate_n]) == 3: But when i am run it, i get: if (len(o) [for o in octate_n]) == 3: ^ SyntaxError: invalid syntax My problem...
[ "Use all:\nif(all(len(o) == 3 for o in octate_n)):\n # do stuff\n\nAbout your seconds question, [o for o in octate_n] creates a list that consists of all items in octate_n (this is called a list comprehension), while (o for o in octate_n) creates a generator that will yield all the items of octate_n (this is cal...
[ 6, 2, 0, 0 ]
[]
[]
[ "if_statement", "python" ]
stackoverflow_0008600567_if_statement_python.txt
Q: pysvn prompts for password with svn+ssh I'm writing Python app which uses pysvn to get svn log history. It works ok for http:// like urls, but for svn+ssh:// I get prompted for a password on the command line! I use callback_get_login to authenticate. Is there any way to avoid the prompt and authenticate with pysvn...
pysvn prompts for password with svn+ssh
I'm writing Python app which uses pysvn to get svn log history. It works ok for http:// like urls, but for svn+ssh:// I get prompted for a password on the command line! I use callback_get_login to authenticate. Is there any way to avoid the prompt and authenticate with pysvn for svn+ssh svn repos?
[ "This is the normal behavior for svn+ssh. Unless you have SSH Keys deployed and are connecting using the username for that host, you are going to have this issue.\nUnfortunately, after some research it looks like PySVN may not support the use of SSH keys at this moment in time.\n" ]
[ 1 ]
[]
[]
[ "pysvn", "python", "ssh", "svn" ]
stackoverflow_0008603991_pysvn_python_ssh_svn.txt
Q: Client/Server in Separate Projects or in One I've written a small Client-/Server software (chat program). It is composed of a server script (pyhon), a desktop-client (python), a webinterface and an android-client (java). How would you organize this? (folder-structure, ...) I would love to have one big project, b...
Client/Server in Separate Projects or in One
I've written a small Client-/Server software (chat program). It is composed of a server script (pyhon), a desktop-client (python), a webinterface and an android-client (java). How would you organize this? (folder-structure, ...) I would love to have one big project, but if I only push them all together in a src folde...
[ "It is good to keep each component in a dedicated space, and if there is something in common that is shared between them, I would turn it into an independent project too. I also would not mix the java source tree with the python one, to avoid mixing everything up.\nSomething like\n/projectname/python/src/core/\n/pr...
[ 2 ]
[]
[]
[ "directory", "eclipse", "java", "project_management", "python" ]
stackoverflow_0008605876_directory_eclipse_java_project_management_python.txt