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: Data encoding in new protocol handshake hybi-10 I'm using a WebSocket for python and JavaScriptand until now the handshake protocol for Google Chrome was draft hybi-00. I guess Google Chrome changed the protocol to draft hybi-10 recently. So today I updated the handshake code and now the WebSocket is succefully cr...
Data encoding in new protocol handshake hybi-10
I'm using a WebSocket for python and JavaScriptand until now the handshake protocol for Google Chrome was draft hybi-00. I guess Google Chrome changed the protocol to draft hybi-10 recently. So today I updated the handshake code and now the WebSocket is succefully created and opened. On the onopen event in JavaScript, ...
[ "The way data is framed in HyBi (HyBi-00 is really Hixie-76) is significantly changed. The new frame format is described in this diagram.\nAlso, for data that is sent from the client to the server, the data is masked. The mask is the first 4 bytes of the frame payload and is decoded (and encoded actually) in place ...
[ 1 ]
[]
[]
[ "google_chrome", "javascript", "python", "websocket" ]
stackoverflow_0007486189_google_chrome_javascript_python_websocket.txt
Q: Django Project Multi-Database Config in settings.py I am currently in the process of taking an asp.NET internal website written in C# and redoing it in the Django web framework. After identifying all of the current data sources being used by the .NET site, I have begun configuring and testing my ability to connec...
Django Project Multi-Database Config in settings.py
I am currently in the process of taking an asp.NET internal website written in C# and redoing it in the Django web framework. After identifying all of the current data sources being used by the .NET site, I have begun configuring and testing my ability to connect to those databases from within the Django framework. P...
[ "Based on this link https://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-dbshell, you should use python dbshell --database mssql.\n" ]
[ 0 ]
[]
[]
[ "configuration", "django", "multi_database", "python" ]
stackoverflow_0007486233_configuration_django_multi_database_python.txt
Q: Getting envisage services in a Handler I'm using envisage workbance and I want to get the service in the Handler. In the _tcp_send_changed function how can I get the services. In the plugin there is the self.application.get_service(....) but here how can I reach them? UPDATED This is my view class MCLidarGUIView(...
Getting envisage services in a Handler
I'm using envisage workbance and I want to get the service in the Handler. In the _tcp_send_changed function how can I get the services. In the plugin there is the self.application.get_service(....) but here how can I reach them? UPDATED This is my view class MCLidarGUIView( HasTraits ): traits_ui_view = ...
[ "I'm just guessing but from the documentation it seams like you have to register a service first. Maybe show us a bit more code so we can help better.\n", "class MyHandler(Handler):\ndef __init__(self, application, **traits):\n Handler.__init__(self, **traits)\n self.application = application\n\n...\n" ]
[ 1, 1 ]
[]
[]
[ "enthought", "plugins", "python" ]
stackoverflow_0007470609_enthought_plugins_python.txt
Q: View output from long running external process called from Python I have a very long running process that I would like to call from a Python program. This process outputs a lot of information to stdout. I would like to see the output from my called program on the command line as it is running. I have read about...
View output from long running external process called from Python
I have a very long running process that I would like to call from a Python program. This process outputs a lot of information to stdout. I would like to see the output from my called program on the command line as it is running. I have read about Popen, and tried p = Popen(cmd, stdout=PIPE, stderr=PIPE) stdout, stde...
[ "I have figured this out by using part of what was mentioned in the comments, and combined that with the following\n# read line without blocking\nwhile not p.poll():\n try: \n line = q.get_nowait() # or q.get(timeout=.1)\n except Empty:\n pass # Do nothing\n else: # got line\n print li...
[ 1 ]
[]
[]
[ "popen", "python" ]
stackoverflow_0007478895_popen_python.txt
Q: how can i print return values (success/failure) from a python script i have a python script, that connects to a web service using suds client, and gets data. Now based on what was queried, i can get a true or false as results. so when i run the script with correct data values, i get nothing on the stdout, but when...
how can i print return values (success/failure) from a python script
i have a python script, that connects to a web service using suds client, and gets data. Now based on what was queried, i can get a true or false as results. so when i run the script with correct data values, i get nothing on the stdout, but when i use incorrect data, i get "data error", based on : except Exception, e...
[ "What you get on stdout is what you print in your script (so in your case, you will get 'data error' on stdout in case of error).\nIf you want to handle correctly the return code of you python script, take a look to the sys.exit(return_code) method which will return to the caller the return_code (in general 0 when ...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0007487467_python.txt
Q: Trim (remove frames from) a video using Python I would like to trim - cut off frames at the beginning and end - a video that can be in a variety of different formats, and then save the trimmed video. Are there any libraries or suggestions on how to do this? Thanks! A: I've been using ffmpeg and the subprocess mo...
Trim (remove frames from) a video using Python
I would like to trim - cut off frames at the beginning and end - a video that can be in a variety of different formats, and then save the trimmed video. Are there any libraries or suggestions on how to do this? Thanks!
[ "I've been using ffmpeg and the subprocess module of python to extract video thumbnails, but it seems ffmpeg can do pretty much anything.\nOnce you install ffmpeg, you can trim off the first second of video like so\n> ffmpeg -i sample.mov -ss 1 trim.mov\n\nSo using the subprocess module of python\nimport subproces...
[ 3 ]
[]
[]
[ "frames", "python", "trim", "video" ]
stackoverflow_0007291653_frames_python_trim_video.txt
Q: Python or awk/sed for cleaning data I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and ...
Python or awk/sed for cleaning data
I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents...
[ "Not to spoil your adventure, but I'd say no and here is why:\n\nR is vectorised where sed/awk are not\nR already has both Perl regular expression and extended regular expressions\nR can more easily make recourse to statistical routines (say, imputation) if you need it\nR can visualize, summarize, ...\n\nand most i...
[ 15, 10, 6, 3, 1, 1 ]
[]
[]
[ "awk", "data_cleaning", "python", "r", "sed" ]
stackoverflow_0007479686_awk_data_cleaning_python_r_sed.txt
Q: Objects mismatch I'm writing in python some json encoders for a dictionary derived class, the class EPPI_dictDB, the object of this class may be store as value some instances of the class parser. BUT when I would encode something goes wrong and the instance of the class EPPI_dictDB passed to the specific encoder ...
Objects mismatch
I'm writing in python some json encoders for a dictionary derived class, the class EPPI_dictDB, the object of this class may be store as value some instances of the class parser. BUT when I would encode something goes wrong and the instance of the class EPPI_dictDB passed to the specific encoder function becomes an in...
[ "Guessing a bit:\nJSON encoders already know how to handle dicts, so it treats your dict subclass the same way as a dict. However, when it reaches s[\"parser\"], it doesn't know what to do with the object, so it calls your default method on it. I.e. from your code, it's seeing p, not s.\nThis seems to be what the d...
[ 0 ]
[]
[]
[ "class", "encoding", "json", "python" ]
stackoverflow_0007487722_class_encoding_json_python.txt
Q: Super simple django e-mail based user registration system? I found the django-registration app, but it seems to complex for what I am trying to do. I want users to simply enter their e-mail (username) + a password and automatically be registered. No activations or confirmations. Hacker News style. Does anyone know...
Super simple django e-mail based user registration system?
I found the django-registration app, but it seems to complex for what I am trying to do. I want users to simply enter their e-mail (username) + a password and automatically be registered. No activations or confirmations. Hacker News style. Does anyone know what the simplest way to implement this would be? Is there some...
[ "Login/Authentication\nTo make Django authenticate using email/password instead of username/password, you will need to add to your settings.py:\nAUTHENTICATION_BACKENDS = ('myproject.myauthenticationbackend')\n\nThis authentication backend needs to be able to authenticate a user based on email/password. A good emai...
[ 3, 2 ]
[]
[]
[ "django", "python", "registration" ]
stackoverflow_0007480896_django_python_registration.txt
Q: Making multidimensional lists in python This question maybe asked earlier (atleast topic wise) , but still I couldn't find a solution for my specific problem. Basically, I need a multidimensional array in python. Such that: I will be able to access contents in list by : contenets[no_of_record][record]. So I ha...
Making multidimensional lists in python
This question maybe asked earlier (atleast topic wise) , but still I couldn't find a solution for my specific problem. Basically, I need a multidimensional array in python. Such that: I will be able to access contents in list by : contenets[no_of_record][record]. So I have a file like : 101, Mrs. Jones' Math Class...
[ "from the csv examples of the doc you should do something along the lines\nimport csv\nrows = []\nwith open('some.csv', 'rb') as f:\n reader = csv.reader(f)\n for row in reader:\n print row\n rows.append(row)\n\n", "If you really want a list of lists you can do it with this:\ncontents = [l.spl...
[ 4, 3, 1, 1 ]
[]
[]
[ "list", "python" ]
stackoverflow_0007488240_list_python.txt
Q: Set eclipse ee preference for mac osx lion I have a mac (osx lion). I have installed eclipse (Eclipse Java EE IDE for Web Developers. Version: Indigo Release; Build id: 20110615-0604). And I have installed the python plugins, following instructions from http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclip...
Set eclipse ee preference for mac osx lion
I have a mac (osx lion). I have installed eclipse (Eclipse Java EE IDE for Web Developers. Version: Indigo Release; Build id: 20110615-0604). And I have installed the python plugins, following instructions from http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm. Now, according to t...
[ "I am assuming that you tried /user/bin/python and it did not work. ( It worked for me while setting up my pycharm ide)..\nThen provide the following path as your python Interpreter path.\n\n/System/Library/Frameworks/Python.framework/Versions/2.6/bin\n\n(of course, your path might be slightly different).\n" ]
[ 1 ]
[]
[]
[ "eclipse", "osx_leopard", "python" ]
stackoverflow_0007488649_eclipse_osx_leopard_python.txt
Q: how to insert HTML code into a table How can I insert a piece of HTML Code (containing " and ') into my MySQL database? It's not that easy for me to simply escape all the " and ' with a backslash, so I'm looking for other solutions. All the solutions I have found are depended on some programming language, such as ...
how to insert HTML code into a table
How can I insert a piece of HTML Code (containing " and ') into my MySQL database? It's not that easy for me to simply escape all the " and ' with a backslash, so I'm looking for other solutions. All the solutions I have found are depended on some programming language, such as PHP, like in this example. The programming...
[ "Generally speaking:\nYou need to escape data before it is inserted into the mySQL query. The Python library that provides access to mySQL should provide an escaping function to do this, or escape the data automatically using prepared statements. \nThe reason why string data needs to be escaped is that quotes (\" o...
[ 2 ]
[]
[]
[ "database", "html", "insert", "mysql", "python" ]
stackoverflow_0007488694_database_html_insert_mysql_python.txt
Q: Convert mongoengine queryset to a json file How do I dump the data in a queryset of Mongo documents to a .json file using python? I've tried to use django serializer, but didn't work as the fields are not accessed in django the same way as they are accessed in mongo. for model in models: json_serializer.seria...
Convert mongoengine queryset to a json file
How do I dump the data in a queryset of Mongo documents to a .json file using python? I've tried to use django serializer, but didn't work as the fields are not accessed in django the same way as they are accessed in mongo. for model in models: json_serializer.serialize(model.objects.all(), indent=2, stream=output...
[ "The django serializer does not know how to handle mongoengine objects, You'll most likely have to write your own json encoder to map them to a simple dictionary:\nclass MyEncoder(json.JSONEncoder):\n def encode_object(self, obj):\n return { 'id':unicode(obj.id), 'other_property': obj.other_property }\n\n...
[ 2 ]
[]
[]
[ "django", "django_queryset", "mongodb", "mongoengine", "python" ]
stackoverflow_0007485663_django_django_queryset_mongodb_mongoengine_python.txt
Q: Does Twisted cache DNS lookups? Does it honour TTL? If I use the Twisted Endpoint API to make a series of connections to the same host, will Twisted cache the DNS lookup between requests? If it does, will it honour the DNS record's TTL? My implementation is fairly vanilla. I instantiate a SSL4ClientEndpoint with h...
Does Twisted cache DNS lookups? Does it honour TTL?
If I use the Twisted Endpoint API to make a series of connections to the same host, will Twisted cache the DNS lookup between requests? If it does, will it honour the DNS record's TTL? My implementation is fairly vanilla. I instantiate a SSL4ClientEndpoint with host, port etc, and through the life of the program I use ...
[ "I think Twisted simply uses the OS' resolver, so the answer to both questions is \"as much as your OS does\".\n" ]
[ 2 ]
[]
[]
[ "dns", "python", "twisted" ]
stackoverflow_0007488720_dns_python_twisted.txt
Q: What method attributes are used in Django? Under the documentation for ModelAdmin.list_display it describes a few ways to configure a method/function for usage and display in an admin's list view: admin_order_field (describes which field in the model to use for ordering by the method) allow_tags (allows HTML to b...
What method attributes are used in Django?
Under the documentation for ModelAdmin.list_display it describes a few ways to configure a method/function for usage and display in an admin's list view: admin_order_field (describes which field in the model to use for ordering by the method) allow_tags (allows HTML to be displayed rather than escaped) short_descripti...
[ "funny that you should ask about this, I was just a bit surprised by a different use of this in the django documentation earlier today:\ndef upper_case_name(obj):\n return (\"%s %s\" % (obj.first_name, obj.last_name)).upper()\nupper_case_name.short_description = 'Name'\n# !!! another occurrence of a \"method att...
[ 5 ]
[ "This question is pretty far-reaching if I'm understanding it correctly. Depending on the object you are looking at there are likely a lot of methods and attributes.\nI recommend:\n\nLook at the source. Django's docs are a great starting point but you'll find it's much more powerful than what is openly described.\n...
[ -6 ]
[ "django", "function", "methods", "python" ]
stackoverflow_0007337681_django_function_methods_python.txt
Q: Changing the Precision of a Float and Storing in Python I have searched around for an answer to this and only found pieces of my problem. I commented the code through the process to say what works and what doesnt and what errors I get for each line. Thanks in advance. # # list_of_numbers is a list ...
Changing the Precision of a Float and Storing in Python
I have searched around for an answer to this and only found pieces of my problem. I commented the code through the process to say what works and what doesnt and what errors I get for each line. Thanks in advance. # # list_of_numbers is a list with numbers # like '3.543345354' # #...
[ "You want the round function:\nn2 = round(n, 2)\n\nAlso, be forewarned: floats are imprecise, and when you round to two places, then print them, they may look like they have more. You will need to use %.2f in your format string to display them with two places. If you need absolute precision (say for money), Decim...
[ 7 ]
[]
[]
[ "floating_point", "python" ]
stackoverflow_0007489042_floating_point_python.txt
Q: Running Another program from python I want to call a program multiple times from a python code, and save the output of that program in a text file. My first problem right now is just calling the other code. I have to redirect to a different directory and call ./rank on output.txt. This is how Im trying to do it: ...
Running Another program from python
I want to call a program multiple times from a python code, and save the output of that program in a text file. My first problem right now is just calling the other code. I have to redirect to a different directory and call ./rank on output.txt. This is how Im trying to do it: TheCommand = "~/src/rank-8-9-2011/rank...
[ "the name of the program in the first argument to subprocess.Popen must not contain ~ as it doesn't pass the string to the shell for processing (which like always using parameterized queries in sql, protects one from string injection attacks, e.g. if instead of output.text one had ;rm -rf /, the system version woul...
[ 5, 2, 0 ]
[]
[]
[ "python", "sys" ]
stackoverflow_0007488948_python_sys.txt
Q: Python socket error - how to repair I have this code: >>> import socket >>> sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> sck.connect(('loaclhost', 2525)) And I have this error: Traceback (most recent call last): File "<pyshell#4>", line...
Python socket error - how to repair
I have this code: >>> import socket >>> sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> sck.connect(('loaclhost', 2525)) And I have this error: Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> sck.connect(('localho...
[ "try changing the connection to \"localhost\" instead of \"loaclhost\"\n", "Your code and error don't match (spelling of localhost and port number), but the error message is due to no server listening on that port. Cut and paste the exact code and error message next time.\n" ]
[ 5, 1 ]
[]
[]
[ "error_handling", "python", "python_3.x", "sockets" ]
stackoverflow_0007489023_error_handling_python_python_3.x_sockets.txt
Q: What is the fastest way to add data to a list without duplication in python (2.5) I have about half a million items that need to be placed in a list, I can't have duplications, and if an item is already there I need to get it's index. So far I have if Item in List: ItemNumber=List.index(Item) else: List.ap...
What is the fastest way to add data to a list without duplication in python (2.5)
I have about half a million items that need to be placed in a list, I can't have duplications, and if an item is already there I need to get it's index. So far I have if Item in List: ItemNumber=List.index(Item) else: List.append(Item) ItemNumber=List.index(Item) The problem is that as the list grows it ge...
[ "You can use a set (in CPython since version 2.4) to efficiently look up duplicate values. If you really need an indexed system as well, you can use both a set and list.\nDoing your lookups using a set will remove the overhead of if Item in List, but not that of List.index(Item)\nPlease note ItemNumber=List.index(I...
[ 16, 13, 6 ]
[]
[]
[ "list", "python" ]
stackoverflow_0007489219_list_python.txt
Q: Python subprocess readlines()? So I'm trying to move away from os.popen to subprocess.popen as recommended by the user guide. The only trouble I'm having is I can't seem to find a way of making readlines() work. So I used to be able to do list = os.popen('ls -l').readlines() But I can't do list = subprocess.Pope...
Python subprocess readlines()?
So I'm trying to move away from os.popen to subprocess.popen as recommended by the user guide. The only trouble I'm having is I can't seem to find a way of making readlines() work. So I used to be able to do list = os.popen('ls -l').readlines() But I can't do list = subprocess.Popen(['ls','-l']).readlines()
[ "ls = subprocess.Popen(['ls','-l'], stdout=subprocess.PIPE)\nout = ls.stdout.readlines()\n\nor, if you want to read line-by-line (maybe the other process is more intensive than ls):\nfor ln in ls.stdout:\n # whatever\n\n", "With subprocess.Popen, use communicate to read and write data:\nout, err = subprocess.P...
[ 39, 32, 13, 3, 3 ]
[]
[]
[ "python", "subprocess" ]
stackoverflow_0007468668_python_subprocess.txt
Q: Using un-managed file in Jenkins build step I've just started using Jenkins today, so it's entirely possible that I've missed something in the docs. I currently have Jenkins set up to run unit tests from a local Git repo (via plugin). I have set up the environment correctly (at least, in a seemingly working condit...
Using un-managed file in Jenkins build step
I've just started using Jenkins today, so it's entirely possible that I've missed something in the docs. I currently have Jenkins set up to run unit tests from a local Git repo (via plugin). I have set up the environment correctly (at least, in a seemingly working condition), but have run into a small snag. I have a si...
[ "I would suggest using some environment variable, like MYPROJECT_SETTINGS. So when running the task by Jenkins you can overwrite the default path to whatever you can put your settings file for Jenkins in.\nThe other option, in case you don't want to copy settings file to each build-machine by hand, would be making ...
[ 1, 0, 0 ]
[]
[]
[ "build", "git", "jenkins", "python" ]
stackoverflow_0007479757_build_git_jenkins_python.txt
Q: joining an always-running thread in python Forgive me if this is a dumb question; I am very new to threading. I am running a thread that will finish when I change it's keeprunning status like so: class mem_mon(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.keeprunn...
joining an always-running thread in python
Forgive me if this is a dumb question; I am very new to threading. I am running a thread that will finish when I change it's keeprunning status like so: class mem_mon(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.keeprunning = True self.maxmem = 0 def run(s...
[ "Use threading.Event as an time.sleep() you can interrupt.\nclass mem_mon(threading.Thread):\n def __init__(self):\n threading.Thread.__init__(self)\n self.keeprunning = True\n self.maxmem = 0\n self.interrupt = threading.Event()\n\n def run(self):\n # this loop will run unt...
[ 3, 0 ]
[]
[]
[ "multithreading", "python" ]
stackoverflow_0007489390_multithreading_python.txt
Q: Easiest way to add a function to existing class I'm using the python's built-in shelve module to manage some simple dictionaries. The problem I'm having is I want to use with shelve.open(filename) as f:, but when I try it claims DbfilenameShelf has no attribute __exit__. So, I'm guessing the easiest way to do this...
Easiest way to add a function to existing class
I'm using the python's built-in shelve module to manage some simple dictionaries. The problem I'm having is I want to use with shelve.open(filename) as f:, but when I try it claims DbfilenameShelf has no attribute __exit__. So, I'm guessing the easiest way to do this is to wrap it in another class and add an __exit__ f...
[ "Don't subclass it. Python comes with a tool for automatically calling close(), contextlib.closing:\nfrom contextlib import closing\nwith closing(shelve.open(filename)) as f:\n # your 'with' block here\n\nwill automatically call the close() method of the object returned by shelve.open(filename) at the end of the...
[ 12, 2 ]
[]
[]
[ "python", "shelve", "wrapper" ]
stackoverflow_0007489732_python_shelve_wrapper.txt
Q: python cProfile giving 'int' object is not callable error Following script runs great: $ python myscript.py When I try to profile my code using cProfile like: $ python -m cProfile -s time myscript.py or $ python -m cProfile myscript.py I get following error: Traceback (most recent call last): File "/System/L...
python cProfile giving 'int' object is not callable error
Following script runs great: $ python myscript.py When I try to profile my code using cProfile like: $ python -m cProfile -s time myscript.py or $ python -m cProfile myscript.py I get following error: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/r...
[ "You have an integer variable named id that is masking the built-in function id. That is messing up cProfile. \nRename your id variable and cProfile should work fine.\n" ]
[ 6 ]
[]
[]
[ "cprofile", "profiler", "python" ]
stackoverflow_0007490079_cprofile_profiler_python.txt
Q: Python Thrift RPC Not working on EC2 I am trying to create a simple client/server application using Thrift which is going to be run on EC2. The example I created works awesome for localhost, but when I try to make the RPC call across two different machines on ec2 (both of which have separately allocated elastic IP...
Python Thrift RPC Not working on EC2
I am trying to create a simple client/server application using Thrift which is going to be run on EC2. The example I created works awesome for localhost, but when I try to make the RPC call across two different machines on ec2 (both of which have separately allocated elastic IP addresses), it does not work with the fol...
[ "I am hazarding a guess that when one of your ec2 instance (\"node1\") attempts the RPC call to the other ec2 instance (\"node2\"), node2 returns its internal IP address instead.\nReference - http://alestic.com/2009/06/ec2-elastic-ip-internal\nQuote:\n\nThis last option uses a little-known feature of the Elastic IP...
[ 4 ]
[]
[]
[ "amazon_ec2", "facebook", "python", "thrift" ]
stackoverflow_0007490015_amazon_ec2_facebook_python_thrift.txt
Q: Python: repr vs backquote In python, is there a difference between repr and the backquote ` (left of 1)? For demonstration: class A(object): def __repr__(self): return 'repr A' def __str__(self): return 'str A' >>> a = A() >>> repr(a) #'repr A' >>> `a` #'repr A' >>> str(a) #'str A' Do ...
Python: repr vs backquote
In python, is there a difference between repr and the backquote ` (left of 1)? For demonstration: class A(object): def __repr__(self): return 'repr A' def __str__(self): return 'str A' >>> a = A() >>> repr(a) #'repr A' >>> `a` #'repr A' >>> str(a) #'str A' Do the backquotes just call repr?...
[ "They're an alias for repr. They have the exact same effect.\nHowever, they're deprecated and have been removed in Python 3. Don't use them; use repr.\n", "According to python.org covering repr: \n\nThis is the same value yielded by conversions (reverse quotes).\n\nIt should be noted that the backtick method is c...
[ 29, 9 ]
[]
[]
[ "python", "python_2.x" ]
stackoverflow_0007490261_python_python_2.x.txt
Q: Tasklets Local Storage in Stackless Python I'm starting with Stackless Python so it's a whole new amazing world for me. I usually use regular threads, and they normally have Thread-local storage (TLS), which is a very useful feature when you need NOT share memory with other threads. So, I'm wondering if Stackles...
Tasklets Local Storage in Stackless Python
I'm starting with Stackless Python so it's a whole new amazing world for me. I usually use regular threads, and they normally have Thread-local storage (TLS), which is a very useful feature when you need NOT share memory with other threads. So, I'm wondering if Stackless Python has something similar: A way to store l...
[ "Solution1: The TLS can be simulated in stackless/greenlet using the current tasklet object, retrieved by the call of stackless.getcurrent(), to store additional data.\nSolution2: If the tasklet didn't support to add extra fields, than you can have a global WeakKeyDictionary instance that will have as weakref key t...
[ 1 ]
[]
[]
[ "python", "python_stackless", "stackless" ]
stackoverflow_0006193826_python_python_stackless_stackless.txt
Q: Python 2.7: output utf-8 in Windows console Let's say s = u"test\u0627\u0644\u0644\u0647 \u0623\u0643\u0628\u0631\u7206\u767A\u043E\u043B\u043E\u043B\u043E" If I try to print it directly, >>> print s Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'cp932' codec can't e...
Python 2.7: output utf-8 in Windows console
Let's say s = u"test\u0627\u0644\u0644\u0647 \u0623\u0643\u0628\u0631\u7206\u767A\u043E\u043B\u043E\u043B\u043E" If I try to print it directly, >>> print s Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'cp932' codec can't encode character u'\u0627' in position 4: illegal ...
[ "Searching SO for python utf8 windows brings as the first result the question Getting python to print in UTF8 on Windows XP with the console which describes what's the problem with printing utf8 in Windows from Python.\n", "I didn't test it on windows, but here you can get small initialization script for both win...
[ 4, 1 ]
[]
[]
[ "python", "utf_8", "windows" ]
stackoverflow_0007078232_python_utf_8_windows.txt
Q: How to unpack a list? Given a function func(*args) and a list, how can I 'unpack' the list such that I pass its contents as separate arguments? I know I can do func(*thelist), but what I actually want to do is pass along another object, besides the contents of the list; something like this func(someobj, *thelist)....
How to unpack a list?
Given a function func(*args) and a list, how can I 'unpack' the list such that I pass its contents as separate arguments? I know I can do func(*thelist), but what I actually want to do is pass along another object, besides the contents of the list; something like this func(someobj, *thelist). How can I do that?
[ "Your code will work exactly as you typed it. \ndef foo(*mylist):\n bar(\"first\", *mylist)\n\ndef bar(*vals):\n print \"|\".join(vals)\n\nfoo(\"a\",\"b\")\n\nwill print: \nfirst|a|b\n\n" ]
[ 4 ]
[]
[]
[ "list", "python" ]
stackoverflow_0007490408_list_python.txt
Q: How to create regular expression to match function definitions I need to find function definitions like function (param1, param2, param3) I am using the following regular expression in python \S+\\((\S+|\s+|,)\\) so that something like re.findall("\S+\\((\S+|\s+|,)\\)",source_code_string) should give me the...
How to create regular expression to match function definitions
I need to find function definitions like function (param1, param2, param3) I am using the following regular expression in python \S+\\((\S+|\s+|,)\\) so that something like re.findall("\S+\\((\S+|\s+|,)\\)",source_code_string) should give me the all the function names, but it's not working. Please suggest impro...
[ "Your regex is fundamentally wrong\n\\S+\\\\((\\S+|\\s+|,)\\\\)\n\ndoes mean match at least one non-whitespace, a bracket then a series of non-whitespace OR a series of whitspace OR a comma and then the closing bracket.\nI think what you meant was this (use raw strings (r'') and escape only once)\n(\\S+)\\s*\\(\\s*...
[ 2, 2, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007475577_python_regex.txt
Q: python3: bind method to class instance with .__get__(), it works but why? I know if you want to add a method to a class instance you can't do a simple assignment like this: >>> def print_var(self): # method to be added print(self.var) >>> class MyClass: var = 5 >>> c = MyClass() >>> c.print_var = p...
python3: bind method to class instance with .__get__(), it works but why?
I know if you want to add a method to a class instance you can't do a simple assignment like this: >>> def print_var(self): # method to be added print(self.var) >>> class MyClass: var = 5 >>> c = MyClass() >>> c.print_var = print_var this indeed would cause print_var to behave like a normal function, s...
[ "The information you're looking for is in the Descriptor HowTo Guide:\n\nTo support method calls, functions include the __get__() method for binding methods during attribute access. This means that all functions are non-data descriptors which return bound or unbound methods depending whether they are invoked from a...
[ 9 ]
[]
[]
[ "descriptor", "methods", "monkeypatching", "python", "python_3.x" ]
stackoverflow_0007490879_descriptor_methods_monkeypatching_python_python_3.x.txt
Q: While Loop Breaking Problem (Python) I am currently trying to connect to a GPS Bluetooth device. My Python 2.7 code worked correctly initially but I have now tried to implement my code into a while loop so that, whilst my device is not available, it will continue to keep on looping for it. Unfortunately, my code s...
While Loop Breaking Problem (Python)
I am currently trying to connect to a GPS Bluetooth device. My Python 2.7 code worked correctly initially but I have now tried to implement my code into a while loop so that, whilst my device is not available, it will continue to keep on looping for it. Unfortunately, my code seems to be stuck in a loop and repeatedly ...
[ "The line\ndiscovered_devices = discover_devices()\n\nshould go inside your while loop, before entering the for loop.\nThen replace your while loop by a for loop to limit the number of attempts.\nAnd to properly exit the inner for loop, do as @Jeremy said: add\nelse:\n continue\nbreak\n\nat the end of it.\nYou m...
[ 5, 4 ]
[]
[]
[ "loops", "python", "while_loop" ]
stackoverflow_0007491373_loops_python_while_loop.txt
Q: need help with programming a word finder in python hi i have a question about python which im a rookie at: i have a text file which contains a list of words (around 23000) in alphabetical order, like a small dictionary each line is a word in that textfile i have to make a programme that asks the user for nine let...
need help with programming a word finder in python
hi i have a question about python which im a rookie at: i have a text file which contains a list of words (around 23000) in alphabetical order, like a small dictionary each line is a word in that textfile i have to make a programme that asks the user for nine letters, and then the programme is supposed to rerange thes...
[ "So if it's an exact match of those 9 letters, we can be a little tricky here. Instead of creating all those permutations and checking each one, merely sort the words into alphabetical order using the python built-in sorted function (doc) and compare the result. \nThe \"trick\" here is realizing you're looking for ...
[ 2, 0, 0 ]
[]
[]
[ "list_manipulation", "python" ]
stackoverflow_0007490453_list_manipulation_python.txt
Q: How can I get the filename of an uploaded file with GAE? I just upload it to the db (coming from a user request) like this: x.file = db.Blob(self.request.get("img")) How do I get the filename, I have both the request and the blob, any solution that could be applied for any of them is ok for me A: The object th...
How can I get the filename of an uploaded file with GAE?
I just upload it to the db (coming from a user request) like this: x.file = db.Blob(self.request.get("img")) How do I get the filename, I have both the request and the blob, any solution that could be applied for any of them is ok for me
[ "The object that is returned by self.request.get(\"img\") will have a property called filename. Assuming that \"img\" is a file upload, of course.\n", "you have to use the BlobInfo returned by BlobstoreUploadHandler\nas described here\nhttp://code.google.com/appengine/docs/python/tools/webapp/blobstorehandlers.ht...
[ 2, 0 ]
[]
[]
[ "file", "filenames", "google_app_engine", "python", "upload" ]
stackoverflow_0007488269_file_filenames_google_app_engine_python_upload.txt
Q: Is there a reliable way to determine the system CPU architecture using Python? Possible Duplicate: How can I return system information in Python? For example, to see if a Solaris is a Solaris X86 or Solaris SPARC? A: >>> import platform >>> platform.system() 'Darwin' >>> platform.processor() 'i386' >>> platfor...
Is there a reliable way to determine the system CPU architecture using Python?
Possible Duplicate: How can I return system information in Python? For example, to see if a Solaris is a Solaris X86 or Solaris SPARC?
[ ">>> import platform\n>>> platform.system()\n'Darwin'\n>>> platform.processor()\n'i386'\n>>> platform.platform()\n'Darwin-10.8.0-i386-64bit'\n>>> platform.machine()\n'i386'\n>>> platform.version()\n'Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386'\n>>> platform.uname()\...
[ 22, 11 ]
[]
[]
[ "architecture", "operating_system", "python" ]
stackoverflow_0007491391_architecture_operating_system_python.txt
Q: Parsing user expression for formatting errors User provides a string containing a Python expression : "a==(1,1) and {b==2 or c==foo}". I am trying to write a parser that checks the following rules: There needs to be a whitespace before and after a logical expression (or or and) There needs to be a whitespace befo...
Parsing user expression for formatting errors
User provides a string containing a Python expression : "a==(1,1) and {b==2 or c==foo}". I am trying to write a parser that checks the following rules: There needs to be a whitespace before and after a logical expression (or or and) There needs to be a whitespace before and after curly braces There should be NO whites...
[ "The most elegant way I'd say is to use something like pyparsing, a real parser combined with \"pythonic\" ease of use.\nIt may be a bit of overkill for small projects, but it isn't too hard to get started and will allow for plenty of growth in the syntax. Software requirements always seem to grow in one direction...
[ 0 ]
[]
[]
[ "parsing", "python", "regex" ]
stackoverflow_0007491571_parsing_python_regex.txt
Q: Problem in loading web page when using polyval, polyfit using numpy I am using django1.3. in CentOS5. My python version is 2.6 and using the numpy 1.6.1. I used in views.py a function which calculate the regression line. A sample code: from numpy import * .... def test_func(request): n=50 t=linspace(-5,5,n) ...
Problem in loading web page when using polyval, polyfit using numpy
I am using django1.3. in CentOS5. My python version is 2.6 and using the numpy 1.6.1. I used in views.py a function which calculate the regression line. A sample code: from numpy import * .... def test_func(request): n=50 t=linspace(-5,5,n) #parameters a=0.8; b=-4 x=polyval([a,b],t) #add some noise ...
[ "You need to add the WSGIApplicationGroup directive to your httpd.conf file.\n<Directory /www/django/apache>\n WSGIApplicationGroup %{GLOBAL}\n Order deny,allow\n Allow from all\n</Directory>\n\n", "I'm currently investigating a similar issue (Gentoo, Python 2.7, Numpy 1.6.0), and it would seem that only...
[ 1, 0 ]
[]
[]
[ "centos", "django", "django_wsgi", "numpy", "python" ]
stackoverflow_0006982125_centos_django_django_wsgi_numpy_python.txt
Q: Python Regex Capture Only Certain Text I am trying to find functionality in python similar to the Ruby function scan. My goal is to grab all the text in-between two curly braces in a list. If there are multiple pairs of curly braces in the string, I want to have multiple entries in the list. When I run this code: ...
Python Regex Capture Only Certain Text
I am trying to find functionality in python similar to the Ruby function scan. My goal is to grab all the text in-between two curly braces in a list. If there are multiple pairs of curly braces in the string, I want to have multiple entries in the list. When I run this code: match = re.search(r'\{(.+)\}', request.para...
[ "Use group(1), or lookbehinds/aheads. (Also, be sure to take the advice of F.J. and J.F. and use either .+? or [^{}]*\nimport re\nmatch = re.search(r'\\{(.+)\\}', \"asdfasd {asdf}asdfasdf\")\nprint match.group(1)\n\nor with lookbehinds/aheads:\nimport re\nmatch = re.search(r'(?<=\\{)(.+)(?=\\})', \"asdfasd {asdf}as...
[ 14, 10, 3 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007491604_python_regex.txt
Q: set data as tkinter background? so i found this code: import Image,ImageDraw import cStringIO from random import randint as rint def randgradient(): img = Image.new("RGB", (300,300), "#FFFFFF") draw = ImageDraw.Draw(img) r,g,b = rint(0,255), rint(0,255), rint(0,255) dr = (rint(0,255) - r)/300. ...
set data as tkinter background?
so i found this code: import Image,ImageDraw import cStringIO from random import randint as rint def randgradient(): img = Image.new("RGB", (300,300), "#FFFFFF") draw = ImageDraw.Draw(img) r,g,b = rint(0,255), rint(0,255), rint(0,255) dr = (rint(0,255) - r)/300. dg = (rint(0,255) - g)/300. db ...
[ "You can convert an image to a Tk image using PIL's ImageTk module. See the PhotoImage class examples.\n" ]
[ 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0007478188_python_tkinter.txt
Q: Tkinter is freezing while the loop is processing, how can i prevent it? I am making some programs which includes while loops(to illustrate some number calculatings) and when I use Tkinter for GUI, the program windows is freezing until the loop finished. I want to add a stop button and I want the windows not to fr...
Tkinter is freezing while the loop is processing, how can i prevent it?
I am making some programs which includes while loops(to illustrate some number calculatings) and when I use Tkinter for GUI, the program windows is freezing until the loop finished. I want to add a stop button and I want the windows not to freeze. How can I do these two things? Thank you
[ "You'll have to use separate threads or processes. Tkinter uses a single thread to process display updates, and the same thread is used to do event callbacks. If your event handler blocks then no Tkinter code will execute until it completes.\nIf you have the Tkinter thread (the one that calls Tk.mainloop) and ano...
[ 3 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0007491777_python_tkinter.txt
Q: how to match two numpy array of unequal length? i have two 1D numpy arrays. The lengths are unequal. I want to make pairs (array1_elemnt,array2_element) of the elements which are close to each other. Lets consider following example a = [1,2,3,8,20,23] b = [1,2,3,5,7,21,35] The expected result is [(1,1...
how to match two numpy array of unequal length?
i have two 1D numpy arrays. The lengths are unequal. I want to make pairs (array1_elemnt,array2_element) of the elements which are close to each other. Lets consider following example a = [1,2,3,8,20,23] b = [1,2,3,5,7,21,35] The expected result is [(1,1), (2,2), (3,3), (8,7), (20,21), ...
[ "How about using the Needleman-Wunsch algorithm? :)\nThe scoring matrix would be trivial, as the \"distance\" between two numbers is just their difference.\nBut that will probably feel like killing a sparrow with a tank ...\n", "You could use the built in map function to vectorize a function that does this. For ...
[ 3, 1, 0, 0, 0 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0007384291_numpy_python.txt
Q: Numpy sum of values in subarrays between pairs of indices Suppose I have an array A. I have a series of index pairs (a1, b1), (a2, b2) ... (an, bn) I want to obtain all the sums of the elements between those pairs. i.e. sum(A[a1:b1]), sum(A[a2:b2]), sum(A[a3:b3]) ... In terms of run-time, what's the most efficien...
Numpy sum of values in subarrays between pairs of indices
Suppose I have an array A. I have a series of index pairs (a1, b1), (a2, b2) ... (an, bn) I want to obtain all the sums of the elements between those pairs. i.e. sum(A[a1:b1]), sum(A[a2:b2]), sum(A[a3:b3]) ... In terms of run-time, what's the most efficient way of doing this? Thanks!
[ "Assuming your index pairs are stored in a NumPy array indices of shape (n, 2) and n is fairly large, it is probably best to avoid any Python loop:\nc = numpy.r_[0, A.cumsum()][indices]\nsums = c[:,1] - c[:,0]\n\n", "Here's another way:\n\na = np.random.rand(3000)\nindices = np.array([[0,3], [9,20], [5,30], [9,33...
[ 9, 1, 0, 0 ]
[]
[]
[ "numpy", "python", "sum" ]
stackoverflow_0007471474_numpy_python_sum.txt
Q: Can't get expected result with Python regex I also tried [a-zA-Z]{2,}-\d+ but with the same results def verify_commit_text(tags): for line in tags: if re.match('^NO-TIK',line): return True elif re.match('^NO-REVIEW', line): return True elif re.match('[a-zA-Z]-[0...
Can't get expected result with Python regex
I also tried [a-zA-Z]{2,}-\d+ but with the same results def verify_commit_text(tags): for line in tags: if re.match('^NO-TIK',line): return True elif re.match('^NO-REVIEW', line): return True elif re.match('[a-zA-Z]-[0-9][0-9]', line): return True ...
[ "The regex is working exactly as you've specified it .. it is searching for 1 character and 1 digit. You probably want something like\nre.match(r'[a-zA-Z]+-\\d+\\Z', line)\n\nFurther, always prefix regular expression strings with an 'r' as in the above. Or it will bite you.\n", "Since you want to match one or m...
[ 2, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007492349_python_regex.txt
Q: Make a redirect page that takes the user to one of the 5 forms (has to be random) So I am learning CGI programming with Python and i need to create some forms that ask input from the users and use the input to display some results. I will have to create five different forms (hence different results) and I want to ...
Make a redirect page that takes the user to one of the 5 forms (has to be random)
So I am learning CGI programming with Python and i need to create some forms that ask input from the users and use the input to display some results. I will have to create five different forms (hence different results) and I want to have a "play again" button on the result page so that when users click on it they can b...
[ "You can use the python module random.\nimport random\nurls = [\n 'form1.html',\n 'form2.html',\n 'form3.html',\n 'form4.html',\n 'form5.html',\n]\nredirect_to = random.choice(urls)\n\n# then do your redirection stuff\n\nhttp://docs.python.org/library/random.html\n" ]
[ 1 ]
[]
[]
[ "cgi", "forms", "html", "python", "redirect" ]
stackoverflow_0007491708_cgi_forms_html_python_redirect.txt
Q: Some help with a regular expression in Python I am very new to both Python and regular expressions, so bear with me. I have some text that looks like this: Change 421387 on 2011/09/20 by person@domain.com Some random text including line breaks Change 421388 on 2011/09/20 by person2@domain.com Some o...
Some help with a regular expression in Python
I am very new to both Python and regular expressions, so bear with me. I have some text that looks like this: Change 421387 on 2011/09/20 by person@domain.com Some random text including line breaks Change 421388 on 2011/09/20 by person2@domain.com Some other random text including line breaks Now, I wan...
[ "With a lookahead assertion.\n>>> re.split(r'(?=\\s+Change \\d+ on \\d{4})\\s+', ''' Change 421387 on 2011/09/20 by person@domain.com\n... Some random text including line breaks\n... Change 421388 on 2011/09/20 by person2@domain.com\n... Some other random text including line breaks''')\n['', 'Change ...
[ 4 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007492599_python_regex.txt
Q: Suppressing traceback (stack trace) for caught exceptions in Python I have python code that catches an exception: # ... except Exception: # Handle the exception When this code is executed, the traceback (stack trace) is printed to the console. How can I suppress it? A: Not recommended, but except Exception:...
Suppressing traceback (stack trace) for caught exceptions in Python
I have python code that catches an exception: # ... except Exception: # Handle the exception When this code is executed, the traceback (stack trace) is printed to the console. How can I suppress it?
[ "Not recommended, but\nexcept Exception:\n pass\n\nWill silently ignore the exception. However, if you don't fix what went wrong, your program may quit anyways because something further down in your code will throw another exception. You should at the least print out a message stating what happened, or debuggi...
[ 5 ]
[]
[]
[ "exception", "exception_handling", "python" ]
stackoverflow_0007492791_exception_exception_handling_python.txt
Q: unixODBC error IM001 I get the following error when trying to do any simple query. I just can't figure out what's changed. Here is an example of the sqlalchemy (Elixir) class: class Song(Entity): using_options(tablename='tbSongs', autoload=True) using_table_options(schema='apra') The database connection ...
unixODBC error IM001
I get the following error when trying to do any simple query. I just can't figure out what's changed. Here is an example of the sqlalchemy (Elixir) class: class Song(Entity): using_options(tablename='tbSongs', autoload=True) using_table_options(schema='apra') The database connection is ok and the classes cons...
[ "I have this error as well and downgrading to unixODBC 2.2.12 fixes it for me (note I can't get PyOBDC to build with 2.2.14, has to be 2.2.12). I'm fairly troubled by the state of the newer releases of ODBC tools for unix (Freetds 0.91 is very problematic as well).\n", "Try removing prepackaged FreeTDS, unixOD...
[ 1, 1, 0 ]
[]
[]
[ "freetds", "python", "sql_server", "unixodbc" ]
stackoverflow_0007370728_freetds_python_sql_server_unixodbc.txt
Q: What are the fastest, most memory efficient, and most concise ways to calculate a 3d range of points I've worked with several projects using python 2.6 and 2.7 that calculate positions, locations, or vectors in 3d space, and I've seen different methods to calculate all the points between two coordinates. For exam...
What are the fastest, most memory efficient, and most concise ways to calculate a 3d range of points
I've worked with several projects using python 2.6 and 2.7 that calculate positions, locations, or vectors in 3d space, and I've seen different methods to calculate all the points between two coordinates. For example, I often see this type of construct, using either xrange or range, to find all the points in a 3 dimen...
[ "The following is definitely more concise and memory efficient, and I would expect it to be faster than the for loop as well but I haven't tested:\nfrom itertools import product\n\nlist(product(xrange(xmin, xmax), xrange(ymin, ymax), xrange(zmin, zmaz)))\n\nYou can save a few characters with map:\nlist(product(*map...
[ 2, 0 ]
[]
[]
[ "3d", "methods", "python", "range" ]
stackoverflow_0007493013_3d_methods_python_range.txt
Q: intermittent problem with two django apps on the same virtual host I have two Django applications (appsystem and testapp) running in separate folders that are enabled in the same apache virtual host setting (see conf file at the end). One application displays a page on the root of the domain and that one seems to...
intermittent problem with two django apps on the same virtual host
I have two Django applications (appsystem and testapp) running in separate folders that are enabled in the same apache virtual host setting (see conf file at the end). One application displays a page on the root of the domain and that one seems to always work fine but when I go to a URL that should go to the second ap...
[ "Have you read http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango at all?\nI suspect your problem would be solved if you used mod_wsgi in daemon mode (i.e. via WSGIDaemonProcess).\n", "Try running them in virtualenv with modwsgi.\n", "FWIW, you have various things wrong with your configuration.\n\nWhy ...
[ 1, 1, 1 ]
[]
[]
[ "apache", "django", "mod_wsgi", "python", "virtualhost" ]
stackoverflow_0007484038_apache_django_mod_wsgi_python_virtualhost.txt
Q: python/bash SQL for tsv flatfiles (No sqlite) Background: sqlite is great for doing SQL operations on data loaded into databases, but many times in my line of work I need to do selects, joins, and where statements on files that aren't loaded into a database and not necessarily worth the time to do loading/initiali...
python/bash SQL for tsv flatfiles (No sqlite)
Background: sqlite is great for doing SQL operations on data loaded into databases, but many times in my line of work I need to do selects, joins, and where statements on files that aren't loaded into a database and not necessarily worth the time to do loading/initialization into a database. Also, the random access ch...
[ "You can hack something together using the csv module and list comprehensions:\nimport csv\n\nreader = csv.reader(open('data.csv', 'r'))\nrows = [row for row in reader]\n\n# select * from data where first column < 4\n# this won't actually work as-is! see the edit below\n[row for row in rows if row[0] < 4]\n\n# sele...
[ 2, 1, 0 ]
[]
[]
[ "bash", "csv", "flat_file", "python", "sql" ]
stackoverflow_0007492972_bash_csv_flat_file_python_sql.txt
Q: Dict of dict issue in django I'm experience strange issue while resulting the dict of dict in django template. data = [{'hrs': 9.0, 'ld': u'pname', 'dn': u'TS', 'ist': u'TS', 'act': u'O', 'date': datetime.date(2011, 9, 19), 'id': 1119556}, {'hrs': 9.0, 'ld': u'pname', 'dn': u'TS', 'ist': u'TS', 'act': u'Ti', 'dat...
Dict of dict issue in django
I'm experience strange issue while resulting the dict of dict in django template. data = [{'hrs': 9.0, 'ld': u'pname', 'dn': u'TS', 'ist': u'TS', 'act': u'O', 'date': datetime.date(2011, 9, 19), 'id': 1119556}, {'hrs': 9.0, 'ld': u'pname', 'dn': u'TS', 'ist': u'TS', 'act': u'Ti', 'date': datetime.date(2011, 9, 21), 'i...
[ "As is explained in the tutorial AT LEAST ONCE, dictionary keys are unique. If you want to have multiple values for a key then you will have to fake it with a sequence.\n{'foo': ['bar', 42]}\n\n", "You cannot have multiple values for the same key in a dictionary. Keys must be distinct. So if you try to save a dat...
[ 2, 0 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0007493163_django_django_templates_python.txt
Q: OpenID Claimed identifier When authenticating with OpenID I am afaict supposed to use the claimed identifier as a key to uniquely identify a specific user. The problem I am having with this is either two independent bugs or a misunderstanding of the spec :). When using node openid I would expect these two URLs to ...
OpenID Claimed identifier
When authenticating with OpenID I am afaict supposed to use the claimed identifier as a key to uniquely identify a specific user. The problem I am having with this is either two independent bugs or a misunderstanding of the spec :). When using node openid I would expect these two URLs to result in the same claimed_id: ...
[ "There's no reason they should result in the same claimed id and in fact you offer nothing in support of that expectation.\nHowever, it should be noted that the first library uses a wrong value for the claimed id (emphasis mine):\n\n7.2. Normalization\nThe end user's input MUST be normalized into an Identifier, as...
[ 1 ]
[]
[]
[ "node.js", "openid", "python" ]
stackoverflow_0007493245_node.js_openid_python.txt
Q: Python code problem, application has been destroyed Tcl error I am making a Tkinter GUI to do nothing except call images - and of course, I have struggled to find decent tkinter documentation all along. There is a line of my code which cannot seem to do as asked - I want to call up all the values in a dictionary a...
Python code problem, application has been destroyed Tcl error
I am making a Tkinter GUI to do nothing except call images - and of course, I have struggled to find decent tkinter documentation all along. There is a line of my code which cannot seem to do as asked - I want to call up all the values in a dictionary and individually print and pull an image by the same name for each ...
[ "I have looked around for a good solution to this but have yet to find the proper solution. Looking at the Tkinter.py class it looks like the Image del value is:\ndef __del__(self):\n if self.name:\n try:\n self.tk.call('image', 'delete', self.name)\n except TclError:\n # May ...
[ 2, 0, 0 ]
[]
[]
[ "python", "pythonw", "tkinter", "windows" ]
stackoverflow_0006133445_python_pythonw_tkinter_windows.txt
Q: Python Flask - Easy Querying Function Can somebody explain me the last line return (rv[0] if rv else None) if one else rv ? Especially the role of one. def query_db(query, args=(), one=False): cur = g.db.execute(query, args) rv = [dict((cur.description[idx][0], value) for idx, value in enume...
Python Flask - Easy Querying Function
Can somebody explain me the last line return (rv[0] if rv else None) if one else rv ? Especially the role of one. def query_db(query, args=(), one=False): cur = g.db.execute(query, args) rv = [dict((cur.description[idx][0], value) for idx, value in enumerate(row)) for row in cur.fetchall()] r...
[ "one indicates whether or not to return only a single record. If one is true then it returns the first (rv[0]) if there are records to be found (if rv), otherwise it returns all the records.\n", "By default, one is False, so by default the list-of-dicts generated from the fetchall gets returned.\nIf you pass True...
[ 2, 1 ]
[]
[]
[ "flask", "python", "querying" ]
stackoverflow_0007493459_flask_python_querying.txt
Q: Distributing a large Python-enabled application: best practices There is a large Python application that consists of numerous third-party packages and binary libraries. Here is an overview of my requirements: Cross-platform (currently Windows and modern Linux distributions) Installing lots (say >100 MB) of binary...
Distributing a large Python-enabled application: best practices
There is a large Python application that consists of numerous third-party packages and binary libraries. Here is an overview of my requirements: Cross-platform (currently Windows and modern Linux distributions) Installing lots (say >100 MB) of binary libraries (DLLs on Windows) Installing third-party Python packages (...
[ "Py2Exe can done most of the prerequisites, and dependencies, to remove and additional install/uninstall you could use any msi installer creator. \n" ]
[ 1 ]
[]
[]
[ "distribution", "python", "setuptools" ]
stackoverflow_0007427984_distribution_python_setuptools.txt
Q: Iinput information into a command prompt in python? I wanted to type this into a command prompt in windows: net users Administrator * And it returns type a password in the cmd I then want to type a password for eg:"pass" Then type it again after enter is pressed. How would i go about this? os.system() does not wor...
Iinput information into a command prompt in python?
I wanted to type this into a command prompt in windows: net users Administrator * And it returns type a password in the cmd I then want to type a password for eg:"pass" Then type it again after enter is pressed. How would i go about this? os.system() does not work. It goes to a new cmd each time. Any ideas?
[ "use subprocess, you can redirect input and output of the process you created.\n" ]
[ 4 ]
[]
[]
[ "cmd", "python" ]
stackoverflow_0007493554_cmd_python.txt
Q: resampling, interpolating matrix I'm trying to interpolate some data for the purpose of plotting. For instance, given N data points, I'd like to be able to generate a "smooth" plot, made up of 10*N or so interpolated data points. My approach is to generate an N-by-10*N matrix and compute the inner product the orig...
resampling, interpolating matrix
I'm trying to interpolate some data for the purpose of plotting. For instance, given N data points, I'd like to be able to generate a "smooth" plot, made up of 10*N or so interpolated data points. My approach is to generate an N-by-10*N matrix and compute the inner product the original vector and the matrix I generated...
[ "This is upsampling. See Help with resampling/upsampling for some example solutions.\nA fast way to do this (for offline data, like your plotting application) is to use FFTs. This is what SciPy's native resample() function does. It assumes a periodic signal, though, so it's not exactly the same. See this refere...
[ 9, 3, 1, 1, 1, 1, 0, 0 ]
[]
[]
[ "generator", "interpolation", "matrix", "python", "signal_processing" ]
stackoverflow_0001851384_generator_interpolation_matrix_python_signal_processing.txt
Q: Python: how to compute date ranges from a list of dates? I have a list of dates, for example: ['2011-02-27', '2011-02-28', '2011-03-01', '2011-04-12', '2011-04-13', '2011-06-08'] How do I find the contiguous date ranges contained within those dates? In the above example, the ranges should be: [{"start_date": '201...
Python: how to compute date ranges from a list of dates?
I have a list of dates, for example: ['2011-02-27', '2011-02-28', '2011-03-01', '2011-04-12', '2011-04-13', '2011-06-08'] How do I find the contiguous date ranges contained within those dates? In the above example, the ranges should be: [{"start_date": '2011-02-27', "end_date": '2011-03-01'}, {"start_date": '2011-04-...
[ "This works, but I'm not happy with it, will work on a cleaner solution an edit the answer. Done, here is a clean, working solution:\nimport datetime\nimport pprint\n\ndef parse(date):\n return datetime.date(*[int(i) for i in date.split('-')])\n\ndef get_ranges(dates):\n while dates:\n end = 1\n ...
[ 10, 0, 0, 0, 0 ]
[]
[]
[ "date", "datetime", "python", "python_datetime" ]
stackoverflow_0006934128_date_datetime_python_python_datetime.txt
Q: Python DST & Time Zone Detection After Addition So I currently have a line of code which looks like this: t1 = datetime(self.year, self.month, self.day, self.hour, self.minute, self.second) ... t2 = timedelta(days=dayNum, hours=time2.hour, minutes=time2.minute, seconds=time2.second) ...
Python DST & Time Zone Detection After Addition
So I currently have a line of code which looks like this: t1 = datetime(self.year, self.month, self.day, self.hour, self.minute, self.second) ... t2 = timedelta(days=dayNum, hours=time2.hour, minutes=time2.minute, seconds=time2.second) sumVal = t1 + t2 I would like for the result to tak...
[ "Perhaps pytz's normalize method is what you are looking for:\nimport datetime as dt\nimport pytz\n\ntz=pytz.timezone('Europe/London')\nt1 = dt.datetime(2012,10,28,0,30,0)\nt1=tz.localize(t1)\nt2 = dt.timedelta(hours=3)\nsumVal = t1 + t2\n\nsumVal remains in BST:\nprint(repr(sumVal))\n# datetime.datetime(2012, 10, ...
[ 5 ]
[]
[]
[ "datetime", "dst", "python", "pytz", "timezone" ]
stackoverflow_0007492930_datetime_dst_python_pytz_timezone.txt
Q: Python script to calculate the time between 2 successive packets received over the serial port I am debugging my code for which I need to write a python script that can read data being sent over the serial port through bluetooth and calculate the time elapsed between each successive packet.I know how to read the d...
Python script to calculate the time between 2 successive packets received over the serial port
I am debugging my code for which I need to write a python script that can read data being sent over the serial port through bluetooth and calculate the time elapsed between each successive packet.I know how to read the data from the serial port but I am having issues with calculating the time between each packet. Any s...
[ "Something like this might do the trick. Just create a IntTimer() object and call .stamp() on it whenever you receive a packet. It's just a start, so if it does what you want then you might need to change it to clean up the old stamps etc., otherwise self.timestamps will just grow and grow. You could use self.times...
[ 1, 1, 0, 0 ]
[]
[]
[ "pyserial", "python" ]
stackoverflow_0007488323_pyserial_python.txt
Q: Is there a way to return/print list item without quotes or brackets? Sorry if this is already mentioned somewhere(I couldn't find it). I basically want to list an item from a list but its including quotes and brackets(which I don't want). Here's my data: inputData = {'red':3, 'blue':1, 'green':2, 'organge':5} Her...
Is there a way to return/print list item without quotes or brackets?
Sorry if this is already mentioned somewhere(I couldn't find it). I basically want to list an item from a list but its including quotes and brackets(which I don't want). Here's my data: inputData = {'red':3, 'blue':1, 'green':2, 'organge':5} Here's my class to find items either based on key or value. class Lookup(dict...
[ "Change \nreturn [item[0] for item in self.items() if item[1] == value]\n\nto \nreturn next(item[0] for item in self.items() if item[1] == value)\n\nRight now you're returning the result of a list comprehension -- a list. Instead, you want to return the first item returned by the equivalent generator expression -- ...
[ 4, 3 ]
[]
[]
[ "python" ]
stackoverflow_0007494384_python.txt
Q: Create mixed (value set) CPPDEFINES in SCons I'd like to set the compiler defines to -DBLUB as well as -DFOO=1. Currently I only have: env.Append("CPPDEFINES", ["BLUB", "VALUE2"]) I now would like to include a third define via "FOO" : 1 and thus use CPPDEFINES as a dictionary so I can later on test quite easy env...
Create mixed (value set) CPPDEFINES in SCons
I'd like to set the compiler defines to -DBLUB as well as -DFOO=1. Currently I only have: env.Append("CPPDEFINES", ["BLUB", "VALUE2"]) I now would like to include a third define via "FOO" : 1 and thus use CPPDEFINES as a dictionary so I can later on test quite easy env["CPPDEFINES"].get("FOO") == 1 or so. Everything ...
[ "If you need to specify a value for any single define, CPPDEFINES must be a dictionary. \nFrom the scons User Manual:\n\nIf $CPPDEFINES is a dictionary, the values of the $CPPDEFPREFIX and $CPPDEFSUFFIX construction variables will be appended to the beginning and end of each item from the dictionary. The key of eac...
[ 4 ]
[]
[]
[ "python", "scons" ]
stackoverflow_0007493121_python_scons.txt
Q: wrapping a function in a class This is not really language-specific, but I'll use Python to explain my question. My program has several nearly self-contained functions. The command line arguments select one of these functions, and provide the input file name. The function is then executed: # main.py: import functi...
wrapping a function in a class
This is not really language-specific, but I'll use Python to explain my question. My program has several nearly self-contained functions. The command line arguments select one of these functions, and provide the input file name. The function is then executed: # main.py: import functions def main(): filename = sys.arg...
[ "If you were writing Java or C# then you would implement these functions as static methods. In those languages all methods have to be part of a class due to the design of the language. In Python, whilst you can emulate a static method, there is absolutely no need to do so for this example.\nPython's creator, Guido ...
[ 4, 2, 1 ]
[]
[]
[ "oop", "python" ]
stackoverflow_0007494209_oop_python.txt
Q: MongoEngine User authentication (django) I am trying to use MongoEngine in a django project I am writing. I am having difficulty getting (or understanding how) the authentication backend works. The user object as far as I can tell is not stored in the request. I have it working but I am not sure if I am doing it i...
MongoEngine User authentication (django)
I am trying to use MongoEngine in a django project I am writing. I am having difficulty getting (or understanding how) the authentication backend works. The user object as far as I can tell is not stored in the request. I have it working but I am not sure if I am doing it in the right/safe way. If someone could look at...
[ "Not sure if you are seeing any issues because you make no mention of any but I use mongoengine for my auth backend and this is how I would handle it:\nfrom django.contrib.auth import login, User\nfrom mongoengine.queryset import DoesNotExist\n\ndef login_view(request):\n try:\n user = User.objects.get(us...
[ 10 ]
[]
[]
[ "authentication", "django", "mongoengine", "python" ]
stackoverflow_0007492775_authentication_django_mongoengine_python.txt
Q: Python (CherryPy) web app deployed locally, but not visible over intranet I've created a Python web app using CherryPy, and have deployed in on my local machine. When I try to view it from another computer in the house, nothing comes back. However, if I create a simple html file, and deploy it with: $ python -m Si...
Python (CherryPy) web app deployed locally, but not visible over intranet
I've created a Python web app using CherryPy, and have deployed in on my local machine. When I try to view it from another computer in the house, nothing comes back. However, if I create a simple html file, and deploy it with: $ python -m SimpleHTTPServer It is visible over the intranet. I'm stumped as to why my app c...
[ "The default settings likely bind to localhost, which is not publicly available. If you want CherryPy to run on a public interface, you'll have to direct it to do that. From this discussion I found:\ncherrypy.config.update(\n {'server.socket_host': '10.149.4.240' } ) # Pub IP\ncherrypy.quickstart()\n\nor \nche...
[ 32 ]
[]
[]
[ "cherrypy", "intranet", "python" ]
stackoverflow_0007494171_cherrypy_intranet_python.txt
Q: HTTP Error 403 Forbidden with urllib2 but not with urllib with facebook graph api I have the following code with urllib2 which prints HTTP Error 403: Forbidden but if I use urllib instead to fetch url, I don't see any error and I do get a list of my friends. The access token used is same in both the cases. url = '...
HTTP Error 403 Forbidden with urllib2 but not with urllib with facebook graph api
I have the following code with urllib2 which prints HTTP Error 403: Forbidden but if I use urllib instead to fetch url, I don't see any error and I do get a list of my friends. The access token used is same in both the cases. url = 'https://graph.facebook.com/me/friends/' params = {'access_token': 'a valid access-token...
[ "This one is solved now. The trouble was that the request should be GET not POST and thus all the query parameters should be passed with url instead of being passed as POST data. So in my case the to get friends the code would look something like this:\nurl = 'https://graph.facebook.com/me/friends/'\nparams = {'acc...
[ 5 ]
[]
[]
[ "facebook_graph_api", "python", "urllib2" ]
stackoverflow_0007491347_facebook_graph_api_python_urllib2.txt
Q: How to iterate over Unicode characters in Python 3? I need to step through a Python string one character at a time, but a simple "for" loop gives me UTF-16 code units instead: str = "abc\u20ac\U00010302\U0010fffd" for ch in str: code = ord(ch) print("U+{:04X}".format(code)) That prints: U+0061 U+0062 U+00...
How to iterate over Unicode characters in Python 3?
I need to step through a Python string one character at a time, but a simple "for" loop gives me UTF-16 code units instead: str = "abc\u20ac\U00010302\U0010fffd" for ch in str: code = ord(ch) print("U+{:04X}".format(code)) That prints: U+0061 U+0062 U+0063 U+20AC U+D800 U+DF02 U+DBFF U+DFFD when what I wanted...
[ "On Python 3.2.1 with narrow Unicode build:\nPythonWin 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win32.\nPortions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.\n>>> import sys\n>>> sys.maxunicode\n65535\n\nWhat you've discovered (UTF-16 ...
[ 7, 3, 3 ]
[]
[]
[ "python", "python_3.x", "unicode" ]
stackoverflow_0007494064_python_python_3.x_unicode.txt
Q: django model foreignkeys question I am very new to programming and databases and I have a question about foreignkeys in django. Say I have a model called Expenses that has a foreignkey pointed to Employees model. class Employees(models.Model): ... class Expenses(models.Model): ... employee = models.Fo...
django model foreignkeys question
I am very new to programming and databases and I have a question about foreignkeys in django. Say I have a model called Expenses that has a foreignkey pointed to Employees model. class Employees(models.Model): ... class Expenses(models.Model): ... employee = models.ForeignKey(Employees) I see that foreign...
[ "Model class names should be singular. This will read much better in Python. You can have the associated database table have a different name by using class Meta: inside the model class. Also, the default Manager is objects, not object.\nYou don't need to go through all that trouble. Django will take care of mappin...
[ 3 ]
[]
[]
[ "django", "model_view_controller", "python" ]
stackoverflow_0007495126_django_model_view_controller_python.txt
Q: What does sys.maxunicode mean? CPython stores unicode strings as either utf-16 or utf-32 internally depending on compile options. In utf-16 builds of Python string slicing, iteration, and len seem to work on code units, not code points, so that multibyte characters behave strangely. E.g., on CPython 2.6 with sys....
What does sys.maxunicode mean?
CPython stores unicode strings as either utf-16 or utf-32 internally depending on compile options. In utf-16 builds of Python string slicing, iteration, and len seem to work on code units, not code points, so that multibyte characters behave strangely. E.g., on CPython 2.6 with sys.maxunicode = 65535: >>> char = u'\U0...
[ "Characters beyond sys.maxunicode=65535 are stored internally using UTF-16 surrogates. Yes you have to deal with this yourself or use a wide build. Even with a wide build you also may have to deal with single characters represented by a combination of code points. For example:\n>>> print('a\\u0301')\ná\n>>> prin...
[ 5 ]
[]
[]
[ "python", "unicode" ]
stackoverflow_0007495150_python_unicode.txt
Q: Python: nonblocking read from stdout of threaded subprocess I have a script (worker.py) that prints unbuffered output in the form... 1 2 3 . . . n where n is some constant number of iterations a loop in this script will make. In another script (service_controller.py) I start a number of threads, each of which st...
Python: nonblocking read from stdout of threaded subprocess
I have a script (worker.py) that prints unbuffered output in the form... 1 2 3 . . . n where n is some constant number of iterations a loop in this script will make. In another script (service_controller.py) I start a number of threads, each of which starts a subprocess using subprocess.Popen(stdout=subprocess.PIPE, ...
[ "Instead of having your service_controller being blocked by i/o access, only the thread loop should read its own controlled process output.\nthen, you can have method in the threaded object controlling the process to get the last polled output.\nof course, don't forget in that case to use some locking mechanism to...
[ 2, 1 ]
[]
[]
[ "multithreading", "nonblocking", "python", "subprocess" ]
stackoverflow_0002470742_multithreading_nonblocking_python_subprocess.txt
Q: PyQT: Silly QPainter.drawEllipse The longer I stare at the code, the less I understand it, but the funnier it gets. In one case QPainter draws the circles, in another it does not. My problem is that if it is successful, QPainter does not draw. If, on the other hand, it was not successful, it does draw. What I actu...
PyQT: Silly QPainter.drawEllipse
The longer I stare at the code, the less I understand it, but the funnier it gets. In one case QPainter draws the circles, in another it does not. My problem is that if it is successful, QPainter does not draw. If, on the other hand, it was not successful, it does draw. What I actually want to achieve is changing the c...
[ "The problem was the source of the paintEvent I created. The paintEvent was called when a containing textbox got focus. But the update region for the event only included the text box, which actually does make sense but I did not know. So paintEvent was called, but the update region did not include the circles.\nI c...
[ 1 ]
[]
[]
[ "pyqt", "python", "qpainter" ]
stackoverflow_0007487905_pyqt_python_qpainter.txt
Q: How to stop django from skipping the login page for a user? User not getting a chance to login. It just redirects to the 404 page: Getting this 404 error: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/pk/invalid/ Using the URLconf defined in namekeepr.urls, Django tried these U...
How to stop django from skipping the login page for a user?
User not getting a chance to login. It just redirects to the 404 page: Getting this 404 error: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/pk/invalid/ Using the URLconf defined in namekeepr.urls, Django tried these URL patterns, in this order: The current URL, pk/invalid/, didn't...
[ "Use the login_required() decorator for your view functions.\nhttps://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.decorators.login_required\nfrom django.contrib.auth.decorators import login_required\n\n@login_required\ndef my_view(request):\n ...\n\nIt will by default redirect your users to LO...
[ 1 ]
[]
[]
[ "authentication", "django", "python" ]
stackoverflow_0007495793_authentication_django_python.txt
Q: Working with trees of class instances in Python I'm looking for more information about dealing with trees of class instances, and how best to go about calling methods on the leaves from the trunk. I have a trunk instance with many branch instances (in a dictionary), and each has many leaf instances (and dicts in t...
Working with trees of class instances in Python
I'm looking for more information about dealing with trees of class instances, and how best to go about calling methods on the leaves from the trunk. I have a trunk instance with many branch instances (in a dictionary), and each has many leaf instances (and dicts in the branches). The leaves are where the action really ...
[ "What I'm taking away from your question is that \"everything works\", but that the code is starting to feel unmanagable and difficult to reason about, and: is there a better way to do this? \nThe one thing your question is missing is a solid context. What sort of problem is your tree structure actually solving? W...
[ 0 ]
[]
[]
[ "class_hierarchy", "python" ]
stackoverflow_0007493615_class_hierarchy_python.txt
Q: python classes dependant on eachother, how to init? I have two classes: class A(object): def __init__(self, b): self b = b class B(object): def __init__(self, a): self a = a I'd like to init them like this: a = A(b) b = B(a) But I can't since 'b' doesn't exist when doing a = A(b). I have to do: a...
python classes dependant on eachother, how to init?
I have two classes: class A(object): def __init__(self, b): self b = b class B(object): def __init__(self, a): self a = a I'd like to init them like this: a = A(b) b = B(a) But I can't since 'b' doesn't exist when doing a = A(b). I have to do: a = A() b = B(a) b.a = a But that seems unclean. Is this ...
[ "You could either make one class instantiate the other:\nclass A(object):\n def __init__(self):\n self.b = B(self)\n\nclass B(object):\n def __init__(self, a):\n self.a = a\n\na = A()\nb = a.b\n\nOr make one class tell the other about itself, like this:\nclass A(object):\n def __init__(self, b):\n self....
[ 6 ]
[]
[]
[ "python" ]
stackoverflow_0007496155_python.txt
Q: simultaneously sending/receiving info from a server, in python? I'm trying to figure out how to make a server that can accept multiple clients at one time. While doing so, I need the client able to send and receive data from the server at the same time. Would i have to make a threaded server? And have a thread for...
simultaneously sending/receiving info from a server, in python?
I'm trying to figure out how to make a server that can accept multiple clients at one time. While doing so, I need the client able to send and receive data from the server at the same time. Would i have to make a threaded server? And have a thread for listening for data. And then another thread for sending out informat...
[ "Use async IO. There are dozen of async IO socket libs for python. Here is a brief benchmark.\nI also tested gevent, eventlet, asyncore, twisted, pyev, pycurl, tornado. \n\nTwsited\nis stable but most slow and also not easy to start with.\ngevent, eventlet (libevent)\neasy to start and fast (code looks like blockin...
[ 3, 2, 1, 1 ]
[]
[]
[ "multithreading", "python", "sockets", "tcp" ]
stackoverflow_0007476072_multithreading_python_sockets_tcp.txt
Q: Python variable scope issue Python script: def show(name):     def getName():         return _name     def setName(value):      _name = value     _name = ''     print('Input parameter: ', name)     print('Global variable: ', say_hello)     print('Change private variable: ', setName(name))     print('Get private...
Python variable scope issue
Python script: def show(name):     def getName():         return _name     def setName(value):      _name = value     _name = ''     print('Input parameter: ', name)     print('Global variable: ', say_hello)     print('Change private variable: ', setName(name))     print('Get private variable: ', getName())     prin...
[ "Assignments in functions are assigned in the functions local scope. setName assigns _name in the local scope in setName, the outer _name is unaffected.\nIn Python 2.X, it is possible to assign to the module global scope by using the global statement, but not to an outer local scope.\nPython 3.X adds the nonlocal s...
[ 1, 0, 0 ]
[]
[]
[ "python", "scope", "variables" ]
stackoverflow_0007495915_python_scope_variables.txt
Q: How do I get LaTeX code to be stored literally in Python? I am using python and sqlite3 to make a database of physics solutions. I have a lot of LaTeX code that I would like to store, but I'm running into a problem. A lot of LaTeX code has characters that python interprets instead of just accepting as literal text...
How do I get LaTeX code to be stored literally in Python?
I am using python and sqlite3 to make a database of physics solutions. I have a lot of LaTeX code that I would like to store, but I'm running into a problem. A lot of LaTeX code has characters that python interprets instead of just accepting as literal text. For example, I've tried the following to store \frac{}{}: foo...
[ "I would simply use raw strings:\nfoo = r\"\\frac{}{}\"\n\nThat'll stop Python from interpreting backslashes as escape sequences and will include them as-is.\n", "Try to store them by prefixing the string with r:\nIn [1]: foo = r\"\\frac{}{}\"\n\nIn [2]: foo\nOut[2]: '\\\\frac{}{}'\n\n", "Have a look at raw str...
[ 5, 4, 2, 1 ]
[]
[]
[ "latex", "python" ]
stackoverflow_0007495693_latex_python.txt
Q: Python regex sub I want to delete all comment. This is my regular expression : re.sub(re.compile('<!--.*-->', re.DOTALL),'', text) But if my text is : bzzzzzz <!-- blabla --> blibli <!-- bloblo --> blublu the result is : bzzzzzz blublu instead of : bzzzzzz blibli blublu Thanks for your help A: I'd suggest no...
Python regex sub
I want to delete all comment. This is my regular expression : re.sub(re.compile('<!--.*-->', re.DOTALL),'', text) But if my text is : bzzzzzz <!-- blabla --> blibli <!-- bloblo --> blublu the result is : bzzzzzz blublu instead of : bzzzzzz blibli blublu Thanks for your help
[ "I'd suggest not to use regex for this kind of stuff. There is always a better solution, such as lxml.html.clean.\nYour example:\nimport lxml.html.clean as clean\ncleaner = clean.Cleaner(comments=True)\ncleaner.clean_html(\"bzzzzzz <!-- blabla --> blibli <!-- bloblo --> blublu\")\n#'bzzzzzz blibli blublu'\n\n", ...
[ 11, 8 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007496408_python_regex.txt
Q: How do I get the mercurial version in a django app? I'd like to use the working directory's mercurial version info within a Django app. By version info, I really mean <changeset, branch, and tag>. Are there plugins or techniques to do this? I've got one way implemented in settings.py, but I haven't found a way I...
How do I get the mercurial version in a django app?
I'd like to use the working directory's mercurial version info within a Django app. By version info, I really mean <changeset, branch, and tag>. Are there plugins or techniques to do this? I've got one way implemented in settings.py, but I haven't found a way I like to make these data available to code and templates....
[ "What's the problem? If you have e.g. HG_REV variable in settings module, you can access it from the rest of the code via django.conf.settings proxy, like any other setting. If you want to expose it to every template, then the easiest way is to write a context processor.\n" ]
[ 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0007496455_django_python.txt
Q: How to define a `from ... import *' api seperate from __all__ in a module? I have a module which is split roughly in half between utility type functions and core api functions. I need to have all of them in __all__ in order to have help() be useful, and also to specify which of the many functions/classes/etc in t...
How to define a `from ... import *' api seperate from __all__ in a module?
I have a module which is split roughly in half between utility type functions and core api functions. I need to have all of them in __all__ in order to have help() be useful, and also to specify which of the many functions/classes/etc in the module are for external use, but I also want to support from mymodule import ...
[ "Almost. While you can't have __all__ do double duty in this way, you can add your own virtual api module which can then be imported...\nclass fake_module(object):\n def __init__(self, name, *args):\n self.name = name\n self.__all__ = []\n all_objects = globals()\n for name in args:\...
[ 5, 4, 2, 0 ]
[]
[]
[ "api", "python", "python_3.x" ]
stackoverflow_0007068340_api_python_python_3.x.txt
Q: Grouping items by match set I am trying to parse a large amount of configuration files and group the results into separate groups based by content - I just do not know how to approach this. For example, say I have the following data in 3 files: config1.txt ntp 1.1.1.1 ntp 2.2.2.2 config2.txt ntp 1.1.1.1 config...
Grouping items by match set
I am trying to parse a large amount of configuration files and group the results into separate groups based by content - I just do not know how to approach this. For example, say I have the following data in 3 files: config1.txt ntp 1.1.1.1 ntp 2.2.2.2 config2.txt ntp 1.1.1.1 config3.txt ntp 2.2.2.2 ntp 1.1.1.1 co...
[ "from collections import defaultdict\n\n#Load the data.\npaths = [\"config1.txt\", \"config2.txt\", \"config3.txt\", \"config4.txt\"]\nfiles = {}\n\nfor path in paths:\n with open(path) as file:\n for line in file.readlines():\n ... #Get data from files\n files[path] = frozenset(data...
[ 2, 2, 2, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0007496687_python.txt
Q: Python regular expression gives unexpected result I'm trying to create an svn pre-commit hook, but can't get my regular expression to work as expected. It should print False for messages that do not look like "DEV-5 | some message". Why do I get True here? Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4...
Python regular expression gives unexpected result
I'm trying to create an svn pre-commit hook, but can't get my regular expression to work as expected. It should print False for messages that do not look like "DEV-5 | some message". Why do I get True here? Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or ...
[ ">>> p = re.compile(\"^[A-Z]+-[0-9]+ \\| .+$\", re.DOTALL)\n>>> print p.search(\"test message\")\nNone\n>>> print p.search(\"DEV-5 | some message\")\n<_sre.SRE_Match object at 0x800eb78b8>\n\n\nyou don't need \\[ and \\]\nyou need to escape |\n\n", "The culprit is the trailing \" | .+$\" which is matching ' messa...
[ 6, 4, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0007497048_python_regex.txt
Q: Remove column of array via indexing in Python I'm trying to remove an observation in an array via indexing. What I have is: import numpy as np test = np.ones([1, 1001]) What I want to do is return an array that is the same as test, but having removed the 5th observation (ie, test[0:4 AND 6:]). Is there a simple...
Remove column of array via indexing in Python
I'm trying to remove an observation in an array via indexing. What I have is: import numpy as np test = np.ones([1, 1001]) What I want to do is return an array that is the same as test, but having removed the 5th observation (ie, test[0:4 AND 6:]). Is there a simple way to do this?
[ "You could use slicing and hstack:\nIn [18]: test_ex5 = np.hstack((test[:,:5],test[:,6:]))\n\nIn [19]: test.shape\nOut[19]: (1, 1001)\n\nIn [20]: test_ex5.shape\nOut[20]: (1, 1000)\n\nNote that your indexing is off by one: test[0:4 AND 6:] would delete two elements instead of one.\n", "Numpy has delete, see http:...
[ 3, 3, 1 ]
[]
[]
[ "arrays", "indexing", "numpy", "python" ]
stackoverflow_0007496458_arrays_indexing_numpy_python.txt
Q: Accessing a web service I have been trying to write a client to access a web service for work. I have successfully written clients using SUDS and ZSI with Python. I have used NetBeans 6.9 to assist in writing a few Java clients. The successful clients have all been accessing freely available web services I have fo...
Accessing a web service
I have been trying to write a client to access a web service for work. I have successfully written clients using SUDS and ZSI with Python. I have used NetBeans 6.9 to assist in writing a few Java clients. The successful clients have all been accessing freely available web services I have found on the internet. The clie...
[ "try to use wireshark (or just debugging) to capture the full request and response for the working Adobe Air Client. Then capture the request/response of the client that you generated. compare the two requests and determine which objects that you are not creating and adding to your client. \n", "The problem with...
[ 0, 0 ]
[]
[]
[ "python", "soap", "suds", "web_services" ]
stackoverflow_0005524394_python_soap_suds_web_services.txt
Q: Pyramid i18n and HTML5 Does Pyramid i18n of .pt files support HTML5 mark-up? Currently the i18n tag extractor (Babel?) seems to want XHTML based input and does not accept HTML5 mark-up. Thus if you want to use i18n in .pt files you are forced to write them in XML'ish way? A: Chameleon 1 included two Babel extrac...
Pyramid i18n and HTML5
Does Pyramid i18n of .pt files support HTML5 mark-up? Currently the i18n tag extractor (Babel?) seems to want XHTML based input and does not accept HTML5 mark-up. Thus if you want to use i18n in .pt files you are forced to write them in XML'ish way?
[ "Chameleon 1 included two Babel extraction plugins (one for python code and one for XML files), which is what the Pyramid documentation is referring to. Chameleon 2 no longer includes those plugins and focuses on its core functionality of being a template library. These two plugins have been cleaned up and are now ...
[ 3 ]
[]
[]
[ "chameleon", "html", "internationalization", "pyramid", "python" ]
stackoverflow_0007339732_chameleon_html_internationalization_pyramid_python.txt
Q: Formatting float in python also before the decimal separator I am formatting floats as follows: logFile.write("Loadcase: %6i %2i %4i %2.2f %2.2f %4f + %4f -> " %(i, freq, amp, cutoff, end_time, penalty_inc, stab_inc)) and the result is like: Loadcase: 5001 1 50 19.00 20.00 0.000000 + 0.000000 -> 0.495386 (ok...
Formatting float in python also before the decimal separator
I am formatting floats as follows: logFile.write("Loadcase: %6i %2i %4i %2.2f %2.2f %4f + %4f -> " %(i, freq, amp, cutoff, end_time, penalty_inc, stab_inc)) and the result is like: Loadcase: 5001 1 50 19.00 20.00 0.000000 + 0.000000 -> 0.495386 (ok) Loadcase: 5002 2 50 9.50 10.00 0.000000 + 0.000000 -> 0.255...
[ "You're misunderstanding what %2.2f means. It means \"give the float 2 columns total, and display 2 positions after the radix point\". Perhaps you want %5.2f instead.\n", "The syntax is\n% fieldwidth . precision conversiontype\n\nSo in you want to leave some space, and show 2 decimals, try\n%8.2f\n\nSee the Pytho...
[ 7, 3, 3 ]
[]
[]
[ "floating_point", "formatting", "python", "tabular" ]
stackoverflow_0007497279_floating_point_formatting_python_tabular.txt
Q: Singleshot: SLOT with arguments I have a strange problem. Here is my code: def method1(self, arg1, delay=True): """This is a method class""" def recall(arg1): self.method1(arg1, delay=False) return if delay: print "A: ", arg1, type(arg1) QtCore.QTimer.singl...
Singleshot: SLOT with arguments
I have a strange problem. Here is my code: def method1(self, arg1, delay=True): """This is a method class""" def recall(arg1): self.method1(arg1, delay=False) return if delay: print "A: ", arg1, type(arg1) QtCore.QTimer.singleShot(1, self, QtCore.SLOT(recall(int...
[ "The parameter passed to the SLOT function must be a string with types as parameters, not a direct call, so you can't connect a slot with parameters to a signal without any parameter.\nYou can use a lambda function instead:\nQtCore.QTimer.singleShot(1, lambda : self.recall(arg1))\n\n", "It looks like when you are...
[ 11, 1 ]
[]
[]
[ "args", "pyqt", "python", "qt", "slots" ]
stackoverflow_0007489262_args_pyqt_python_qt_slots.txt
Q: Reading ASCII file in Python (numpy-array?) I have a problem reading ASCII file in Python. Here's an example of the file: http://pastebin.com/CTwwPPKA I tried using numpy's genfromtxt: data = np.genfromtxt("example.txt") But this way I cannot read dates and times properly since they should be datetime objects. On...
Reading ASCII file in Python (numpy-array?)
I have a problem reading ASCII file in Python. Here's an example of the file: http://pastebin.com/CTwwPPKA I tried using numpy's genfromtxt: data = np.genfromtxt("example.txt") But this way I cannot read dates and times properly since they should be datetime objects. On the other hand, loadtxt can only read float valu...
[ "You want to use csv.reader() with the csv.excel_tab dialect.\nExamples of csv usage\n", "you have to use dtype option here.\nx = np.genfromtxt(\"example.txt\", dtype=None)\nprint(x[0])\n\nand you will get\n('DATA', 34967565, '2011-08-04', '19:00:00:081', 0.0272448, -0.17718500000000001, 4.2143899999999999, 524.5...
[ 3, 3 ]
[]
[]
[ "ascii", "numpy", "python" ]
stackoverflow_0007497328_ascii_numpy_python.txt
Q: Want to Add all amounts for each country Hello I have a django app dealing with Sales/purchases. What I want to do is add amounts depending on thier country type. Looking at the sales table, there are two different country types. Uk and EU (I know EU is not a country but nevermind :) ) models.py COUNTRY_TYPE_CHOI...
Want to Add all amounts for each country
Hello I have a django app dealing with Sales/purchases. What I want to do is add amounts depending on thier country type. Looking at the sales table, there are two different country types. Uk and EU (I know EU is not a country but nevermind :) ) models.py COUNTRY_TYPE_CHOICES = ( (1, 'UK'), (2, 'EU'), ...
[ "from django.db.models import Sum\nSale.objects.values('country_type').annotate(Sum('amount')) \n\n", "This work quiet well for me.\nuk_sales = Sale.objects.filter(country_type='1')\nuk_amount = uk_sales.aggregate(price = Sum('amount'))['price']\n\n" ]
[ 2, 0 ]
[ "If you are using Django 1.1 or newer, the you can use Django Aggregate Support with something like:\nquery_amount = Item.objects.extra(select={'sum': 'sum(amount)'}).values('sum', 'amount')\nquery_amount.query.group_by = ['country_type']\n\nHere's Django official documentation on the topic. And here's a nice tutor...
[ -1 ]
[ "add", "django", "python", "sum" ]
stackoverflow_0007461706_add_django_python_sum.txt
Q: How do I properly install django registration on localhost? I have a directory for a django project on my localhost /MyDjangoList/ In this folder I have a django application called PK I downloaded django-registration and unzipped the folder into the /MyDjangoList/ I went into terminal and went to the django-regist...
How do I properly install django registration on localhost?
I have a directory for a django project on my localhost /MyDjangoList/ In this folder I have a django application called PK I downloaded django-registration and unzipped the folder into the /MyDjangoList/ I went into terminal and went to the django-registration folder and ran python setup.py install. It did a bunch of ...
[ "If you want to install it to a system folder, I'd recommend:\nsudo pip install django-registration\n\nyou may need to:\nsudo apt-get install python-pip\n\nbeforehand (assuming ubu/debian).\nIf you'd like to put it alongside in a folder instead, unzip it, and use it just as if it was another Django app. That means...
[ 2, 1, 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0007491507_django_python.txt
Q: 'str' object has no attribute '__dict__' I want to serialize a dictionary to JSON in Python. I have this 'str' object has no attribute 'dict' error. Here is my code... from django.utils import simplejson class Person(object): a = "" person1 = Person() person1.a = "111" person2 = Person() person2.a = "222" ...
'str' object has no attribute '__dict__'
I want to serialize a dictionary to JSON in Python. I have this 'str' object has no attribute 'dict' error. Here is my code... from django.utils import simplejson class Person(object): a = "" person1 = Person() person1.a = "111" person2 = Person() person2.a = "222" list = {} list["first"] = person1 list["second...
[ "How about\ns = simplejson.dumps([p.__dict__ for p in list.itervalues()])\n\n", "What do you think [p.__dict__ for p in list] does?\nSince list is not a list, it's a dictionary, the for p in list iterates over the key values of the dictionary. The keys are strings. \nNever use names like list or dict for variab...
[ 7, 6, 3 ]
[]
[]
[ "dictionary", "json", "python", "serialization" ]
stackoverflow_0007498070_dictionary_json_python_serialization.txt
Q: Scrapy "parse" function not being executed I have started to use scrapy on Ubuntu 11, and facing issue. Specifically the parse function in the following code does not execute, although the terminal shows the spider executed and closed successfully from scrapy.contrib.spiders import CrawlSpider from scrapy.selector...
Scrapy "parse" function not being executed
I have started to use scrapy on Ubuntu 11, and facing issue. Specifically the parse function in the following code does not execute, although the terminal shows the spider executed and closed successfully from scrapy.contrib.spiders import CrawlSpider from scrapy.selector import HtmlXPathSelector class myTestSpider(...
[ "Your parse() function does not seem to belong to your spider class.\nIndent the whole function for one indention, so it belongs to the class and gets called.\n" ]
[ 1 ]
[]
[]
[ "python", "scrapy", "web_scraping" ]
stackoverflow_0007498021_python_scrapy_web_scraping.txt
Q: try/except in list comprehension Is it possible to convert the following into a list comprehension? cleaned_list = [] for item in dirtry_list: try: item.video except Video.DoesNotExist: pass else: cleaned_list.append(item) A: You cannot put a try:statement in a list comprehens...
try/except in list comprehension
Is it possible to convert the following into a list comprehension? cleaned_list = [] for item in dirtry_list: try: item.video except Video.DoesNotExist: pass else: cleaned_list.append(item)
[ "You cannot put a try:statement in a list comprehension. Generators exist for more complex list processing:\ndef clean(lst):\n for item in lst:\n try:\n item.video\n except Video.DoesNotExist:\n pass\n else:\n yield item\n\ncleaned_list = clean(dirty_list)\n\...
[ 15, 11, 4 ]
[]
[]
[ "django", "python" ]
stackoverflow_0007493220_django_python.txt
Q: How to find all groups in a list in python? I have a list like this [0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,1] and I want to group them and then find the length of each group. So the result will be like that: [[2,0],[3,1].....[4,1]] A: Use itertools.groupby: >>> import itertools >>> l = [0,0,1,1,1,0,0,0,1,1,0,0,1,1,1...
How to find all groups in a list in python?
I have a list like this [0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,1] and I want to group them and then find the length of each group. So the result will be like that: [[2,0],[3,1].....[4,1]]
[ "Use itertools.groupby:\n>>> import itertools\n>>> l = [0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,1]\n>>> [(len(list(g)), k) for k,g in itertools.groupby(l)]\n[(2, 0), (3, 1), (3, 0), (2, 1), (2, 0), (4, 1)]\n\n", "In [7]: import itertools\n\nIn [8]: [[sum(1 for _ in g),v] for v,g in itertools.groupby(l)]\nOut[8]: [[2, 0], ...
[ 8, 2 ]
[]
[]
[ "list", "python" ]
stackoverflow_0007498335_list_python.txt
Q: What happens when a module is imported in python I've following use case: a.py: import b import c c.fun() b.py: def fun(): print 'b' c.py: def fun(): b.fun() python a.py doesn't work. It fails with NameError: global name 'b' is not defined. My understanding of import in python was that a name is added in s...
What happens when a module is imported in python
I've following use case: a.py: import b import c c.fun() b.py: def fun(): print 'b' c.py: def fun(): b.fun() python a.py doesn't work. It fails with NameError: global name 'b' is not defined. My understanding of import in python was that a name is added in sys.modules. If that is the case then c.py should also ...
[ "The module c.py has to import b in order to get this working...\nWhen importing a module then it is added to the globals-dictionary that is available in the current script's scope only (use \"globals()\" to print its content)\n", "You have to add all modules which you want to use in that script.\nOther way to pa...
[ 4, 2, 1 ]
[]
[]
[ "code_organization", "import", "python" ]
stackoverflow_0007495038_code_organization_import_python.txt
Q: Edit group content in python regular expression MatchObject I have the following (simplified) code - this is the essence of what i would like to do def replace_todo(m): m[2] = '*' if value else ' ' return m.group() I want to edit a specific group in the match object, and then render the whole match out in...
Edit group content in python regular expression MatchObject
I have the following (simplified) code - this is the essence of what i would like to do def replace_todo(m): m[2] = '*' if value else ' ' return m.group() I want to edit a specific group in the match object, and then render the whole match out including the edited part. The replace_todo function gets called on...
[ "I am novice when it comes to regex but couldn't you take m.groups() initially, change whatever you wish to and then return the variable?\nSay:\nx=list(m.groups()) #NOTE: groups and not group\nx[2] = '*' if value else ' '\nreturn x\n\nEDIT\nMaybe now I get what you are trying to achieve. As mentioned in the comment...
[ 2 ]
[]
[]
[ "django", "python", "regex" ]
stackoverflow_0007498304_django_python_regex.txt
Q: unsupported operand type(s) for *: 'Decimal' and vat I seem to be having a problem multiplying in Django. I want to multiply the Total Purchase including VAT with my VAT value. Unfortunately, I got this error. unsupported operand type(s) for *: 'Decimal' and 'VAT' It looks like my program calls vat (see views) `'...
unsupported operand type(s) for *: 'Decimal' and vat
I seem to be having a problem multiplying in Django. I want to multiply the Total Purchase including VAT with my VAT value. Unfortunately, I got this error. unsupported operand type(s) for *: 'Decimal' and 'VAT' It looks like my program calls vat (see views) `'VAT' rather than decimal. I'm not sure why there is an err...
[ "purchases[0].vat yields an instance of the VAT model. You need to use purchases[0].vat.vat to get the actual value.\n", "At a guess, did you mean to say:\nvat = purchases[0].vat.vat\n\n" ]
[ 4, 1 ]
[]
[]
[ "django", "math", "models", "python" ]
stackoverflow_0007498623_django_math_models_python.txt
Q: Django - How to filter down duplicates in a query? I have a query in Django that is resulting in unique rows but some contain common values in various fields. I want to consolidate those rows with the common values. Example: Assume each row returns an id, library, book title, author, and publication date. ...
Django - How to filter down duplicates in a query?
I have a query in Django that is resulting in unique rows but some contain common values in various fields. I want to consolidate those rows with the common values. Example: Assume each row returns an id, library, book title, author, and publication date. I only want to know only about the book title, author a...
[ "Could you try this:\nBooks.objects.all().only('title', 'author', 'date').extra(where=['library IS NOT NULL']).distinct()\n\n", "Chances are your data model is incomplete. It sounds like you're trying to find a library which is in possession of a particular book. In the case where there are many libraries in po...
[ 2, 0 ]
[]
[]
[ "django", "orm", "python" ]
stackoverflow_0007488660_django_orm_python.txt
Q: create own python link So I'm in the following situation. I have a package generated with py2app. This has it's own structure and my projects sources are located in: /dist.app/Contents/Resources/lib/python2.7/my_project Now this works fine, however I want to give the possibility that developers add their own code...
create own python link
So I'm in the following situation. I have a package generated with py2app. This has it's own structure and my projects sources are located in: /dist.app/Contents/Resources/lib/python2.7/my_project Now this works fine, however I want to give the possibility that developers add their own code where they want. So going t...
[ "Are you talking about creating a plugin system for your app? The usual way to do this is have a directory somewhere that is designated the \"plugins\" directory - any folders in there are loaded as plugins. You could either hardcode this path or make it configurable using the application ui or a configuration file...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0007498855_python.txt
Q: Running CPython Applications With Visual Studio? I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto...
Running CPython Applications With Visual Studio?
I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the "b...
[ "Python tools for Visual Studio is an addin which supports both CPython and IronPython.\n", "Eclipse and PyDev already provide an excellent development environment for Python. Is there any reason you cannot use them?\n", "Are you trying to build CPython itself? Doesn't it come with project files suitable for u...
[ 3, 1, 1, 0 ]
[]
[]
[ "python", "visual_studio", "visual_studio_2010" ]
stackoverflow_0002747017_python_visual_studio_visual_studio_2010.txt